SlideShare a Scribd company logo
Chapter 6: Adversarial Search
In which we examine the problems that arise when we try to plan
ahead in a world where other agents are planning against us.
CS 420: Artificial Intelligence 2
Adversarial Search
 Multi-agent environment:
 any given agent needs to consider the actions
of other agents and how they affect its own
welfare
 introduce possible contingencies into the
agent’s problem-solving process
 cooperative vs. competitive
 Adversarial search problems: agents have
conflicting goals -- games
CS 420: Artificial Intelligence 3
Games vs. Search Problems
 "Unpredictable"
opponent
 specifying a move
for every possible
opponent reply
 Time limits
 unlikely to find
goal, must
approximate
CS 420: Artificial Intelligence 4
AI and Games
 In AI, “games” have special
format:
 deterministic, turn-taking, 2-
player, zero-sum games of
perfect information
 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)
 Or, the total payoff to all players
is the same for every instance of
the game (constant sum)
Go! 围棋
CS 420: Artificial Intelligence 5
Game Problem Formulation
 A game with 2 players (MAX and MIN, MAX moves
first, turn-taking) can be defined as a search
problem with:
 initial state: board position
 player: player to move
 successor function: a list of legal (move, state) pairs
 goal test: whether the game is over – terminal states
 utility function: gives a numeric value for the terminal
states (win, loss, draw)
 Game tree = initial state + legal moves
CS 420: Artificial Intelligence 6
Game Tree (2-player, deterministic)
Utility value
CS 420: Artificial Intelligence 7
Optimal Strategies
 MAX must find a contingent strategy, specifying MAX’s move in:
 the initial state
 the states resulting from every possible response by MIN
 E.g., 2-ply game (the tree is one move deep, consisting of two half-
moves, each of which is called a ply):
3 12 8 2 4 6 14 5 2
MAX
MAX
MIN 3 2 2
3
CS 420: Artificial Intelligence 8
Minimax Value
 Perfect play for deterministic game, assume both
players play optimally
 Idea: choose move to position with highest
minimax value = best achievable payoff against
best play
( )
MINIMAX VALUE n
 
( )
Utility n
( )
max ( )
s Successors n MINIMAX s

( )
min ( )
s Successors n MINIMAX s

if n is a terminal state
if n is a MAX node
if n is a MIN node
CS 420: Artificial Intelligence 9
A Partial Game Tree for Tic-Tac-Toe
O’s turn (MIN)
X’s turn (MAX)
by Yosen Lin
CS 420: Artificial Intelligence 10
Minimax Algorithm
CS 420: Artificial Intelligence 11
Minimax with Tic-Tac-Toe
 Work on board.
 Walk through a real tic-tac-toe program.
CS 420: Artificial Intelligence 12
Analysis of Minimax
 Optimal play for MAX assumes that MIN also plays
optimally, what if MIN does not play optimally?
 A complete depth-first search?
 Yes
 Time complexity?
 O(bm)
 Space complexity?
 O(bm) (depth-first exploration)
 For chess, b ≈ 35, m ≈ 100 for "reasonable"
games
 exact solution completely infeasible
CS 420: Artificial Intelligence 13
Optimal Decisions for Multiplayer Games
 Extend minimax idea to multiplayer
A
B
C
A
(1,2,6) (4,2,3) (6,1,2) (7,4,1) (5,1,1) (1,5,2) (7,7,1) (5,4,5)
(1,2,6) (6,1,2) (1,5,2) (5,4,5)
(1,2,6) (1,5,2)
(1,2,6)
CS 420: Artificial Intelligence 14
Interesting Thoughts
 Multiplayer games usually involve alliances,
which can be a natural consequence of
optimal strategies
 If the game is non zero-sum, collaboration
can also occur
 For example, a terminal state with utilities <Va
= 1000, Vb = 1000>
 The optimal strategy is for both players to do
everything possible to reach this state
CS 420: Artificial Intelligence 15
α-β Pruning
 The number of game states with minimax
search is exponential in the # of moves
 Is it possible to compute the correct
minimax decision without looking at every
node in the game tree?
 Need to prune away branches that cannot
possibly influence the final decision
CS 420: Artificial Intelligence 16
α-β Pruning Example
[-∞, 3]
[-∞,+∞]
CS 420: Artificial Intelligence 17
α-β Pruning Example
[-∞,+∞]
[-∞, 3]
CS 420: Artificial Intelligence 18
α-β Pruning Example
[3, 3]
[3,+∞]
CS 420: Artificial Intelligence 19
α-β Pruning Example
[3, 3]
[3,+∞]
[-∞, 2]
CS 420: Artificial Intelligence 20
α-β Pruning Example
[3, 3]
[3, 14]
[-∞, 2] [-∞, 14]
CS 420: Artificial Intelligence 21
α-β Pruning Example
[3, 3]
[3, 5]
[-∞, 2] [-∞, 5]
CS 420: Artificial Intelligence 22
α-β Pruning Example
[3, 3]
[3, 3]
[-∞, 2] [2, 2]
CS 420: Artificial Intelligence 23
A Simple Formula
( )
max(min(3,12,8),min(2, , ),min(14,5,2))
max(3,min(2, , ),2)
max(3, ,2)
3
MINIMAX VALUE root
x y
x y
z





