Title: Search: Games
1Search Games Adversarial Search
- Artificial Intelligence
- CMSC 25000
- January 29, 2002
2Agenda
- Game search characteristics
- Minimax procedure
- Adversarial Search
- Alpha-beta pruning
- If its bad, we dont need to know HOW awful!
- Game search specialties
- Progressive deepening
- Singular extensions
3Games as Search
- Nodes Board Positions
- Each ply (depth 1) Move
- Special feature
- Two players, adversial
- Static evaluation function
- Instantaneous assessment of board configuration
- NOT perfect (maybe not even very good)
4Minimax Lookahead
- Modeling adversarial players
- Maximizer positive values
- Minimizer negative values
- Decisions depend on choices of other player
- Look forward to some limit
- Static evaluate at limit
- Propagate up via minimax
5Minimax Procedure
- If at limit of search, compute static value
- Relative to player
- If minimizing level, do minimax
- Report minimum
- If maximizing level, do minimax
- Report maximum
6Minimax Example
2
MAX
MIN
2
1
MAX
7Alpha-Beta Pruning
- Alpha-beta principle If you know its bad, dont
waste time finding out HOW bad - May eliminate some static evaluations
- May eliminate some node expansions
- Similar to branch bound
8Simple Alpha-Beta Example
2
gt2
MAX
MIN
lt1
2
MAX
1
9Alpha-Beta Detailed Example
10Alpha-Beta Detailed Example
11Alpha-Beta Detailed Example
12Alpha-Beta Detailed Example
13Alpha-Beta Detailed Example
14Alpha-Beta Detailed Example
15Alpha-Beta Detailed Example
16Alpha-Beta Detailed Example
17Alpha-Beta Detailed Example
18Alpha-Beta Detailed Example
19Alpha-Beta Detailed Example
20Alpha-Beta Detailed Example
21Alpha-Beta Detailed Example
22Alpha-Beta Detailed Example
23Alpha-Beta Detailed Example
24Alpha-Beta Detailed Example
25Alpha-Beta Detailed Example
26Alpha-Beta Detailed Example
27Alpha-Beta Detailed Example
28Alpha-Beta Detailed Example
29Alpha-Beta Detailed Example
30Alpha-Beta Detailed Example
31Alpha-Beta Detailed Example
32Alpha-Beta Detailed Example
33Alpha-Beta Detailed Example
34Alpha-Beta Detailed Example
35Alpha-Beta Detailed Example
36Alpha-Beta Detailed Example
37Alpha-Beta Detailed Example
38Alpha-Beta Detailed Example
39Alpha-Beta Detailed Example
40Alpha-Beta Detailed Example
41Alpha-Beta Detailed Example
42Alpha-Beta Detailed Example
43Alpha-Beta Detailed Example
44Alpha-Beta Detailed Example
45Alpha-Beta Detailed Example
46Alpha-Beta Detailed Example
47Alpha-Beta Detailed Example
48Alpha-Beta Procedure
If levelTOP_LEVEL, alpha NEGMAX beta
POSMAX If (reached Search-limit), compute
return static value of current If level is
minimizing level, While more children to explore
AND alpha lt beta ab alpha-beta(child) if
(ab lt beta), then beta ab Report beta If level
is maximizing level, While more children to
explore AND alpha lt beta ab
alpha-beta(child) if (ab gt alpha), then alpha
ab Report alpha
49Alpha-Beta Pruning Analysis
- Worst case
- Bad ordering Alpha-beta prunes NO nodes
- Best case
- Assume cooperative oracle orders nodes
- Best value on left
- If an opponent has some response that makes move
bad no matter what the moving player does, then
the move is bad. - Implies check move where opposing player has
choice, check all own moves
50Optimal Alpha-Beta Ordering
1
4
3
2
7
5
6
10
8
9
13
11
12
35
36
37
38
39
40
32
33
34
29
30
31
26
27
28
23
24
25
14
15
16
17
18
19
20
21
22
51Optimal Ordering Alpha-Beta
- Significant reduction of work
- 11 of 27 static evaluations
- Lower bound on of static evaluations
- if d is even, s 2bd/2-1
- if d is odd, s b(d1)/2b(d-1)/2-1
- Upper bound on of static evaluations
- bd
- Reality somewhere between the two
- Typically closer to best than worst
52Heuristic Game Search
- Handling time pressure
- Focus search
- Be reasonably sure best option found is likely
to be a good option. - Progressive deepening
- Always having a good move ready
- Singular extensions
- Follow out stand-out moves
53Progressive Deepening
- Problem Timed turns
- Limited depth
- If too conservative, too shallow
- If too generous, wont finish
- Solution
- Always have a (reasonably good) move ready
- Search at progressively greater depths
- 1,2,3,4,5..
54Progressive Deepening
- Question Arent we wasting a lot of work?
- E.g. cost of intermediate depths
- Answer (surprisingly) No!
- Assume cost of static evaluations dominates
- Last ply (depth d) Cost bd
- Preceding plies b0 b1b(d-1)
- (bd - 1)/(b -1)
- Ratio of last ply cost/all preceding b - 1
- For large branching factors, prior work small
relative to final ply
55Singular Extensions
- Problem Explore to some depth, but things change
a lot in next ply - False sense of security
- aka horizon effect
- Solution Singular extensions
- If static value stands out, follow it out
- Typically, forced moves
- E.g. follow out captures
56Additional Pruning Heuristics
- Tapered search
- Keep more branches for higher ranked children
- Rank nodes cheaply
- Rule out moves that look bad
- Problem
- Heuristic May be misleading
- Could miss good moves
57Summary
- Game search
- Key features Alternating, adversarial moves
- Minimax search Models adversarial game
- Alpha-beta pruning
- If a branch is bad, dont need to see how bad!
- Exclude branch once know cant change value
- Can significantly reduce number of evaluations
- Heuristics Search under pressure
- Progressive deepening Singular extensions