A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Minimax Algorithm

Graduate Depth 82 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
398prerequisites beneath it
See this on the map →
Algorithm Design BasicsRecursion Basics+1 more→→Alpha-Beta Pruning
adversarial-search games game-theory

Core Idea

Minimax is a recursive algorithm for two-player zero-sum games where one player maximizes utility and the other minimizes it. Values propagate from leaves: max nodes return the maximum child value, min nodes return the minimum. The algorithm assumes both players play optimally.

Explainer

Consider a game like tic-tac-toe or chess where two players alternate turns, one trying to win and the other trying to prevent it. The minimax algorithm treats this as a tree search problem — a natural extension of the recursive thinking and algorithm design you already know. From any game state, you recursively enumerate all possible moves, then all responses to those moves, and so on until you reach terminal states (wins, losses, or draws) that can be scored.

The key insight is that the two players have opposing objectives. One player (call them Max) wants the highest possible score; the other (Min) wants the lowest. At each level of the game tree, the acting player picks the move that is best *for them*. A Max node returns the maximum value among its children, because Max will choose the most favorable outcome. A Min node returns the minimum, because Min will choose the outcome most damaging to Max. Values propagate upward from the leaves — the terminal scores — through alternating max and min layers until you reach the root, which tells Max the best score achievable against a perfectly rational opponent.

This is where the "zero-sum" assumption matters: whatever Max gains, Min loses. There is no cooperation, no mutual benefit — the game is purely adversarial. The algorithm assumes optimal play from both sides, which means it finds the strategy that guarantees the best worst-case outcome. In tic-tac-toe, minimax proves that perfect play by both sides always ends in a draw. In more complex games, it establishes the theoretical value of positions even if the full tree is too large to search exhaustively.

The practical challenge is that game trees grow exponentially. Chess has roughly 1040 legal positions, making full minimax search impossible. This is why minimax is typically combined with depth-limited search and an evaluation function that estimates the value of non-terminal positions, along with pruning strategies like alpha-beta pruning that skip branches guaranteed to be irrelevant. But the foundational logic remains the same: alternate between maximizing and minimizing at each level, assume your opponent plays as well as possible, and choose the move that leads to the best guaranteed outcome. Understanding minimax gives you the conceptual backbone for all adversarial search algorithms in AI.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Conditional Statements → Defining and Calling Functions → Functions: Decomposing Problems → Function Parameters and Argument Passing → Return Values → Variable Scope → Introduction to Classes → Objects and Instances → Methods and Attributes → Algorithm Design Basics → Minimax Algorithm

Longest path: 83 steps · 398 total prerequisite topics

Prerequisites (3)

Leads To (1)