Why Do AI Researchers Study Game Playing?
Why Do AI Researchers Study Game Playing?
Why Do AI Researchers Study Game Playing?
Two-Player Game
Opponents Move
Generate New Position
Game
Over?
yes
no
Generate Successors
Evaluate Successors
Move to Highest-Valued Successor
no
Game
Over?
yes
4
opponents
turn
leaf nodes
are evaluated
Mini-Max Terminology
utility function: the function applied to leaf nodes
backed-up value
of a max-position: the value of its largest successor
of a min-position: the value of its smallest successor
Minimax
Perfect play for deterministic games
Idea: choose move to position with highest minimax
value
= best achievable payoff against best play
E.g., 2-ply game:
Minimax Strategy
Why do we take the min value every other
level of the tree?
These nodes represent the opponents
choice of move.
The computer assumes that the human will
choose that move that is of least value to
the computer.
8
Minimax algorithm
Sample Evaluations
X = Computer; O = Opponent
O O X
X X
O
X
X
rows
cols
diags
rows
cols
diags
11
1
12
Properties of Minimax
Alpha-Beta Procedure
The alpha-beta procedure can speed up a
depth-first minimax search.
Alpha: a lower bound on the value that a
max node may ultimately be assigned
v>
14
- pruning example
15
- pruning example
=3
alpha cutoff
16
- pruning example
17
- pruning example
18
- pruning example
19
Alpha Cutoff
=3
>3
3
10
20
Beta Cutoff
=4
<4
>8
cutoff
21
Alpha-Beta Pruning
max
min
max
eval
2 10 11 1 2 2
12
25
22
Properties of -
Pruning does not affect final result. This means that it
gets the exact same result as does full minimax.
Good move ordering improves effectiveness of pruning
With "perfect ordering," time complexity = O(bm/2)
doubles depth of search
23
The - algorithm
cutoff
24
The - algorithm
cutoff
25
100
< 100
...
< 100
26
27
Additional Refinements
Waiting for Quiescence: continue the search
until no drastic change occurs from one level to
the next.
Secondary Search: after choosing a move,
search a few more levels beneath it to be sure it
still looks good.
Book Moves: for some parts of the game
(especially initial and end moves), keep a
catalog of best moves to make.
28
Evaluation functions
For chess/checkers, 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), etc.
29
31
32
33
Kalah
Ps holes
KP
6
Kp
counterclockwise
ps holes
To move, pick up all the stones in one of your holes, and
put one stone in each hole, starting at the next one,
including your Kalah and skipping the opponents Kalah.
34
Kalah
If the last stone lands in your Kalah, you get
another turn.
If the last stone lands in your empty hole, take all
the stones from your opponents hole directly
across from it and put them in your Kalah.
If all of your holes become empty, the opponent
keeps the rest of the stones.
The winner is the player who has the most
stones in his Kalah at the end of the game.
35
37
Games of Chance
What about games that involve chance,
such as
rolling dice
picking a card
min
chance
max
38
Games of Chance
chance node with
max children
c
di
d1
dk
S(c,di)
s in S(c,di)
s in S(c,di)
39
.4
min
chance
.6
.4
.6
.4
1.2
.6
max
leaf
3 5 1 4 1 2 4 5
40
Complexity
Instead of O(bm), it is O(bmnm) where n is
the number of chance outcomes.
Since the complexity is higher (both time
and space), we cannot search as deeply.
Pruning algorithms may be applied.
41
Summary
Games are fun to work on!
They illustrate several important points about AI.
Perfection is unattainable must approximate.
Game playing programs have shown the world
what AI can do.
42