0% found this document useful (0 votes)
23 views20 pages

Adversarial Search

Uploaded by

voramahek21
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)
23 views20 pages

Adversarial Search

Uploaded by

voramahek21
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/ 20

CS 561 Artificial Intelligence

Lecture #

Adversarial Search

Rashmi Dutta Baruah


Dept. of Computer Science & Engineering
IIT Guwahati
Outline
 Introduction : games
 Minimax algorithm
 Alpha-Beta algorithm
Games
 Game Theory (from Economics)
 Game is a formal model representing strategic interactions
(conflicting or cooperating) among multiple agents.
 Game with only one player : decision problem
 Game theory: study of such models and applied to many fields
including political science, psychology, and computer science.
 Games in AI
 Adversarial search problems: Games
 competitive multi-agent environment where, while planning, an agent
needs to consider the actions of other agents whose goals are conflicting.
 deterministic, two-player, turn-taking, zero-sum games of perfect
information (the utility values at the end of the game are always equal and
opposite, eg. chess)
Games
 Strategic and Extensive form of games
 Strategic form (also called normal form)
 usually represented by a matrix that shows the players,
strategies, and pay offs
 players choose a strategy simultaneously (without knowing the
other player’s strategy).
 players choose the strategy only once and than the game is over,
such games are also called static (or simultaneous move) games
 Extensive form (also called game trees)
 completely describes how the game is played over time.
Games
 Example: Prisoner’s dilemma
 Two players, “prisoners” 1, 2.
 Each is questioned by authorities separately and without
communication.
 Each has two strategies. We will consider games in
 Prisoner 1: Defect, Cooperate extensive forms next.
 Prisoner 2: Defect, Cooperate
 consequences quantified in prison years (payoff 0,1,2,3)
Prisoner2
Strategic or Normal Form
Cooperate (C) Defect (D)

Cooperate (C) 2,2 0,3


Prisoner1
Defect (D) 3,0 1,1
Games
 Game can be formulated as search problem
 𝑆0 : initial state
 𝑃𝐿𝐴𝑌𝐸𝑅 𝑠 : which player has the move in a state
 𝐴𝐶𝑇𝐼𝑂𝑁𝑆 𝑠 : returns the set of legal moves
 𝑅𝐸𝑆𝑈𝐿𝑇 𝑠, 𝑎 : transition model, defines the result of a move
 𝑇𝐸𝑅𝑀𝐼𝑁𝐴𝐿 − 𝑇𝐸𝑆𝑇 𝑆 : true when the game is over and false
otherwise. States where game has ended are called terminal
states.
 𝑈𝑇𝐼𝐿𝐼𝑇𝑌 𝑠, 𝑝 : gives final numeric value for a game that ends
in terminal state s for a player p. Example, in chess win +1, loss
0, draw 1/2 .
Games
 Game tree: nodes are game states, edges are moves, and defined by
initial state, 𝐴𝐶𝑇𝐼𝑂𝑁𝑆 function and 𝑅𝐸𝑆𝑈𝐿𝑇 function.

Two players: MAX and MIN


Max always moves first. Min is the
opponent.
they take turns moving until the
game is over
Minimax Algorithm
 Minimax: algorithm to find optimal strategy
 Idea: choose move to a state with highest minimax value
An action by one player is called a
ply, two ply (a action and a
counter action) is called a move.
Minimax Algorithm
• Generate the game tree down to the terminal nodes. minimax value of a
• Apply the utility function to the terminal nodes. node is the utility
(for MAX) of being
• For a set S of sibling nodes, pass up to the parent in the corresponding
• the lowest value in S if the siblings are MAX nodes state.
• the largest value in S if the siblings are MIN nodes
• Recursively do the above, until the backed-up values reach the
initial state.
• The value of the initial state is the minimum score for MAX.

𝑈𝑇𝐼𝐿𝐼𝑇𝑌 𝑠 𝑖𝑓 𝑇𝑅𝐸𝑅𝑀𝐼𝑁𝐴𝐿 − 𝑇𝐸𝑆𝑇(𝑠)


𝑀𝐼𝑁𝐼𝑀𝐴𝑋 𝑠 = ൞𝑚𝑎𝑥𝑎∈𝐴𝐶𝑇𝐼𝑂𝑁𝑆 𝑠 𝑀𝐼𝑁𝐼𝑀𝐴𝑋 𝑅𝐸𝑆𝑈𝐿𝑇 𝑠, 𝑎 𝑖𝑓 𝑃𝐿𝐴𝑌𝐸𝑅 𝑠 = 𝑀𝐴𝑋
𝑚𝑖𝑛𝑎∈𝐴𝐶𝑇𝐼𝑂𝑁𝑆 𝑠 𝑀𝐼𝑁𝐼𝑀𝐴𝑋 𝑅𝐸𝑆𝑈𝐿𝑇 𝑠, 𝑎 𝑖𝑓 𝑃𝐿𝐴𝑌𝐸𝑅 𝑠 = 𝑀𝐼𝑁
Minimax Algorithm

In this game Max’s best move is A1, because he is guaranteed a score of at least 3.
Properties of minimax
 Complete? Yes (if tree is finite)
 Optimal? Yes (against an optimal opponent)
 Time complexity? O(bm)
 Space complexity? O(bm) (depth-first exploration)

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


→ exact solution completely infeasible
Alpha-Beta pruning
 The exponent part of the time complexity can be reduced to
half O(bm/2).
 Idea: instead of looking at every node, prune away the
branches of the tree that cannot possibly influence the final
decision.
 Alpha-beta pruning gets its name from the following two
parameters that describe bounds on the backed-up values that
appear anywhere along the path:
α = the value of the best (i.e., highest-value) choice found so far at
any choice point along the path for MAX
𝛽 = the value of the best (i.e. lowest-value) choice found so far at any
choice point along the path for MIN
Alpha-Beta pruning
 Alpha-Beta search updates the values of 𝛼 and 𝛽 as it goes
along and prunes the remaining branches at a node (i.e.,
terminates the recursive call)
 when the value of the current node is worse than the current 𝛼
and 𝛽 value for MAX or MIN, respectively.
 While the backed-up values are updated we note that:
 the 𝛼 values of MAX nodes (including the start node) can never
decrease.
 the 𝛽 values of MIN nodes can never increase.
α-β pruning example
𝛼 𝑣𝑎𝑙𝑢𝑒

𝛽 𝑣𝑎𝑙𝑢𝑒

≤3
α-β pruning example

𝛼 𝑐𝑢𝑡𝑜𝑓𝑓
α-β pruning example
α-β pruning example
α-β pruning example
Alpha-Beta pruning
 𝛼 − 𝑐𝑢𝑡𝑜𝑓𝑓 ∶ search can be discontinued below any MIN
node having a beta value less than or equal to the alpha value
of any of its MAX node ancestors.
 𝛽 − 𝑐𝑢𝑡𝑜𝑓𝑓: search can be discontinued below any MAX
node having an alpha value greater than or equal to the beta
value of its MIN node ancestors.
Alpha-Beta pruning
 Alpha-Beta is guaranteed to compute the same Minimax
value for the root node as computed by Minimax
 In the worst case, Alpha-Beta does NO pruning.
 In the best case, Alpha-Beta will examine only 2bm/2 leaf
nodes.
 The best case occurs when each player's best move is the
leftmost alternative (i.e., the first child generated). So, at
MAX nodes the child with the largest value is generated
first, and at MIN nodes the child with the smallest value
is generated first.

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