TExcelTAD
Home › Linear Programming & Duality for Algorithms › Zero-Sum Games and the Minimax Theorem via MWU

Zero-Sum Games and the Minimax Theorem via MWU

In a two-player zero-sum game, whatever one player wins the other loses. Von Neumann's minimax theorem (1928) says that such a game has a value: there is a mixed strategy for each player that guarantees it, no matter what the opponent knows. This lesson proves the theorem twice. The first proof is LP duality: each player's best guarantee is an LP, and the two LPs are duals. The second proof is algorithmic: let one player run multiplicative weights against a best-responding opponent, and the regret bound forces the two guarantees together. The second proof also gives a simple algorithm that computes ε\varepsilon-optimal strategies in O(ln⁡n/ε2)O(\ln n / \varepsilon^2) rounds, the prototype of the fast approximate LP solvers of the next lesson.

Games, mixed strategies and the value

The game is an m×nm \times n matrix AA with entries in [0,1][0, 1]: if the row player picks row ii and the column player picks column jj, the row player pays AijA_{ij} to the column player. A mixed strategy is a probability vector, p∈Δmp \in \Delta_m for rows and q∈Δnq \in \Delta_n for columns, and the expected payment is pTAqp^T A q.

If the row player must announce pp first, the column player best-responds and the row player pays max⁡j(pTA)j\max_j (p^T A)_j (a pure best response suffices, since pTAqp^T A q is linear in qq). The row player's best guarantee and the column player's best guarantee are

vR=min⁡p∈Δmmax⁡j (pTA)j,vC=max⁡q∈Δnmin⁡i (Aq)i.v_R = \min_{p \in \Delta_m} \max_{j} \,(p^T A)_j, \qquad v_C = \max_{q \in \Delta_n} \min_{i} \,(A q)_i .

Moving first can only hurt, so vC≤vRv_C \le v_R (for any pp and qq: min⁡i(Aq)i≤pTAq≤max⁡j(pTA)j\min_i (Aq)_i \le p^T A q \le \max_j (p^T A)_j).

Theorem (von Neumann, 1928). vC=vRv_C = v_R. This common number is the value of the game.

Proof 1: LP duality

The row player's problem is an LP with variables pp and vv:

min⁡  vs.t.∑ipiAij≤v  ∀j,∑ipi=1,p≥0.\min \; v \quad \text{s.t.} \quad \sum_i p_i A_{ij} \le v \ \ \forall j, \quad \sum_i p_i = 1, \quad p \ge 0 .

Dualize it with the recipe (Building the Dual Mechanically): a multiplier qj≥0q_j \ge 0 per column constraint and a free uu for the equation give max⁡{u:∑jAijqj≥u ∀i, ∑jqj=1, q≥0}\max \{ u : \sum_j A_{ij} q_j \ge u\ \forall i,\ \sum_j q_j = 1,\ q \ge 0 \}, which is exactly the column player's problem. Both are feasible and bounded, so strong duality gives vR=vCv_R = v_C. □\square

The program solves both LPs for a 3×43 \times 4 game.

python · try it yourself
from fractions import Fraction
from scipy.optimize import linprog

A = [[0.0, 1.0, 0.3, 0.6], [0.9, 0.2, 0.5, 0.4], [0.4, 0.6, 0.1, 0.8]]
m, n = len(A), len(A[0])

row = linprog([0] * m + [1], A_ub=[[A[i][j] for i in range(m)] + [-1] for j in range(n)], b_ub=[0] * n,
              A_eq=[[1] * m + [0]], b_eq=[1], bounds=[(0, None)] * m + [(None, None)], method="highs")
col = linprog([0] * n + [-1], A_ub=[[-A[i][j] for j in range(n)] + [1] for i in range(m)], b_ub=[0] * m,
              A_eq=[[1] * n + [0]], b_eq=[1], bounds=[(0, None)] * n + [(None, None)], method="highs")
p, q = [float(v) for v in row.x[:m]], [float(v) for v in col.x[:n]]
print("row player's optimal p:", [round(v, 4) for v in p], " guarantee v_R =", round(float(row.fun), 6))
print("column player's optimal q:", [round(v, 4) + 0.0 for v in q], " guarantee v_C =", round(float(-col.fun), 6))
print("value as a fraction:", Fraction(float(row.fun)).limit_denominator(1000))
row player's optimal p: [0.3333, 0.5185, 0.1481]  guarantee v_R = 0.525926
column player's optimal q: [0.4444, 0.4815, 0.0, 0.0741]  guarantee v_C = 0.525926
value as a fraction: 71/135

