Professional Documents
Culture Documents
5.1 GamePlaying (AIML)
5.1 GamePlaying (AIML)
• Minimax Search
• Alpha-Beta Pruning
• - Implemented on top of Minimax Search
• - Improves efficiency of Minimax Search)
Minimax Search
• Two Players: Max and Min
• The Max (Min) player selects the move that leads to the
successor node with the highest (Lowest) score
• A simple game tree. Nodes with the maximizer to move are squares;
nodes with the minimizer to move are circles
• 1 -> Max Wins; -1 -> Min wins
Example 2: Continued
Return min{MINIMAX(N1),….,MINIMAX(Nm)}
• Else
• Return min{MINIMAX(N1),….,MINIMAX(Nm)}
• End
Minimax Search
function MINIMAX(N)
Begin
• Return minimum{MINIMAX(N1),
….,MINIMAX(Nm)}
•
• Else
Minimax Search
A's Winning strategy
2-Ply Minimax Game
(one move for each player)
2-Ply Minimax Game
(one move for each player)
Pruning
Pruning
Minimax search has to search large number of states
But possible to compute correct minimax decision without
looking at every node in search tree
Eliminating a branch of search tree from consideration
(without looking at it) is called pruning
Alpha-beta pruning
– Prunes away branches that cannot possibly influence
final minimax decision
– Returns same move as general minimax
Pruning (Cut-off)
Parent
of A
A β = 10
10
B α = 14 α >= β
14 C
Pruning (Deep Cut-off)
Ancestor α = 10
of D
10
β <= α D β=5 G
5 E
Pruning Rules
Alpha-Beta Pruning
Can be applied to trees of any depth
Often possible to prune entire subtrees rather than just leaves
Alpha-beta name
– Alpha = value of best (highest-value) choice found so far at any
choice point along path for MAX
In other words, the worst score (lowest) MAX could possibly get
Update alpha only during MAX’s turn/ply
– Beta = value of best (lowest-value) choice found so far at any choice
point along path for MIN
In other words, the worst score (highest) MIN could possibly get
Update beta only during MIN’s turn/ply
Alpha and Beta Cut-offs
• Alpha cut-off
• When pruned subtree has rooted at Max node
• Beta Cut-off
• When pruned subtree has rooted at Min node
Alpha beta pruning. Example 1
Example 2
Example 2 Solution
Example 3
The figure shows a 4-ply game tree with evaluation function values
at the horizon. The nodes in the horizon carry reference numbers
(sequence numbers going left to right) at the bottom. Use these
reference numbers when you want to enter a list of nodes. Answer
the following question (next slide)
Example 3
• Questions:
a) What is the MinMax value of the game?
b) What is the number of alpha-cuts and the number of beta-cuts
induced by the AlphaBeta pruning?
c) How many nodes are pruned (unexplored) by AlphaBeta pruning?
Count only the horizon nodes
d) List the nodes pruned by alpha-cuts. Count only the horizon nodes.
e) List the nodes pruned by beta-cuts. Count only the horizon nodes
Check Your Answers
a) 10
b) 3,2
c) 14
d) 14,16,17,18,19,20,21,22,23,24
e) 7,8,11,12