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

Similar documents
Game playing. Chapter 6. Chapter 6 1

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

Game Playing. Philipp Koehn. 29 September 2015

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

Game playing. Chapter 6. Chapter 6 1

Game Playing: Adversarial Search. Chapter 5

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

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

CS 380: ARTIFICIAL INTELLIGENCE

Game playing. Chapter 5. Chapter 5 1

Lecture 5: Game Playing (Adversarial Search)

Game playing. Outline

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

ADVERSARIAL SEARCH. Chapter 5

Artificial Intelligence. Topic 5. Game playing

Game playing. Chapter 5, Sections 1 6

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

CS 188: Artificial Intelligence

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

Programming Project 1: Pacman (Due )

Adversarial search (game playing)

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

Game Playing State-of-the-Art

Adversarial Search. CMPSCI 383 September 29, 2011

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

Artificial Intelligence

CS 5522: Artificial Intelligence II

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

Adversarial Search Lecture 7

CS 188: Artificial Intelligence Spring Announcements

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

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

CSE 473: Artificial Intelligence. Outline

CS 331: Artificial Intelligence Adversarial Search II. Outline

CS 188: Artificial Intelligence Spring 2007

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

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

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

Game-Playing & Adversarial Search

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

CS 188: 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

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

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

CS 188: Artificial Intelligence Spring Game Playing in Practice

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

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

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

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

Adversarial Search Aka Games

Games and Adversarial Search

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

COMP219: Artificial Intelligence. Lecture 13: Game Playing

CS 771 Artificial Intelligence. Adversarial Search

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

CS 188: Artificial Intelligence. Overview

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

Game Playing State of the Art

Set 4: Game-Playing. ICS 271 Fall 2017 Kalev Kask

Foundations of AI. 6. Adversarial Search. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard & Bernhard Nebel

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

Artificial Intelligence

Game Playing. Garry Kasparov and Deep Blue. 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.

Adversarial Search 1

CSE 573: Artificial Intelligence Autumn 2010

CS 4700: Foundations of Artificial Intelligence

Artificial Intelligence. Minimax and alpha-beta pruning

School of EECS Washington State University. Artificial Intelligence

Artificial Intelligence Adversarial Search

Artificial Intelligence

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

CPS331 Lecture: Search in Games last revised 2/16/10

CSE 573: Artificial Intelligence

Game Playing AI Class 8 Ch , 5.4.1, 5.5

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

Ar#ficial)Intelligence!!

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

Adversarial Search and Game Playing

Intuition Mini-Max 2

Adversarial Search. Rob Platt Northeastern University. Some images and slides are used from: AIMA CS188 UC Berkeley

Adversarial Search (Game Playing)

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

Foundations of Artificial Intelligence

Artificial Intelligence

Foundations of Artificial Intelligence

Artificial Intelligence Search III

CSE 473: Ar+ficial Intelligence

CPS 570: Artificial Intelligence Two-player, zero-sum, perfect-information Games

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

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

Game-playing AIs: Games and Adversarial Search I AIMA

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

Lecture 14. Questions? Friday, February 10 CS 430 Artificial Intelligence - Lecture 14 1

Foundations of AI. 5. Board Games. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard and Luc De Raedt SA-1

Games (adversarial search problems)

ARTIFICIAL INTELLIGENCE (CS 370D)

Game-playing: DeepBlue and AlphaGo

Game-Playing & Adversarial Search Alpha-Beta Pruning, etc.

More Adversarial Search

Artificial Intelligence

Transcription:

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

Finite perfect-information zero-sum games Finite: finitely many agents, actions, states Perfect information: every agent knows the current state, all of the actions, and what they do No simultaneous actions players move one-at-a-time Constant-sum: regardless of how the game ends, Σ{agents utilities} = k. For every such game, there s an equivalent game in which (k = 0). Thus constant-sum games usually are called zero-sum games Examples: Deterministic: chess, checkers, go, othello (reversi), connect-four, qubic, mancala (awari, kalah), 9 men s morris (merelles, morels, mill) Stochastic: backgammon, monopoly, yahtzee, parcheesi, roulette, craps We ll start with deterministic games CMSC 421, Chapter 6 2

Outline A brief history of work on this topic The minimax theorem Game trees The minimax algorithm α-β pruning Resource limits and approximate evaluation CMSC 421, Chapter 6 3