Proof 2: no regret implies minimax

Let the row player run multiplicative weights over its mm rows, and let the column player best-respond each round:

text
MINIMAX-BY-MWU(A, T)
1  w_i = 1 for every row
2  for t = 1 .. T
3      p(t) = w / sum(w)
4      j(t) = a column maximizing (p(t)^T A)_j              -- best response
5      cost vector m_i = A[i][j(t)];  w_i = w_i * (1 - eta * m_i)
6  return  p_bar = average of p(t),  q_bar = empirical distribution of j(1..T)

Write δ=2ln⁡m/T\delta = 2\sqrt{\ln m / T} for the average regret bound. The regret theorem, divided by TT, says

1T∑tp(t)TAej(t)  ≤  min⁡i1T∑tAi j(t)+δ  =  min⁡i(Aqˉ)i+δ  ≤  vC+δ.\frac{1}{T} \sum_t p^{(t)T} A e_{j(t)} \;\le\; \min_i \frac{1}{T} \sum_t A_{i\, j(t)} + \delta \;=\; \min_i (A \bar q)_i + \delta \;\le\; v_C + \delta .

Each term on the left is a best response, p(t)TAej(t)=max⁡j(p(t)TA)j≥vRp^{(t)T} A e_{j(t)} = \max_j (p^{(t)T} A)_j \ge v_R. So vR≤vC+δv_R \le v_C + \delta for every TT, and letting T→∞T \to \infty gives vR≤vCv_R \le v_C. With the easy inequality, vR=vCv_R = v_C. □\square

The proof also shows that the averages are good strategies: by convexity, max⁡j(pˉTA)j≤1T∑tmax⁡j(p(t)TA)j≤v+δ\max_j (\bar p^T A)_j \le \frac{1}{T} \sum_t \max_j (p^{(t)T} A)_j \le v + \delta, and min⁡i(Aqˉ)i≥v−δ\min_i (A \bar q)_i \ge v - \delta. So T=⌈4ln⁡m/ε2⌉T = \lceil 4 \ln m / \varepsilon^2 \rceil rounds give ε\varepsilon-optimal strategies for both players, each round costing one matrix-vector product, O(mn)O(mn) time.

python · try it yourself
import math

A = [[0.0, 1.0, 0.3, 0.6], [0.9, 0.2, 0.5, 0.4], [0.4, 0.6, 0.1, 0.8]]
m, n = len(A), len(A[0])
value = 71 / 135

for T in [100, 1000, 10000]:
    eta = math.sqrt(math.log(m) / T)
    w, p_sum, q_count = [1.0] * m, [0.0] * m, [0] * n
    for t in range(T):
        W = sum(w)
        p = [wi / W for wi in w]
        payoff = [sum(p[i] * A[i][j] for i in range(m)) for j in range(n)]
        j = max(range(n), key=lambda k: payoff[k])                # column player's best response
        q_count[j] += 1
        p_sum = [a + b for a, b in zip(p_sum, p)]
        w = [w[i] * (1 - eta * A[i][j]) for i in range(m)]
    p_bar = [s / T for s in p_sum]
    q_bar = [c / T for c in q_count]
    upper = max(sum(p_bar[i] * A[i][j] for i in range(m)) for j in range(n))   # what p_bar guarantees
    lower = min(sum(A[i][j] * q_bar[j] for j in range(n)) for i in range(m))   # what q_bar guarantees
    print(f"T = {T:5}: v in [{lower:.4f}, {upper:.4f}], gap {upper - lower:.4f}, delta = {2 * math.sqrt(math.log(m) / T):.4f}, p_bar {[round(v, 3) for v in p_bar]}")
print(f"exact value 71/135 = {value:.4f}")
T =   100: v in [0.5000, 0.5384], gap 0.0384, delta = 0.2096, p_bar [0.326, 0.491, 0.183]
T =  1000: v in [0.5166, 0.5296], gap 0.0130, delta = 0.0663, p_bar [0.332, 0.51, 0.158]
T = 10000: v in [0.5229, 0.5271], gap 0.0042, delta = 0.0210, p_bar [0.333, 0.516, 0.151]
exact value 71/135 = 0.5259