The value of the root and hence the minimax decision
are independent of the values of pruned leaves x and y
where z ≤ 2
α-β Pruning Exercise
CS 420: Artificial Intelligence 24
2 5 8 1 2 7 3 6 9
MAX
MAX
MIN
CS 420: Artificial Intelligence 25
Basic Idea of α-β
 Consider a node n such that
Player has a choice of
moving to
 If Player has a better choice
m either at the parent of n
or at any choice point
further up, then n will never
be reached in actual play
 α-β pruning gets it name
from the two parameters
that describe bounds on the
backed-up values
CS 420: Artificial Intelligence 26
Definitions of α and β
 α = the value of the best (highest-value) choice
we have found so far at any choice point along the
path for MAX
 β = the value of the best (lowest-value) choice we
have found so far at any choice point along the
path for MIN
 α-β search updates the values of α and β as it
goes along and prunes the remaining branches at
a node as soon as the value of the current node is
worse than the current α or β for MAX or MIN
respectively
CS 420: Artificial Intelligence 27
The α-β Algorithm
CS 420: Artificial Intelligence 28
Now, Trace The Behavior
A
3 12 8 2 4 6 14 5 2
MAX
MIN 3 2 2
3
CS 420: Artificial Intelligence 29
Analysis of α-β
 Pruning does not affect final result
 The effectiveness of alpha-beta pruning is highly dependent
on the order of successors
 It might be worthwhile to try to examine first the successors
that are likely to be best
 With "perfect ordering," time complexity = O(bm/2)
 effective branching factor becomes
 For chess, 6 instead of 35
 it can look ahead roughly twice as far as minimax in the same
amount of time
 Ordering in chess: captures, threats, forward moves, and then
backward moves
b
CS 420: Artificial Intelligence 30
Random Ordering?
 If successors are examined in random order rather
than best-first, the complexity will be roughly
O(b3m/4)
 Adding dynamic move-ordering schemes, such as
trying first the moves that were found to be best
last time, brings us close to the theoretical limit
 The best moves are often called killer moves
(killer move heuristic)
CS 420: Artificial Intelligence 31
Dealing with Repeated States
 In games, repeated states occur frequently
because of transpositions --
 different permutations of the move sequence end up in
the same position
 e.g., [a1, b1, a2, b2] vs. [a1, b2, a2, b1]
 It’s worthwhile to store the evaluation of this
position in a hash table the first time it is
encountered
 similar to the “explored set” in graph-search
 Tradeoff:
 Transposition table can be too big
 Which to keep and which to discard
CS 420: Artificial Intelligence 32
Imperfect, Real-Time Decisions
 Minimax generates the entire game search space
 Alpha-beta prunes large part of it, but still needs
to search all the way to terminal states
 However, moves must be made in reasonable
amount of time
 Standard approach: turning non-terminal nodes
into terminal leaves
 cutoff test: replaces terminal test, e.g., depth limit
 heuristic evaluation function = estimated desirability or
utility of position
CS 420: Artificial Intelligence 33
Evaluation Functions
 The performance of a game-playing
program is dependent on the quality of its
evaluation function
 Order the terminal states the same way as the
true utility function
 Evaluation of nonterminal states correlate with
the actual chance of winning
 Computation must not take too long!
CS 420: Artificial Intelligence 34
Playing Chess, Experience is
Important
 Most eval. Functions work by calculating various
features of the state
 Different features form various categories of
states
 Consider the category of two-pawns vs. one pawn
and suppose experience suggests that 72% of the
states lead to a win (+1), 20% to a loss(0), and
8% to a draw (1/2)
 Expected value = 0.72*1 + 0.20*0 + 0.08*1/2 = 0.76
 Too many categories and too much experience are
required
 Introductory chess books give an approximate material value
for each piece:
 each pawn is worth 1, a knight or bishop is worth 3, a rook 5,
and the queen 9
 Other features such as “good pawn structure” and “king safety”
worth half a pawn
 For chess, typically linear weighted sum of features
Eval(s) = w1 f1 (s) + w2 f2 (s) + … + wn fn(s)
 wi is a weight and fi is a feature of the position
 e.g., f is the # of each piece, and w is the value of each piece
 Linear assumption: contribution of each feature is independent
of the values of the other features
 There are also non-linear combinations of features
CS 420: Artificial Intelligence 35
CS 420: Artificial Intelligence 36
Cutting off Search
 Modify alpha-beta search so that:
 Terminal? is replaced by Cutoff?
 Utility is replaced by Eval
 if Cutoff-Test(state, depth) then return Eval(state)
 depth is chosen such that the amount of time used will
not exceed what the rules of the game allow
 Iterative deepening search can be applied
 When time runs out, returns the move selected by the deepest
completed search
CS 420: Artificial Intelligence 37
Result?
 Does it work in practice?
 Chess problem. Assume we can generate and evaluate a