A brief history 1846 (Babbage): machine to play tic-tac-toe 1928 (von Neumann): minimax theorem 1944 (von Neumann & Morgenstern): backward-induction algorithm (produces perfect play) 1950 (Shannon): minimax algorithm (finite horizon, approximate evaluation) 1951 (Turing): program (on paper) for playing chess 1952 7 (Samuel): checkers program, capable of beating its creator 1956 (McCarthy): pruning to allow deeper search 1957 (Bernstein): first complete chess program, on an IBM 704 vacuumtube computer, could examine about 350 positions/minute CMSC 421, Chapter 6 4

A brief history, continued 1967 (Greenblatt): first program to compete in human chess tournaments: 3 wins, 3 draws, 12 losses 1992 (Schaeffer): Chinook won the 1992 US Open checkers tournament 1994 (Schaeffer): Chinook became world checkers champion; Tinsley (human champion) withdrew for health reasons 1997 (Hsu et al): Deep Blue won 6-game chess match against world chess champion Gary Kasparov 2007 (Schaeffer et al, 2007): Checkers solved: with perfect play, it s a draw. This took 10 14 calculations over 18 years CMSC 421, Chapter 6 5

Basics A strategy specifies what an agent will do in every possible situation Strategies may be pure (deterministic) or mixed (probabilistic) Suppose agents A and B use strategies s and t to play a two-person zero-sum game G. Then A s expected utility is U A (s, t) From now on, we ll just call this U(s, t) Since G is zero-sum, U B (s, t) = U(s, t) Instead of A and B, we ll call the agents Max and Min Max wants to maximize U and Min wants to minimize it CMSC 421, Chapter 6 6

The Minimax Theorem (von Neumann, 1928) Minimax theorem: Let G be a two-person finite zero-sum game with players Max and Min. Then there are strategies s and t, and a number V G called G s minimax value, such that If Min uses t, Max s expected utility is V G, i.e., max s U(s, t ) = V G If Max uses s, Max s expected utility is V G, i.e., min t U(s, t) = V G Corollary 1: U(s, t ) = V G. Corollary 2: If G is a perfect-information game, then there are pure strategies s and t that satisfy the theorem. CMSC 421, Chapter 6 7

Game trees MA () MIN (O) MA () MIN (O) O O O O O O...... The name game tree comes from AI. Mathematical game theorists call this the extensive form of a game............. Root node the initial state TERMINAL O O O O O O O O O O... Children of a node the states a player can move to Utility 1 0 +1 CMSC 421, Chapter 6 8

Strategies on game trees MA () MIN (O) MA () MIN (O) O O... O O O O............... To construct a pure strategy for Max: At each node where it s Max s move, choose one branch At each node where it s Min s move, include all branches Let b = the O branching O factor O (max.... number of children of any node) TERMINAL O O O O O O O Utility h = the tree s height (max. depth of any node) 1 0 +1 The number of pure strategies for Max b h/2, with equality if every node of height < h node has b children CMSC 421, Chapter 6 9

Strategies on game trees MA () MIN (O) MA () MIN (O) O O... O O O O............... To construct a pure strategy for Min: At each node where it s Min s move, choose one branch At each node where it s Max s move, include all branches The number O of pure O strategies O. for.. Min b h/2 TERMINAL O O O O O O O with equality if every node of height < h node has b children Utility 1 0 +1 CMSC 421, Chapter 6 10

Finding the best strategy Brute-force way to find Max s and Min s best strategies: Construct the sets S and T of all of Max s and Min s pure strategies, then choose s = arg max s S t = arg min t T Complexity analysis: min t T U Max(s, t) max s S U Max(s, t) Need to construct and store O(b h/2 + b h/2 ) = O(b h/2 ) strategies Each strategy is a tree that has O(b h/2 ) nodes Thus space complexity is O(b h/2 b h/2 ) = O(b h ) Time complexity is slightly worse But there s an easier way to find the strategies CMSC 421, Chapter 6 11

Minimax Algorithm Compute a game s minimax value recursively from the minimax values of its subgames: MA 3 A 1 A 2 A 3 MIN 3 2 2 A 11 A 13 A 21 A 22 A 23 A 32 A 33 A 12 A 31 3 12 8 2 4 6 14 5 2 function Minimax(s) returns a utility value if s is a terminal state then return Max s payoff at s else if it is Max s move in s then return max{minimax(result(a, s)) : a is applicable to s} else return min{minimax(result(a, s)) : a is applicable to s} To get the next action, return argmax and argmin instead of max and min CMSC 421, Chapter 6 12

Properties of the minimax algorithm Is it sound? I.e., when it returns answers, are they correct? CMSC 421, Chapter 6 13

Properties of the minimax algorithm Is it sound? I.e., when it returns answers, are they correct? Yes (can prove this by induction) Is it complete? I.e., does it always return an answer when one exists? CMSC 421, Chapter 6 14

