Search

Search papers and lessons

Minimax Game

Level 3 · 13 min read

A minimax game is a two-player contest where one side's gain is the other's loss, and the best play for both sides meets at one shared number, the game value.

On this page

  • Colour = topic mix
  • Probability
  • Generative models
  • Discrete math
  • Optimization
  • Sign in to see your progress

TL;DR

A minimax game is a contest between two players whose gains are exactly opposite: whatever one player wins, the other loses. Each player picks a strategy to protect themselves against the other's best reply. The row player maximises the worst outcome they can be handed, and the column player minimises the best outcome the row player can reach. With randomised strategies, these two guarantees meet at one number, the value of the game.

Where you'll see it: in the training objective of generative adversarial networks, in robust optimisation where you plan for the worst case, and in the game-theory analysis of bluffing and betting.

Intuition

Start with a game you can play with your hands. Two players each show one of two options, and a referee pays one player what the other owes. Rock-paper-scissors is a familiar example. Every outcome nets to zero, so there is no shared prize to split, only a contest where one side's gain is the other's loss. Such a game is called zero-sum.

The question is how to play it well. Always making the same move is a bad idea, because an opponent who notices the habit will exploit it. Being unpredictable is worth something, and the minimax idea gives a clean way to reason about it. Assume your opponent will answer you as well as they possibly can. Then pick the plan whose worst case is as good as possible. That is the cautious plan, and in a zero-sum game it is the right kind of caution, because no hidden cooperation can rescue you from a bad answer.

Here is the surprising part. If both players are allowed to randomise, the cautious plan of the first player and the cautious plan of the second player always give the same number. Neither side can do better than that number against a sensible opponent, and neither side is forced to give it up. Von Neumann proved this, and the result is called the minimax theorem.

flowchart LR
  A["Row player picks a mixed strategy"] --> C["Payoff matrix"]
  B["Column player picks a mixed strategy"] --> C
  C --> D["Row player maximises the worst case"]
  C --> E["Column player minimises the best case for the row player"]
  D --> F["Both values agree (the game value)"]
  E --> F

The same shape appears in machine learning. A generative adversarial network has a generator that tries to produce realistic samples and a discriminator that tries to tell them apart from real data. One side's gain is the other side's loss, so training is a minimax game, not an ordinary minimisation problem.

The math

Zero-sum games and the payoff matrix

Definition: Two-player zero-sum game

A game with a row player R and a column player C. R chooses a row ii from mm options, and C chooses a column jj from nn options at the same time. The payoff AijA_{ij} goes to R, and C pays the same amount, so the total is always zero. The m×nm \times n matrix AA of all payoffs is the payoff matrix.

A strategy is a rule for choosing. A pure strategy picks one row or column every time. A mixed strategy is a probability distribution over the options. R's mixed strategy is a vector p\mathbf{p} of probabilities that sum to 1, with pip_i the chance of row ii. C's mixed strategy is a vector q\mathbf{q} with qjq_j the chance of column jj. If the two choices are made independently, then the expected payoff, in the sense of Expected Value, is

E[AIJ]=∑i=1m∑j=1npi qj Aij=p⊤A q.\mathbb{E}[A_{IJ}] = \sum_{i=1}^{m} \sum_{j=1}^{n} p_i\, q_j\, A_{ij} = \mathbf{p}^\top A\, \mathbf{q}.

Here II and JJ are the random choices of the two players, and p⊤\mathbf{p}^\top is p\mathbf{p} written as a row vector.

The two guarantees

R wants a strategy whose worst case is as high as possible. For a mixed p\mathbf{p}, the worst case is the smallest expected payoff over all of C's replies:

vR=max⁡pmin⁡qp⊤A q.v_R = \max_{\mathbf{p}} \min_{\mathbf{q}} \mathbf{p}^\top A\, \mathbf{q}.

C wants the mirror image: a strategy whose worst case, measured from R's side, is as low as possible.

vC=min⁡qmax⁡pp⊤A q.v_C = \min_{\mathbf{q}} \max_{\mathbf{p}} \mathbf{p}^\top A\, \mathbf{q}.

The first is called the maximin value and the second the minimax value. There is always an easy inequality between them. For any p\mathbf{p} and q\mathbf{q}, the minimum over q\mathbf{q} is no larger than the particular value p⊤Aq\mathbf{p}^\top A\mathbf{q}, which is no larger than the maximum over p\mathbf{p}. So vR≤vCv_R \le v_C always holds.

The minimax theorem says the inequality is an equality for mixed strategies, for any finite payoff matrix:

vR=vC=v.v_R = v_C = v.

The common number vv is the value of the game. R can guarantee at least vv and C can guarantee at most vv.

Why pure strategies are not enough

Equality often fails for pure strategies. Write the pure maximin as max⁡imin⁡jAij\max_i \min_j A_{ij} and the pure minimax as min⁡jmax⁡iAij\min_j \max_i A_{ij}. When these two numbers are different, there is no saddle point, and the game can only be solved with mixing. The worked examples below show this.

Continuous games and saddle points