million nodes per second, this will allow us to search
roughly 200 million nodes per move under standard time
control (3 minutes per move).
 With minimax, only 5-ply, but with alpha-beta,10-ply
 4-ply lookahead is a hopeless chess player!
 4-ply ≈ human novice
 8-ply ≈ typical PC, human master
 12-ply ≈ Deep Blue, Kasparov
CS 420: Artificial Intelligence 38
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.
 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.
 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.
CS 420: Artificial Intelligence 39
Summary
 Games are fun to work on!
 They illustrate several important points
about AI
 Perfection is unattainable  must
approximate
CS 420: Artificial Intelligence 40
Exercise 1
 Prove that: for every game tree, the utility
obtained by MAX using minimax decisions
against a suboptimal MIN will never be
lower than the utility obtained playing
against an optimal MIN.
CS 420: Artificial Intelligence 41
Exercise 2
 Consider the following game:
 Draw the complete game tree, using the following convention:
 State: (Sa, Sb) where Sa and Sb denote the token locations
 Identify the terminal state in a square box and assign it a value
 Put loop states in double square boxes
 Since it’s not clear how to assign values to loop states, annotate
each with a “?”
1 2 3 4
A B
CS 420: Artificial Intelligence 42
Answer to Ex1
 Consider a MIN node whose children are
terminal nodes. If MIN plays suboptimally,
then the value of the node is greater than
or equal to the value it would have if MIN
played optimally. Hence, the value of the
MAX node that is the MIN node’s parent
can only be increased. This argument can
be extended by a simple induction all the
way to the root.
CS 420: Artificial Intelligence 43
Game Tree for Ex2
Think about how to get
the values

More Related Content

What's hot

Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
lordmwesh
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
Yasir Khan
 
Problem Solving
Problem Solving Problem Solving
Problem Solving
Amar Jukuntla
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
vikas dhakane
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
DataminingTools Inc
 
State Space Representation and Search
State Space Representation and SearchState Space Representation and Search
State Space Representation and Search
Hitesh Mohapatra
 
Alpha beta
Alpha betaAlpha beta
Alpha beta
sabairshad4
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
SamiaAziz4
 
Alpha beta pruning in ai
Alpha beta pruning in aiAlpha beta pruning in ai
Alpha beta pruning in ai
Savyasachi14
 
AI_Session 10 Local search in continious space.pptx
AI_Session 10 Local search in continious space.pptxAI_Session 10 Local search in continious space.pptx
AI_Session 10 Local search in continious space.pptx
Asst.prof M.Gokilavani
 
AI_Unit I notes .pdf
AI_Unit I notes .pdfAI_Unit I notes .pdf
AI_Unit I notes .pdf
Asst.prof M.Gokilavani
 
Stuart russell and peter norvig artificial intelligence - a modern approach...
Stuart russell and peter norvig   artificial intelligence - a modern approach...Stuart russell and peter norvig   artificial intelligence - a modern approach...
Stuart russell and peter norvig artificial intelligence - a modern approach...
Lê Anh Đạt
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchNilu Desai
 
Informed search algorithms.pptx
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
Dr.Shweta
 
Min-Max algorithm
Min-Max algorithmMin-Max algorithm
Min-Max algorithm
Dr. C.V. Suresh Babu
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
DataminingTools Inc
 
Artificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge RepresentationArtificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge Representation
ThenmozhiK5
 
Forward and Backward chaining in AI
Forward and Backward chaining in AIForward and Backward chaining in AI
Forward and Backward chaining in AI
Megha Sharma
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
Megha Sharma
 
I. Alpha-Beta Pruning in ai
I. Alpha-Beta Pruning in aiI. Alpha-Beta Pruning in ai
I. Alpha-Beta Pruning in ai
vikas dhakane
 

What's hot (20)

Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
 
Problem Solving
Problem Solving Problem Solving
Problem Solving
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
State Space Representation and Search
State Space Representation and SearchState Space Representation and Search
State Space Representation and Search
 
Alpha beta
Alpha betaAlpha beta
Alpha beta
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
 
Alpha beta pruning in ai
Alpha beta pruning in aiAlpha beta pruning in ai
Alpha beta pruning in ai
 
AI_Session 10 Local search in continious space.pptx
AI_Session 10 Local search in continious space.pptxAI_Session 10 Local search in continious space.pptx
AI_Session 10 Local search in continious space.pptx
 
AI_Unit I notes .pdf
AI_Unit I notes .pdfAI_Unit I notes .pdf
AI_Unit I notes .pdf
 
Stuart russell and peter norvig artificial intelligence - a modern approach...
Stuart russell and peter norvig   artificial intelligence - a modern approach...Stuart russell and peter norvig   artificial intelligence - a modern approach...
Stuart russell and peter norvig artificial intelligence - a modern approach...
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Informed search algorithms.pptx
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
 
Min-Max algorithm
Min-Max algorithmMin-Max algorithm
Min-Max algorithm
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
Artificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge RepresentationArtificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge Representation
 
Forward and Backward chaining in AI
Forward and Backward chaining in AIForward and Backward chaining in AI
Forward and Backward chaining in AI
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
 
I. Alpha-Beta Pruning in ai
I. Alpha-Beta Pruning in aiI. Alpha-Beta Pruning in ai
I. Alpha-Beta Pruning in ai
 

