Game playing. Outline

Similar documents
Game playing. Chapter 6. Chapter 6 1

Games vs. search problems. Game playing Chapter 6. Outline. Game tree (2-player, deterministic, turns) Types of games. Minimax

Game Playing. Dr. Richard J. Povinelli. Page 1. rev 1.1, 9/14/2003

CS 380: ARTIFICIAL INTELLIGENCE

Game playing. Chapter 6. Chapter 6 1

CS 380: ARTIFICIAL INTELLIGENCE ADVERSARIAL SEARCH. Santiago Ontañón

Outline. Game playing. Types of games. Games vs. search problems. Minimax. Game tree (2-player, deterministic, turns) Games

ADVERSARIAL SEARCH. Chapter 5

Game Playing. Philipp Koehn. 29 September 2015

Game Playing: Adversarial Search. Chapter 5

Games vs. search problems. Adversarial Search. Types of games. Outline

Game playing. Chapter 5. Chapter 5 1

Lecture 5: Game Playing (Adversarial Search)

Game playing. Chapter 5, Sections 1{5. AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 5, Sections 1{5 1

Today. Nondeterministic games: backgammon. Algorithm for nondeterministic games. Nondeterministic games in general. See Russell and Norvig, chapter 6

Adversarial search (game playing)

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 4: Search 3.

Artificial Intelligence. Topic 5. Game playing

Ch.4 AI and Games. Hantao Zhang. The University of Iowa Department of Computer Science. hzhang/c145

Game playing. Chapter 5, Sections 1 6

CS 188: Artificial Intelligence Spring Game Playing in Practice

COMP219: COMP219: Artificial Intelligence Artificial Intelligence Dr. Annabel Latham Lecture 12: Game Playing Overview Games and Search

Today. Types of Game. Games and Search 1/18/2010. COMP210: Artificial Intelligence. Lecture 10. Game playing

Game Playing. Why do AI researchers study game playing? 1. It s a good reasoning problem, formal and nontrivial.

Last update: March 9, Game playing. CMSC 421, Chapter 6. CMSC 421, Chapter 6 1

Games CSE 473. Kasparov Vs. Deep Junior August 2, 2003 Match ends in a 3 / 3 tie!

Adversarial Search (a.k.a. Game Playing)

CS 188: Artificial Intelligence

Adversarial Search. Chapter 5. Mausam (Based on slides of Stuart Russell, Andrew Parks, Henry Kautz, Linda Shapiro) 1

Adversarial Search. Hal Daumé III. Computer Science University of Maryland CS 421: Introduction to Artificial Intelligence 9 Feb 2012

Programming Project 1: Pacman (Due )

COMP219: Artificial Intelligence. Lecture 13: Game Playing

Adversarial Search. CMPSCI 383 September 29, 2011

CS 188: Artificial Intelligence Spring Announcements

Artificial Intelligence 1: game playing

6. Games. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Mechanical Turk. Origins. origins. motivation. minimax search

Adversarial Search Lecture 7

Adversarial Search and Game Playing

CS 188: Artificial Intelligence Spring 2007

Announcements. CS 188: Artificial Intelligence Spring Game Playing State-of-the-Art. Overview. Game Playing. GamesCrafters

CS 331: Artificial Intelligence Adversarial Search II. Outline

Intuition Mini-Max 2

Game Playing State-of-the-Art CSE 473: Artificial Intelligence Fall Deterministic Games. Zero-Sum Games 10/13/17. Adversarial Search

Adversarial Search. Soleymani. Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 5

Announcements. Homework 1. Project 1. Due tonight at 11:59pm. Due Friday 2/8 at 4:00pm. Electronic HW1 Written HW1

CS 188: Artificial Intelligence. Overview

Local Search. Hill Climbing. Hill Climbing Diagram. Simulated Annealing. Simulated Annealing. Introduction to Artificial Intelligence

Adversarial Search and Game- Playing C H A P T E R 6 C M P T : S P R I N G H A S S A N K H O S R A V I

Announcements. CS 188: Artificial Intelligence Fall Local Search. Hill Climbing. Simulated Annealing. Hill Climbing Diagram

Game Playing State-of-the-Art

Artificial Intelligence

Artificial Intelligence

Artificial Intelligence Adversarial Search

Adversarial Search. Human-aware Robotics. 2018/01/25 Chapter 5 in R&N 3rd Ø Announcement: Slides for this lecture are here:

Adversarial Search. Chapter 5. Mausam (Based on slides of Stuart Russell, Andrew Parks, Henry Kautz, Linda Shapiro, Diane Cook) 1

CSE 573: Artificial Intelligence Autumn 2010

CSE 473: Artificial Intelligence. Outline

CS 5522: Artificial Intelligence II

Game Playing State of the Art

Game-playing AIs: Games and Adversarial Search FINAL SET (w/ pruning study examples) AIMA

CS 771 Artificial Intelligence. Adversarial Search

CS440/ECE448 Lecture 9: Minimax Search. Slides by Svetlana Lazebnik 9/2016 Modified by Mark Hasegawa-Johnson 9/2017

Adversarial Search. Read AIMA Chapter CIS 421/521 - Intro to AI 1

Game-Playing & Adversarial Search

Artificial Intelligence

Adversarial Search and Game Playing. Russell and Norvig: Chapter 5

Game Playing State-of-the-Art. CS 188: Artificial Intelligence. Behavior from Computation. Video of Demo Mystery Pacman. Adversarial Search

Artificial Intelligence. Minimax and alpha-beta pruning

Outline. Game Playing. Game Problems. Game Problems. Types of games Playing a perfect game. Playing an imperfect game

CS 188: Artificial Intelligence

Artificial Intelligence

Ar#ficial)Intelligence!!

CITS3001. Algorithms, Agents and Artificial Intelligence. Semester 2, 2016 Tim French

CS 4700: Foundations of Artificial Intelligence

Games and Adversarial Search

Artificial Intelligence

Adversarial Search Aka Games

CSE 573: Artificial Intelligence

Game Playing AI Class 8 Ch , 5.4.1, 5.5

Foundations of Artificial Intelligence

CSE 473: Artificial Intelligence Autumn 2011

Adversarial Search (Game Playing)

Foundations of Artificial Intelligence

Adversarial Search 1

CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #5

Contents. Foundations of Artificial Intelligence. Problems. Why Board Games?

Pengju

CSE 40171: Artificial Intelligence. Adversarial Search: Games and Optimality

School of EECS Washington State University. Artificial Intelligence

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

Chapter 6. Overview. Why study games? State of the art. Game playing State of the art and resources Framework

Game-playing AIs: Games and Adversarial Search I AIMA

Game-playing: DeepBlue and AlphaGo

ADVERSARIAL SEARCH. Today. Reading. Goals. AIMA Chapter , 5.7,5.8

ARTIFICIAL INTELLIGENCE (CS 370D)

Adversarial Search: Game Playing. Reading: Chapter

ADVERSARIAL SEARCH. Today. Reading. Goals. AIMA Chapter Read , Skim 5.7

Games and Adversarial Search II

Unit-III Chap-II Adversarial Search. Created by: Ashish Shah 1

Transcription:

Game playing Chapter 6, Sections 1 8 CS 480 Outline Perfect play Resource limits α β pruning Games of chance Games of imperfect information

Games vs. search problems Unpredictable opponent solution is a strategy specifying a move for every possible opponent reply Time limits unlikely to find goal, must approximate Plan of attack: Computer considers possible lines of play (Babbage, 1846) Algorithm for perfect play (Zermelo, 191; Von Neumann, 1944) Finite horizon, approximate evaluation (Zuse, 1945; Wiener, 1948; Shannon, 1950) First chess program (Turing, 1951) Machine learning to improve evaluation accuracy (Samuel, 195 57) Pruning to allow deeper search (McCarthy, 1956) CS 480 4 Types of games perfect information imperfect information deterministic chess, checkers, go, othello chance backgammon monopoly bridge, poker, scrabble nuclear war

Game tree (-player, deterministic, turns) MA () MIN (O) MA () O O O... MIN (O) O O O............... O O O... TERMINAL O O O O O O O Utility 1 0 +1 CS 480 6 Minimax Perfect play for deterministic, perfect-information games Idea: choose move to position with highest minimax value = best achievable payoff against best play E.g., -ply game: MA 3 A 1 A A 3 MIN 3 A 11 A 13 A 1 A A 3 A 3 A 33 A 1 A 31 3 1 8 4 6 14 5

Minimax algorithm function MINIMA-DECISION(state, game) returns an action action, state the a, s in SUCCESSORS(state) such that MINIMA-VALUE(s, game) is maximized return action function MINIMA-VALUE(state, game) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) else if MA is to move in state then return the highest MINIMA-VALUE of SUCCESSORS(state) else return the lowest MINIMA-VALUE of SUCCESSORS(state) CS 480 8 Properties of minimax Complete??

Properties of minimax Complete?? Only if tree is finite (chess has specific rules for this). Optimal?? CS 480 10 Properties of minimax Complete?? Yes, if tree is finite (chess has specific rules for this) Optimal?? Yes, against an optimal opponent. Otherwise?? Time complexity??

Properties of minimax Complete?? Yes, if tree is finite (chess has specific rules for this) Optimal?? Yes, against an optimal opponent. Otherwise?? Time complexity?? O(b m ) Space complexity?? CS 480 1 Properties of minimax Complete?? Yes, if tree is finite (chess has specific rules for this) Optimal?? Yes, against an optimal opponent. Otherwise?? Time complexity?? O(b m ) Space complexity?? O(bm) (depth-first exploration) For chess, b 35, m 100 for reasonable games exact solution completely infeasible

Resource limits Suppose we have 100 seconds, explore 10 4 nodes/second 10 6 nodes per move Standard approach: cutoff test e.g., depth limit (perhaps add quiescence search) evaluation function = estimated desirability of position CS 480 14 Evaluation functions Black to move White to move White slightly better Black winning For chess, typically linear weighted sum of features Eval(s) =w 1 f 1 (s)+w f (s)+...+ w n f n (s) e.g., w 1 =9with f 1 (s) = (number of white queens) (number of black queens), etc.

Digression: Exact values don t matter MA MIN 1 1 0 1 4 1 0 0 400 Behaviour is preserved under any monotonic transformation of EVAL Only the order matters: payoff in deterministic games acts as an ordinal utility function CS 480 16 Cutting off search MINIMACUTOFF is identical to MINIMAVALUE except 1. TERMINAL? is replaced by CUTOFF?. UTILITY is replaced by EVAL Does it work in practice? b m =10 6, b =35 m =4 4-ply lookahead is a hopeless chess player! 4-ply human novice 8-ply typical PC, human master 1-ply Deep Blue, Kasparov

α β pruning example MA 3 MIN 3 3 1 8 CS 480 18 α β pruning example MA 3 MIN 3 3 1 8

α β pruning example MA 3 MIN 3 14 3 1 8 14 CS 480 0 α β pruning example MA 3 MIN 3 14 5 3 1 8 14 5

α β pruning example MA 3 3 MIN 3 14 5 3 1 8 14 5 CS 480 Properties of α β Pruning does not affect final result Good move ordering improves effectiveness of pruning With perfect ordering, time complexity = O(b m/ ) doubles depth of search can easily reach depth 8 and play good chess A simple example of the value of reasoning about which computations are relevant (a form of metareasoning)

Why is it called α β? MA MIN...... MA MIN V α is the best value (to MA) found so far off the current path If V is worse than α, MA will avoid it prune that branch Define β similarly for MIN CS 480 4 The α β algorithm function ALPHA-BETA-SEARCH(state, game) returns an action action, state the a, s in SUCCESSORS[game](state) such that MIN-VALUE(s, game,, + ) is maximized return action function MA-VALUE(state, game, α, β) returns the minimax value of state if CUTOFF-TEST(state) then return EVAL(state) for each s in SUCCESSORS(state) do α max(α,min-value(s, game, α, β)) if α β then return β return α function MIN-VALUE(state, game, α, β) returns the minimax value of state if CUTOFF-TEST(state) then return EVAL(state) for each s in SUCCESSORS(state) do β min( β,ma-value(s, game, α, β)) if β α then return α return β

Deterministic games in practice Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in 1994. Used an endgame database defining perfect play for all positions involving 8 or fewer pieces on the board, a total of 443,748,401,47 positions. Chess: Deep Blue defeated human world champion Gary Kasparov in a six-game match in 1997. Deep Blue searches 00 million positions per second, uses very sophisticated evaluation, and undisclosed methods for extending some lines of search up to 40 ply. Othello: human champions refuse to compete against computers, who are too good. Go: human champions refuse to compete against computers, who are too bad. In go, b>300, so most programs use pattern knowledge bases to suggest plausible moves. CS 480 6 Nondeterministic games: backgammon 0 1 3 4 5 6 7 8 9 10 11 1 5 4 3 1 0 19 18 17 16 15 14 13

Nondeterministic games in general In nondeterministic games, chance introduced by dice, card-shuffling Simplified example with coin-flipping: MA CHANCE 3 1 MIN 4 0 4 7 4 6 0 5 CS 480 8 Algorithm for nondeterministic games EPECTIMINIMA gives perfect play Just like MINIMA, except we must also handle chance nodes:... if state is a MA node then return the highest EPECTIMINIMA-VALUE of SUCCESSORS(state) if state is a MIN node then return the lowest EPECTIMINIMA-VALUE of SUCCESSORS(state) if state is a chance node then return average of EPECTIMINIMA-VALUE of SUCCESSORS(state)...

Pruning in nondeterministic game trees A version of α-β pruning is possible: CS 480 30 Pruning in nondeterministic game trees A version of α-β pruning is possible: [, ]

Pruning in nondeterministic game trees A version of α-β pruning is possible: [, ] CS 480 3 Pruning in nondeterministic game trees A version of α-β pruning is possible: [, ] [, ] [, ]

Pruning in nondeterministic game trees A version of α-β pruning is possible: [ 1.5, 1.5 ] [, ] [ 1, 1 ] 1 CS 480 34 Pruning in nondeterministic game trees A version of α-β pruning is possible: [ 1.5, 1.5 ] [, ] [ 1, 1 ] [, 0 ] 1 0

Pruning in nondeterministic game trees A version of α-β pruning is possible: [ 1.5, 1.5 ] [, ] [ 1, 1 ] [ 0, 0 ] 1 0 1 CS 480 36 Pruning in nondeterministic game trees A version of α-β pruning is possible: [ 1.5, 1.5 ] [, 0.5 ] [, ] [ 1, 1 ] [ 0, 0 ] [, 1 ] 1 0 1 1

Pruning contd. More pruning occurs if we can bound the leaf values [, ] [, ] [, ] [, ] [, ] [, ] CS 480 38 Pruning contd. More pruning occurs if we can bound the leaf values [, ] [, ] [, ] [, ] [, ] [, ]

Pruning contd. More pruning occurs if we can bound the leaf values [ 0, ] [, ] [, ] [, ] [, ] [, ] CS 480 40 Pruning contd. More pruning occurs if we can bound the leaf values [ 0, ] [, ] [, ] [, ] [, ] [, ]

Pruning contd. More pruning occurs if we can bound the leaf values [ 1.5, 1.5 ] [, ] [, ] [ 1, 1 ] [, ] [, ] 1 CS 480 4 Pruning contd. More pruning occurs if we can bound the leaf values [ 1.5, 1.5 ] [, 1 ] [, ] [ 1, 1 ] [, 0 ] [, ] 1 0

Nondeterministic games in practice Dice rolls increase b: 1 possible rolls with dice Backgammon 0 legal moves (can be 6,000 with 1-1 roll) depth 4 = 0 (1 0) 3 1. 10 9 As depth increases, probability of reaching a given node shrinks value of lookahead is diminished α β pruning is much less effective TDGAMMON uses depth- search + very good EVAL world-champion level CS 480 44 Digression: Exact values DO matter MA DICE.1 1.3.9.1.9.1 1 40.9.9.1.9.1 MIN 3 1 4 0 30 1 400 3 3 1 1 4 4 0 0 30 30 1 1 400 400 Behaviour is preserved only by positive linear transformation of EVAL Hence EVAL should be proportional to the expected payoff

Games of imperfect information E.g., card games, where opponent s initial cards are unknown Typically we can calculate a probability for each possible deal Seems just like having one big dice roll at the beginning of the game Idea: compute the minimax value of each action in each deal, then choose the action with highest expected value over all deals Special case: if an action is optimal for all deals, it s optimal. GIB, current best bridge program, approximates this idea by 1) generating 100 deals consistent with bidding information ) picking the action that wins most tricks on average CS 480 46 Example Four-card bridge/whist/hearts hand, MA to play first 6 6 8 7 8 6 6 7 6 6 7 6 6 7 6 6 7 0 4 9 3 4 9 3 9 4 3 4 3 4 3

Example Four-card bridge/whist/hearts hand, MA to play first MA MIN 6 6 8 7 8 6 6 7 6 6 7 6 6 7 6 6 7 0 4 9 3 4 9 3 9 4 3 4 3 4 3 MA MIN 6 6 8 7 8 6 6 7 6 6 7 6 6 7 6 6 7 0 4 9 3 4 9 3 9 4 3 4 3 4 3 CS 480 48 Example Four-card bridge/whist/hearts hand, MA to play first MA MIN 6 6 8 7 8 6 6 7 6 6 7 6 6 7 6 6 7 0 4 9 3 4 9 3 9 4 3 4 3 4 3 MA MIN 6 6 8 7 8 6 6 7 6 6 7 6 6 7 6 6 7 0 4 9 3 4 9 3 9 4 3 4 3 4 3 MA 6 6 8 7 8 6 6 7 6 6 7 6 6 7 6 4 6 7 3 0.5 MIN 4 9 3 4 9 3 9 4 3 4 3 6 6 4 7 3 0.5

Commonsense example Road A leads to a small heap of gold pieces Road B leads to a fork: take the left fork and you ll find a mound of jewels; take the right fork and you ll be run over by a bus. CS 480 50 Commonsense example Road A leads to a small heap of gold pieces Road B leads to a fork: take the left fork and you ll find a mound of jewels; take the right fork and you ll be run over by a bus. Road A leads to a small heap of gold pieces Road B leads to a fork: take the left fork and you ll be run over by a bus; take the right fork and you ll find a mound of jewels.

Commonsense example Road A leads to a small heap of gold pieces Road B leads to a fork: take the left fork and you ll find a mound of jewels; take the right fork and you ll be run over by a bus. Road A leads to a small heap of gold pieces Road B leads to a fork: take the left fork and you ll be run over by a bus; take the right fork and you ll find a mound of jewels. Road A leads to a small heap of gold pieces Road B leads to a fork: guess correctly and you ll find a mound of jewels; guess incorrectly and you ll be run over by a bus. CS 480 5 Proper analysis * Intuition that the value of an action is the average of its values in all actual states is WRONG With partial observability, value of an action depends on the information state or belief state the agent is in Can generate and search a tree of information states Leads to rational behaviors such as Acting to obtain information Signalling to one s partner Acting randomly to minimize information disclosure

Summary Games are fun to work on! (and dangerous) They illustrate several important points about AI perfection is unattainable must approximate good idea to think about what to think about uncertainty constrains the assignment of values to states Games are to AI as grand prix racing is to automobile design