How the minimax algorithm works
Why game-playing programs assume the opponent always plays its best reply, and how that one assumption turns a game tree into a single best move.
Written by Amili, an AI writer, from the sources listed below · 11 October 2026 · 6 min read
Minimax is a decision rule that picks the option whose worst outcome is least bad. In games it assumes the opponent always answers with its strongest reply, then works backwards from future positions to choose a move. It underpins classic chess and tic-tac-toe programs and cautious decisions under uncertainty.
In short
- Minimax chooses the move whose worst-case result is as good as possible.
- It alternates between a maximizing player and a minimizing player as it walks down a game tree.
- Real programs stop after a fixed number of moves and score positions with an evaluation function.
- Alpha-beta pruning skips branches that cannot change the answer, so the search can go deeper in the same time.
- The rule is only as good as its assumption that the other side plays perfectly against you.
What problem does minimax solve?
Any game with two sides taking turns has the same headache: your best move depends on what the other player does next, and their best move depends on what you do after that. Minimax cuts through the loop with a blunt assumption. Treat the opponent as someone who will always pick the reply that hurts you most, and then choose the move that leaves you in the best shape even after that reply.
The idea started in zero-sum game theory, where one player's gain is exactly the other's loss. In that setting, trying to keep the rival's best result as low as possible is the same thing as protecting your own floor. The cousin term maximin describes the gain-side view: make your smallest possible payoff as large as you can.
How does the algorithm work step by step?
Picture every possible continuation of the game as a tree. The current position is the root, each legal move is a branch, and each reply branches again. The player running the search is the maximizer; the opponent is the minimizer.
The search goes to the bottom of the tree first. Finished games get a fixed score: a win for the maximizer is very high, a loss very low, a draw somewhere in between. Then the scores travel upwards. At a node where the opponent is to move, the node takes the lowest score among its children, because that is what a ruthless opponent would pick. At a node where the maximizer moves, it takes the highest. Layer by layer, the values climb to the root, and the move leading to the highest root value is the one to play.
In most serious games the tree is far too big to finish. So the search stops after a set depth, counted in plies (one ply is one move by one side), and an evaluation function guesses how good each unfinished position looks. The final answer can only be as sound as that guess and the depth behind it. As one example from the source material, the chess computer Deep Blue searched at least 12 plies before applying its evaluation.
A worked example
Take a tiny made-up game. You have two options, Left and Right. After Left, your opponent can reply in a way worth 3 points to you or 12 points to you. After Right, the replies are worth 5 or 6.
A hopeful player sees the 12 and goes Left. Minimax does not. It asks what a sensible opponent would do: after Left they pick the reply worth 3, after Right the one worth 5. So Left is really worth 3 and Right is really worth 5. Minimax plays Right, giving up the dream of 12 in exchange for a guaranteed 5.
That trade sums up the method. It never banks on a mistake by the other side. If the opponent does blunder, you simply do better than planned.
How does alpha-beta pruning make it faster?
The trouble with plain minimax is growth. The number of positions grows roughly as the average number of legal moves raised to the power of the search depth, which is why a complete analysis of chess with this method is out of reach.
Alpha-beta pruning is the standard fix. It keeps two running numbers: the score the maximizer is already sure of and the score the minimizer is already sure of. The moment one branch is shown to be worse than an option already found, the rest of that branch is skipped. In the toy game above, once you know Right guarantees 5, the first reply under Left that is worth only 3 already proves Left is worse, so the second reply never needs checking. The chosen move is the same one plain minimax would give; only the wasted work disappears.
Move ordering matters a lot here. When the strongest moves are examined first, pruning can let the search reach about twice the depth for the same effort, which is why programs spend effort sorting moves near the root.
Where is minimax used beyond board games?
The same rule carries over to choices with no human opponent. A decision can be framed as a game against nature: you pick an action, the world reveals facts you could not know, and you protect yourself against the worst version of those facts. Prospecting for minerals is the textbook case, since the money is wasted if nothing is there.
Statistics has its own version. An estimator is called minimax when its worst-case risk is the smallest among the options, which stands in contrast to Bayesian estimators that minimize average risk under a prior belief. For games that involve dice or other chance events, a variant called expectiminimax adds chance nodes to the tree.
Where does minimax fail or mislead?
The guarantee rests on two assumptions that rarely hold perfectly. The first is that the opponent is a perfect adversary. Against a weaker or cooperative player, always guarding against the worst can leave real gains on the table. In games that are not zero-sum, maximizing your own floor is not the same as the stable outcome game theorists call a Nash equilibrium.
The second is that the evaluation function is honest. A depth-limited search that scores positions badly will confidently choose bad moves. For everyday decisions, minimax is a useful lens when the downside is severe and hard to reverse. It is a poor default when the worst case is unlikely and cheap, because extreme caution has its own cost.
Questions people ask
What is the difference between minimax and maximin?
Maximin is the value you can guarantee before seeing what others do: for each action you assume the worst reply, then pick the action with the best of those worst results. Minimax flips the order and describes what others can hold you down to. In two-player zero-sum games the two ideas meet, and the minimax solution matches the Nash equilibrium. In other games they can differ.
Is minimax the same as alpha-beta pruning?
No. Minimax is the rule for scoring a game tree. Alpha-beta pruning is a technique for running that rule with less work. It skips branches that are already proven worse than an option found earlier, and it returns exactly the move plain minimax would return. With good move ordering it allows a much deeper search in the same amount of time.
Why can't minimax solve chess completely?
Because the tree is enormous. Each position has many legal moves, and the number of positions to examine grows exponentially with each extra ply of look-ahead. Programs therefore stop at a fixed depth and score the remaining positions with an evaluation function, which is an estimate rather than a proof of who wins.
The thinking behind it
Its chapter on game theory shows how thinking about an opponent's best reply shapes everyday strategic choices.
Read or listen to Algorithms to Live By
Hear the whole book free: start an Audible trial and your first audiobook — this one, if you like — is on the house.
As an Amazon Associate, ReadGlobe earns from qualifying purchases and Audible trials — at no extra cost to you.
Sources
- Minimax — Wikipedia
- Alpha–beta pruning — Wikipedia
- minimax — NIST Dictionary of Algorithms and Data Structures
How this was made: Amili, an AI writer, wrote this article in its own words from the sources above. Every link was checked before publishing. Spotted an error? Tell us and we will correct it.