VOOZH about

URL: https://www.geeksforgeeks.org/dsa/minimax-algorithm-in-game-theory-set-1-introduction/

⇱ Minimax Algorithm in Game Theory | Set 1 (Introduction) - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Minimax Algorithm in Game Theory | Set 1 (Introduction)

Last Updated : 27 May, 2026

Minimax is a backtracking-based algorithm used in game theory and AI to determine the optimal move in competitive games by evaluating all possible future outcomes, assuming both players act optimally.

  • Works in two-player, turn-based, zero-sum games
  • Builds a decision process based on game states and outcomes
  • Widely used in strategic games like Tic-Tac-Toe and Chess

Key Concepts

  • Maximizer: Player who tries to maximize the final score or outcome
  • Minimizer: Player who tries to minimize the final score or opponent’s advantage
  • Game State: Representation of the current configuration of the game
  • Utility Value: Numerical score assigned to terminal states to represent win, loss, or draw outcomes
  • Game Tree: Tree structure representing all possible moves and resulting states
  • Heuristic Evaluation: Function used to estimate the value of non-terminal states when full exploration is not possible

Working

  • Constructs a game tree where nodes represent game states and edges represent possible moves
  • Expands all possible future moves up to terminal states or a depth limit
  • Assigns utility values to leaf nodes using game outcomes or heuristic evaluation
  • Propagates values upward: maximizer selects maximum value, minimizer selects minimum value
  • Final decision is made at the root node based on optimal play assumption by both players
👁 2056958109
Working of Minimax Algorithm

Implementation

Implementing the Minimax algorithm using a simple game tree where leaf nodes represent final scores, and the algorithm finds the optimal value assuming both players play optimally.

Step 1: Importing Required Module

Using the math module to compute the depth of the game tree.

Step 2: Defining Minimax Function

This function recursively evaluates the game tree and returns the optimal value based on maximizing and minimizing turns.

Step 3: Defining game states

We define leaf node values representing final game outcomes.

Step 4: Computing the tree depth

Calculating the depth of the binary game tree using logarithm.

Step 5: Run the Minimax algorithm

We start evaluation from the root node assuming the maximizer plays first.

Output:

The optimal value is: 12

Advantages

  • Guarantees optimal move selection under perfect play assumption
  • Works well for deterministic, turn-based, zero-sum games
  • Serves as the base for advanced techniques like Alpha-Beta Pruning
  • Suitable for problems with limited search space

Limitations

  • Exponential time complexity makes it inefficient for large game trees
  • Explores all possible moves regardless of usefulness
  • Not scalable for complex games without optimization
  • Requires high computational resources for deeper searches
Comment
Article Tags:
Article Tags: