Professional Documents
Culture Documents
Chapter 8
Outline
• Overview
• Minimax search
• Adding alpha-beta cutoffs
• Additional refinements
• Iterative deepening
• Specific games
2
Overview
Old beliefs
Games provided a structured task in which it was very easy to
measure success or failure.
3
Overview
Chess
The average branching factor is around 35.
4
Overview
5
Overview
6
Overview
7
Overview
8
Minimax Search
9
Minimax Search
A -2 Maximizing ply
Player
B -6 C -2 D -4
Minimizing ply
E F G H I J K Opponent
9 -6 0 0 -2 -4 -3
Two-ply search
10
Minimax Search
Player(Position, Depth):
for each S ∈ SUCCESSORS(Position) do
RESULT = Opponent(S, Depth + 1)
NEW-VALUE = VALUE(RESULT)
Opponent(Position, Depth):
for each S ∈ SUCCESSORS(Position) do
RESULT = Player(S, Depth + 1)
NEW-VALUE = VALUE(RESULT)
Any-Player(Position, Depth):
for each S ∈ SUCCESSORS(Position) do
RESULT = Any-Player(S, Depth + 1)
NEW-VALUE = − VALUE(RESULT)
• MOVE-GEN(Position, Player).
• STATIC(Position, Player).
• DEEP-ENOUGH(Position, Depth)
14
Minimax Search
1. if DEEP-ENOUGH(Position, Depth), then return:
15
Minimax Search
4. if SUCCESSORS is not empty:
RESULT-SUCC = MINIMAX(SUCC, Depth+1, Opp(Player))
NEW-VALUE = - VALUE(RESULT-SUCC)
if NEW-VALUE > BEST-SCORE, then:
BEST-SCORE = NEW-VALUE
BEST-PATH = PATH(RESULT-SUCC) + SUCC
5. Return:
VALUE = BEST-SCORE
PATH = BEST-PATH
16
Adding Alpha-Beta Cutoffs
17
Adding Alpha-Beta Cutoffs
A
Maximizing ply
>3
Player
B 3 C
Minimizing ply
D E F G Opponent
3 5 -5
Alpha cutoffs
18
Adding Alpha-Beta Cutoffs
A
Maximizing ply
>3
Player
B C
<5 Minimizing ply
Opponent
D E F G H
3 5 Maximizing ply
Player
I J M N
5 7 Minimizing ply
Alpha and Beta Opponent
cutoffs K L
0
19
Adding Alpha-Beta Cutoffs
Opponent
β
Player
α≥β α
Opponent
α≥β
Player
Alpha and Beta
cutoffs
20
Player(Position, Depth, α, β):
for each S ∈ SUCCESSORS(Position) do
RESULT = Opponent(S, Depth + 1, α, β)
NEW-VALUE = VALUE(RESULT)
if α ≥ β then return
VALUE = α
PATH = BEST-PATH
return
VALUE = α
PATH = BEST-PATH
21
Opponent(Position, Depth, α, β):
for each S ∈ SUCCESSORS(Position) do
RESULT = Player(S, Depth + 1, α, β)
NEW-VALUE = VALUE(RESULT)
if β ≤ α then return
VALUE = β
PATH = BEST-PATH
return
VALUE = β
PATH = BEST-PATH
22
Any-Player(Position, Depth, α, β):
for each S ∈ SUCCESSORS(Position) do
RESULT = Any-Player(S, Depth + 1, −β, −α)
NEW-VALUE = − VALUE(RESULT)
if α ≥ β then return
VALUE = α
PATH = BEST-PATH
return
VALUE = α
PATH = BEST-PATH
23
Adding Alpha-Beta Cutoffs
24
Adding Alpha-Beta Cutoffs
1. if DEEP-ENOUGH(Position, Depth), then return:
25
Adding Alpha-Beta Cutoffs
4. if SUCCESSORS is not empty:
RESULT-SUCC = MINIMAX-A-B(SUCC, Depth + 1,
Opp(Player), − PassTd, − UseTd)
NEW-VALUE = - VALUE(RESULT-SUCC)
if NEW-VALUE > PassTd, then:
PassTd = NEW-VALUE
BEST-PATH = PATH(RESULT-SUCC) + SUCC
• Futility cutoffs
• Waiting for quiescence
• Secondary search
• Using book moves
• Not assuming opponent’s optimal move
27
Iterative Deepening
Iteration 1
Iteration 2
Iteration 3
28
Iterative Deepening
29
Iterative Deepening
30
Iterative Deepening
Depth-First Iterative Deepening (DFID)
1. Set SEARCH-DEPTH = 1
31
Iterative Deepening
Iterative-Deepening-A* (IDA*)
32
Iterative Deepening
33
Homework
Presentations
– Specific games: Chess – State of the Art
34