KEMBAR78
Mini-Max Algorithm in Artificial Intelligence.pptx
1
TriaRight:
The New Era of Learning
Welcome
To PACK
365
2
Module 03
3
Mini-Max Algorithm
in Artificial Intelligence
4
Mini-Max Algorithm in Artificial
Intelligence
Mini-Max algorithm is a decision-making algorithm used in artificial
intelligence, particularly in game theory and computer games. It is designed
to minimize the possible loss in a worst-case scenario(hence "min") and
maximize the potential gain (therefore "max").
5
Minimax Algorithm – An Introduction
 Minimax Algorithm is used in Artificial Intelligence in computer
games
 It's at the heart of almost every computer board game
 Minimax chooses the path which maximizes the gain of the current
player, while minimizing the gain of the adversary
 A search tree is generated, depth-first, starting with the current game
position up to the end game position.
 Can work in real time(i.e.- not turn based) with timer (iterative
deepening, later)
6
Where is the algorithm used ?
 Applies to games where:
• Players take turns
• Have perfect information
• Chess, Checkers, Tactics
 Most widely used in logic games. These games are also called as zero
sum games i.e. a game in which gain of player’s move is exactly
balanced by loss incurred by opponent’s move
 Used in economic situations
 Used in social situations
7
Minimax Algorithm-Components
 Search tree :
• Squares represent decision states (i.e.- after a move)
• Branches are decisions (i.e.- the move)
• Start at root
• Nodes at end are leaf nodes
 Unlike binary trees can have any number of children
• Depends on the game situation
 Levels usually called plies (a ply is one level)
• Each ply is where "turn" switches to other player
 Players called Min and Max
8
Minimax Algorithm-Description(1)
 Assign points to the outcome of a game
• Ex: Tic-Tac-Toe: X wins, value of 1. O wins, value -1.
 Max (X) tries to maximize point value, while Min (O) tries to minimize point value
 Assume both players play to best of their ability
• Always make a move to minimize or maximize points
 So, in choosing, Max will choose best move to get highest points, assuming Min
will choose best move to get lowest points
9
Maximizing Player (Max):
• Aims to maximize their score or utility value.
• Chooses the move that leads to the highest possible utility value,
assuming the opponent will play optimally.
Minimizing Player (Min):
• Aims to minimize the maximizer's score or utility value.
• Selects the move that results in the lowest possible utility value for
the maximizer, assuming the opponent will play optimally.
10
How is Minimax tree generated ?
Step 1:Creation of a MAX node
Step 2:Generation of children nodes (MIN) using DFS
A1
Step 3:Node A1 is generated.
Step 4:Children of a A1 are generated
Step 5:Node evaluation takes place using
evaluation function.
Values are filled in nodes
Step 6:Now A1 chooses the minimum of the (two)
child node values
Step 7:Repeat steps 3 to 6 till all children of main
nodes (A1,A2,A3) are generated and
filled
Step 8:The Main mode chooses the max value
of the child node values and this tells us
the best possible move that we should take
A2 A3
7 3 15 1 12 20
3 15 1
15
MIN
MAX
11
Properties Of Minimax Algorithm
• Complete?
• Yes (if tree is finite)
• Optimal?
• Yes (against an optimal opponent).
• Can it be beaten by an opponent playing sub-optimally?
• No
• Time complexity?
• O(bm
) ,where m is depth and b is branching factor
• Space complexity?
• O(bm) (depth-first search, generate all actions at once)
• O(m) (backtracking search, generate actions one at a time)
12
13
Steps involved in the Mini-Max Algorithm
• The Min-Max algorithm involves several key steps, executed recursively
until the optimal move is determined. Here is a step-by-step breakdown:
 Step 1: Generate the Game Tree
• Objective: Create a tree structure representing all possible moves from
the current game state.
• Details: Each node represents a game state, and each edge represents a
possible move.
 Step 2: Evaluate Terminal States
• Objective: Assign utility values to the terminal nodes of the game tree.
• Details: These values represent the outcome of the game (win, lose, or
draw).
14
 Step 3: Propagate Utility Values Upwards
• Objective: Starting from the terminal nodes, propagate the utility
values upwards through the tree.
• Details: For each non-terminal node:
• If it's the maximizing player's turn, select the maximum value from the child
nodes.
• If it's the minimizing player's turn, select the minimum value from the child
nodes.
 Step 4: Select Optimal Move
• Objective: At the root of the game tree, the maximizing player selects
the move that leads to the highest utility value.
15
9 18 10
7
12 30
max
min
Normal Minimax
( CPU with max move)
9 7 12
12
Perfect move calculated every time
Human error not taken into
account
No randomness
*Numbers illustrate evaluation score of the game
board i.e. game state
16
9 18 10
7
12 30
10 7 12
10
Random Minimax
( CPU with random move)
Case 1: Θ->infinity
optimal minimax
strategy
(previous example)
Case 2: Θ->0
random strategy
(current example)
CPU move
Wrong
move !!
Correct
move !!
Note that CPU does not play optimal
move because of Rminimax
*Numbers illustrate evaluation score of the game
board i.e. game state
17
THANK
YOU

