Title: CMSC 421: Intro to Artificial Intelligence
1CMSC 421 Intro to Artificial Intelligence
October 6, 2003 Lecture 7 Games Professor
Bonnie J. Dorr TA Nate Waisbrot
2Reading
Finish Chapter 6 start Chapter 7.
3Games
- Games are a form of multiagent environment
- Why study games?
- Fun historically entertaining
- Interesting subject of study because they are
hard - Easy to represent and agents restricted to small
number of actions
4Relation of Games to Search
- Search no adversary
- Solution is (heuristic) method for finding goal
- Heuristics and CSP techniques can find optimal
solution - Evaluation function estimate of cost from start
to goal through given node - Examples path planning, scheduling activities
- Games adversary
- Solution is strategy
- Time limits force an approximate solution
- Evaluation function evaluate goodness of game
position - Examples chess, checkers, Othello, backgammon
5Types of Games
6Game Playing
- Two players MAX and MIN
- MAX moves first and they take turns until the
game is over - A move is planned and executed as follows
- consider all legal moves
- evalute resulting position for each one
- pick best position and move there
- opponent moves
- repeat
7Partial Game Tree for Tic-Tac-Toe
8Minimax Algorithm
9Two-Ply Game Tree
10Two-Ply Game Tree
11Two-Ply Game Tree
12Two-Ply Game Tree
13Properties of Minimax
?
?
?
?
14How do we deal with resource limits?
- Evaluation function return an estimate of the
expected utility of the game from a given
position - Alpha-beta pruning return appropriate minimax
decision without exploring entire tree
15Heuristic Evaluation Function Tic Tac Toe
16Heuristic Evaluation Functions
Eval(s) w1f1(s) w2f2(s) wnfn(s)
17What is Alpha-Beta Cutoff?
3
3,8
MAX
3
2
-8,2
MIN
3
12
2
MAX
X
18Alpha-beta Pruning
- Replace TERMINAL-TEST
- and UTILITY in Minimax
- if TERMINAL-TEST(state) then return
UTILITY(state) - if CUTOFF-TEST(state) then return EVAL(state)
19Minimax with Alpha-Beta Pruning
- Set alpha-beta values for all game-tree nodes to
-8, 8 - For each move, run DFS to generate game tree
(DFS) to a given depth - Back-up evaluation estimates whenever possible
- For MAX node n set alpha(n) to be max value found
so far - For MIN node n set beta(n) to be min value found
so far - Prune branches that do not change final decision
- Alpha cutoff stop searching below MIN node if
its beta value is less than or equal to the alpha
value of its ancestor - Beta cutoff stop searching below MAX node if its
alpha value is greater than or equal to the beta
value of its ancestor
20Alpha-Beta Example
-8,8
-8, -8
21Alpha-Beta Example (continued)
3,8
-8,3
22Alpha-Beta Example (continued)
3,8
-8,3
23Alpha-Beta Example (continued)
3,8
3,3
24Alpha-Beta Example (continued)
3,8
-8,2
3,3
25Alpha-Beta Example (continued)
,
3,14
-8,2
3,3
-8,14
26Alpha-Beta Example (continued)
,
3,5
-8,2
3,3
-8,5
27Alpha-Beta Example (continued)
3,3
2,2
-8,2
3,3
28Alpha-Beta Example (continued)
3,3
2,2
-8,2
3,3
29Final Comments about Alpha-Beta Pruning
- Pruning does not affect final results
- Good move ordering improves effectiveness of
pruning - With perfect ordering, time complexity is
O(bm/2) - Definition of optimal play for MAX assumes MIN
plays optimally maximizes worst-case outcome for
MAX. - But if MIN does not play optimally, MAX will do
even better. Can be proved.