Similar to Adversarial search

AI_unit3.pptx
AI_unit3.pptxAI_unit3.pptx
AI_unit3.pptx
G1719HarshalDafade
 
Chess engine presentation
Chess engine presentationChess engine presentation
Chess engine presentation
TanushreeSharma34
 
Game playing
Game playingGame playing
Game playing
NivethaS35
 
1.game
1.game1.game
1.game
veeramakali
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
Dheerendra k
 
Game playing
Game playingGame playing
Game playing
Tribhuvan University
 
ch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.pptch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.ppt
SanGeet25
 
12 adversal search
12 adversal search12 adversal search
12 adversal search
Tianlu Wang
 
cs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.pptcs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.ppt
Samiksha880257
 
Topic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptTopic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).ppt
SabrinaShanta2
 
Adversarial Search
Adversarial SearchAdversarial Search
Adversarial Search
Megha Sharma
 
cai
caicai
GamePlaying.ppt
GamePlaying.pptGamePlaying.ppt
GamePlaying.ppt
VihaanN2
 
Capgemini 1
Capgemini 1Capgemini 1
Capgemini 1
berasrujana
 
9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx
umairshams6
 
Game and Search
Game and SearchGame and Search
Game and Search
Adri Jovin
 
Unit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).pptUnit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).ppt
ganesh15478
 
Game playing.ppt
Game playing.pptGame playing.ppt
Game playing.ppt
DrIndrajeetKumar
 
It is an artificial document, please. regarding Ai topics
It is an artificial document, please. regarding Ai topicsIt is an artificial document, please. regarding Ai topics
It is an artificial document, please. regarding Ai topics
chougulesup79
 

Similar to Adversarial search (20)

AI_unit3.pptx
AI_unit3.pptxAI_unit3.pptx
AI_unit3.pptx
 
Chess engine presentation
Chess engine presentationChess engine presentation
Chess engine presentation
 
Game playing
Game playingGame playing
Game playing
 
1.game
1.game1.game
1.game
 
Games.4
Games.4Games.4
Games.4
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Game playing
Game playingGame playing
Game playing
 
ch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.pptch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.ppt
 
12 adversal search
12 adversal search12 adversal search
12 adversal search
 
cs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.pptcs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.ppt
 
Topic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptTopic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).ppt
 
Adversarial Search
Adversarial SearchAdversarial Search
Adversarial Search
 
cai
caicai
cai
 
GamePlaying.ppt
GamePlaying.pptGamePlaying.ppt
GamePlaying.ppt
 
Capgemini 1
Capgemini 1Capgemini 1
Capgemini 1
 
9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx
 
Game and Search
Game and SearchGame and Search
Game and Search
 
Unit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).pptUnit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).ppt
 
Game playing.ppt
Game playing.pptGame playing.ppt
Game playing.ppt
 
It is an artificial document, please. regarding Ai topics
It is an artificial document, please. regarding Ai topicsIt is an artificial document, please. regarding Ai topics
It is an artificial document, please. regarding Ai topics
 

More from pramod naik

Electrical lab
Electrical labElectrical lab
Electrical lab
pramod naik
 
Dsp manual
Dsp manualDsp manual
Dsp manual
pramod naik
 
3 pandasadvanced
3 pandasadvanced3 pandasadvanced
3 pandasadvanced
pramod naik
 
2 pandasbasic
2 pandasbasic2 pandasbasic
2 pandasbasic
pramod naik
 
1 pythonbasic
1 pythonbasic1 pythonbasic
1 pythonbasic
pramod naik
 
Chapter07
Chapter07Chapter07
Chapter07
pramod naik
 
Chapter06
Chapter06Chapter06
Chapter06
pramod naik
 
Chapter05
Chapter05Chapter05
Chapter05
pramod naik
 
Chapter04b
Chapter04bChapter04b
Chapter04b
pramod naik
 
Chapter04a
Chapter04aChapter04a
Chapter04a
pramod naik
 
Chapter01
Chapter01Chapter01
Chapter01
pramod naik
 
Ilsvrc2015 deep residual_learning_kaiminghe
Ilsvrc2015 deep residual_learning_kaimingheIlsvrc2015 deep residual_learning_kaiminghe
Ilsvrc2015 deep residual_learning_kaiminghe
pramod naik
 
Ganesan dhawanrpt
Ganesan dhawanrptGanesan dhawanrpt
Ganesan dhawanrpt
pramod naik
 

More from pramod naik (13)

Electrical lab
Electrical labElectrical lab
Electrical lab
 
Dsp manual
Dsp manualDsp manual
Dsp manual
 
3 pandasadvanced
3 pandasadvanced3 pandasadvanced
3 pandasadvanced
 
2 pandasbasic
2 pandasbasic2 pandasbasic
2 pandasbasic
 
1 pythonbasic
1 pythonbasic1 pythonbasic
1 pythonbasic
 
Chapter07
Chapter07Chapter07
Chapter07
 
Chapter06
Chapter06Chapter06
Chapter06
 
Chapter05
Chapter05Chapter05
Chapter05
 