The interval [min⁡i(Aqˉ)i,max⁡j(pˉTA)j][\min_i (A\bar q)_i, \max_j (\bar p^T A)_j] always contains the value, so each run certifies an approximation of it, and it shrinks as TT grows. The averaged row strategy approaches the LP's optimal pp.

In C++

The same dynamics on the same game, for T=10 000T = 10\,000.

cpp · try it yourself
#include <cmath>
#include <cstdio>
#include <vector>

int main() {
    const std::vector<std::vector<double>> A = {{0.0, 1.0, 0.3, 0.6}, {0.9, 0.2, 0.5, 0.4}, {0.4, 0.6, 0.1, 0.8}};
    const int m = 3, n = 4, T = 10000;
    const double eta = std::sqrt(std::log(m) / T);
    std::vector<double> w(m, 1.0), pbar(m, 0.0), qbar(n, 0.0);
    for (int t = 0; t < T; t++) {
        double W = w[0] + w[1] + w[2];
        std::vector<double> p(m);
        for (int i = 0; i < m; i++) { p[i] = w[i] / W; pbar[i] += p[i] / T; }
        int best = 0;
        double bestPay = -1;
        for (int j = 0; j < n; j++) {
            double pay = 0;
            for (int i = 0; i < m; i++) pay += p[i] * A[i][j];
            if (pay > bestPay) { bestPay = pay; best = j; }
        }
        qbar[best] += 1.0 / T;
        for (int i = 0; i < m; i++) w[i] *= 1 - eta * A[i][best];
    }
    double upper = 0, lower = 1;
    for (int j = 0; j < n; j++) { double s = 0; for (int i = 0; i < m; i++) s += pbar[i] * A[i][j]; if (s > upper) upper = s; }
    for (int i = 0; i < m; i++) { double s = 0; for (int j = 0; j < n; j++) s += A[i][j] * qbar[j]; if (s < lower) lower = s; }
    std::printf("value in [%.4f, %.4f]; p_bar = (%.3f, %.3f, %.3f)\n", lower, upper, pbar[0], pbar[1], pbar[2]);
}
value in [0.5229, 0.5271]; p_bar = (0.333, 0.516, 0.151)

Both players learning

The column player does not have to best-respond. If both players run a no-regret algorithm, their time-averaged strategies still converge to optimal strategies, by the same argument applied on both sides: each average regret bounds the distance of the averages from the value. This is how large games are solved in practice. Poker programs such as Libratus (Brown and Sandholm, 2018) used counterfactual regret minimization, a no-regret method for games in extensive form, which converges at the same O(1/T)O(1/\sqrt{T}) rate in the worst case; "optimistic" variants of MWU converge faster, at rate O~(1/T)\tilde O(1/T), when both players use them (Rakhlin and Sridharan, 2013).

Beyond two players

The minimax theorem is special to two-player zero-sum games. In general games, no-regret dynamics converge (in the time-average sense) to coarse correlated equilibria, a weaker notion, and computing a Nash equilibrium is PPAD-complete even for two players (Chen and Deng, 2006; Daskalakis, Goldberg and Papadimitriou, 2006 for three or more). The zero-sum case is the one where learning and optimization meet exactly, which is why it reappears in boosting (Freund and Schapire, 1997: the weak-learning assumption is a statement about the value of a game) and in the LP solvers of the next lesson.

Test yourself

Why is vC≤vRv_C \le v_R easy?

  1. Because AA is square
  2. For any p,qp, q: min⁡i(Aq)i≤pTAq≤max⁡j(pTA)j\min_i (Aq)_i \le p^T A q \le \max_j (p^T A)_j
  3. Because of strong duality
  4. Because the game is symmetric

In the MWU proof of the minimax theorem, what does the column player do each round?

  1. Also runs MWU
  2. Plays a best response to the row player's current distribution
  3. Plays uniformly at random
  4. Copies the row player

How many rounds of MWU against best responses give ε\varepsilon-optimal strategies for an mm-row game with payoffs in [0,1][0, 1]?

  1. O(m)O(m)
  2. O(ln⁡m/ε2)O(\ln m / \varepsilon^2)
  3. O(1/ε)O(1/\varepsilon)
  4. O(2m)O(2^m)