0% found this document useful (0 votes)
27 views

Adversarial Search

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

Adversarial Search

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

Module – 3

Search in Complex environment


•Adversarial search - Games, Optimal
decisions in games, The Minimax algorithm,
Alpha-Beta pruning. Constraint Satisfaction
Problems – Defining CSP, Constraint
Propagation- inference in CSPs,
Backtracking search for CSPs, Structure of
CSP problems.
ADVERSARIAL SEARCH

• In which we examine the problems that arise when we try to


plan ahead in a world In which we examine the problems that
arise when we try to plan ahead in a world In which we
examine the problems that arise when we try to plan ahead in
a world
ADVERSARIAL SEARCH
• Search in competitive environments
• Where agent’s goals are in conflict
• Games are good example of adversarial Search
• States are easy to represent(unlike many other real world
problems)
• Agents are restricted to a small number of actions
• Outcomes of agent action defined by precise rule
• Usually hard too solve
Example
8 PUZZLE CHESS TIC TAC GAME
How to define a problem formally?
• Consider a game with two players MAX and MIN
• Max moves first(places x) followed by MIN
• A game can be formally defined as a search problem with the
following elements
• So - The initial state
• Player(s)-Defines which player has a move in a state(s)
• Actions(s)-returns the set of legal moves in a state
• Results(s,a)-The transition model which defines the result of a move
• Terminal-Test(s)-True when game is over, false otherwise
• Utility(s,p)-utility function (also called an objective function or payoff
function)
• defines the final numeric value for a game that ends in terminal state s for a
player p.
• chess, Tic tac toe the outcome is a win, loss, or draw, with values +1, 0, or -1
GAME TREE
Initial state, Actions function, and result Function defines
Game tree.
A game tree is a tree where nodes of the tree are the game
states and Edges of the tree are the moves by players.

SEARCH TREE
search tree is a tree that is superimposed on the full game
tree, and examines enough nodes to allow a player to
determine what move to make.
Game tree for Tic-tac-toe
• MAX has 9 possible moves.
• Play alternates between MAX’s placing an X and MIN’s
placing an O.
• The number on each leaf node indicates the utility value of
the terminal state from the point of view of MAX;
• high values are assumed to be good for MAX and bad for MIN

• Number of nodes are in this game tree?


9+(8*9)+7*(8*9)+……………….
• For tic-tac-toe the game tree is relatively small—fewer than 9! = 362,
880 terminal nodes.
• But for chess there are over 1040 nodes, so the game tree is best
thought of as a theoretical construct that we cannot realize in the
physical world.
• But regardless of the size of the game tree, it is MAX’s job to search
for a good move.
• search tree for a tree that is superimposed on the full game tree, and
examines enough nodes to allow a player to determine what move to
make.
Optimal decisions in games?
• A Normal search problem:
• The optimal solution is a sequence of actions leading to a goal
state
• An adversarial search problems:
• MIN(P2) interferes the sequence of actions
• Strategy for MAX:
• Specify moves in the initial state
• Observes every possible response by MIN
• Specify moves
• The optimal strategy can be determined from the minimax
value of each node
How to calculate utility of non terminal nodes
How to calculate minimax value?
Consider a “reduced” tic tac toe game
• The possible moves for MAX at the root node are labeled a1, a2, and a3.
• The possible replies to a1 for MIN are b1, b2,b3, and so on.
Optimal strategy can be determined using minimax value of
each node, MINIMAX(n).
• MINIMAX(n) for the user for MAX is the utility of being in the corresponding state
• So, MAX will always prefer to move to a state of maximum value
• The minimax value of a terminal state is just its utility.
• MAX prefers to move to a state of maximum value, whereas MIN prefers a state of
minimum value
How to calculate minimax value?
Utility function vs minimax function
Working of Min Max Algorithm
Steps involved in solving two player game
• This limitation of the minimax algorithm can be improved from alpha-beta pruning .
Minimax Algorithm
p
ALPHA BETA PRUNING ALGORITHM
ALPHA BETA PRUNING ALGORITHM
Working –ALPHA BETA PRUNING ALGORITHM
CONSTRAINT SATISFACTION PROBLEM

You might also like