Properties of the minimax algorithm Is it sound? I.e., when it returns answers, are they correct? Yes (can prove this by induction) Is it complete? I.e., does it always return an answer when one exists? Yes on finite trees (e.g., chess has specific rules for this). Space complexity? CMSC 421, Chapter 6 15

Properties of the minimax algorithm Is it sound? I.e., when it returns answers, are they correct? Yes (can prove this by induction) Is it complete? I.e., does it always return an answer when one exists? Yes on finite trees (e.g., chess has specific rules for this). Space complexity? O(bh), where b and h are as defined earlier Time complexity? CMSC 421, Chapter 6 16

Properties of the minimax algorithm Is it sound? I.e., when it returns answers, are they correct? Yes (can prove this by induction) Is it complete? I.e., does it always return an answer when one exists? Yes on finite trees (e.g., chess has specific rules for this). Space complexity? O(bh), where b and h are as defined earlier Time complexity? O(b h ) For chess, b 35, h 100 for reasonable games 35 100 10 135 nodes This is about 10 55 times the number of particles in the universe (about 10 87 ) no way to examine every node! But do we really need to examine every node? CMSC 421, Chapter 6 17

Pruning example 1 MA 3 MIN 3 2 3 12 8 2 CMSC 421, Chapter 6 18

Pruning example 1 MA 3 MIN 3 2 3 12 8 2 Max will never move to this node, because Max can do better by moving to the first one Thus we don t need to figure out this node s minimax value CMSC 421, Chapter 6 19

Pruning example 1 MA 3 MIN 3 2 14 3 12 8 2 14 This node might be better than the first one CMSC 421, Chapter 6 20

Pruning example 1 MA 3 MIN 3 2 14 5 3 12 8 2 14 5 It still might be better than the first one CMSC 421, Chapter 6 21

Pruning example 1 MA 3 3 MIN 3 2 14 5 2 3 12 8 2 14 5 2 No, it isn t CMSC 421, Chapter 6 22

Pruning example 2 a 7 b = 7 c e 5 d j f =5 i Same idea works farther down in the tree Max won t move to e, because Max can do better by going to b Don t need e s exact value, because it won t change minimax(a) So stop searching below e CMSC 421, Chapter 6 23

Alpha-beta pruning Start a minimax search at node c Let α = biggest lower bound on any ancestor of f α = max( 2, 4, 0) = 4 in the example If the game reaches f, Max will get utility 3 2 c 2 d 4 To reach f, the game must go through d But if the game reaches d, Max can get utility 4 by moving off of the path to f So the game will never reach f We can stop trying to compute u (f), because it can t affect u (c) 4 0 3 3 e f 0 α = 4 This is called an alpha cutoff CMSC 421, Chapter 6 24

Alpha-beta pruning Start a minimax search at node a Let β = smallest upper bound on any ancestor of d β = min(5, 2, 3) = 2 in the example If the game reaches d, Max will get utility 0 5 a 5 b 2 To reach d, the game must go through b But if the game reaches b, Min can make Max s utility 2 by moving off of the path to d So the game will never reach d We can stop trying to compute u (d), because it can t affect u (a) 2 3 0 0 c d 3 β = 2 This is called a beta cutoff CMSC 421, Chapter 6 25

The alpha-beta algorithm function Alpha-Beta(s, α, β) returns a utility value inputs: s, current state in game α, the value of the best alternative for max along the path to s β, the value of the best alternative for min along the path to s if s is a terminal state then return Max s payoff at s else if it is Max s move at s then v for every action a applicable to s do v max(v, Alpha-Beta(result(a, s), α, β)) if v β then return v α max(α, v) else v for every action a applicable to s do v min(v, Alpha-Beta(result(a, s), α, β)) if v α then return v β min(β, v) return v CMSC 421, Chapter 6 26

α-β pruning example α = b α = a c e d j m f i k l g h CMSC 421, Chapter 6 27

α-β pruning example α = b 7 α = 7 a 7 c e d j m f i k l g h CMSC 421, Chapter 6 28

α-β pruning example α = b 7 f g h e α = 7 a 7 d c i k l j m CMSC 421, Chapter 6 29

α-β pruning example α = b 7 f 5 g 5 h -3 e α = 7 a 7 d c i k l j m CMSC 421, Chapter 6 30

α-β pruning example α = 7 a α = 7 c b 7 d 5 e 5 j alpha cutoff f 5 i k l g 5 h -3 m CMSC 421, Chapter 6 31

