0% found this document useful (0 votes)
56 views

Chapter3 Adversarial Search Part2

Alpha-beta pruning is an optimization of the minimax algorithm used in game trees. It prunes branches that cannot possibly contribute to finding an optimal solution. This allows deeper search with the same computational effort by avoiding searching parts of the tree that cannot affect the final decision. The algorithm maintains upper and lower bounds (alpha and beta) during search and prunes branches where the opponent's value falls outside these bounds. Examples demonstrate how alpha-beta pruning reduces the search space by cutting off subtrees where the opponent's best possible value is worse than the current player's minimum value.

Uploaded by

M. Saad Jumani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Chapter3 Adversarial Search Part2

Alpha-beta pruning is an optimization of the minimax algorithm used in game trees. It prunes branches that cannot possibly contribute to finding an optimal solution. This allows deeper search with the same computational effort by avoiding searching parts of the tree that cannot affect the final decision. The algorithm maintains upper and lower bounds (alpha and beta) during search and prunes branches where the opponent's value falls outside these bounds. Examples demonstrate how alpha-beta pruning reduces the search space by cutting off subtrees where the opponent's best possible value is worse than the current player's minimum value.

Uploaded by

M. Saad Jumani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Chapter 3 Adversarial Search

COMP 472 Artificial Intelligence

Russell & Norvig – Section 5.1 & 5.4


Some slides from: robotics.stanford.edu/~latombe/
2 Adversarial Search

´ MiniMax Search
´ Alpha – beta pruning
3 Alpha-Beta Pruning

´ Optimization over minimax, that:


´ ignores (cuts off, prunes) branches of the tree that
cannot possibly lead to a better solution
´ reduces branching factor
´ allows deeper search with same effort
4 Alpha-Beta Pruning Example 1

´ With minimax, we look at all possible nodes at the n-ply depth


´ With α-β pruning, we ignore branches that could not possibly
contribute to the final decision
B will be >= 5
So we can ignore B’s right
branch, because A must be 3
D will be <= 0
But C will be >= 3
So we can ignore D’s right
branch
E will be <= 2.
So we can ignore E’s right
branch
Because C will be 3.
5 A Closer Look

£ -1 ³ 3 A max level

min level
3 B £ -1 C D E

¬ Pruning
node C will not contribute its
-1
value to node A… so this part
of the tree can’t have any
effect on the value that will
be backed up to node A
6 Alpha-Beta Pruning Algorithm
´ α : lower bound on the final backed-up value.
´ β : upper bound on the final backed-up value.
´ Alpha pruning:
´ eg. if MAX node's α = 6, then the search can prune branches
from a MIN descendant that has a β <= 6.
´ if child β <= ancestor α à prune

a=6 b=+∞ MAX


value ³ 6
incompatible…
so stop searching the right branch;
the value cannot come from there! a=-∞ b=5 MIN
value £ 5
7 Alpha-Beta Pruning Algorithm
´ α : lower bound on the final backed-up value.
´ β : upper bound on the final backed-up value.
´ Beta pruning:
´ eg. if a MIN node's β = 6, then the search can prune branches
from a MAX descendant that has an α >= 6.
´ if ancestor β <= child α à prune

a=-∞ b=6 MIN


value £ 6
incompatible…
so stop searching the right branch;
the value cannot come from there! a=7 b=+∞ MAX
value ³ 7
8
Alpha-Beta Pruning Algorithm
01 function alphabeta(node, depth, α, β, maximizingPlayer)
02 if depth = 0 or node is a terminal node
03 return the heuristic value of node
04 if maximizingPlayer Initial call:
05 v := -∞ alphabeta(origin, depth, -∞, +∞, TRUE)
06 for each child of node
07 v := max(v, alphabeta(child, depth - 1, α, β, FALSE))
08 α := max(α, v)
09 if β ≤ α
10 break (* β cut-off *)
11 return v
12 else
13 v := ∞
14 for each child of node
15 v := min(v, alphabeta(child, depth - 1, α, β, TRUE))
16 β := min(β, v)
17 if β ≤ α
18 break (* α cut-off *)
19 return v source: http://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning
9 Example: tic-tac-toe

max level

min level
10 Example: tic-tac-toe
max level

a=-∞ b=2
min level
value £ 2

e(n) = 2
11 Example: tic-tac-toe

max level

a=-∞ b=2 1
min level
value £ 2 1

e(n) = 2 e(n) = 1
12 Example: tic-tac-toe
a=1 b=+∞
max level
value ³ 1

min level value = 1

e(n) = 2 e(n) = 1
13 Example: tic-tac-toe
a=1 b=+∞
max level value ³ 1

a=-∞ b=-1

min level value = 1 value £ -1

e(n) = 2 e(n) = 1 e(n) = -1


14 Example: tic-tac-toe
incompatible… a=1 b=+∞
so stop searching the right branch;
max level
the value cannot come from there!
max level value ³ 1

a=-∞ b=-1

min level value = 1


child β <= ancestor α à stop search value £ -1

Search can be discontinued below


any MIN node whose β is <= α
of one of its MAX ancestors

e(n) = 2 e(n) = 1 e(n) = -1


15 Alpha – Beta Pruning Example 2

Max ≥3
≥6 =6
-------------------------------------------------------------------------------------------------------
Min ≤5 =3 ≤6ü =6 ≤5x
-------------------------------------------------------------------------------------------------------
Max ≥5 =5 =3 ≥6ü=6 =7 =5
-------------------------------------------------------------------------------------------------------
Min ≤5 =5 ≤7ü ≤4 =3 =6 ≤6x ≤6 =7 =5
≤4 x
--------------------------------------------------------------------------------------------------------
=5 =6 =7 =4 =3 =6 =6 =7 =5
16 Alpha – Beta Pruning Example 2
17 Alpha – Beta Pruning Example 3
18 Alpha – Beta Pruning Example 3
19 Alpha – Beta Pruning Example 3

