Download presentation
Presentation is loading. Please wait.
Published byJohnathan Cummings Modified over 6 years ago
1
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6
2
Games like Chess or Go are compact settings that mimic the uncertainty of interacting with the natural world For centuries humans have used them to exert their intelligence Recently, there has been great success in building game programs that challenge human supremacy
3
Relation to Previous Lecture
Here, uncertainty is caused by the actions of another agent (MIN), which competes with our agent (MAX)
4
Relation to Previous Lecture
Here, uncertainty is caused by the actions of another agent (MIN), which competes with our agent (MAX) MIN wants MAX to fail (and vice versa) No plan exists that guarantees MAX’s success regardless of which actions MIN executes (the same is true for MIN) At each turn, the choice of which action to perform must be made within a specified time limit The state space is enormous: only a tiny fraction of this space can be explored within the time limit
5
Specific Setting Two-player, turn-taking, deterministic, fully observable, zero-sum, time-constrained game State space Initial state Successor function: it tells which actions can be executed in each state and gives the successor state for each action MAX’s and MIN’s actions alternate, with MAX playing first in the initial state Terminal test: it tells if a state is terminal and, if yes, if it’s a win or a loss for MAX, or a draw All states are fully observable
6
Game Tree MAX nodes MAX’s play MIN’s play Terminal state (win for MAX) MIN nodes Here, symmetries have been used to reduce the branching factor
7
Game tree (2-player, deterministic, turns)
8
Minimax Perfect play for deterministic games
Idea: choose move to position with highest minimax value = best achievable payoff against best play E.g., 2-ply game:
9
Minimax algorithm
10
20 A C D B E F G H I J K M L 15 N O P Q R S T U V W X Y Z A1 -3 -5 -10
4 6 -7 12 4 8 20 12 30 20 10
11
v= -i Max v= i Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
12
v= -i Max v= i Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
13
v= -i Max v= i Min v= -3 Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
14
v= -i Max v= i Min v= -3 Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
15
v= -i Max v= i Min v= 15 Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
16
v= -i Max v= i Min v= 15 Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
17
v= -i Max v= i Min return v= 15 Max 20 A C D B E F G H I J K M L 15 N
O P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
18
v= -i Max v= 15 Min return v= 15 Max 20 A C D B E F G H I J K M L 15 N
O P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
19
v= -i Max v= 15 Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q
R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
20
v= -i Max v= 15 Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q
R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
21
v= -i Max v= 15 Min v= -10 Max 20 A C D B E F G H I J K M L 15 N O P Q
R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
22
v= -i Max v= 15 Min v= -10 Max 20 A C D B E F G H I J K M L 15 N O P Q
R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
23
v= -i Max v= 15 Min v= 3 Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
24
v= -i Max v= 15 Min return v= 3 Max 20 A C D B E F G H I J K M L 15 N
O P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
25
v= -i Max v= 3 Min return v= 3 Max 20 A C D B E F G H I J K M L 15 N O
P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
26
v= -i Max return v= 3 Min Max 20 A C D B E F G H I J K M L 15 N O P Q
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
27
v= 3 Max return v= 3 Min Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
28
v= 3 Max v= i Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
29
v= 3 Max v= i Min return v= 6 Max 20 A C D B E F G H I J K M L 15 N O
P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
30
v= 3 Max v= 6 Min Max 20 A C D B E F G H I J K M L 15 N O P Q R S T U
W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
31
v= 3 Max v= 6 Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
32
v= 3 Max v= 6 Min return v= 12 Max 20 A C D B E F G H I J K M L 15 N O
P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
33
v= 3 Max return v= 6 Min Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
34
v= 6 Max return v= 6 Min Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
35
v= 6 Max v= i Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
36
v= 6 Max v= i Min return v= 8 Max 20 A C D B E F G H I J K M L 15 N O
P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
37
v= 6 Max v= 8 Min Max 20 A C D B E F G H I J K M L 15 N O P Q R S T U
W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
38
v= 6 Max v= 8 Min v= -i Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
39
v= 6 Max v= 8 Min return v= 30 Max 20 A C D B E F G H I J K M L 15 N O
P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
40
v= 6 Max v= 8 Min Max 20 A C D B E F G H I J K M L 15 N O P Q R S T U
W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
41
v= 6 Max v= 8 Min v=-i Max 20 A C D B E F G H I J K M L 15 N O P Q R S
T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
42
v= 6 Max v= 8 Min return v=20 Max 20 A C D B E F G H I J K M L 15 N O
P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
43
v= 6 Max return v= 8 Min Max 20 A C D B E F G H I J K M L 15 N O P Q R
S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
44
v= 8 with move to D Max Min Max 20 A C D B E F G H I J K M L 15 N O P
Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
45
max min 15 3 6 12 8 30 20 max 20 A C D B E F G H I J K M L 15 N O P Q
R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
46
max 6 8 3 min 15 3 6 12 8 30 20 max 20 A C D B E F G H I J K M L 15 N
O P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
47
8 max 6 8 3 min 15 3 6 12 8 30 20 max 20 A C D B E F G H I J K M L 15
O P Q R S T U V W X Y Z A1 -3 -5 -10 3 4 6 -7 12 4 8 20 12 30 20 10
48
Game Tree MAX’s play MIN’s play Terminal state (win for MAX) In general, the branching factor and the depth of terminal states are large Chess: Number of states: ~1040 Branching factor: ~35 Number of total moves in a game: ~100
49
Choosing an Action: Basic Idea
Using the current state as the initial state, build the game tree uniformly to the maximal depth h (called horizon) feasible within the time limit Evaluate the states of the leaf nodes Back up the results from the leaves to the root and pick the best action assuming the worst from MIN Minimax algorithm
50
Evaluation Function Function e: state s number e(s)
e(s) is a heuristics that estimates how favorable s is for MAX e(s) > 0 means that s is favorable to MAX (the larger the better) e(s) < 0 means that s is favorable to MIN e(s) = 0 means that s is neutral
51
Example: Tic-tac-Toe e(s) = number of rows, columns, and diagonals open for MAX - number of rows, columns, and diagonals open for MIN 8-8 = 0 6-4 = 2 3-3 = 0
52
Construction of an Evaluation Function
Usually a weighted sum of “features”: Features may include Number of pieces of each type Number of possible moves Number of squares controlled
53
Backing up Values Tic-Tac-Toe tree at horizon = 2 1 -1 1 -2 Best move
6-5=1 5-6=-1 5-5=0 5-5=1 4-5=-1 6-4=2 5-4=1 6-6=0 4-6=-2
54
Continuation 1 1 1 3 2 1 2 1 2 3 1 1
55
Why using backed-up values?
At each non-leaf node N, the backed-up value is the value of the best state that MAX can reach at depth h if MIN plays well (by the same criterion as MAX applies to itself) If e is to be trusted in the first place, then the backed-up value is a better estimate of how favorable STATE(N) is than e(STATE(N))
56
Minimax Algorithm Expand the game tree uniformly from the current state (where it is MAX’s turn to play) to depth h Compute the evaluation function at every leaf of the tree Back-up the values from the leaves to the root of the tree as follows: A MAX node gets the maximum of the evaluation of its successors A MIN node gets the minimum of the evaluation of its successors Select the move toward a MIN node that has the largest backed-up value
57
Minimax Algorithm Expand the game tree uniformly from the current state (where it is MAX’s turn to play) to depth h Compute the evaluation function at every leaf of the tree Back-up the values from the leaves to the root of the tree as follows: A MAX node gets the maximum of the evaluation of its successors A MIN node gets the minimum of the evaluation of its successors Select the move toward a MIN node that has the largest backed-up value Horizon: Needed to return a decision within allowed time
58
Repeated States Left as an exercise
[Distinguish between states on the same path and states on different paths]
59
Game Playing (for MAX) Repeat until a terminal state is reached
Select move using Minimax Execute move Observe MIN’s move Note that at each cycle the large game tree built to horizon h is used to select only one move All is repeated again at the next cycle (a sub-tree of depth h-2 can be re-used)
60
Can we do better? Yes ! Much better ! Pruning 3 3 -1
This part of the tree can’t have any effect on the value that will be backed up to the root Pruning -1
61
Example
62
Example The beta value of a MIN node is an upper bound on
the final backed-up value. It can never increase b = 2 2
63
Example 1 b = 1 2 The beta value of a MIN node is an upper bound on
the final backed-up value. It can never increase
64
Example 1 b = 1 2 a = 1 The alpha value of a MAX
node is a lower bound on the final backed-up value. It can never decrease
65
Example 1 b = 1 2 a = 1 -1 b = -1
66
Example 1 b = 1 2 a = 1 -1 b = -1 Search can be discontinued below
any MIN node whose beta value is less than or equal to the alpha value of one of its MAX ancestors
67
Alpha-Beta Pruning Explore the game tree to depth h in depth-first manner Back up alpha and beta values whenever possible Prune branches that can’t lead to changing the final decision
68
Example 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
69
Example 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
70
Example 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
71
Example -3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
72
Example -3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
73
Example -3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
74
Example 3 -3 3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
75
Example 3 -3 3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
76
Example 3 -3 3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
77
Example 3 -3 3 5 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
78
Example 3 2 -3 3 2 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
79
Example 3 2 -3 3 2 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
80
Example 2 2 3 2 -3 3 2 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
81
Example 2 2 3 2 -3 3 2 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
82
Example 2 2 3 2 -3 3 2 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
83
Example 2 2 3 2 -3 3 2 5 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
84
Example 2 2 3 2 1 -3 3 2 1 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
85
Example 2 2 3 2 1 -3 3 2 1 -3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
86
Example 2 2 3 2 1 -3 3 2 1 -3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
87
Example 2 1 2 1 3 2 1 -3 3 2 1 -3 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
88
Example 2 1 2 1 3 2 1 -3 3 2 1 -3 -5 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
89
Example 2 1 2 1 3 2 1 -3 3 2 1 -3 -5 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
90
Example 2 1 2 1 -5 3 2 1 -5 -3 3 2 1 -3 -5 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
91
Example 2 1 2 1 -5 3 2 1 -5 -3 3 2 1 -3 -5 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
92
Example 1 1 2 1 2 1 -5 3 2 1 -5 -3 3 2 1 -3 -5 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
93
Example 1 1 2 1 2 2 1 -5 2 3 2 1 -5 2 -3 3 2 1 -3 -5 2 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
94
Example 1 1 2 1 2 2 1 -5 2 3 2 1 -5 2 -3 3 2 1 -3 -5 2 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2
95
Alpha-Beta Algorithm Update the alpha/beta value of the parent of a node N when the search below N has been completed or discontinued Discontinue the search below a MAX node N if its alpha value is the beta value of a MIN ancestor of N Discontinue the search below a MIN node N if its beta value is the alpha value of a MAX ancestor of N
96
The α-β algorithm
97
The α-β algorithm
98
( -i, i) v= -i T1 T3 T2 G H D E F 5 3 I J K L M N O P R Q 7 S T U V W
X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
99
( -i, i) v= -i ( -i, i) T1 T3 T2 G H D E F 5 3 I J K L M N O P R Q 7 S
U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
100
( -i, i) v= -i ( -i, i) v= i Min T1 T3 T2 G H D E F 5 3 I J K L M N O
P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
101
( -i, i) v= -i ( -i, i) v= 3 Min T1 T3 T2 G H D E F 5 3 I J K L M N O
P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
102
( -i, i) v= -i ( -i, 3) v= 3 T1 T3 T2 G H D E F 5 3 I J K L M N O P R
Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
103
( -i, i) v= -i ( -i, 3) v= 3 min T1 T3 T2 G H D E F 5 3 I J K L M N O
P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
104
( -i, i) v= -i Max ( -i, 3) Return v=3 T1 T3 T2 G H D E F 5 3 I J K L
O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
105
( -i, i) v= 3 Max ( -i, 3) v= 3, return v T1 T3 T2 G H D E F 5 3 I J K
L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
106
( 3, i) v= 3 Max ( -i, 3) T1 T3 T2 G H D E F 5 3 I J K L M N O P R Q 7
S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
107
( 3, i) v= 3 (3, i) v= i T1 T3 T2 G H D E F 5 3 I J K L M N O P R Q 7
S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
108
( 3, i) v= 3 (3, i) v= i (3, i) v= -i T1 T3 T2 G H D E F 5 3 I J K L M
N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
109
( 3, i) v= 3 (3, i) v= i (3, i) v= -i (3, i) v= i T1 T3 T2 G H D E F 5
J K L M N O P v= i R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
110
( 3, i) v= 3 (3, i) v= i (3, i) v= -i (3, i) v= i T1 T3 T2 G H D E F 5
J K L M N O P v= i R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
111
( 3, i) v= 3 (3, i) v= i (3, i) v= -i (3, i) v= 0 Min T1 T3 T2 G H D E
F (3, i) v= -i 5 3 (3, i) I J K L M N O P v= 0 Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
112
( 3, i) v= 3 (3, i) v= i (3, i) v= -i (3, i) Return v=0 Min T1 T3 T2 G
H D E F (3, i) 5 v= -i 3 (3, i) I J K L M N O P Return v=0 Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
113
( 3, i) v= 3 (3, i) v= i (3, i) v= 0 T1 T3 T2 G H D E F 5 3 I J K L M
N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
114
( 3, i) v= 3 (3, i) v= i (3, i) v= 0 (3, i) T1 T3 T2 G H D E F 5 3 I J
K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
115
( 3, i) v= 3 (3, i) v= i (3, i) v= 0 (3, i) v= i Min T1 T3 T2 G H D E
F (3, i) 5 v= 0 3 (3, i) I J K L M N O P v= i Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
116
( 3, i) v= 3 (3, i) v= i (3, i) v= 0 (3, i) v= 5 Min T1 T3 T2 G H D E
F (3, i) 5 v= 0 3 (3, i) I J K L M N O P v= 5 Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
117
( 3, i) v= 3 (3, i) v= i (3, i) v= 0 (3, 5) v= 5 Min T1 T3 T2 G H D E
F (3, i) 5 v= 0 3 (3, 5) I J K L M N O P v= 5 Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
118
( 3, i) v= 3 (3, i) v= i (3, i) v= 0 (3, 5) v= 5 Min T1 T3 T2 G H D E
F (3, i) 5 v= 0 3 (3, 5) I J K L M N O P v= 5 Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
119
( 3, i) v= 3 (3, i) v= i (3, i) v= 0 Max (3, 5) Return v= 5 T1 T3 T2 G
H D E F (3, i) 5 v= 0 3 Max (3, 5) I J K L M N O P Return v= 5 R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
120
( 3, i) v= 3 (3, i) v= i (3, i) v= 5 Max T1 T3 T2 G H D E F 5 3 I J K
L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
121
( 3, i) v= 3 (3, i) v= i (5, i) v= 5 Max T1 T3 T2 G H D E F 5 3 I J K
L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
122
( 3, i) v= 3 (3, i) v= i Min (5, i) Return v=5 T1 T3 T2 G H D E F 5 3
J K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
123
( 3, i) v= 3 (3, i) v= 5 Min (5, i) Return v=5 T1 T3 T2 G H D E F 5 3
J K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
124
( 3, i) v= 3 (3, 5) v= 5 Min T1 T3 T2 G H D E F 5 3 I J K L M N O P R
Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
125
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v=-i T1 T3 T2 G H D E F 5 3 I J K L
O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
126
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,5) v= i T1 T3 T2 G H D E F
J v= i K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
127
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,5) v= i Min 7 T1 T3 T2 G H
D E F 5 3 (3,5) I J v= i K L M N O P Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
128
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,5) v= 7 Min 7 T1 T3 T2 G H
D E F 5 3 (3,5) I J v= 7 K L M N O P Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
129
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,5) v= 7 Min 7 T1 T3 T2 G H
D E F 5 3 (3,5) I J v= 7 K L M N O P Min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
130
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i Max (3,5) Return v= 7 7 T1 T3
G H D E F 5 3 Max (3,5) I J Return v= 7 K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
131
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= 7 Max (3,5) Return v= 7 7 T1 T3
G H D E F 5 3 Max (3,5) I J Return v= 7 K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
132
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) Return v=7 Max 7 T1 T3 T2 G H D E F
J K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
133
( 3, i) v= 3 (3, 5) v= 5 Min 7 T1 T3 T2 G H D E F 5 3 I J K L M N O P
R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
134
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i 7 T1 T3 T2 G H D E F 5 3 I J
K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
135
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,5) v= i 7 T1 T3 T2 G H D E
F 5 3 (3,5) I J K L M N O P v= i R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
136
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,5) v= i min 7 T1 T3 T2 G H
D E F 5 3 (3,5) I J K L M N O P v= i min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
137
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,5) v= 4 min 7 T1 T3 T2 G H
D E F 5 3 (3,5) I J K L M N O P v= 4 min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
138
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,4) v= 4 min 7 T1 T3 T2 G H
D E F 5 3 (3,4) I J K L M N O P v= 4 min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
139
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i (3,4) v= 4 min 7 T1 T3 T2 G H
D E F 5 3 (3,4) I J K L M N O P v= 4 min R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
140
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= -i Max (3,4) Return v= 4 7 T1 T3
G H v= -i D E F 5 3 Max (3,4) I J K L M N O P Return v= 4 R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
141
( 3, i) v= 3 (3, 5) v= 5 Min (3,5) v= 4 Max (3,4) Return v= 4 7 T1 T3
G H v= 4 D E F 5 3 Max (3,4) I J K L M N O P Return v= 4 R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
142
( 3, i) v= 3 (3, 5) v= 5 Min (4,5) v= 4 Max 7 T1 T3 T2 G H D E F 5 3 I
J K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
143
( 3, i) v= 3 (3, 5) v= 5 Min (4,5) v= 4 Max (4,5) v= i 7 T1 T3 T2 G H
D E F 5 3 Max (4,5) I J K L M N O P v= i R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
144
( 3, i) v= 3 (3, 5) v= 5 Min (4,5) v= 4 Max (4,5) v= i 7 T1 T3 T2 G H
D E F 5 3 Max (4,5) I J K L M N O P v= i R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
145
( 3, i) v= 3 (3, 5) v= 5 Min (4,5) v= 4 Max (4,5) v= 2 7 T1 T3 T2 G H
D E F 5 3 Max (4,5) I J K L M N O P v= 2 R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
146
( 3, i) v= 3 (3, 5) v= 5 Min (4,5) v= 4 Max (4,5) return v=2 7 T1 T3
G H v= 4 D E F 5 3 Max (4,5) I J K L M N O P return v=2 R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
147
( 3, i) v= 3 (3, 5) v= 5 Min (4,5) v= 4 Max 7 T1 T3 T2 G H D E F 5 3 I
J K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
148
( 3, i) v= 3 (3, 5) v= 5 Min (4,5) Return v= 4 Max 7 T1 T3 T2 G H D E
F 5 3 Max I J K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
149
( 3, i) v= 3 (3, 5) v= 4 Min 7 T1 T3 T2 G H D E F 5 3 I J K L M N O P
R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
150
( 3, i) v= 3 (3, 4) Return v=4 Min 7 T1 T3 T2 G H D E F 5 3 I J K L M
O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
151
( 3, i) v= 4 Min 7 T1 T3 T2 G H D E F 5 3 I J K L M N O P R Q 7 S T U
W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
152
( 4, i) v= 4 Min 7 T1 T3 T2 G H D E F 5 3 I J K L M N O P R Q 7 S T U
W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
153
return v=4 and associated move to T3
Min G H D E F 5 3 I J K L M N O P R Q 7 S T U V W X Y Z A1 A2 A3 A4 A5 A6 A7 A8 A9 10 3 5 6 7 8 8 10 -3 -12 4 2 6 4 5 2 8
154
How much do we gain? Consider these two cases: 3 a = 3 -1 b=-1 (4) 3
155
How much do we gain? Assume a game tree of uniform branching factor b
Minimax examines O(bh) nodes, so does alpha-beta in the worst-case The gain for alpha-beta is maximum when: The MIN children of a MAX node are ordered in increasing backed up values The MAX children of a MIN node are ordered in decreasing backed up values Then alpha-beta examines O(bh/2) nodes [Knuth and Moore, 1975] But this requires an oracle (if we knew how to order nodes perfectly, we would not need to search the game tree) If nodes are ordered at random, then the average number of nodes examined by alpha-beta is ~O(b3h/4)
156
Heuristic Ordering of Nodes
Order the nodes below the root according to the values backed-up at the previous iteration Order MIN (resp.MAX) nodes by decreasing (increasing) values of the evaluation function e computed at these nodes
157
Other Improvements Adaptive horizon + iterative deepening
Extended search: Retain k>1 best paths, instead of just one, and extend the tree at greater depth below their leaf nodes to (help dealing with the “horizon effect”) Singular extension: If a move is obviously better than the others in a node at horizon h, then expand this node along this move Use transposition tables to deal with repeated states Null-move search
158
Deterministic games in practice
Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in Used a precomputed endgame database defining perfect play for all positions involving 8 or fewer pieces on the board, a total of 444 billion positions. Chess: Deep Blue defeated human world champion Garry Kasparov in a six-game match in 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: 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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.