α-β pruning example α = 7 a α = 7 b 7 d 5 e 5 alpha cutoff f 5 i k g 5 h -3 c j l m CMSC 421, Chapter 6 32

α-β pruning example α = 7 a α = 7 c b 7 d 5 8 e 5 j alpha cutoff 8 f 5 i 8 k l g 5 h -3 0 8 β = 8 m CMSC 421, Chapter 6 33

α-β pruning example α = 7 a α = 7 c b 7 d m 5 8 e 5 j alpha cutoff 8 f 5 i 8 k l β = 8 9 beta cutoff g 5 h -3 0 8 9 CMSC 421, Chapter 6 34

α-β pruning example α = 7 a α = 7 8 c b 7 α = 7 8 d m 5 8 8 e 5 j alpha cutoff 8 f 5 i 8 k l β = 8 9 beta cutoff g 5 h -3 0 8 9 CMSC 421, Chapter 6 35

α-β pruning example α = 7 a α = 7 8 c b 7 α = 7 8 β = 8 d m 5 8 8 e 5 j alpha cutoff 8 f 5 i 8 k l β = 8 9 beta cutoff g 5 h -3 0 8 9 CMSC 421, Chapter 6 36

Properties of α-β α-β is a simple example of the value of reasoning about which computations are relevant (a form of metareasoning) if α minimax(s) β, then alpha-beta returns minimax(s) if minimax(s) α, then alpha-beta returns a value α if minimax(s) β, then alpha-beta returns a value β If we start with α = and, then alpha-beta will always return minimax(s) Good move ordering can enable us to prune more nodes. Best case is if at nodes where it s Max s move, children are largest-value first at nodes where it s Min s move, children are smallest-value first In this case time complexity = O(b h/2 ) doubles the solvable depth Worst case is the reverse In this case, α-β will search every node CMSC 421, Chapter 6 37

Resource limits Even with alpha-beta, it can still be infeasible to search the entire game tree (e.g., recall chess has about 10 135 nodes) need to limit the depth of the search Basic approach: let d be a positive integer Whenever we reach a node of depth > d If we re at a terminal state, then return Max s payoff Otherwise return an estimate of the node s utility value, computed by a static evaluation function CMSC 421, Chapter 6 38

α-β with a bound d on the search depth function Alpha-Beta(s, α, β, d) returns a utility value inputs: s, α, β, same as before d, an upper bound on the search depth if s is a terminal state then return Max s payoff at s else if d = 0 then return Eval(s) else if it is Max s move at s then v for every action a applicable to s do v max(v, Alpha-Beta(result(a, s), α, β, d 1)) if v β then return v α max(α, v) else v for every action a applicable to s do v min(v, Alpha-Beta(result(a, s), α, β, d 1)) if v α then return v β min(α, v) return v CMSC 421, Chapter 6 39

Evaluation functions Eval(s) is supposed to return an approximation of s s minimax value Eval is often a weighted sum of features Eval(s) = w 1 f 1 (s) + w 2 f 2 (s) +... + w n f n (s) Black to move White to move E.g., White slightly better Black winning 1(number of white pawns number of black pawns) + 3(number of white knights number of black knights) +... CMSC 421, Chapter 6 40

Exact values for Eval don t matter MA MIN 1 2 1 20 1 2 2 4 1 20 20 400 Behavior is preserved under any monotonic transformation of Eval Only the order matters: In deterministic games, payoff acts as an ordinal utility function CMSC 421, Chapter 6 41

Discussion Deeper lookahead (i.e., larger depth bound d) usually gives better decisions Exceptions do exist Main result in my PhD dissertation (30 years ago!): pathological games in which deeper lookahead gives worse decisions But such games hardly ever occur in practice Suppose we have 100 seconds, explore 10 4 nodes/second 10 6 35 8/2 nodes per move α-β reaches depth 8 pretty good chess program Some modifications that can improve the accuracy or computation time: node ordering (see next slide) quiescence search biasing transposition tables thinking on the opponent s time... CMSC 421, Chapter 6 42

Node ordering Recall that I said: Best case is if at nodes where it s Max s move, children are largest first at nodes where it s Min s move, children are smallest first In this case time complexity = O(b h/2 ) doubles the solvable depth Worst case is the reverse How to get closer to the best case: Every time you expand a state s, apply Eval to its children When it s Max s move, sort the children in order of largest Eval first When it s Min s move, sort the children in order of smallest Eval first CMSC 421, Chapter 6 43

