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 -optimal strategies in rounds, the prototype of the fast approximate LP solvers of the next lesson.
Games, mixed strategies and the value
The game is an matrix with entries in : if the row player picks row and the column player picks column , the row player pays to the column player. A mixed strategy is a probability vector, for rows and for columns, and the expected payment is .
If the row player must announce first, the column player best-responds and the row player pays (a pure best response suffices, since is linear in ). The row player's best guarantee and the column player's best guarantee are
Moving first can only hurt, so (for any and : ).
Theorem (von Neumann, 1928). . This common number is the value of the game.
Proof 1: LP duality
The row player's problem is an LP with variables and :
Dualize it with the recipe (Building the Dual Mechanically): a multiplier per column constraint and a free for the equation give , which is exactly the column player's problem. Both are feasible and bounded, so strong duality gives .
The program solves both LPs for a game.
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 rows, and let the column player best-respond each round:
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 for the average regret bound. The regret theorem, divided by , says
Each term on the left is a best response, . So for every , and letting gives . With the easy inequality, .
The proof also shows that the averages are good strategies: by convexity, , and . So rounds give -optimal strategies for both players, each round costing one matrix-vector product, time.
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 always contains the value, so each run certifies an approximation of it, and it shrinks as grows. The averaged row strategy approaches the LP's optimal .
In C++
The same dynamics on the same game, for .
#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 rate in the worst case; "optimistic" variants of MWU converge faster, at rate , 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 easy?
- Because is square
- For any :
- Because of strong duality
- Because the game is symmetric
In the MWU proof of the minimax theorem, what does the column player do each round?
- Also runs MWU
- Plays a best response to the row player's current distribution
- Plays uniformly at random
- Copies the row player
How many rounds of MWU against best responses give -optimal strategies for an -row game with payoffs in ?