Mini-Max Algorithm in Artificial Intelligence.pptx

  • 1.
    1 TriaRight: The New Eraof Learning Welcome To PACK 365
  • 2.
  • 3.
  • 4.
    4 Mini-Max Algorithm inArtificial Intelligence Mini-Max algorithm is a decision-making algorithm used in artificial intelligence, particularly in game theory and computer games. It is designed to minimize the possible loss in a worst-case scenario(hence "min") and maximize the potential gain (therefore "max").
  • 5.
    5 Minimax Algorithm –An Introduction  Minimax Algorithm is used in Artificial Intelligence in computer games  It's at the heart of almost every computer board game  Minimax chooses the path which maximizes the gain of the current player, while minimizing the gain of the adversary  A search tree is generated, depth-first, starting with the current game position up to the end game position.  Can work in real time(i.e.- not turn based) with timer (iterative deepening, later)
  • 6.
    6 Where is thealgorithm used ?  Applies to games where: • Players take turns • Have perfect information • Chess, Checkers, Tactics  Most widely used in logic games. These games are also called as zero sum games i.e. a game in which gain of player’s move is exactly balanced by loss incurred by opponent’s move  Used in economic situations  Used in social situations
  • 7.
    7 Minimax Algorithm-Components  Searchtree : • Squares represent decision states (i.e.- after a move) • Branches are decisions (i.e.- the move) • Start at root • Nodes at end are leaf nodes  Unlike binary trees can have any number of children • Depends on the game situation  Levels usually called plies (a ply is one level) • Each ply is where "turn" switches to other player  Players called Min and Max
  • 8.
    8 Minimax Algorithm-Description(1)  Assignpoints to the outcome of a game • Ex: Tic-Tac-Toe: X wins, value of 1. O wins, value -1.  Max (X) tries to maximize point value, while Min (O) tries to minimize point value  Assume both players play to best of their ability • Always make a move to minimize or maximize points  So, in choosing, Max will choose best move to get highest points, assuming Min will choose best move to get lowest points
  • 9.
    9 Maximizing Player (Max): •Aims to maximize their score or utility value. • Chooses the move that leads to the highest possible utility value, assuming the opponent will play optimally. Minimizing Player (Min): • Aims to minimize the maximizer's score or utility value. • Selects the move that results in the lowest possible utility value for the maximizer, assuming the opponent will play optimally.
  • 10.
    10 How is Minimaxtree generated ? Step 1:Creation of a MAX node Step 2:Generation of children nodes (MIN) using DFS A1 Step 3:Node A1 is generated. Step 4:Children of a A1 are generated Step 5:Node evaluation takes place using evaluation function. Values are filled in nodes Step 6:Now A1 chooses the minimum of the (two) child node values Step 7:Repeat steps 3 to 6 till all children of main nodes (A1,A2,A3) are generated and filled Step 8:The Main mode chooses the max value of the child node values and this tells us the best possible move that we should take A2 A3 7 3 15 1 12 20 3 15 1 15 MIN MAX
  • 11.
    11 Properties Of MinimaxAlgorithm • Complete? • Yes (if tree is finite) • Optimal? • Yes (against an optimal opponent). • Can it be beaten by an opponent playing sub-optimally? • No • Time complexity? • O(bm ) ,where m is depth and b is branching factor • Space complexity? • O(bm) (depth-first search, generate all actions at once) • O(m) (backtracking search, generate actions one at a time)
  • 12.
  • 13.
    13 Steps involved inthe Mini-Max Algorithm • The Min-Max algorithm involves several key steps, executed recursively until the optimal move is determined. Here is a step-by-step breakdown:  Step 1: Generate the Game Tree • Objective: Create a tree structure representing all possible moves from the current game state. • Details: Each node represents a game state, and each edge represents a possible move.  Step 2: Evaluate Terminal States • Objective: Assign utility values to the terminal nodes of the game tree. • Details: These values represent the outcome of the game (win, lose, or draw).
  • 14.
    14  Step 3:Propagate Utility Values Upwards • Objective: Starting from the terminal nodes, propagate the utility values upwards through the tree. • Details: For each non-terminal node: • If it's the maximizing player's turn, select the maximum value from the child nodes. • If it's the minimizing player's turn, select the minimum value from the child nodes.  Step 4: Select Optimal Move • Objective: At the root of the game tree, the maximizing player selects the move that leads to the highest utility value.
  • 15.
    15 9 18 10 7 1230 max min Normal Minimax ( CPU with max move) 9 7 12 12 Perfect move calculated every time Human error not taken into account No randomness *Numbers illustrate evaluation score of the game board i.e. game state
  • 16.
    16 9 18 10 7 1230 10 7 12 10 Random Minimax ( CPU with random move) Case 1: Θ->infinity optimal minimax strategy (previous example) Case 2: Θ->0 random strategy (current example) CPU move Wrong move !! Correct move !! Note that CPU does not play optimal move because of Rminimax *Numbers illustrate evaluation score of the game board i.e. game state
  • 17.