Title: Game Playing
1Game Playing
- Introduction to Artificial Intelligence
- CS440/ECE448
- Lecture 7
- FIRST HOMEWORK
- DUE TODAY
2Last lecture
- Constraint satisfaction problems
- Line-drawing interpretation
- This lecture
- Games
- Minimax
- ?? pruning
- Reading
- Chapter 6
3Line Drawing Interpretation
- Goal Given a line drawing of a 3-D
- object, label edges as being
- Convex
- Concave -
- Occluding
-
4Constraints (Junction Labels)
Complete junction catalog for line drawings of
trihedral-vertex polyhedra
5Nonsense objects
- A consistent labeling is a necessary condition
for a line drawing to correspond to a physically
realizable object (e.g. a polyhedron with
trihedral vertices)
6Types of Games
Chance
Deterministic
Chess, Checkers Go, Othello Backgammon, Monopoly
Battleship Bridge, Poker, Scrabble, Nuclear war
Perfect Information
Imperfect Information
7Games vs. search problems
- Unpredictable opponent
- ? solution is a contingency plan.
- Time limits ? unlikely to find goal, must
approximate. - Plan of attack
- algorithm for perfect play Von Neumann, 1944
- finite horizon, approximate evaluation Zuse,
1945 Shannon, 1950 Samuel, 1952-57 - pruning to reduce costs McCarthy, 1956.
8Deterministic Two-person Games
- Two players move in turn.
- Each Player knows what the other has done and can
do. - Either one of the players wins (and the other
loses) or there is a draw.
9Games as Search Grundys Game Nilsson, Chapter
3
- Initially a stack of pennies stands between two
players. - Each player divides one of the current stacks
into two unequal stacks. - The game ends when every stack contains one or
two pennies. - The first player who cannot play loses.
- Min starts. Can we devise a winning strategy for
Max?
MAX
MIN
10Grundys Game States
7
Mins turn
11When is there a winning strategy for Max?
- When it is MINs turn to play, a win must be
obtainable for MAX from all the results of the
move. - When it is MAXs turn, a win must be obtainable
from at least one of the results of the move.
12(No Transcript)
13Minimax
- Initial state Board position and whose turn it
is. - Operators Legal moves that the player can make.
- Terminal test A test of the state to determine
if game is over set of states satisfying
terminal test are terminal states. - Utility function numeric value for outcome of
game (leaf nodes). - E.g. 1 win, -1 loss, 0 draw.
- E.g. of points scored if tallying points as in
backgammon. - Assumption Opponent will always chose operator
(move) to maximize own utility.
14Minimax
- Perfect play for deterministic,
perfect-information games. - Maxs strategy choose action with highest
minimax value - ) best achievable payoff against best play by
min. - Consider a 2-ply (two step) game
- Max wants largest outcome --- Min wants
smallest.
15(No Transcript)
16Properties of Minimax
- Complete
- Optimal
- Time complexity
- Space complexity
Yes, if tree is finite. Yes, against an optimal
opponent. Otherwise?? O(bm). O(bm).
- Note For chess, b ? 35, m ? 100 for a
reasonable game. - Solution is completely infeasible
-
- Actually only 1040 board positions, not 35100
17Resource limits
- Suppose we have 100 seconds, explore 104
nodes/second - ? 106 nodes per move.
- Standard approach
- cutoff test
- e.g., depth limit,
- evaluation function estimated desirability of
position - (an approximation to the utility used in minimax).
18Cutting off search
- Replace MinimaxValue with MinimaxCutoff .
- MinimaxCutoff is identical to MinimaxValue except
- 1. Terminal? is replaced by Cutoff?
- 2. Utility is replaced by Eval.
- Does it work in practice?
- bm 106, b35 ? m4
- 4-ply lookahead is a hopeless chess player!
- 4-ply human novice
- 8-ply typical PC, human master
- 12-ply Deep Blue, Kasparov
19Evaluation Function
- For chess, typically linear weighted
- sum of features
- Eval(s) w1 f1(s) w2 f2(s) ... wn fn(s)
- e.g., w1 9 with
- f1(s) (number of white queens) - (number of
black queens) - w2 5 with
- f2(s) (number of white rooks) - (number of
black rooks)
20Digression Exact Values Don't Matter
MAX MIN
- Behavior is preserved under any monotonic
transformation of Eval. - Only the order matters
- payoff in deterministic games acts as an ordinal
utility function.
21Horizon effect
- Bad news may be hidden beyond the cutoff depth.
Black to move..
22Another idea
- ?? Pruning
- Essential idea is to stop searching down a branch
of tree when you can determine that it is a dead
end.
23??? Pruning Example
? 3
MAX
3
MIN
12
8
3
24How is the search tree pruned?
- ? is the best value (to MAX) found so far.
- If V ? ?, then the subtree containing V will
have utility no greater than V. - ? Prune that branch
- ? can be defined similarly from MINs
perspective.
25(No Transcript)
26Properties of ???
- Pruning does not affect final result.
- Good move ordering improves effectiveness of
pruning. - With perfect ordering, time complexity
O(bm/2) - doubles depth of search
- can easily reach depth 8 and play good chess.
- A simple example of the value of reasoning about
which - computations are relevant (a form of
metareasoning).
27Deterministic games in practice
- Checkers In 1994 Chinook ended 40-year-reign of
human world champion Marion Tinsley. Used an
endgame database defining perfect play for all
positions involving 8 or fewer pieces on the
board, a total of 443,748,401,247 positions. - Chess Deep Blue defeated human world champion
Gary Kasparov in a six-game match in 1997. Deep
Blue searches 200 million positions per second,
uses very sophisticated evaluation, and
undisclosed methods for extending some lines of
search up to 40 ply. - Othello Human champions refuse to compete
against computers, who are too good. - Go Human champions refuse to compete against
computers, who are too bad. In Go, b gt 300, so
most programs use pattern knowledge bases to
suggest plausible moves.