Two players take turns. MAX wants the biggest score, MIN wants the smallest. Minimax searches the tree depth-first and passes the best value up to the root. Turn on pruning to see which branches can be skipped.
The best line of play appears when the search finishes.
Highlighted lines are running in the current step. Lines 6 and 7 only run with pruning on.
Minimax is a decision rule for two-player, turn-based games. It assumes both players play perfectly: MAX picks the move with the highest score and MIN picks the move with the lowest. The search goes down to the leaves (end positions with a score) and passes values back up, so the root ends up with the best score MAX can guarantee.
Same tree as the default example in the Visualizer, with alpha-beta pruning on. The root A is a MAX node and levels alternate MAX / MIN. Leaf scores are from MAX's point of view.
Default tree. Dashed branches (//) are the ones pruned.
C takes 5.B (MIN) now has a value of at most 5 (beta = 5). Go to F (MAX): leaf G = 6, so F is at least 6.B = min(5, 6) = 5.A (MAX): A is at least 5 (alpha = 5). Go to I (MIN), then J (MAX): leaves K = 1, L = 2, so J = 2.I (MIN) is now at most 2, which is below alpha 5. MAX at A will never pick I, so prune M (N, O).A = max(5, I) = 5, since I is at most 2.Tic-tac-toe, checkers, and chess engines.
Computer opponents that pick a move by looking ahead.
Planning against a worst-case adversary.