Chapter04b
Chapter04bChapter04b
Chapter04b
 
Chapter04a
Chapter04aChapter04a
Chapter04a
 
Chapter01
Chapter01Chapter01
Chapter01
 
Ilsvrc2015 deep residual_learning_kaiminghe
Ilsvrc2015 deep residual_learning_kaimingheIlsvrc2015 deep residual_learning_kaiminghe
Ilsvrc2015 deep residual_learning_kaiminghe
 
Ganesan dhawanrpt
Ganesan dhawanrptGanesan dhawanrpt
Ganesan dhawanrpt
 

Recently uploaded

acting board rough title here lolaaaaaaa
acting board rough title here lolaaaaaaaacting board rough title here lolaaaaaaa
acting board rough title here lolaaaaaaa
angelicafronda7
 
ART FORMS OF KERALA: TRADITIONAL AND OTHERS
ART FORMS OF KERALA: TRADITIONAL AND OTHERSART FORMS OF KERALA: TRADITIONAL AND OTHERS
ART FORMS OF KERALA: TRADITIONAL AND OTHERS
Sandhya J.Nair
 
Caffeinated Pitch Bible- developed by Claire Wilson
Caffeinated Pitch Bible- developed by Claire WilsonCaffeinated Pitch Bible- developed by Claire Wilson
Caffeinated Pitch Bible- developed by Claire Wilson
ClaireWilson398082
 
Fed by curiosity and beauty - Remembering Myrsine Zorba
Fed by curiosity and beauty - Remembering Myrsine ZorbaFed by curiosity and beauty - Remembering Myrsine Zorba
Fed by curiosity and beauty - Remembering Myrsine Zorba
mariavlachoupt
 
一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理
一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理
一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理
zeyhe
 
Codes n Conventionss copy (2).pptx new new
Codes n Conventionss copy (2).pptx new newCodes n Conventionss copy (2).pptx new new
Codes n Conventionss copy (2).pptx new new
ZackSpencer3
 
Inter-Dimensional Girl Boards Segment (Act 3)
Inter-Dimensional Girl Boards Segment (Act 3)Inter-Dimensional Girl Boards Segment (Act 3)
Inter-Dimensional Girl Boards Segment (Act 3)
CristianMestre
 
一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理
一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理
一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理
taqyed
 
Memory Rental Store - The Ending(Storyboard)
Memory Rental Store - The Ending(Storyboard)Memory Rental Store - The Ending(Storyboard)
Memory Rental Store - The Ending(Storyboard)
SuryaKalyan3
 
一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理
一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理
一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理
zeyhe
 
一比一原版(GU毕业证)格里菲斯大学毕业证成绩单
一比一原版(GU毕业证)格里菲斯大学毕业证成绩单一比一原版(GU毕业证)格里菲斯大学毕业证成绩单
一比一原版(GU毕业证)格里菲斯大学毕业证成绩单
zvaywau
 
A Brief Introduction About Hadj Ounis
A Brief  Introduction  About  Hadj OunisA Brief  Introduction  About  Hadj Ounis
A Brief Introduction About Hadj Ounis
Hadj Ounis
 
2137ad - Characters that live in Merindol and are at the center of main stories
2137ad - Characters that live in Merindol and are at the center of main stories2137ad - Characters that live in Merindol and are at the center of main stories
2137ad - Characters that live in Merindol and are at the center of main stories
luforfor
 
The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎
The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎
The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎
iraqartsandculture
 
IrishWritersCtrsPersonalEssaysMay29.pptx
IrishWritersCtrsPersonalEssaysMay29.pptxIrishWritersCtrsPersonalEssaysMay29.pptx
IrishWritersCtrsPersonalEssaysMay29.pptx
Aine Greaney Ellrott
 
ashokathegreat project class 12 presentation
ashokathegreat project class 12 presentationashokathegreat project class 12 presentation
ashokathegreat project class 12 presentation
aditiyad2020
 
2137ad Merindol Colony Interiors where refugee try to build a seemengly norm...
2137ad  Merindol Colony Interiors where refugee try to build a seemengly norm...2137ad  Merindol Colony Interiors where refugee try to build a seemengly norm...
2137ad Merindol Colony Interiors where refugee try to build a seemengly norm...
luforfor
 
Memory Rental Store - The Chase (Storyboard)
Memory Rental Store - The Chase (Storyboard)Memory Rental Store - The Chase (Storyboard)
Memory Rental Store - The Chase (Storyboard)
SuryaKalyan3
 
一比一原版(DU毕业证)迪肯大学毕业证成绩单
一比一原版(DU毕业证)迪肯大学毕业证成绩单一比一原版(DU毕业证)迪肯大学毕业证成绩单
一比一原版(DU毕业证)迪肯大学毕业证成绩单
zvaywau
 

Recently uploaded (19)

acting board rough title here lolaaaaaaa
acting board rough title here lolaaaaaaaacting board rough title here lolaaaaaaa
acting board rough title here lolaaaaaaa
 
ART FORMS OF KERALA: TRADITIONAL AND OTHERS
ART FORMS OF KERALA: TRADITIONAL AND OTHERSART FORMS OF KERALA: TRADITIONAL AND OTHERS
ART FORMS OF KERALA: TRADITIONAL AND OTHERS
 
