Professional Documents
Culture Documents
Minimax Procedure
minimax(board, depth, type)
If depth = 0 return Eval-Fn(board)
else if type = max
cur-max = -inf
loop for b in succ(board)
b-val = minimax(b,depth-1,min)
cur-max = max(b-val,cur-max)
return cur-max
else (type = min)
cur-min = inf
loop for b in succ(board)
b-val = minimax(b,depth-1,max)
cur-min = min(b-val,cur-min)
return cur-min
Minimax
max
min
max
min
Minimax
max
min
10
10
max
min
10
10
14
9
14
2
13
24
1
24
Pruning
Suppose your program can search 1000
positions/second.
In chess, you get roughly 150 seconds per move so you
can search 150,000 positions.
Since chess has a branching factor of about 35, your
program can only search 34 ply!
An average human plans 68 moves ahead so your
program will act like a novice.
Fortunately, we can often avoid searching parts of the
game tree by keeping track of the best and worst
alternatives at each point. This is called pruning the
search tree.
Alpha-Beta Pruning
Alpha-beta pruning is used on top of minimax search to
detect paths that do not need to be explored. The intuition
is:
The MAX player is always trying to maximize the score. Call
this .
The MIN player is always trying to minimize the score. Call
this .
When a MIN node has <= the of its MAX ancestors,
then this path will never be taken. (MAX has a better
option.) This is called an -cutoff.
When a MAX node has >= the of its MIN ancestors, then
this path will never be taken. (MIN has a better option.) this
is called an -cutoff
Bounding Search
The minimax procedure explores every path of length
depth. Can we do less work?
MAX
B
MIN
E
G H
Bounding Search
MAX
B (3)
(3)
MIN
E (3) F (12) G (8) H
Bounding Search
MAX
B (3)
(3)
C (<-5)
MIN
E (3) F (12) G (8) H (-5) I
Bounding Search
A (3)
MAX
B (3)
C (<-5)
D (2)
MIN
E (3) F (12) G (8) H (-5) I
J (15)
K (5) L (2)
- pruning: example
6
MAX
MIN
12
- pruning: example
6
MAX
MIN
12
- pruning: example
6
MAX
MIN
12
- pruning: example
6
MAX
Selected move
MIN
12
Opponent
Player
Opponent
Properties of Alpha-Beta
Pruning
Alpha-beta pruning
Pruning does not affect final result
Alpha-beta pruning
Asymptotic time complexity
O((b/log b)d)
Procedure
minimax-(board, depth, type, , )
If depth = 0 return Eval-Fn(board)
else if type = max
cur-max = -inf
loop for b in succ(board)
b-val = minimax-(b,depth-1,min, , )
cur-max = max(b-val,cur-max)
= max(cur-max,
if cur-max >= finish loop
return cur-max
else type = min
cur-min = inf
loop for b in succ(board)
b-val = minimax-(b,depth-1,max, , )
cur-min = min(b-val,cur-min)
= min(cur-min,
if cur-min <= finish loop
return cur-min
Pruning Example
max
min
max
min
Pruning Example
max
min
10
10
max
min
10
10
14
9
14
Max
Min
Max
Min
A (3)
MIN
E F G H I
(3) (12) (8) (-5)
J
K L
(15) (5) (2)
Original Ordering
A (3)
B (3) C (<-5) D (<2)
E F G H I
(3) (12) (8) (-5)
L
K J
(2) (5) (15)
Better Ordering
http://www.gametheory.net/applets/
P(d ) max
i
s S ( C , di )
(utility ( s ))
Complexity of expectiminimax
The expectiminimax considers all the possible dice-roll
sequences
It takes O(bmnm)
where n is the number of distinct rolls
Whereas, minimax takes O(bm)
Problems
The extra cost compared to minimax is very high
Alpha-beta pruning is more difficult to apply
Context
Terrorists do a lot of different things
The U.S. can try and anticipate all kinds of
things in defense of these attacks
If the U.S. fails to invest wisely, then we
lose important battles.
A Smallpox Exercise
The U.S. government is concerned about
the possibility of smallpox bioterrorism.
Terrorists could make no smallpox attack, a
small attack on a single city, or
coordinated attacks on multiple cities (or
do other things).
Small Attack
Big Attack
Stockpile
C11
C12
C13
Surveillance
C21
C22
C23
First Responders
C31
C32
C33
Mass Inoculation
C41
C42
C43
Minimax Strategy
The U.S. should choose the defense with smallest rowwise max cost.
The terrorist should choose the attack with largest columnwise min cost.
If these are not equal then a randomized strategy is better.
Cost Example
To illustrate a key idea, consider the
problem of estimating the cost C11 in the
game theory matrix. This is the cost
associated with stockpiling vaccine when
no smallpox attack occurs.
Some components of the cost are fixed,
others are random.
More examples
Cost to treat one smallpox case; this is normal with
mean $200,000 and s.d. $50,000.
Cost to inoculate 25,000 people; this is normal with
mean $60,000 and s.d. $10,000.
Economic costs of a single attack; this is gamma
with mean $5 billion and s.d. $10 billion.
Games + Risk
Game theory and statistical risk analysis can
be combined to give arguably useful
guidance in threat management.
We generate many random tables,
according to the risk analysis, and find
which defenses are best.
Conclusions
For our rough risk analysis, minimax favors universal
inoculation, minimum expected loss favors stockpiling.
This accords with the public and federal thinking on threat
preparedness.