◄ WORLD V · SONNY 5DART 208 · a helldive at the net

THE NEGAMAX one player's max is the other's min, negated

In a zero-sum game my gain is your loss, so the two players are duals: max(a,b) = −min(−a,−b). That single identity collapses the whole minimax tree — which alternates MAX and MIN levels — into one rule applied everywhere: take the max of the negated child values. Every node becomes a MAX node; the alternation is absorbed into a sign flip. That is negamax, and it is why one short function plays both sides.

THE TECHNIQUE max(a,b) = −min(−a,−b) ; every node a negated MAX

Score a tiny 2-ply game two ways — the textbook MAX-of-MIN, and negamax (MAX of negated children only) — and confirm they return the identical value. The MIN level is computed as −max(−·): live demo


HISTORY & CREDIT von Neumann 1928 · Knuth–Moore 1975

“A game program needs separate MAX logic for me and MIN logic for my opponent.” — no; they are the same logic under a sign. Negate the score at each ply and both players run the identical max. Half the code, and alpha–beta pruning falls out symmetric. cited

1928 · John von Neumann — the minimax theorem: in a zero-sum game the max–min value equals the min–max value, the duality at the root of game theory.
1950s · Shannon & Turing — minimax becomes a chess program, MAX and MIN alternating down the tree.
1975 · Knuth & Moore — “An analysis of alpha-beta pruning” formalises the negamax simplification: one rule, negated per ply.

Zero-sum means the payoff to one side is the negative of the payoff to the other — a duality baked into the game. Negamax just refuses to write the same rule twice. Knuth–Moore 1975

RECOMMEND FOR I-13 minimax tree = negamax tree, computed

On the canonical compiler, a 2-ply tree with leaves [3,5,2,9] scores 3 as MAX-of-MIN, and the identical 3 in negamax form (each MIN node computed as −max(−·)):

$ i13 run negamax.i13 # leaves [3,5], [2,9]; root = MAX of two MIN identity max(3,7) = 7 , -min(-3,-7) = 7 -- the duality minimax MIN nodes [3,2] -> MAX root = 3 negamax -max(-3,-5)=3, -max(-2,-9)=2 -> MAX = 3 -- same, one rule
Recommend: negamax is LIT for I-13 — verified the identity max(3,7)=−min(−3,−7)=7 and that a 2-ply tree scores 3 both as textbook MAX-of-MIN and as pure negamax (MAX of negated children). The opponent is not a second algorithm — just a minus sign. One max plays both hands.