For a function f(x,y)f(x, y) where the first player chooses xx to make ff small and the second chooses yy to make ff large, a saddle point is a pair (x∗,y∗)(x^\ast, y^\ast) with

f(x∗,y)≤f(x∗,y∗)≤f(x,y∗)f(x^\ast, y) \le f(x^\ast, y^\ast) \le f(x, y^\ast)

for every xx and yy. Neither player gains by moving away from it. The minimax theorem extends to this setting when ff is convex in xx and concave in yy and the sets of choices are convex (and one of them is compact), which is the setting of Sion's theorem.

−1.5−1−0.500.511.500.511.522.5x (first player's choice)worst-case value
  • worst case over y
Take f(x, y) = x^2 - y^2 with y in [-1, 1]. For each x, the second player picks y = 0 to push the value up to x^2. The first player's best choice is x = 0, giving value 0.

Training a GAN as a minimax game

In a generative adversarial network, the generator GG maps noise zz to a fake sample, and the discriminator DD outputs a probability that its input is real. Goodfellow and co-authors wrote the training problem as one value function:

min⁡Gmax⁡D V(D,G)=Ex∼pdata[log⁡D(x)]+Ez∼pz[log⁡(1−D(G(z)))].\min_G \max_D\ V(D, G) = \mathbb{E}_{x \sim p_{\text{data}}}\big[\log D(x)\big] + \mathbb{E}_{z \sim p_z}\big[\log\big(1 - D(G(z))\big)\big].

The discriminator maximises VV by telling real from fake well. The generator minimises VV by making D(G(z))D(G(z)) close to 1. In practice both are neural networks, and training alternates a gradient step for DD upward on VV with a gradient step for GG downward on VV. This is gradient descent-ascent, the minimax form of Gradient Descent.

Worked examples

Example
A 2 by 2 game with no saddle point

Let R be the row player and C the column player. The payoff matrix is

A=(3−102).A = \begin{pmatrix} 3 & -1 \\ 0 & 2 \end{pmatrix}.
  1. Check for pure strategies. The row minima are −1-1 and 00, so the pure maximin is max⁡(−1,0)=0\max(-1, 0) = 0. The column maxima are 33 and 22, so the pure minimax is min⁡(3,2)=2\min(3, 2) = 2.
  2. Since 0≠20 \ne 2, there is no saddle point. R must mix. Let pp be the chance R plays row 1, so row 2 has chance 1−p1 - p.
  3. Against column 1, R's expected payoff is 3p+0(1−p)=3p3p + 0(1-p) = 3p. Against column 2 it is −p+2(1−p)=2−3p-p + 2(1-p) = 2 - 3p.
  4. R's guarantee is the smaller of these two lines, min⁡(3p, 2−3p)\min(3p,\ 2 - 3p). The lines cross where 3p=2−3p3p = 2 - 3p, which gives p=13p = \tfrac{1}{3}. At that point the guarantee is 3⋅13=13 \cdot \tfrac{1}{3} = 1.
  5. Check: at p=13p = \tfrac{1}{3}, the payoff against column 2 is 2−3⋅13=12 - 3 \cdot \tfrac{1}{3} = 1 as well. Both columns give 1, so R's guarantee is exactly 1.
  6. Now C's side. Let qq be the chance C plays column 1. Against row 1, the payoff is 3q−(1−q)=4q−13q - (1 - q) = 4q - 1. Against row 2, it is 2(1−q)2(1 - q). Setting them equal: 4q−1=2−2q4q - 1 = 2 - 2q, so q=12q = \tfrac{1}{2}, and the value is 4⋅12−1=14 \cdot \tfrac{1}{2} - 1 = 1.
  7. Both sides agree: v=1v = 1. R plays row 1 with probability 13\tfrac{1}{3}, and C plays column 1 with probability 12\tfrac{1}{2}.

Interpretation: against a sensible opponent, neither player can expect more than 1 per round, and the mixed plan is what makes that guarantee hold. Any fixed row would let C punish R.

00.20.40.60.81−10123p (chance R plays row 1)expected payoff
  • payoff vs column 1
  • payoff vs column 2
R's guarantee is the lower of the two lines. It peaks at p = 1/3, where both lines equal 1.
Example
Matching pennies: the smallest mixed game

Each player shows heads or tails. R wins if the coins match, and C wins if they differ. The payoff matrix, with rows heads and tails for R and columns heads and tails for C, is

A=(1−1−11).A = \begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix}.
  1. Pure maximin: the row minima are −1-1 and −1-1, so the value is −1-1.
  2. Pure minimax: the column maxima are 11 and 11, so the value is 11. The gap means there is no saddle point.
  3. Let R play heads with probability pp. Against C's heads, the payoff is p−(1−p)=2p−1p - (1-p) = 2p - 1. Against C's tails, it is −p+(1−p)=1−2p-p + (1-p) = 1 - 2p.
  4. These two are equal when 2p−1=1−2p2p - 1 = 1 - 2p, which gives p=12p = \tfrac{1}{2}. At that point both are 0.
  5. By symmetry C also plays 12\tfrac{1}{2} on each side, and the value is v=0v = 0.

