G Pl i Game Playing
α-β Pruning α β Pruning
Introduction to Artificial Intelligence Hadi Moradi
1
Properties of - //the leaf node (terminal state) ) 9 ( The - - - PowerPoint PPT Presentation
G Game Playing Pl i - Pruning Pruning Introduction to Artificial Intelligence Hadi Moradi 1 2. - pruning: search cutoff Pruning: eliminating a branch of the search tree from consideration without exhaustive examination
1
Pruning: eliminating a branch of the search tree
Does it work?
Yes, it roughly cuts the branching factor from b to √b
2
3
4
5
6
Player Opponent
m
Opponent
If α > v then MAX will chose m so prune tree under n Similar for β for MIN
Player
β
7
Opponent
8
9
10
11
Complete: Yes, for finite state-space Optimal: Yes Time complexity: O(bm) Space complexity: O(bm) (= DFS
Does not keep all nodes in memory.)
12
Note: These are both Local variables. At the Start of the algorithm, l h We initialize them to
α = -∞ and β = +∞
13
α = -∞ β +
β = +∞
14
In Max-Value:
α= -∞ β= +∞ V= -∞
Max-Value loops
15
In Max-Value:
α= -∞ β= +∞ v= -∞
α= -∞ β= +∞
16
In Min-Value:
α= -∞ β= +∞ v= -∞
α= -∞ β= +∞ v= +∞ v= +∞
17
In Min-Value:
α= -∞ β= +∞ v= -∞
α= -∞ β= +∞ v= +∞ v= +∞
Min-Value loops
18
α= -∞ β= +∞ v= -∞
α= -∞ β= +∞ v= +∞ α= -∞ β= +∞
19
Utility(state) =5
In Min-Value:
α= -∞ β= +∞ v= -∞
α= -∞ β= +∞ v= 5 v= 5
20
In Min-Value:
α = -∞ β = +∞
α= -∞ β= 5 v= 5 v= 5
21
In Min-Value:
α = -∞ β = +∞
α= -∞ β= 5 v= 5 α= -∞ β= 5 v= 5
22
α= -∞ β= +∞ v= -∞
α= -∞ β= 5 v= 5 α= -∞ β= 5
23
Utility(state) =10
In Min-Value:
α = -∞ β = +∞
α= -∞ β= 5 v= 5 <10
24
α= -∞ β= +∞ v= -∞
α= -∞ β= 5 v= 5 α= -∞ β= 5
25
Utility(state) =4
In Min-Value:
α= -∞ β= +∞ v= -∞
α= -∞ β= 5 v= 5 >4
26
In Min-Value:
α= -∞ β= +∞ v= -∞
α= -∞ β= 5 v= 4
27
In Min-Value:
α= -∞ β= +∞ v= -∞
α= -∞ β= 4 v= 4
28
α= -∞ β= +∞ v= 4
29
α= 4 β= +∞ v= 4
30
In Max-Value:
α= -∞ β= +∞ v= -∞
α= 4 β= +∞ v= 4
31
α= -∞ β= +∞ v= -∞
α= 4 β= +∞ v= +∞
32
α= -∞ β= +∞ v= -∞
4
33
α= 4 β= +∞ v= +∞
α= -∞ β= +∞ v= -∞
4
34
α= 4 β= +∞
α= -∞ β= +∞ v= -∞
α= 4 β= +∞ v= 2
35
α= -∞ β= +∞ v= -∞
α= 4 β= +∞ v= 2
36
α= 4 β= +∞ v= 4 >2
37
From:
For a given node N,
38
A move (max) B move (min) A move (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 39 8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2
A move (max) B move (min) A move (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 40 8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2
41
Chess basics
8x8 board, 16 pieces per side, average branching
Rating system based on competition
500
1200
2000
2500+ --- grand master
2500 grand master
time limited moves important aspects: position, material 42
First discussed by Shannon, Sci. American, 1950 Initially, two approaches
human-like brute force search
1966 MacHack ---1100 --- average tournament
1970’s
discovery that 1 ply = 200 rating points 43 hash tables quiescence search
Chess 4.x reaches 2000 (expert level),
Belle 2200, 1983
special purpose hardware special purpose hardware
1986 --- Cray Blitz and Hitech 100,000 to
44
1985, Hsu build BLSI move generator (using
Anantharaman combined with chess program
1986 CCC ---- no luck, but notice “blind forced
singular extension: if you see a position where only
45
1987 --- new algorithm won (Chiptest) 400-
Deep thought:
250 chips (2M pos/sec /// 6-7M pos/soc) Evaluation hardware
piece placement pawn placement pawn placement passed pawn eval file configurations
120 t t t
120 parameters to tune
Tuning done to master’s games
hill climbing and linear fits
46
g
1989 --- rating of 2480 = = = Kasparov beats
Deep Blue is the next generation
parallel version of deep thought
200 M pos/sec 60B positions in the 3 minutes
DB 1 = 32 Rs/6000’s with 6 chess proc/node DB 2 = faster 32 nodes w 8 chess proc/node (256 proc) message passing architecture message passing architecture search as much as 20-30 levels deep using sing.
In 1997, Kasparov beaten
Kasparov changed strategy in earlier games 47 As much a psychological as mental victory
http://www.research.ibm.com/deepblue/
48
49
50
CHANCE
?
expectimax and expectimin, expected values over all possible outcomes
3 ? 0.5 0.5
CHANCE
? 8
51
8 17
Order-preserving transformation do not necessarily behave the same!
52
53
54
C id th f ll i t i hi h th l ti f ti l
(a) Compute the backed up
Consider the following game tree in which the evaluation function values are shown below each leaf node. Assume that the root node corresponds to the maximizing player. Assume the search always visits children left-to-right.
(a) Compute the backed-up values computed by the minimax algorithm. Show your answer by writing
A Max
your answer by writing values at the appropriate nodes in the above tree. (b) Compute the backed-up
A B C D Min
(b) Compute the backed up values computed by the alpha-beta algorithm. What nodes will not be
E F G H I J K Max
examined by the alpha- beta pruning algorithm? (c) What move should Max
L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
55
( ) choose once the values have been backed-up all the way?
A Max
α = -∞ β = +∞
Max-Value loops
B C D Max Min
Max-Value loops
E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
56
A Max
α = -∞ β = +∞
B C D Max Min
Min-Value loops
E F G H I J K Max
L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
57
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max
Max-Value loops
L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
p
58
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
59
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
60
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
61
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
62
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
63
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
64
A Max
α = -∞ β = +∞
B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min
65
66
67