0% found this document useful (0 votes)
2 views30 pages

Module 3 L3 Adversarial Search Game Theory

The document provides an overview of search algorithms, focusing on adversarial search in competitive environments like games. It explains the Minimax algorithm for decision-making in games, detailing its properties, limitations, and the use of Alpha-Beta pruning to optimize performance. The document also includes examples and definitions related to game states and player actions in the context of Tic-Tac-Toe.
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)
2 views30 pages

Module 3 L3 Adversarial Search Game Theory

The document provides an overview of search algorithms, focusing on adversarial search in competitive environments like games. It explains the Minimax algorithm for decision-making in games, detailing its properties, limitations, and the use of Alpha-Beta pruning to optimize performance. The document also includes examples and definitions related to game states and player actions in the context of Tic-Tac-Toe.
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/ 30

Quick Recap

Breadth First
Search
Quick Recap
Uninformed
Depth First
Search / Blind
Search
Search

Uniform Cost
Search

Search
Algorithms A* Search f (n) = g (n)
Informed Search + h (n)
/ Heuristic
Search Best First Search f (n) = h (n)
Algorithm
Adversarial
Search
Adversarial Search
Adversarial Search?
Adversarial?
Involving Two People Or Two Sides Who Oppose Each Other
Adversarial Search
• Search in competitive environments
• Where agent’s goals are in conflict
• Games are good examples of adversarial search

Which one’s are adversarial search?


Adversarial Search (Games) vs Search
Problems
• Unpredictable Opponent -> specifying a move for every possible
opponent reply
• Time limits -> unlikely to find goal, most approximate
Let’s Play TIC TAC TOE
https://g.co/kgs/E7ZXbxn

https://playtictactoe.org/
Understand MIN and MAX
How to formally define a game?
• 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 the 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) - Defines the final numerical value for a game that ends in a terminal state s
for player p
• For example tic-tac-toe, the outcome win, loss or draw with values -1, 0, 1
Game Tree
• The initial state, actions function, and result function define game
tree for a game
• Game tree – a tree where nodes are game states and edges are moves
MiniMax Search Algorithm
MAX
10
• Consider the following two player
game tree in which the static
scores are given from the first 10 5 MIN
players point of view

MAX
10 18 5 50

MIN
10 9 14 18 5 4 50 3
MiniMax Search Algorithm
• Consider the following two player
game tree in which the static
scores are given from the first
players point of view
Implement Minimax algorithm
Implement Minimax algorithm
MAX – X turn [AI]
MIN – O turn [Human]

X O X X O X X O X
O O X O O X O O X
X X X O X O

+1 0 -1
Minimax algorithm for Tic-Tac-Toe
X O X
O O X MAX – X turn
MAX – X turn [AI] +1
MIN – O turn [Human]

X O X X O X X O X
O O X O O O MIN – O turn
X O X
X X X
-1 0
+1

X O X X O X X O X X O X
O O X O O X O O X O O X MAX – X turn
0 +1 0
X O X O O X X O
-1 Backtracking now!
X O X X O X X O X
O O X O O X O O X
0 O +1 X O 0
X X O X X X
Minimax algorithm for Tic-Tac-Toe
Perform the Search X
using Minimax O
X
algorithm
O X O
Minimax algorithm for Tic-Tac-Toe
Minimax algorithm for Tic-Tac-Toe
• Properties of Mini-Max algorithm:
• Complete- Min-Max algorithm is Complete. It will
definitely find a solution (if exist), in the finite search tree.
• Optimal- Min-Max algorithm is optimal if both opponents
are playing optimally.
• Time complexity- As it performs DFS for the game-tree, so
the time complexity of Min-Max algorithm is O(bm),
where b is branching factor of the game-tree, and m is the
maximum depth of the tree.
• Space Complexity- Space complexity of Mini-max
algorithm is also similar to DFS which is O(bm).
• 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 will
be discussing in the next topic.
Alpha Beta pruning Algorithm
The problem with minimax MAX α
search is that the number of
game states it has to examine is
exponential in the number of MIN β

moves
MAX α

MIN β

10 9 14 18 5 4 50 3
Alpha Beta pruning Algorithm
• Alpha Beta proposes to find the optimal
path without looking at every node in MAX α
the game tree
• Max contains alpha and min contains
beta bound during the calculation
• In both min and max mode, we return MIN β
when α >= β.
• Both minimax and alpha-beta give same
path
MAX α
• Alpha Beta gives optimal solution as it
takes less time to get the value for the
root node
MIN β

10 9 14 18 5 4 50 3
α >= β Alpha Beta pruning Algorithm
MAX α
10

10 5 MIN β

MAX α
10 14 5

MIN β

10 9 14 18 5 4 50 3
MiniMax Search Algorithm
MAX
10
• Consider the following two player
game tree in which the static
scores are given from the first 10 5 MIN
players point of view

MAX
10 18 5 50

MIN
10 9 14 18 5 4 50 3
α >= β Alpha Beta pruning Algorithm
Minimax algorithm for Tic-Tac-Toe
α >= β Alpha Beta pruning Algorithm
α >= β Alpha Beta pruning Algorithm
α >= β Alpha Beta pruning Algorithm
α >= β Alpha Beta pruning Algorithm
Alpha Beta algorithm for Tic-Tac-Toe
O X O X X O O
X X X
X O O X O O X O

Problem #1 Problem #2 Problem #3

X O X
X O
O

Problem #4

You might also like