Professional Documents
Culture Documents
Game Playing: Games. Why? Minimax Search Alpha-Beta Pruning
Game Playing: Games. Why? Minimax Search Alpha-Beta Pruning
Games. Why?
Minimax search
Alpha-beta pruning
Some games:
Ball games
Card games
Board games
Computer games
...
2
Why study board games ?
One of the oldest sub-fields of AI
3
Game playing
Up till now we have assumed the situation is not going to
change whilst we search.
Turing (chess)
4
Why study board games ?
“A chess (or draughts) playing computer would be
proof of a machine doing something thought to
require intelligence”
6
Types of games
Deterministic Chance
7
Game Playing - Chess
Size of search space (10120 - average of 40 moves)
8
Game Playing - Chess
1958 - First computer to play chess was an IBM 704 - about one
millionth capacity of deep blue.
9
Game Playing - Chess
May 11th 1997, Gary Kasparov lost a six match game to Deep
blue
3.5 to 2.5
Two wins for deep blue, one win for Kasparov and three
draws
10
Game Playing - Minimax
Game Playing: An opponent tries to thwart your every
move
1944 - John von Neumann outlined a search method
(Minimax) that maximised your position whilst
minimising your opponents
MIN 1 B -3 C
MAX 4 D 1 E 2 F -3 G
4 -5 -5 1 -7 2 -3 -8
14
Alpha-Beta idea:
Principles:
generate the tree depth-first, left-to-right
propagate final values of nodes as initial estimates
MAX 2 Alpha-value
MIN 2 =2 1 Beta-value
MAX
2 5 1
16
The Alpha-Beta principles (1):
- If an ALPHA-value is larger or equal than the Beta-value
of a descendant node:
stop generation of the children of the descendant
MAX 2 Alpha-value
MIN 2 =2 1 Beta-value
MAX
2 5 1
17
The Alpha-Beta principles (2):
- If an Beta-value is smaller or equal than the Alpha-value
of a descendant node:
stop generation of the children of the descendant
MAX 2
MIN 2 =2 1 Beta-value
MAX Alpha-value
2 5 3
18
Alpha-Beta Pruning example
A
MAX
<=6 B C
MIN
6 D >=8 E
MAX
H I J K
6 5 8
= agent = opponent
19
Alpha-Beta Pruning example
>=6 A
MAX
6 B <=2 C
MIN
6 D >=8 E 2 F G
MAX
H I J K L M
6 5 8 2 1
= agent = opponent
20
Alpha-Beta Pruning example
>=6 A
MAX
6 B 2 C
MIN
6 D >=8 E 2 F G
MAX
H I J K L M
6 5 8 2 1
= agent = opponent
21
Alpha-Beta Pruning example
6 A
MAX
6 B 2 C beta
cutoff
MIN
6 D >=8 E alpha 2 F G
cutoff
MAX
H I J K L M
6 5 8 2 1
= agent = opponent
22
Mini-Max with at work:
4 16 5 31 = 5 39
MAX
8 6 5 23
= 4 15 = 5 30 3 38
MIN
8 2 2 10 1 18 1 33
4 12 3 20 3 25 2 35
=8 5 9 8 9 27 6 29 = 3 37
= 4 14 = 5 22
MAX
8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2 8 6 4
1 3 4 7 9 11 13 17 19 21 24 26 28 32 34 36
11 static evaluations saved !! 23
“DEEP” cut-offs
- For game trees with at least 4 Min/Max layers:
the Alpha - Beta rules apply also to deeper levels.
4
4
4
4 2
4 2
24
The Gain: Best case:
- If at every layer: the best node is the left-most one
MAX
MIN
MAX
21 12 3 MIN
21 24 27 12 15 18 3 6 9
MAX
21 20 19 24 23 22 27 26 25 12 11 10 15 14 13 18 17 16 3 2 1 6 5 4 9 8 7
26
Best case gain pictured:
# Static evaluations b = 10
No pruning
100000
10000 Alpha-Beta
Best case
1000
100
10
Depth
1 2 3 4 5 6 7
- Note: algorithmic scale.
- Conclusion: still exponential growth !!
- Worst case??
For some trees alpha-beta does nothing,
For some trees: impossible to reorder to avoid cut-offs27
The horizon effect.
Queen lost
depth-bound
29
Time bounds:
How to play within reasonable time bounds?
Even with fixed depth-bound, times can vary strongly!
Solution:
Iterative Deepening !!!
30
Summary