Interpretation: a predictable player always loses to an opponent who notices the pattern. The fair coin is the only way to make each side's worst case equal.

Tradeoffs and failure modes

The minimax theorem is strong, but it covers a narrow case. The table below sorts common situations.

SituationWhat goes wrongBetter choice
Two players, finite zero-sum matrixPure strategies may have no saddle pointSolve for mixed strategies, which is a linear program
Non-zero-sum game, such as a bargaining problemThe two values differ, so minimax no longer describes the outcomeUse a Nash equilibrium
Deep GAN training, non-convex and non-concaveNo theorem guarantees a stable value; the updates can cycle or collapseCareful optimisers, regularisers, and variant losses
Robust planning against an adversaryWorst-case plans can be too cautious and give up too much average performanceA tuned mix of worst-case and average-case objectives

A common failure is that simultaneous gradient steps move away from the equilibrium instead of toward it. Take the simple game f(x,y)=xyf(x, y) = xy, where the first player minimises and the second maximises. The equilibrium is (0,0)(0, 0). If both players take a simultaneous gradient step with size η\eta, the new point is (x−ηy, y+ηx)(x - \eta y,\ y + \eta x), and its squared distance from the origin is

(x−ηy)2+(y+ηx)2=(1+η2)(x2+y2).(x - \eta y)^2 + (y + \eta x)^2 = (1 + \eta^2)(x^2 + y^2).

Every step multiplies the distance by 1+η2\sqrt{1 + \eta^2}, so the iterates spiral away from the equilibrium. This is why training a GAN with plain simultaneous updates can be unstable, even when the equilibrium exists.

History

John von Neumann proved the minimax theorem for finite zero-sum games in 1928. The paper appeared in the journal Mathematische Annalen. He was working on the mathematics of parlour games, and the result established that a finite two-player zero-sum contest has a well-defined value.

In 1944 von Neumann and the economist Oskar Morgenstern published Theory of Games and Economic Behavior. The book used the minimax theorem as the foundation for a theory of rational choice under conflict, and it made game theory a standard tool in economics.

Linear programming, developed in the late 1940s by George Dantzig and others, gave a practical way to compute mixed strategies for finite games. A matrix game can be written as a pair of dual linear programs, which is one reason the minimax theorem is closely tied to optimisation.

John Nash extended the idea in 1950 to games with any number of players and no zero-sum restriction, introducing the Nash equilibrium. Minimax remained the special case where the two players' interests are exactly opposite.

In 2014 Ian Goodfellow and co-authors proposed generative adversarial networks, with training written as a minimax problem over neural networks. That brought the old idea into deep learning, where the theorem's guarantees no longer apply in general, and much later work is about making the game behave.

Check yourself

QuestionWhat is the defining property of a zero-sum game, in one sentence?Show answer

In every outcome, the payoffs of the two players add up to zero. What one player gains, the other loses. This is why each player can reason about the other as a rival who plays their best reply, and why a cautious plan protects against the worst case.

QuestionFor the matrix A = [[2, 0], [0, 2]] with the row player maximising, compute the pure maximin value and the pure minimax value, and say whether a saddle point exists.Show answer

The row minima are 0 and 0, so the pure maximin is 0. The column maxima are 2 and 2, so the pure minimax is 2. The two values differ, so there is no pure saddle point. The mixed value is 1, reached by playing each row with probability 1/2, and each column also with probability 1/2 against the opponent's mix. Check: if R plays 1/2 and 1/2, every column gives the same expected payoff, 1.

QuestionIn the 2 by 2 example, why must R's guarantee equal the value where the two lines cross, rather than at the endpoints p = 0 or p = 1?Show answer

At p = 0 the guarantee is the smaller of 0 and 2, which is 0. At p = 1 it is the smaller of 3 and -1, which is -1. Both endpoints are worse than the crossing point. The guarantee is a minimum of two straight lines, so it is a tent shape whose peak is where they cross. The crossing at p = 1/3 gives the highest point of the tent, 1.

QuestionWhy does a fair coin appear in the matching pennies game, and what goes wrong if one player always shows heads?Show answer

A fair coin makes the opponent indifferent: heads and tails give the same expected payoff, 0. If R always shows heads, C simply shows tails every round and wins every time. A predictable pattern gives the opponent a sure gain, so the mixed strategy is the only one with a guaranteed worst case of 0.

QuestionIn a GAN, the discriminator wants V to be large and the generator wants it small. If the discriminator becomes perfect, what does the value V equal, and why does that make the generator's gradient signal weak?Show answer

If D is perfect, it outputs D(x) = 1 on real data and D(G(z)) = 0 on fake data, so log D(x) = 0 and log(1 - D(G(z))) = 0, giving V = 0 in the limit. This is the discriminator's best possible value, so the generator is pushed to change. In practice a perfect discriminator also gives the generator a very flat signal, since the log term saturates, which is one reason GAN training needs careful loss choices.

Sources