2.6-Adversarial Search Algorithms
2.6-Adversarial Search Algorithms
Artificial Intelligence
(BITE308L)
Adversarial
Search Algorithms
Dr. S. Hemalatha
School of Computer science Engineering & Information Systems
VIT, Vellore
ADVERSARIAL
SEARCH ALGORITHMS
• Multi-agent environments:
• The unpredictability of these other agents can introduce contingencies into the
agent’s problem-solving process
• Competitive environments:
• the agents’ goals are in conflict
• Giving rise to ADVERSARIAL search problems
• often known as GAMES
1
08-02-2024
ADVERSARIAL
SEARCH ALGORITHMS
• ZERO-SUM GAMES
• AI: Most common games are of a specialized kind;
• deterministic, turn-taking, two-player,
• zero-sum games of perfect information (such as chess)
• Means: deterministic & fully observable environments:
• two agents act alternately
• the utility values at the end of the game are always equal & opposite
• Eg: if one player wins a game of chess, the other player necessarily loses
• This opposition between the agents’ utility functions that makes the situation
adversarial.
Prepared by S.Hemalatha/SCORE
ADVERSARIAL
SEARCH ALGORITHMS
• AI research:
• Abstract nature of games makes them an appealing subject for study
• state of a game is easy to represent
• agents are usually restricted to a small number of actions whose outcomes are
defined by precise rules
• Physical games, such as croquet and ice hockey, have much more complicated
descriptions, a much larger range of possible actions, and rather imprecise
rules defining the legality of actions
• Thus, physical games have NOT attracted much interest in the AI community
• Exception: robot soccer
Prepared by S.Hemalatha/SCORE
2
08-02-2024
GAMES
AI REPRESENTATION
Prepared by S.Hemalatha/SCORE
GAMES
AI REPRESENTATION
Prepared by S.Hemalatha/SCORE
3
08-02-2024
GAMING
REQUIREMENTS
• Final Lookup:
• how state-of-the-art game-playing programs fare against human opposition
• & at directions for future developments.
Prepared by S.Hemalatha/SCORE
MAX
MIN
Prepared by S.Hemalatha/SCORE
4
08-02-2024
Prepared by S.Hemalatha/SCORE
GAME TREE
TIC-TAC-TOE
Prepared by S.Hemalatha/SCORE
5
08-02-2024
6
08-02-2024
Prepared by S.Hemalatha/SCORE
Prepared by S.Hemalatha/SCORE
7
08-02-2024
Prepared by S.Hemalatha/SCORE
8
08-02-2024
MINIMAX ALGORITHM
EXAMPLE
Step-1:
• entire game-tree generaated
• utility function applied the to get
utility values for terminal states
Prepared by S.Hemalatha/SCORE
MINIMAX ALGORITHM
EXAMPLE
Step 2:
• Find the utility value for the Maximizer
• 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
Prepared by S.Hemalatha/SCORE
9
08-02-2024
MINIMAX ALGORITHM
EXAMPLE
Step 3
• It's a turn for minimizer,
• For node B= min(4,6) = 4
• For node C= min (-3, 7) = -3
Prepared by S.Hemalatha/SCORE
MINIMAX ALGORITHM
EXAMPLE
• Step 4:
• Now it's a turn for Maximizer,
• For node A max(4, -3)= 4
Prepared by S.Hemalatha/SCORE
10
08-02-2024
MINIMAX ALGORITHM
PROPERTIES
• 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:
• Time complexity: 𝑂 𝑏 (it performs DFS for the game-tree)
• 𝑏: branching factor of the game-tree
• 𝑚: maximum depth of the tree
• Space Complexity:
• Space complexity: 𝑂 𝑏𝑚 (DFS)
Prepared by S.Hemalatha/SCORE
MINIMAX ALGORITHM
LIMITATIONS
• The algorithm gets really slow for complex games such as Chess, go, etc
• This type of games has a huge branching factor,
• the player has lots of choices to decide
• This limitation of the minimax algorithm can be improved from alpha-beta
pruning
Prepared by S.Hemalatha/SCORE
11
08-02-2024
MINIMAX ALGORITHM
EXAMPLE SCENARIO
X O O
O
X X
X O O X O O X O O
X O O O X
X X X X X X X
X O O X O O X O O X O O
X O X O O O O X O X
O X X X X X X X O X X
Prepared by S.Hemalatha/SCORE
12
08-02-2024
Prepared by S.Hemalatha/SCORE
The two-parameters:
• Alpha:
• The best (highest-value) choice we have found so far at any point along the path
of Maximizer
• Initial value of alpha is −∞
• Beta:
• The best (lowest-value) choice we have found so far at any point along the path
of Minimizer
• Initial value of beta is +∞
Prepared by S.Hemalatha/SCORE
13
08-02-2024
Prepared by S.Hemalatha/SCORE
Prepared by S.Hemalatha/SCORE
14
08-02-2024
Prepared by S.Hemalatha/SCORE
Prepared by S.Hemalatha/SCORE
15
08-02-2024
Prepared by S.Hemalatha/SCORE
Step 1:
• Max player will start first move
from node A
• 𝛼 = −∞ and 𝛽 = +∞
• alpha & beta values passed down
to node B
• Again, 𝛼 = −∞ and 𝛽 = +∞
• Node B passes the same value to
its child D
Prepared by S.Hemalatha/SCORE
16
08-02-2024
Prepared by S.Hemalatha/SCORE
Prepared by S.Hemalatha/SCORE
17
08-02-2024
Prepared by S.Hemalatha/SCORE
18
08-02-2024
Step 6:
• At node F:
• Right: 𝛼 = max 3,0 = 3
• Leftt: 𝛼 = max 3,1 = 3
• still α remains 3
• but the node value of F will
become 1
Prepared by S.Hemalatha/SCORE
Prepared by S.Hemalatha/SCORE
19
08-02-2024
Prepared by S.Hemalatha/SCORE
20
08-02-2024
Prepared by S.Hemalatha/SCORE
SUMMARY
In this session,
• Adversarial Search basics
• Mini-max algorithm
• Alpha-beta pruning
Next session,
• Knowledge representation
Prepared by S.Hemalatha/SCORE
21