CSC-411-AI-lec6-Adversarial Search
CSC-411-AI-lec6-Adversarial Search
Adversarial Search
Mona Leeza
Email : monaleeza.bukc@bahria.edu.pk
Outline
• Optimal decisions
• MiniMax Algorithm
• α-β pruning
• Imperfect, real-time decisions
Games vs. search problems
• "Unpredictable" opponent specifying a
move for every possible opponent reply
Games Playing (1)
We will be concerned with games that, like chess,
have the following characteristics:
• Two players
• Turn-taking
• Deterministic
The same move in the same situation always has
the same effect.
• Perfect information
The entire game state is always available to both
players.
Two-Agent Games
• Two-agent, perfect information, zero-
sum games
• Two agents move in turn until either
one of them wins or the result is a
draw.
• Each player has a complete model of
the environment and of its own and
the other’s possible actions and their
effects.
Minimax Procedure (1)
• Two player : MAX and MIN
• Task : find a “best” move for MAX
• Assume that MAX moves first, and that the two
players move alternately.
• MAX node
– nodes at even-numbered depths correspond to positions
in which it is MAX’s move next
• MIN node
– nodes at odd-numbered depths correspond to positions in
which it is MIN’s move next
Game tree (2-player, deterministic, turns)
tic-tac-toe
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:
An Example
Compute the backed-up values calculated by the minimax
algorithm. Show your answer by writing values at the
appropriate nodes in the above tree.
5 3 4 6 5 3 6 4 7 5 2 4 5 3 8 2
Minimax algorithm
Properties of minimax
• Complete? Yes (if tree is finite)
• Optimal? Yes (against an optimal opponent)
• Time complexity? O(bm) (b-legal moves; m- max tree depth)
• Space complexity? O(bm) (depth-first exploration)
e(p)=5-4=1 e(p)=6-4=2
Question?
• How to improve
search efficiency?
• It is possible to
cut-off some
unnecessary
subtrees?
Alpha-Beta Pruning
• It is possible to compute the correct minimax decision without looking
at every node in the game tree.
B C
B C D
B C D
B C D
Standard approach:
cutoff test:
e.g., depth limit (perhaps add quiescence search)
evaluation function
= estimated desirability of position
Game Include an Element of Chance
Backgammon
Game Include an Element of Chance
Deterministic Games in Practice
• Checkers : Chinook ended 40-year-reign of human
world champion Marion Tinsley in 1994. Used a
precomputed endgame database defining perfect
play for all positions involving 8 or fewer pieces on
the board, a total of 444 billion positions. Checkers
is now solved.
MIN
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 8 6 4
Alpha Beta Pruning (Exercise)
4 16 5 31 = 5 39
MAX
8 6 5 23
= 4 15 = 5 30 3 38
MIN
8 2 2 10 1 18 1 33
4 12 3 20 3 25 2 35
=8 5 9 8 9 27 6 29= 3 37
= 4 14 = 5 22
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 8 6 4
1 3 4 7 9 11 13 17 19 21 24 26 28 32 34 36
11 static evaluations saved !!
TUTORIAL 06
1. Differentiate between Game and Search
2. Explain the Adversarial search strategy.
3. Describe the working of minimax algorithm.
4. Write down the properties of minimax algorithm.
5. Describe the working of alpha-beta pruning algorithm.
6. Write down the properties of alpha-beta pruning algorithm.
TUTORIAL 06
TUTORIAL 06
TUTORIAL 06