Caffeinated Pitch Bible- developed by Claire Wilson
Caffeinated Pitch Bible- developed by Claire WilsonCaffeinated Pitch Bible- developed by Claire Wilson
Caffeinated Pitch Bible- developed by Claire Wilson
 
Fed by curiosity and beauty - Remembering Myrsine Zorba
Fed by curiosity and beauty - Remembering Myrsine ZorbaFed by curiosity and beauty - Remembering Myrsine Zorba
Fed by curiosity and beauty - Remembering Myrsine Zorba
 
一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理
一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理
一比一原版(UniSA毕业证)南澳大学毕业证成绩单如何办理
 
Codes n Conventionss copy (2).pptx new new
Codes n Conventionss copy (2).pptx new newCodes n Conventionss copy (2).pptx new new
Codes n Conventionss copy (2).pptx new new
 
Inter-Dimensional Girl Boards Segment (Act 3)
Inter-Dimensional Girl Boards Segment (Act 3)Inter-Dimensional Girl Boards Segment (Act 3)
Inter-Dimensional Girl Boards Segment (Act 3)
 
一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理
一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理
一比一原版(qut毕业证)昆士兰科技大学毕业证如何办理
 
Memory Rental Store - The Ending(Storyboard)
Memory Rental Store - The Ending(Storyboard)Memory Rental Store - The Ending(Storyboard)
Memory Rental Store - The Ending(Storyboard)
 
一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理
一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理
一比一原版(QUT毕业证)昆士兰科技大学毕业证成绩单如何办理
 
一比一原版(GU毕业证)格里菲斯大学毕业证成绩单
一比一原版(GU毕业证)格里菲斯大学毕业证成绩单一比一原版(GU毕业证)格里菲斯大学毕业证成绩单
一比一原版(GU毕业证)格里菲斯大学毕业证成绩单
 
A Brief Introduction About Hadj Ounis
A Brief  Introduction  About  Hadj OunisA Brief  Introduction  About  Hadj Ounis
A Brief Introduction About Hadj Ounis
 
2137ad - Characters that live in Merindol and are at the center of main stories
2137ad - Characters that live in Merindol and are at the center of main stories2137ad - Characters that live in Merindol and are at the center of main stories
2137ad - Characters that live in Merindol and are at the center of main stories
 
The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎
The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎
The Last Polymath: Muntadher Saleh‎‎‎‎‎‎‎‎‎‎‎‎
 
IrishWritersCtrsPersonalEssaysMay29.pptx
IrishWritersCtrsPersonalEssaysMay29.pptxIrishWritersCtrsPersonalEssaysMay29.pptx
IrishWritersCtrsPersonalEssaysMay29.pptx
 
ashokathegreat project class 12 presentation
ashokathegreat project class 12 presentationashokathegreat project class 12 presentation
ashokathegreat project class 12 presentation
 
2137ad Merindol Colony Interiors where refugee try to build a seemengly norm...
2137ad  Merindol Colony Interiors where refugee try to build a seemengly norm...2137ad  Merindol Colony Interiors where refugee try to build a seemengly norm...
2137ad Merindol Colony Interiors where refugee try to build a seemengly norm...
 
Memory Rental Store - The Chase (Storyboard)
Memory Rental Store - The Chase (Storyboard)Memory Rental Store - The Chase (Storyboard)
Memory Rental Store - The Chase (Storyboard)
 
一比一原版(DU毕业证)迪肯大学毕业证成绩单
一比一原版(DU毕业证)迪肯大学毕业证成绩单一比一原版(DU毕业证)迪肯大学毕业证成绩单
一比一原版(DU毕业证)迪肯大学毕业证成绩单
 