<=4
a=-∞
β=4
20 Alpha – Beta Pruning Example 3

<=3
a=-∞
β=3
21 Alpha – Beta Pruning Example 3

<=3
a=-∞
β=3
22 Alpha – Beta Pruning Example 3

=3
a=-∞
β=3
23 Alpha – Beta Pruning Example 3

>=3
a=3
β=+∞
=3
a=-∞
β=3
24 Alpha – Beta Pruning Example 3

>=3
a=3
β=+∞
=3
25 Alpha – Beta Pruning Example 3

>=3
α=3

=3 <=2
β=3 β=2
26 Alpha – Beta Pruning Example 3
child β <= ancestor α à prune

>=3
a=3
β=+∞
=3 <=2
a=-∞
β=2
27 Alpha – Beta Pruning Example 3

=3

=3
28 Alpha – Beta Pruning Example 3

<=3

=3

=3
29 Alpha – Beta Pruning Example 3

<=3

=3

=3 <=4
30 Alpha – Beta Pruning Example 3

<=3

=3

=3 <=2
31 Alpha – Beta Pruning Example 3

<=3

=3

=3 =2
32 Alpha – Beta Pruning Example 3

<=3

=3 =2

=3 =2
33 Alpha – Beta Pruning Example 3

<=2

=3 =2

=3 =2
34 Alpha – Beta Pruning Example 3

<=2

=3 =2

=3 =2 <=5
35 Alpha – Beta Pruning Example 3

<=2

=3 =2

=3 =2 =4
36 Alpha – Beta Pruning Example 3

<=2

=3 =2 >=2

=3 =2 =4
37 Alpha – Beta Pruning Example 3
ancestor β <= child α à prune

<=2

=3 =2 >=4

=3 =2 =4
38 Alpha – Beta Pruning Example 3

=2

=3 =2

=3 =2 =4
39 Alpha – Beta Pruning Example 3
>= 2

=2

=3 =2

=3 =2 =4
40 Alpha – Beta Pruning Example 3
>= 2

=2

=3 =2

=3 =2 =4
41 Alpha – Beta Pruning Example 3
child β <= ancestor α à prune
>= 2
deep cut!

=2

=3 =2

=3 =2 =4 <=1
42 Alpha – Beta Pruning Example 3
child β <= ancestor α à prune
>= 2

<=1
=2

=3 =2

=3 =2 =4 <=1
43 Alpha – Beta Pruning Example 3
child β <= ancestor α à prune
>= 2

<=1
=2

=3 =2

=3 =2 =4 <=1

11 nodes explored out of 27


44 Efficiency

´ Depends on the order the siblings


´ In worst case:
´ alpha-beta provides no pruning
´ In best case:
´ branching factor is reduced to its square root
´ so can search can go twice as deep with the same
amount of computation
45 Alpha-Beta: Best ordering

Original (arbitrary) game tree

Best ordering for alpha-beta


source: G. Luger (2005)
46 Alpha-Beta: Best ordering

´ best ordering:
1. children of MIN : smallest node first
2. children of MAX: largest node first
47 Alpha-Beta: Best ordering

2 0
48 Alpha-Beta: Best ordering

2 0

2 3 7 0 3 3
49 Alpha-Beta: Best ordering

2 0

2 3 7 0 3 3

2 3 1 7 4 2 0 3 0 3 2 1

8 nodes explored out of 27


50 Applications

´ 1992 – 1994 Checkers: Tinsley VS Chinook


´ Marion Tinsley – World Champion for over
40 years
´ Chinook – Developed by Jonathan
Schaeffer, professor at University of Alberta
´ In 1992, Tinsley beat Chinook in 4 games to
2, with 33 draws.
´ In 1996: 6 draws https://webdocs.cs.ualber
ta.ca/~chinook/play/
´ In 2007, Schaeffer announced that
checkers was solved, and anyone playing
against Chinook would only be able to
draw, never win.
51 Applications

´ 1997 Othello: Murakami VS Logistello


´ Takeshi Murakami – World Othello
Champion
´ Logistello – Developed by Michael Buro
runs on a standard PC
´ Logistello beat Murakami by 6 games to 0

https://skatgame.net/mburo/log.html
(including source code)
52 Applications

´ 1997 Chess: Kasparov VS Deep Blue


´ Garry Kasparov – 50 billion neurons 2
positions/sec
´ Deep Blue – 32 RISC (Reduced Instruction-
Set Computer) processors + 256 VLSI (Very
Large-Scale Integration) chess engines
200,000,000 pos/sec
´ Deep Blue wins by 3 wins, 1 loss, and 2
draws
53 Applications

´ 1997 Chess: Kasparov VS Deep Junior


´ Garry Kasparov – still 50 billion neurons 2
positions/sec
´ Deep Junior – 8 CPU, 8 GB RAM, Win 2000
2,000,000 pos/sec Available at $100
´ Match ends in a 3/3 tie!
54 Applications

´ 2016 Go: AlphaGo VS Lee Se-dol


´ GO was always considered a much harder
game to automate than chess because of
its very high branching factor (35 for chess
vs 250 for Go!)
´ In 2016, AlphaGo beat Lee Sedol in a five-
game match of GO.
´ In 2017 AlphaGo beat Ke Jie, the world
No.1 ranked player at the time

´ uses a Monte Carlo tree search algorithm


to find its moves based on knowledge
previously "learned" by deep learning
55 The End

You might also like