0% found this document useful (0 votes)
106 views38 pages

CSC-411-AI-lec6-Adversarial Search

Here are the key points about adversarial search and game playing algorithms: 1. Games vs search problems: Games have an unpredictable opponent who can react to the agent's moves, requiring the agent to consider its opponent's possible replies. Search problems have a fixed problem state. 2. Minimax algorithm: For two-player zero-sum perfect information games, minimax finds the optimal move by considering all possible future game states and choosing the move that maximizes the minimum possible payoff against optimal opponent play. 3. Alpha-beta pruning: An optimization of minimax that prunes subtrees where the minimax value of the subtree has been determined without evaluating all leaf nodes. This improves search efficiency without changing the result.

Uploaded by

Abdullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views38 pages

CSC-411-AI-lec6-Adversarial Search

Here are the key points about adversarial search and game playing algorithms: 1. Games vs search problems: Games have an unpredictable opponent who can react to the agent's moves, requiring the agent to consider its opponent's possible replies. Search problems have a fixed problem state. 2. Minimax algorithm: For two-player zero-sum perfect information games, minimax finds the optimal move by considering all possible future game states and choosing the move that maximizes the minimum possible payoff against optimal opponent play. 3. Alpha-beta pruning: An optimization of minimax that prunes subtrees where the minimax value of the subtree has been determined without evaluating all leaf nodes. This improves search efficiency without changing the result.

Uploaded by

Abdullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Lecture 06

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)

 For chess, b ≈ 35, m ≈100 for "reasonable" games


 exact solution completely infeasible
Example : Tic-Tac-Toe (1)
• MAX marks crosses MIN marks circles
• it is MAX’s turn to play first.
– With a depth bound of 2, conduct a breadth-first
search
– evaluation function e(p) of a position p
• If p is not a winning for either player,
e(p) = (no. of complete rows, columns, or diagonals that
are still open for MAX) - (no. of complete rows,
columns, or diagonals that are still open for MIN)
• If p is a win of MAX, e(p) = 
• If p is a win of MIN, e(p) = - 
– evaluation function e(p) of a position p
• If p is not a winning for either player,
e(p) = (no. of complete rows, columns, or diagonals that
are still open for MAX) - (no. of complete rows, columns,
or diagonals that are still open for MIN)

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.

• Alpha-beta pruning allows to eliminate large parts of the tree from


consideration, without influencing the final decision.

• Alpha-beta pruning gets its name from two parameters.


– They describe bounds on the values that appear anywhere along
the path under consideration:
• α = the value of the best (i.e., highest value) choice found so far
along the path for MAX
• β = the value of the best (i.e., lowest value) choice found so far
along the path for MIN
Alpha-Beta Pruning

The leaves below B have the values 3, 12 and 8.


The value of B is exactly 3.
It can be inferred that the value at the root is at least 3,
because MAX has a choice worth 3.
Alpha-Beta Pruning

B C

C, which is a MIN node, has a value of at most 2.


But B is worth 3, so MAX would never choose C.
Therefore, there is no point in looking at the other successors of C.
Alpha-Beta Pruning

B C D

• D, which is a MIN node, is worth at most 14.


• This is still higher than MAX’s best alternative (i.e., 3), so D’s other
successors are explored.
Alpha-Beta Pruning

B C D

• The second successor of D is worth 5, so the


exploration continues.
Alpha-Beta Pruning

B C D

The third successor is worth 2, so now D is worth exactly 2.


MAX’s decision at the root is to move to B, giving a value of 3
Properties 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

 A simple example of the value of reasoning about


which computations are relevant (a form of
metareasoning)
Why is it called α-β?
 α is the value of the
best (i.e., highest-value)
choice found so far at
any choice point along
the path for max
 If v is worse than α,
max will avoid it
 prune that branch
 Define β similarly for
min
The α-β algorithm
The α-β algorithm
Resource limits
Suppose we have 100 secs, explore 104 nodes/sec
 106 nodes per move

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.

• Chess: Deep Blue defeated human world champion


Garry 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. Current programs are even better, if less
historic.
Deterministic Games in Practice
• 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 > 300, so most programs use
pattern knowledge bases to suggest
plausible moves, along with aggressive
pruning.
Summary
• All the game start with defining by the initial state (how the board is set
up), the legal actions in each state, the result of each action, a terminal
test (which says when the game is over), and a utility function that
applies to terminal states.

• In two-player zero-sum games which has perfect information, the


minimax algorithm can select optimal moves by a depth-first
enumeration of the game tree.

• The alpha–beta search algorithm computes the same as minimax, but


achieves much greater efficiency by eliminating subtrees that are
provably irrelevant.
Summary
• Usually, it is not feasible to consider the whole game
tree (even with alpha–beta) need to cut the search off
at some point and apply a heuristic evaluation
function that estimates the utility of a state.

• Games of chance can be handled by an extension to


the minimax algorithm that evaluates a chance node
by taking the average utility of all its children,
weighted by the probability of each child.
Alpha Beta Pruning (Exercise)
MAX

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy