0% found this document useful (0 votes)
22 views50 pages

Adversarial Search_ Game Trees and Minimax Evaluation

The document discusses adversarial search and game-playing, focusing on the challenges of planning in environments where multiple agents compete against each other. It outlines techniques such as pruning and heuristic evaluation functions to optimize decision-making in games, and explains the minimax algorithm for determining optimal moves in two-player games. Additionally, it differentiates between perfect and imperfect information games, as well as deterministic and non-deterministic games, while highlighting the limitations of the minimax algorithm in complex scenarios.

Uploaded by

divyanshibr.2325
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)
22 views50 pages

Adversarial Search_ Game Trees and Minimax Evaluation

The document discusses adversarial search and game-playing, focusing on the challenges of planning in environments where multiple agents compete against each other. It outlines techniques such as pruning and heuristic evaluation functions to optimize decision-making in games, and explains the minimax algorithm for determining optimal moves in two-player games. Additionally, it differentiates between perfect and imperfect information games, as well as deterministic and non-deterministic games, while highlighting the limitations of the minimax algorithm in complex scenarios.

Uploaded by

divyanshibr.2325
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/ 50

Adversarial Search and Game-

Playing
Environment Type
Fully Turn-taking: Semi-dynamic
Observable Deterministic and non-deterministic

yes

Multi-agent

yes

Sequential
yes no

Discrete no
yes Discrete

yes
Game Game Matrices Continuous Action Games
Tree
Search
2
Adversarial Search
 Examine the problems that arise when we try to plan ahead in
a world where other agents are planning against us. A good
example is in board games.
 Adversarial games, while much studied in AI, are a small part
of game theory in economics.
Techniques to get the best optimal solution
 Techniques to get best optimal solution in a limited time:
 Pruning: A technique which allows ignoring the unwanted portions of a
search tree which make no difference in its final result.

 Heuristic Evaluation Function: It allows to approximate the cost


value at each level of the search tree, before reaching the goal node.
Typical AI assumptions
 Two agents whose actions alternate
 Utility values for each agent are the opposite of the other
creates the adversarial situation
 Fully observable environments
 In game theory terms: Zero-sum games of perfect
information.
 We’ll relax these assumptions later.
Search versus Games
 Search – no adversary
Solution is (heuristic) method for finding goal
Heuristic techniques can find optimal solution
Evaluation function: estimate of cost from start to goal
through given node
Examples: path planning, scheduling activities
 Games – adversary
Solution is strategy (strategy specifies move for every
possible opponent reply).
Optimality depends on opponent.
Time limits force an approximate solution
Evaluation function: evaluate “goodness” of game position
Examples: chess, checkers, Othello, backgammon
Games vs. Search Problems
Unpredictable opponent  specifying a move for
every possible opponent reply.
Time limits  unlikely to find goal, must approximate.
Types of Games
 Mainly games of strategy with the following characteristics:
1. Sequence of moves to play
2. Rules that specify possible moves
3. Rules that specify a payment for each move
4. Objective is to maximize your payment
Types of Games
deterministic Chance moves
Perfect Chess, Backgammon,
information checkers, go, monopoly
othello
Imperfect Bridge, Skat Poker, scrabble,
information blackjack
(Initial Chance
Moves)
 Perfect information: A game with the perfect information is that
in which agents can look into the complete board. Agents have all
the information about the game, and they can see each other moves
also. Examples are Chess, Checkers, Go, etc.
 Imperfect information: If in a game agents do not have all
information about the game and not aware with what's going on,
such type of games are called the game with imperfect information,
such as tic-tac-toe, Battleship, blind, Bridge, etc.
 Deterministic games: Deterministic games are those games which
follow a strict pattern and set of rules for the games, and there is no
randomness associated with them. Examples are chess, Checkers,
Go, tic-tac-toe, etc.
 Non-deterministic games: Non-deterministic are those games
which have various unpredictable events and has a factor of chance
or luck. This factor of chance or luck is introduced by either dice or
cards. These are random, and each action response is not fixed.
Such games are also called as stochastic games.
Example: Backgammon, Monopoly, Poker, etc.
Two Player Game
Games as Adversarial Search
 States:
board configurations
 Initial state:
the board position and which player will move
 Successor function:
returns list of (move, state) pairs, each indicating a legal
move and the resulting state
 Terminal test:
determines when the game is over
 Utility function:
gives a numeric value in terminal states (e.g., -1, 0, +1 for
loss, tie, win)
Game Setup
 Two players: MAX and MIN
 MAX moves first and they take turns until the game is over
Winner gets award, loser gets penalty.
 Games as search:
Initial state: e.g. board configuration of chess
Successor function: list of (move, state) pairs specifying
legal moves.
Terminal test: Is the game finished?
Utility function: Gives numerical value of terminal states.
E.g. win (+1), lose (-1) and draw (0) in tic-tac-toe or chess
Size of search trees
 b = branching factor
 d = number of moves by both players
 Search tree is O(bd)
 Chess
b ~ 35
D ~100
- search tree is ~ 10 154 (!!)
- completely impractical to search this
 Game-playing emphasizes being able to make optimal
decisions in a finite amount of time
Somewhat realistic as a model of a real-world agent
Even if games themselves are artificial
Game Tree (2-player, Deterministic,
Turns)
 Explanation:
 From the initial state, MAX has 9 possible moves as he starts first.
MAX place x and MIN place o, and both player plays alternatively
until we reach a leaf node where one player has three in a row or
all squares are filled.
 Both players will compute each node, minimax, the minimax value
which is the best achievable utility against an optimal adversary.
 Suppose both the players are well aware of the tic-tac-toe and
playing the best play. Each player is doing his best to prevent
another one from winning. MIN is acting against Max in the game.
 So in the game tree, we have a layer of Max, a layer of MIN, and
each layer is called as Ply. Max place x, then MIN puts o to
prevent Max from winning, and this game continues until the
terminal node.
 In this either MIN wins, MAX wins, or it's a draw. This game-tree
is the whole search space of possibilities that MIN and MAX are
playing tic-tac-toe and taking turns alternately.
Game tree (2-player,
deterministic, turns)

How do we search this tree to find the optimal move?


Mini-Max Terminology
 move: a move by both players
 ply: a half-move
 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 procedure: search down several levels; at the
bottom level apply the utility function, back-up values all the
way up to the root node, and that node selects the move.
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:
Mini-Max Example
Minimax Strategy
Why do we take the min value every other level of the
tree?
These nodes represent the opponent’s choice of move.
The computer assumes that the human will choose that
move that is of least value to the computer.
Algorithm
Properties of Minimax
 Complete?
Yes (if tree is finite)
 Optimal?
Yes (against an optimal opponent)
No (does not exploit opponent weakness against suboptimal
opponent)
 Time complexity?
O(bm)
 Space complexity?
O(bm) (depth-first exploration)
Working of Min-Max Algorithm
 Example: There are two players
one is called Maximizer and other
is called Minimizer.
 Step-1: In the first step, the
algorithm generates the entire
game-tree and apply the utility
function to get the utility values
for the terminal states.
 let's take A is the initial state of the
tree. Suppose maximizer takes first
turn which has worst-case initial
value =- infinity, and minimizer
will take next turn which has
worst-case initial value = +infinity.
 Step 2: Now, first we find the utilities value for the
Maximizer, its initial value is -∞, so we will compare each
value in terminal state with initial value of Maximizer and
determines the higher nodes values. It will find the maximum
among the all.
For node D
max(-1,- -∞) => max(-1,4)= 4
For Node E
max(2, -∞) => max(2, 6)= 6
For Node F
max(-3, -∞) => max(-3,-5) = -3
For node G
max(0, -∞) = max(0, 7) = 7
 Step 3: In the next step, it's a turn for minimizer, so it will
compare all nodes value with +∞, and will find the 3rd layer
node values.
 For node B= min(4,6) = 4
 For node C= min (-3, 7) = -3
 Step 4: Now it's a turn for Maximizer, and it will again
choose the maximum of all nodes value and find the
maximum value for the root node. In this game tree, there are
only 4 layers, hence we reach immediately to the root node,
but in real games, there will be more than 4 layers.
 For node A max(4, -3)= 4
Limitation of the minimax
Algorithm
 The main drawback of the minimax algorithm is that it gets
really slow for complex games such as Chess, go, etc.
 This type of games has a huge branching factor, and the
player has lots of choices to decide.
 This limitation of the minimax algorithm can be improved
from alpha-beta pruning which we have discussed in the
next topic.
Two-Ply Game Tree
Two-Ply Game Tree
Two-Ply Game Tree
Two-Ply Game Tree
Minimax maximizes the utility for the worst-case outcome for max

The minimax decision


Example of Algorithm
Execution
MAX to move
Multiplayer games
 Games allow more than two players
 Single minimax values become vectors
Example
Zero sum games: zero-sum describes a situation in which a participant's
gain or loss is exactly balanced by the losses or gains of the other
participant(s). If the total gains of the participants are added up, and the
total losses are subtracted, they will sum to zero.

• A and B make simultaneous moves, illustrates minimax solutions.


• Can they do better than minimax?
• Can we make the space less complex?
• Pure strategy vs mix strategies
Aspects of multiplayer games
 Previous slide (standard minimax analysis) assumes that each
player operates to maximize only their own utility.

 In practice, players make alliances


E.g, C strong, A and B both weak
May be best for A and B to attack C rather than each other

 If game is not zero-sum (i.e., utility(A) = - utility(B) then


alliances can be useful even with 2 players.
e.g., both cooperate to maximum the sum of the utilities
Practical problem with minimax
search
 Number of game states is exponential in the number of
moves.
Solution: Do not examine every node
=> pruning
Remove branches that do not influence final decision

 Revisit example …

You might also like