Beruflich Dokumente
Kultur Dokumente
INTRODUCTION
Alpha-Beta Pruning is a search algorithm that seeks to decrease the number of nodes that are evaluated by the minimax algorithm in its search tree. It is an adversarial search algorithm used commonly for machine playing of two player games (Tic-Toc-Toe, Chess, etc.). It stop completely evaluating a move when atleast one possibility has been found that proves the move to be worse than previously examined move.
ALPHA-BETA EXAMPLE
Do DF-search until first leaf Range of possible values
[-,+]
[-, +]
[-,+]
[-,3]
[-,+]
[-,3]
[3,+]
[3,3]
[3,+]
[3,14]
[3,3]
[-,2]
[-,14]
[3,5]
[3,3]
[,2]
[-,5]
10
[3,3]
[3,3]
[,2]
[2,2]
11
[3,3]
[3,3]
[-,2]
[2,2]
12
ALPHA-BETA ALGORITHM
Depth first search
only considers nodes along a single path from root at any time
a = highest-value choice found at any choice point of path for MAX (initially, a = infinity) b = lowest-value choice found at any choice point of path for MIN (initially, b = +infinity) Pass current values of a and b down to child nodes during search. Update values of a and b during search:
MAX updates a at MAX nodes MIN updates b at MIN nodes Prune remaining branches at a node when a b
13
WHEN TO PRUNE
Prune whenever a b. Prune below a Max node whose alpha value becomes greater than or equal to the beta value of its ancestors.
Max nodes update alpha based on childrens returned values.
Prune below a Min node whose beta value becomes less than or equal to the alpha value of its ancestors.
Min nodes update beta based on childrens returned values.
14
a, b, initial values
a= b =+
a, b, passed to kids
a= b =+
15
a= b =+
a= b =3
MIN updates b, based on kids
16
a= b =+
a= b =3
MIN updates b, based on kids. No change.
17
a=3 b =+
18
a=3 b =+
a, b, passed to kids
a=3 b =+
19
a=3 b =+
MIN updates b, based on kids.
a=3 b =2
20
a=3 b =+
a=3 b =2
a b,
so prune.
21
b =+
22
a=3 b =+
,
a, b, passed to kids
a=3 b =+
23
a=3 b =+
a=3 b =14
24
a=3 b =+
a=3 b =5
25
a=3 b =+
26
Max calculates the same node value, and makes the same move!
2
27
EFFECTIVENESS OF ALPHA-BETA
Alpha-beta is guaranteed to compute the same value for the root node as computed by minimax, with less or equal computation Worst case: branches are ordered so that no pruning takes place. examining b^d leaf nodes, where each node has b children and a d-ply search is performed Best case: examine only (b)^(d/2) leaf nodes. Result is you can search twice as deep as minimax! Best case is when each players best move is the first alternative generated
In practice often get O(b(d/2)) rather than O(bd) e.g., in chess go from b ~ 35 to b ~ 6
this permits much deeper search in the same amount of time
28
Repeated states are again possible. Store them in memory = transposition table
29
EXAMPLE
6 30
ANSWER TO EXAMPLE
Max -which nodes can be pruned?
Min
Max 6 5 3 4 1 2 7 8 Answer: NONE! Because the most favorable nodes for both are explored last (i.e., in the diagram, are on the right-hand side).
31
SECOND EXAMPLE (THE EXACT MIRROR IMAGE OF THE FIRST EXAMPLE) -which nodes can be pruned?
4 32
ANSWER TO SECOND EXAMPLE (THE EXACT MIRROR IMAGE OF THE FIRST EXAMPLE) -which nodes can be pruned?
Max
Min
Max
4 3 6 5 8 7 2 1 Answer: LOTS! Because the most favorable nodes for both are explored first (i.e., in the diagram, are on the left-hand side).
33
QUESTIONS ?
34
THANK YOU!
35