Sec 9
Sec 9
Intelligence
SEARCH ALGORITHMS
Games – Minimax Algorithm
Game Playing Algorithms
Game playing algorithms: Help find the best move to win.
Characteristics of games:
Two players.
Zero-sum: One wins, the other loses.
Alternate turns.
Deterministic: Clear win/loss conditions.
Complete information: Full knowledge of game environment, rules, and opponent's moves.
Minimax Algorithm
Minimax: A recursive algorithm used in decision-making and game theory for two-player
turn-based games like Tic-Tac-Toe and Chess.
Players: Maximizer (us) and Minimizer (the opponent).
Our goal: Maximize our score with each move.
Opponent's goal: Minimize our score by choosing moves that put us in the worst possible
position.
4/24/2025 3
Minimax Algorithm
4/24/2025 4
Minimax Algorithm
Step 1:
• Starting from the bottom, the maximizer selects the maximum value
from available options.
• For node D max(-1,4)= 4
• For Node E max(2, 6)= 6
• For Node F max(-3,-5) = -3
• For node G max(0, 7) = 7
4/24/2025 5
Minimax Algorithm
Step 2:
Now, it is a turn for minimizer, the minimizer selects
the minimum value from available options.
For node B min(4,6) = 4
For node C min (-3, 7) = -3
4/24/2025 6
Minimax Algorithm
Step 3:
Now it's a turn for maximizer, and it will again
choose the maximum of all nodes value and find the maximum
value for the root node.
For node A max(4, -3)= 4
Therefore, the best choice for the first move for
maximizer is to the left, and the optimal value he get is 4.
4/24/2025 7
4/24/2025 8
Minimax Algorithm
4/24/2025 9
Example: Tic Tac Toe AI game
Draw
won
Lose
4/24/2025 10
Example: Tic Tac Toe AI game
4/24/2025 11
Example:
• What will the first move for Max to get the optimal value?
• What is the optimal value he gets
4/24/2025 12
Example:
4/24/2025 13
THANK YOU
4/24/2025 14