Title: Game Playing Pruning
1Game Playing ?-? Pruning
- Introduction to Artificial Intelligence
- Hadi Moradi
- moradi_at_usc.edu
22. ?-? pruning search cutoff
- Pruning eliminating a branch of the search tree
from consideration without exhaustive examination
of each node - ?-? pruning the basic idea is to prune portions
of the search tree that cannot improve the
utility value of the max or min node, by just
considering the values of nodes seen so far. - Does it work?
- Yes, it roughly cuts the branching factor from b
to ?b resulting in double as far look-ahead than
pure minimax
3?-? pruning example
? 6
MAX
MIN
6
6
12
8
4?-? pruning example
? 6
MAX
MIN
6
? 2
6
12
8
2
5?-? pruning example
? 6
MAX
MIN
6
? 2
? 5
6
12
8
2
5
6?-? pruning example
? 6
MAX
Selected move
MIN
? 5
6
? 2
6
12
8
2
5
7?-? pruning general principle
Player
m
?
6
Opponent
If ? gt v then MAX will chose m so prune tree
under n Similar for ? for MIN
Player
n
v
Opponent
2
8Properties of ?-?
9The ?-? algorithm
//the leaf node (terminal state)
10The ?-? algorithm (cont.)
//the leaf node (terminal state)
11Remember Minimax Recursive implementation
Time complexity O(bm)Space complexity O(bm)
( DFSDoes not keep all nodes in memory.)
Complete Yes, for finite state-spaceOptimal
Yes
12More on the ?-? algorithm start from Minimax
13The ?-? algorithm
Note These are both Local variables. At
the Start of the algorithm, We initialize them
to ? -? and ? ?
14A Walk Through Example
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
? -? ? ?
MIN
MAX
5 10 4 2
8 7
15In Max-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
Max-Value loops over these
MIN
MAX
5 10 4 2
8 7
16In Max-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
? -? ß ?
MIN
MAX
5 10 4 2
8 7
17In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
18In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
Min-Value loops over these
MAX
5 10 4 2
8 7
19? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
Utility(state) 5
20In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
21In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
? -? ? ?
MIN
MAX
5 10 4 2
8 7
22In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
? -? ? ?
MIN
MAX
5 10 4 2
8 7
23- ? Best choice so far for MAX
- Best choice so far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
Utility(state) 10
24In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
? -? ? ?
MIN
MAX
5 10 4 2
8 7
25- ? Best choice so far for MAX
- Best choice so far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
Utility(state) 4
26In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
27In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
28In Min-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
29? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
30? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
31In Max-Value
? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
32? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
33? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
34? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
35? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
36? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
37? Best choice so far for MAX ? Best choice so
far for MIN
MAX
MIN
MAX
5 10 4 2
8 7
38Another way to understand the algorithm
- From http//yoda.cis.temple.edu8080/UGAIWWW/lect
ures95/search/alpha-beta.html - For a given node N,
- ? is the value of N to MAX
- ? is the value of N to MIN
39Alpha/Beta pruning - example (4)
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
40Alpha/Beta pruning - example (4)
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
41State-of-the-art for deterministic games
42Chess As An Example
- Chess basics
- 8x8 board, 16 pieces per side, average branching
factor of 38 - Rating system based on competition
- 500 --- beginner/legal
- 1200 --- good weekend warrier
- 2000 --- world championship level
- 2500 --- grand master
- time limited moves
- important aspects position, material
43Sketch of Chess History
- First discussed by Shannon, Sci. American, 1950
- Initially, two approaches
- human-like
- brute force search
- 1966 MacHack ---1100 --- average tournament
player - 1970s
- discovery that 1 ply 200 rating points
- hash tables
- quiescence search
44Sketch of Chess History
- Chess 4.x reaches 2000 (expert level), 1979
- Belle 2200, 1983
- special purpose hardware
- 1986 --- Cray Blitz and Hitech 100,000 to 120,000
position/sec using special purpose hardware
45Deep Blue History
- 1985, Hsu build BLSI move generator (using DARPA
funding!) - Anantharaman combined with chess program leading
to 50K moves/second algorithm - 1986 CCC ---- no luck, but notice blind forced
move was a problem - singular extension if you see a position where
only a single move determines the line, follow it - 1987 --- new algorithm won (Chiptest) 400-500K
position/sec
46IBM checks in
- Deep thought
- 250 chips (2M pos/sec /// 6-7M pos/soc)
- Evaluation hardware
- piece placement
- pawn placement
- passed pawn eval
- file configurations
- 120 parameters to tune
- Tuning done to masters games
- hill climbing and linear fits
- 1989 --- rating of 2480 Kasparov beats
47IBM Checks In
- Deep Blue is the next generation
- parallel version of deep thought
- 200 M pos/sec ? 60B positions in the 3 minutes
allotted for move - DB 1 32 Rs/6000s with 6 chess proc/node
- DB 2 faster 32 nodes w 8 chess proc/node (256
proc) - message passing architecture
- search as much as 20-30 levels deep using sing.
extension - In 1997, Kasparov beaten
- Kasparov changed strategy in earlier games
- As much a psychological as mental victory
- http//www.research.ibm.com/deepblue/
48Nondeterministic games
49Algorithm for nondeterministic games
50Remember Minimax algorithm
51Nondeterministic games the element of chance
expectimax and expectimin, expected values over
all possible outcomes
?
CHANCE
0.5
0.5
?
3
?
8
8
17
52Evaluation functions Exact values DO matter
Order-preserving transformation do not
necessarily behave the same!
NOTE It is not the same as MINIMAX algorithm
53State-of-the-art for nondeterministic games
54Summary
55Exercise Game Playing
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
values at the appropriate nodes in the above
tree. - (b)Â Compute the backed-up values computed by the
alpha-beta algorithm. What nodes will not be
examined by the alpha-beta pruning algorithm? - (c)Â What move should Max choose once the values
have been backed-up all the way?
56Exercise Game Playing
? -? ? ?
Max-Value loops over these
57Exercise Game Playing
? -? ? ?
Min-Value loops over these
58Exercise Game Playing
? -? ? ?
Max-Value loops over these
59Exercise Game Playing
? -? ? ?
60Exercise Game Playing
? -? ? ?
61Exercise Game Playing
? -? ? ?
62Exercise Game Playing
? -? ? ?
63Exercise Game Playing
? -? ? ?
64Exercise Game Playing
? -? ? ?
65Exercise Game Playing
? -? ? ?
66(No Transcript)
67(No Transcript)