Quiescence search and biasing In a game like checkers or chess The evaluation is based greatly on material pieces It s likely to be inaccurate if there are pending captures e.g., if someone is about to take your queen Search deeper to reach a position where there aren t pending captures Evaluations will be more accurate here But it creates another problem You re searching some paths to an even depth, others to an odd depth Paths that end just after your opponent s move will generally look worse than paths that end just after your move Add or subtract a number called the biasing factor to try to fix this CMSC 421, Chapter 6 44

Transposition tables Often there are multiple paths to the same state (i.e., the state space is a really graph rather than a tree) Idea: when you compute s s minimax value, store it in a hash table visit s again retrieve its value rather than computing it again The hash table is called a transposition table Problem: far too many states to store all of them s Store some of the states, rather than all of them Try to store the ones that you re most likely to need CMSC 421, Chapter 6 45

Thinking on the opponent s time Current state s, children s 1,..., s n Compute their minimax values, move to the one that looks best say, s i You computed s i s minimax value as the minimum of the values of its children, s i1,..., s im Let s ij be the one that has the smallest minimax value That s where the opponent is most likely to move to Do a minimax search below s ij while waiting for the opponent to move If your opponent moves to s ij then you ve already done a lot of the work of figuring out your next move CMSC 421, Chapter 6 46

Game-tree search in practice Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in 1994. Checkers was solved in April 2007: from the standard starting position, both players can guarantee a draw with perfect play. This took 10 14 calculations over 18 years. Checkers has a search space of size 5 10 20. Chess: Deep Blue defeated human world champion Gary Kasparov in a sixgame match in 1997. Deep Blue searches 200 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: until recently, human champions didn t compete against computers because the computers were too bad. But that has changed... CMSC 421, Chapter 6 47

Game-tree search in the game of go A game tree s size grows exponentially with both its depth and its branching factor Go is much too big for a normal game-tree search: branching factor = about 200 game length = about 250 to 300 moves number of paths in the game tree = 10 525 to 10 620 For comparison: Number of atoms in universe = about 10 80 Number of particles in universe = about 10 87 b =2 b =3 b =4 CMSC 421, Chapter 6 48

Game-tree search in the game of go During the past couple years, go programs have gotten much better Main reason: Monte Carlo roll-outs Basic idea: do a minimax search of a randomly selected subtree At each node that the algorithm visits, It randomly selects some of the children There are some heuristics for deciding how many Calls itself recursively on these, ignores the others CMSC 421, Chapter 6 49

Forward pruning in chess Back in the 1970s, some similar ideas were tried in chess The approach was called forward pruning Main difference: select the children heuristically rather than randomly It didn t work as well as brute-force alpha-beta, so people abandoned it Why does a similar idea work so much better in go? CMSC 421, Chapter 6 50

Perfect-information nondeterministic games Backgammon: chance is introduced by dice 0 1 2 3 4 5 6 7 8 9 10 11 12 25 24 23 22 21 20 19 18 17 16 15 14 13 CMSC 421, Chapter 6 51

Expectiminimax MA CHANCE 3 1 0.5 0.5 0.5 0.5 MIN 2 4 0 2 2 4 7 4 6 0 5 2 function ExpectiMinimax(s) returns an expected utility if s is a terminal state then return Max s payoff at s if s is a chance node then return Σ s P (s s)expectiminimax(s ) else if it is Max s move at s then return max{expectiminimax(result(a, s)) : a is applicable to s} else return min{expectiminimax(result(a, s)) : a is applicable to s} This gives optimal play (i.e., highest expected utility) CMSC 421, Chapter 6 52

With nondeterminism, exact values do matter MA DICE 2.1 1.3.9.1.9.1 21 40.9.9.1.9.1 MIN 2 3 1 4 20 30 1 400 2 2 3 3 1 1 4 4 20 20 30 30 1 1 400 400 At chance nodes, we need to compute weighted averages Behavior is preserved only by positive linear transformations of Eval Hence Eval should be proportional to the expected payoff CMSC 421, Chapter 6 53

In practice Dice rolls increase b: 21 possible rolls with 2 dice Given the dice roll, 20 legal moves on average (for some dice roles, can be much higher) depth 4 = 20 (21 20) 3 1.2 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-2 search + very good Eval world-champion level CMSC 421, Chapter 6 54

Summary We looked at games that have the following characteristics: two players zero sum perfect information deterministic finite In these games, can do a game-tree search minimax values, alpha-beta pruning In sufficiently complicated games, perfection is unattainable must approximate: limited search depth, static evaluation function In games that are even more complicated, further approximation is needed Monte Carlo roll-outs If we add an element of chance (e.g., dice rolls), expectiminimax CMSC 421, Chapter 6 55