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.
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
“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
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
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(−·)):