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 of each node � Does it work? � Yes, it roughly cuts the branching factor from b to √ b resulting in double as far look-ahead than pure minimax l i i d bl f l k h d h i i 2
α - β pruning: example ≥ 6 MAX MIN 6 6 12 8 3
α - β pruning: example ≥ 6 MAX ≤ 2 MIN 6 6 12 8 2 4
α - β pruning: example ≥ 6 MAX ≤ 5 ≤ 2 MIN 6 6 12 8 2 5 5
6 ≤ 5 ≤ 5 5 5 α - β pruning: example ≥ 6 ≤ 2 ≤ 2 2 2 Selected move 8 8 6 6 12 12 6 6 MAX MIN
α - β pruning: general principle Player α = 6 m 6 Opponent Opponent If α > v then MAX will chose m so prune tree under n Similar for β for MIN β Player n Opponent v = 2 7
8 Properties of α - β
//the leaf node (terminal state) ) 9 ( The α - β algorithm
//the leaf node (terminal state) 10 The α - β algorithm (cont.)
Remember Minimax: Recursive implementation p Time complexity: O(b m ) Complete: Yes, for finite state-space Space complexity: O(bm) (= DFS Optimal: Yes 11 Does not keep all nodes in memory.)
More on the α - β algorithm: start from Minimax t t f Mi i 12
The α - β algorithm Note: These are both Local variables. At the Start of the algorithm, We initialize them to l h α = - ∞ and β = + ∞ 13
A Walk Through Example p α : Best choice so far for MAX α : Best choice so far for MAX β : Best choice so far for MIN α = - ∞ MAX β β = + ∞ + MIN … MAX 5 10 4 2 8 7 14
In Max-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ V= - ∞ Max-Value loops over these MIN … MAX 5 5 10 4 2 8 7 10 4 2 8 7 15
In Max-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ MIN β = + ∞ … MAX 5 5 10 4 2 8 7 10 4 2 8 7 16
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ MIN β = + ∞ … v= + ∞ v= + ∞ MAX 5 5 10 4 2 8 7 10 4 2 8 7 17
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ MIN β = + ∞ … v= + ∞ v= + ∞ Min-Value loops over these MAX 5 5 10 4 2 8 7 10 4 2 8 7 18
α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ β = + ∞ MIN … v= + ∞ α = - ∞ β = + ∞ MAX 5 5 10 4 2 8 7 10 4 2 8 7 Utility(state) =5 19
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ MIN β = + ∞ … v= 5 v= 5 MAX 5 5 10 4 2 8 7 10 4 2 8 7 20
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ α = - ∞ MIN β = 5 … v= 5 v= 5 MAX 5 5 10 4 2 8 7 10 4 2 8 7 21
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ α = - ∞ β = 5 MIN … v= 5 α = - ∞ β = 5 v= 5 MAX 5 5 10 4 2 8 7 10 4 2 8 7 22
α : Best choice so far for MAX β : Best choice so far for MIN α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ β = 5 MIN … v= 5 α = - ∞ β = 5 MAX 5 5 10 4 2 8 7 10 4 2 8 7 Utility(state) =10 23
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ α = - ∞ β = 5 MIN … v= 5 <10 MAX 5 5 10 4 2 8 7 10 4 2 8 7 24
α : Best choice so far for MAX β : Best choice so far for MIN α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ β = 5 MIN … v= 5 α = - ∞ β = 5 MAX 5 5 10 4 2 8 7 10 4 2 8 7 Utility(state) =4 25
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ β = 5 MIN … v= 5 >4 MAX 5 5 10 4 2 8 7 10 4 2 8 7 26
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ β = 5 MIN … v= 4 MAX 5 5 10 4 2 8 7 10 4 2 8 7 27
In Min-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = - ∞ β = 4 MIN … v= 4 MAX 5 5 10 4 2 8 7 10 4 2 8 7 28
α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= 4 MIN … MAX 5 5 10 4 2 8 7 10 4 2 8 7 29
α : Best choice so far for MAX β : Best choice so far for MIN β α = 4 MAX β = + ∞ v= 4 MIN … MAX 5 5 10 4 2 8 7 10 4 2 8 7 30
In Max-Value: α : Best choice so far for MAX β : Best choice so far for MIN β α = - ∞ MAX β = + ∞ v= - ∞ α = 4 β = + ∞ MIN … v= 4 MAX 5 5 10 4 2 8 7 10 4 2 8 7 31
α : Best choice so far for MAX β β : Best choice so far for MIN α = - ∞ MAX β = + ∞ v= - ∞ α = 4 β = + ∞ MIN … v= + ∞ MAX 5 5 10 4 2 8 7 10 4 2 8 7 32
α : Best choice so far for MAX β β : Best choice so far for MIN α = - ∞ MAX β = + ∞ v= - ∞ MIN … MAX 5 10 4 2 8 7 5 10 4 2 8 7 α = 4 4 β = + ∞ v= + ∞ 33
α : Best choice so far for MAX β β : Best choice so far for MIN α = - ∞ MAX β = + ∞ v= - ∞ MIN … MAX 5 10 4 2 8 7 5 10 4 2 8 7 α = 4 4 β = + ∞ 34
α : Best choice so far for MAX β β : Best choice so far for MIN α = - ∞ MAX β = + ∞ v= - ∞ α = 4 β = + ∞ MIN … v= 2 MAX 5 5 10 4 2 8 7 10 4 2 8 7 35
α : Best choice so far for MAX β β : Best choice so far for MIN α = - ∞ MAX β = + ∞ v= - ∞ α = 4 β = + ∞ MIN … v= 2 MAX 5 5 10 4 2 8 7 10 4 2 8 7 36
α : Best choice so far for MAX β : Best choice so far for MIN β α = 4 MAX β = + ∞ v= 4 >2 MIN … MAX 5 5 10 4 2 8 7 10 4 2 8 7 37
Another way to understand the algorithm � From: http://yoda.cis.temple.edu:8080/UGAIWWW/lectures95/se arch/alpha-beta.html h/ l h b t ht l � For a given node N, α is the value of N to MAX β is the value of N to MIN 38
Alpha/Beta pruning - example (4) A move (max) B move (min) A move (max) 8 8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 9 7 2 7 2 39
Alpha/Beta pruning - example (4) A move (max) B move (min) A move (max) 8 8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 9 7 2 7 2 40
41 deterministic games State-of-the-art for
Chess As An Example � Chess basics Ch b i � 8x8 board, 16 pieces per side, average branching factor of 38 factor of 38 � Rating system based on competition � 500 --- beginner/legal � 1200 --- good weekend warrier � 2000 --- world championship level � 2500+ --- grand master 2500 grand master � time limited moves � important aspects: position, material 42
Sketch of Chess History � First discussed by Shannon, Sci. American, 1950 � Initially, two approaches � human-like � brute force search � 1966 MacHack ---1100 --- average tournament player � 1970’s � discovery that 1 ply = 200 rating points � hash tables � quiescence search 43
Recommend
More recommend