Adversarial Search
Adversarial Search
ADVERSARIAL SEARCH
Multi-agent Games
Deterministic games Non-deterministic games
Adversarial Searches
In previous Chapter, we have studied the search strategies which are only associated with a
single agent that aims to find the solution which often expressed in the form of a sequence of
actions.
There might be some situations where more than one agent is searching for the solution in the
same search space, and this situation usually occurs in game playing.
The environment with more than one agent is termed as multi-agent environment, in which
each agent is an opponent of other agent and playing against each other. Each agent needs to
consider the action of other agent and effect of that action on their performance.
So, Searches in which two or more players with conflicting goals are trying to explore the same
search space for the solution, are called adversarial searches, often known as Games.
Games
Playing games (not all ) can be seen as a Search Problem
Multiplayer games as multi-agent environments.
Agents' goals are in conflict.
Mostly deterministic and fully observable environments.
Some games are not trivial search problems, e.g., Chess has an average branching factor of 35,
and games often go to 50 moves by each player, so the search tree has about 35 100or 10154
nodes.
Finding optimal move: choosing a good move with time limits.
Heuristic evaluation functions allow us to approximate the true utility of a state without doing
a complete search.
Determinist
ic Game
Two players take turns making
moves
Board state fully observable,
deterministic evaluation of moves
One player wins by defeating the
other (or else there is a tie)
Want a strategy to win, assuming
the other person plays as well as
possible
A (partial) game tree for the game of tic-tac-toe
Game tree
Is a tree where nodes of the tree are the game
states and Edges of the tree are the moves by
players. Game tree involves initial state, action's
function, and result Function.
Levels alternate between max (player 1
moves) and min (player 2 moves)
Create a utility function
Evaluation of board/game state to determine how
strong the position of player 1 is.
Player 1 wants to maximize the utility function
-99 +99
Player 2 wants to minimize the utility function
Last state
(Leaf node)
Calculated by utility function,
depends on the game.
The Utility Function
Assign utility values to leaves – Sometimes called board evaluation function –
◦ If leaf is a final state, assign the maximum or minimum possible utility value (depending on
who would win).
◦ If leaf is not a final state, must use some other heuristic, specific to the game, to evaluate
how good/bad the state is at that point
Min-Max (Minimax) Algorithm
• Min-max algorithm is a recursive or backtracking algorithm which is used in decision-making
and game theory. It provides an optimal move for the player assuming that opponent is also
playing optimally.
• In this algorithm, two players play the game, one is called MAX and other is called MIN.
• Min-Max algorithm is mostly used for game playing in AI. Such as Chess, Checkers, tic-tac-toe,
and various two-players game. This Algorithm computes the min-max decision for the current
state.
MinMax Algorithm
• Both Players of the game are opponent of each other, where
MAX will select the maximized value and MIN will select the
minimized value.
Min-Max Algorithm - Example 1
MinMax Algorithm - Example 1
Min-Max Algorithm - Example 1
Minimax maximizes the utility for the worst-case outcome for max
Min (O)
-99 0 -99
Max(X)
Terminal
+99 +99
Min-Max Example 3
5 Max
5 3 4 Min
7 6 5 5 6 4
Max
Min
4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3
5 3 4 Min
7 6 5 5 6 4
Max
Min
4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3