Adversarial search

  • 1. Chapter 6: Adversarial Search In which we examine the problems that arise when we try to plan ahead in a world where other agents are planning against us.
  • 2. CS 420: Artificial Intelligence 2 Adversarial Search  Multi-agent environment:  any given agent needs to consider the actions of other agents and how they affect its own welfare  introduce possible contingencies into the agent’s problem-solving process  cooperative vs. competitive  Adversarial search problems: agents have conflicting goals -- games
  • 3. CS 420: Artificial Intelligence 3 Games vs. Search Problems  "Unpredictable" opponent  specifying a move for every possible opponent reply  Time limits  unlikely to find goal, must approximate
  • 4. CS 420: Artificial Intelligence 4 AI and Games  In AI, “games” have special format:  deterministic, turn-taking, 2- player, zero-sum games of perfect information  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)  Or, the total payoff to all players is the same for every instance of the game (constant sum) Go! 围棋
  • 5. CS 420: Artificial Intelligence 5 Game Problem Formulation  A game with 2 players (MAX and MIN, MAX moves first, turn-taking) can be defined as a search problem with:  initial state: board position  player: player to move  successor function: a list of legal (move, state) pairs  goal test: whether the game is over – terminal states  utility function: gives a numeric value for the terminal states (win, loss, draw)  Game tree = initial state + legal moves
  • 6. CS 420: Artificial Intelligence 6 Game Tree (2-player, deterministic) Utility value
  • 7. CS 420: Artificial Intelligence 7 Optimal Strategies  MAX must find a contingent strategy, specifying MAX’s move in:  the initial state  the states resulting from every possible response by MIN  E.g., 2-ply game (the tree is one move deep, consisting of two half- moves, each of which is called a ply): 3 12 8 2 4 6 14 5 2 MAX MAX MIN 3 2 2 3
  • 8. CS 420: Artificial Intelligence 8 Minimax Value  Perfect play for deterministic game, assume both players play optimally  Idea: choose move to position with highest minimax value = best achievable payoff against best play ( ) MINIMAX VALUE n   ( ) Utility n ( ) max ( ) s Successors n MINIMAX s  ( ) min ( ) s Successors n MINIMAX s  if n is a terminal state if n is a MAX node if n is a MIN node
  • 9. CS 420: Artificial Intelligence 9 A Partial Game Tree for Tic-Tac-Toe O’s turn (MIN) X’s turn (MAX) by Yosen Lin
  • 10. CS 420: Artificial Intelligence 10 Minimax Algorithm
  • 11. CS 420: Artificial Intelligence 11 Minimax with Tic-Tac-Toe  Work on board.  Walk through a real tic-tac-toe program.
  • 12. CS 420: Artificial Intelligence 12 Analysis of Minimax  Optimal play for MAX assumes that MIN also plays optimally, what if MIN does not play optimally?  A complete depth-first search?  Yes  Time complexity?  O(bm)  Space complexity?  O(bm) (depth-first exploration)  For chess, b ≈ 35, m ≈ 100 for "reasonable" games  exact solution completely infeasible
  • 13. CS 420: Artificial Intelligence 13 Optimal Decisions for Multiplayer Games  Extend minimax idea to multiplayer A B C A (1,2,6) (4,2,3) (6,1,2) (7,4,1) (5,1,1) (1,5,2) (7,7,1) (5,4,5) (1,2,6) (6,1,2) (1,5,2) (5,4,5) (1,2,6) (1,5,2) (1,2,6)
  • 14. CS 420: Artificial Intelligence 14 Interesting Thoughts  Multiplayer games usually involve alliances, which can be a natural consequence of optimal strategies  If the game is non zero-sum, collaboration can also occur  For example, a terminal state with utilities <Va = 1000, Vb = 1000>  The optimal strategy is for both players to do everything possible to reach this state
  • 15. CS 420: Artificial Intelligence 15 α-β Pruning  The number of game states with minimax search is exponential in the # of moves  Is it possible to compute the correct minimax decision without looking at every node in the game tree?  Need to prune away branches that cannot possibly influence the final decision
  • 16. CS 420: Artificial Intelligence 16 α-β Pruning Example [-∞, 3] [-∞,+∞]
  • 17. CS 420: Artificial Intelligence 17 α-β Pruning Example [-∞,+∞] [-∞, 3]
  • 18. CS 420: Artificial Intelligence 18 α-β Pruning Example [3, 3] [3,+∞]
  • 19. CS 420: Artificial Intelligence 19 α-β Pruning Example [3, 3] [3,+∞] [-∞, 2]
  • 20. CS 420: Artificial Intelligence 20 α-β Pruning Example [3, 3] [3, 14] [-∞, 2] [-∞, 14]
  • 21. CS 420: Artificial Intelligence 21 α-β Pruning Example [3, 3] [3, 5] [-∞, 2] [-∞, 5]
  • 22. CS 420: Artificial Intelligence 22 α-β Pruning Example [3, 3] [3, 3] [-∞, 2] [2, 2]
  • 23. CS 420: Artificial Intelligence 23 A Simple Formula ( ) max(min(3,12,8),min(2, , ),min(14,5,2)) max(3,min(2, , ),2) max(3, ,2) 3 MINIMAX VALUE root x y x y z      The value of the root and hence the minimax decision are independent of the values of pruned leaves x and y where z ≤ 2
  • 24. α-β Pruning Exercise CS 420: Artificial Intelligence 24 2 5 8 1 2 7 3 6 9 MAX MAX MIN
  • 25. CS 420: Artificial Intelligence 25 Basic Idea of α-β  Consider a node n such that Player has a choice of moving to  If Player has a better choice m either at the parent of n or at any choice point further up, then n will never be reached in actual play  α-β pruning gets it name from the two parameters that describe bounds on the backed-up values
  • 26. CS 420: Artificial Intelligence 26 Definitions of α and β  α = the value of the best (highest-value) choice we have found so far at any choice point along the path for MAX  β = the value of the best (lowest-value) choice we have found so far at any choice point along the path for MIN  α-β search updates the values of α and β as it goes along and prunes the remaining branches at a node as soon as the value of the current node is worse than the current α or β for MAX or MIN respectively
  • 27. CS 420: Artificial Intelligence 27 The α-β Algorithm
  • 28. CS 420: Artificial Intelligence 28 Now, Trace The Behavior A 3 12 8 2 4 6 14 5 2 MAX MIN 3 2 2 3
  • 29. CS 420: Artificial Intelligence 29 Analysis of α-β  Pruning does not affect final result  The effectiveness of alpha-beta pruning is highly dependent on the order of successors  It might be worthwhile to try to examine first the successors that are likely to be best  With "perfect ordering," time complexity = O(bm/2)  effective branching factor becomes  For chess, 6 instead of 35  it can look ahead roughly twice as far as minimax in the same amount of time  Ordering in chess: captures, threats, forward moves, and then backward moves b
  • 30. CS 420: Artificial Intelligence 30 Random Ordering?  If successors are examined in random order rather than best-first, the complexity will be roughly O(b3m/4)  Adding dynamic move-ordering schemes, such as trying first the moves that were found to be best last time, brings us close to the theoretical limit  The best moves are often called killer moves (killer move heuristic)
  • 31. CS 420: Artificial Intelligence 31 Dealing with Repeated States  In games, repeated states occur frequently because of transpositions --  different permutations of the move sequence end up in the same position  e.g., [a1, b1, a2, b2] vs. [a1, b2, a2, b1]  It’s worthwhile to store the evaluation of this position in a hash table the first time it is encountered  similar to the “explored set” in graph-search  Tradeoff:  Transposition table can be too big  Which to keep and which to discard
  • 32. CS 420: Artificial Intelligence 32 Imperfect, Real-Time Decisions  Minimax generates the entire game search space  Alpha-beta prunes large part of it, but still needs to search all the way to terminal states  However, moves must be made in reasonable amount of time  Standard approach: turning non-terminal nodes into terminal leaves  cutoff test: replaces terminal test, e.g., depth limit  heuristic evaluation function = estimated desirability or utility of position
  • 33. CS 420: Artificial Intelligence 33 Evaluation Functions  The performance of a game-playing program is dependent on the quality of its evaluation function  Order the terminal states the same way as the true utility function  Evaluation of nonterminal states correlate with the actual chance of winning  Computation must not take too long!
  • 34. CS 420: Artificial Intelligence 34 Playing Chess, Experience is Important  Most eval. Functions work by calculating various features of the state  Different features form various categories of states  Consider the category of two-pawns vs. one pawn and suppose experience suggests that 72% of the states lead to a win (+1), 20% to a loss(0), and 8% to a draw (1/2)  Expected value = 0.72*1 + 0.20*0 + 0.08*1/2 = 0.76  Too many categories and too much experience are required
  • 35.  Introductory chess books give an approximate material value for each piece:  each pawn is worth 1, a knight or bishop is worth 3, a rook 5, and the queen 9  Other features such as “good pawn structure” and “king safety” worth half a pawn  For chess, typically linear weighted sum of features Eval(s) = w1 f1 (s) + w2 f2 (s) + … + wn fn(s)  wi is a weight and fi is a feature of the position  e.g., f is the # of each piece, and w is the value of each piece  Linear assumption: contribution of each feature is independent of the values of the other features  There are also non-linear combinations of features CS 420: Artificial Intelligence 35
  • 36. CS 420: Artificial Intelligence 36 Cutting off Search  Modify alpha-beta search so that:  Terminal? is replaced by Cutoff?  Utility is replaced by Eval  if Cutoff-Test(state, depth) then return Eval(state)  depth is chosen such that the amount of time used will not exceed what the rules of the game allow  Iterative deepening search can be applied  When time runs out, returns the move selected by the deepest completed search
  • 37. CS 420: Artificial Intelligence 37 Result?  Does it work in practice?  Chess problem. Assume we can generate and evaluate a million nodes per second, this will allow us to search roughly 200 million nodes per move under standard time control (3 minutes per move).  With minimax, only 5-ply, but with alpha-beta,10-ply  4-ply lookahead is a hopeless chess player!  4-ply ≈ human novice  8-ply ≈ typical PC, human master  12-ply ≈ Deep Blue, Kasparov
  • 38. CS 420: Artificial Intelligence 38 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.  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.  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.
  • 39. CS 420: Artificial Intelligence 39 Summary  Games are fun to work on!  They illustrate several important points about AI  Perfection is unattainable  must approximate
  • 40. CS 420: Artificial Intelligence 40 Exercise 1  Prove that: for every game tree, the utility obtained by MAX using minimax decisions against a suboptimal MIN will never be lower than the utility obtained playing against an optimal MIN.
  • 41. CS 420: Artificial Intelligence 41 Exercise 2  Consider the following game:  Draw the complete game tree, using the following convention:  State: (Sa, Sb) where Sa and Sb denote the token locations  Identify the terminal state in a square box and assign it a value  Put loop states in double square boxes  Since it’s not clear how to assign values to loop states, annotate each with a “?” 1 2 3 4 A B
  • 42. CS 420: Artificial Intelligence 42 Answer to Ex1  Consider a MIN node whose children are terminal nodes. If MIN plays suboptimally, then the value of the node is greater than or equal to the value it would have if MIN played optimally. Hence, the value of the MAX node that is the MIN node’s parent can only be increased. This argument can be extended by a simple induction all the way to the root.
  • 43. CS 420: Artificial Intelligence 43 Game Tree for Ex2 Think about how to get the values