Games, Equilibria & Markov Games
Nash equilibria, zero-sum games and their multi-state version.
A game is a decision problem with several decision makers, each with its own reward, and each one's best choice depends on the others'. This lesson builds the machinery the rest of the topic stands on: mixed strategies and best responses, Nash equilibria and how to compute them by hand, von Neumann's minimax theorem and the linear program that solves any zero-sum matrix game, the solution concepts beyond Nash, and Markov games, where states and transitions return.
What you’ll learn
- Define normal-form games, mixed strategies, best responses and Nash equilibria, and find every equilibrium of a 2×2 game with the indifference principle.
- State von Neumann's minimax theorem, derive it from linear-programming duality, and solve a zero-sum matrix game by linear programming.
- Define correlated, coarse correlated and Stackelberg equilibria, and compare them with Nash equilibria on concrete games.
- Define Markov games and their values, write Shapley's value iteration, and explain why independent learners face a non-stationary problem.
Normal-form games and best responses
A best response to is any maximizing . The objective is linear in , which has a useful consequence. Write : an average of the pure actions' payoffs , weighted by . An average never exceeds its largest term, so
and a mixed strategy is a best response exactly when it puts weight only on actions that attain this maximum. Some pure action is always a best response; mixing is only ever allowed, when several actions tie.
A profile is a Nash equilibrium when each strategy is a best response to the other, and an -Nash equilibrium when neither player can gain more than by deviating. Nash (1950, 1951) proved, with Kakutani's and then Brouwer's fixed-point theorem, that every finite game has an equilibrium in mixed strategies.
| Chicken | Column swerves (C) | Column dares (D) |
|---|---|---|
| Row swerves (C) | ||
| Row dares (D) |
In chicken, the column driver dares half the time. What is the row driver's best response?
- Dare for sure
- Swerve with probability ⅔
- Swerve and dare with probability ½ each
- Swerve for sure
Show the answer
D. Swerve for sure
Swerving earns and daring , so swerving is the unique best response. A mixed strategy is a best response only when the actions tie, which here happens when the column driver swerves with probability exactly ⅔.
Computing equilibria by indifference
The best-response characterization turns equilibrium computation into algebra. If the row player mixes over several actions in an equilibrium, all of them must earn the same against . So in a 2×2 game with a fully mixed equilibrium, each player's mix is pinned down by the other player's indifference. This is the indifference principle, and it is the classic source of surprises: your equilibrium mix depends on your opponent's payoffs, not your own.
Pure equilibria. Check each cell for a profitable unilateral switch. At (C, D) the row driver would get 0 instead of 2 by daring, and the column driver 6 instead of 7 by swerving, so neither switches; (D, C) is the mirror image. At (C, C) either driver gains by daring (7 > 6), and at (D, D) either gains by swerving (2 > 0).
The mixed equilibrium. Let be the probability that the column driver swerves. The row driver mixes only if both actions pay the same:
The game is symmetric, so the row driver's swerve probability solves the same equation: . Each driver's expected payoff is the common value of the two sides:
So chicken has three equilibria, an odd number, as almost every finite game does (Wilson, 1971). Matching pennies, with no pure equilibrium, has one: indifference gives .
In chicken's mixed equilibrium, each driver dares with probability ⅓, independently. How likely is a crash (both dare)?
Show the answer
0.11
. Independent randomization cannot avoid the crash, which is why each driver earns only , less than the 6 both would get by swerving. A traffic light that correlates the drivers' actions can do better, as the next steps show.
Zero-sum games: the minimax theorem
In a zero-sum game the row player can guarantee whatever the opponent does (the maximin value), and the column player can hold the row player to (the minimax value). Going second can only help, so maximin ≤ minimax always. Von Neumann (1928) proved that with mixed strategies the two are equal: the minimax theorem.
The common number is the value of the game, and it has strong consequences that fail in general-sum games. Every Nash equilibrium pays the row player exactly . Equilibrium strategies are interchangeable: any maximin paired with any minimax is an equilibrium, so the players need no coordination. And each player's set of equilibrium strategies is a convex polytope.
A tennis server chooses to serve wide or down the T; the returner leans wide, stays central or leans toward the T. Entries are the server's chance of winning the point (zero-sum: the returner gets the rest). With = probability of serving wide, each returner action gives a line in :
Against any fixed the returner picks the lowest line, so the server maximizes the lower envelope. The two leaning lines cross where ; the central line lies above both there () and is never the lowest anywhere:
The returner mixes only the two leaning actions, with = probability of leaning wide set to make the server indifferent:
Check: against both serves win with probability , and against staying central would let the server win 0.64. The "safe" central option, which neither leaning action beats against both serves, gets zero weight: an equilibrium keeps only actions that are best responses to the opponent's equilibrium mix. (A 50/50 mix of the two leans, , does beat central's against both serves: an action that is never a best response is always dominated by some mixture.)
For larger games, linear programming does the work. The inner minimum is linear in , so it is attained at a pure action: . Introduce a variable for it:
The row player's problem, with variables and inequality constraints:
Attach multipliers to the inequalities and to the equality. The Lagrangian is . Its supremum over the free and over is finite only if and , which gives the dual:
The dual is exactly the column player's problem . Both programs are feasible and bounded, so strong LP duality makes their optimal values equal:
import numpy as np
from scipy.optimize import linprog
def solve_zero_sum(A):
"""Maximin strategy x and value v of the row player, who maximizes x^T A y."""
m, n = A.shape
c = np.zeros(m + 1); c[-1] = -1.0 # variables (x, v); maximize v
A_ub = np.hstack([-A.T, np.ones((n, 1))]) # v - (A^T x)_j <= 0 for each column j
b_ub = np.zeros(n)
A_eq = np.hstack([np.ones((1, m)), np.zeros((1, 1))]) # sum_i x_i = 1
bounds = [(0, None)] * m + [(None, None)] # x >= 0, v free
res = linprog(c, A_ub=A_ub, b_ub=b_ub, A_eq=A_eq, b_eq=[1.0],
bounds=bounds, method="highs")
return res.x[:m], res.x[-1]
serve = np.array([[0.45, 0.66, 0.85],
[0.80, 0.62, 0.40]])
x, v = solve_zero_sum(serve) # x = (0.5, 0.5), v = 0.625, as derived aboveSwapping roles (solve with ) gives the column player's minimax strategy. Interior-point and simplex solvers handle games with thousands of actions per player this way.
Beyond Nash: correlation and commitment
Nash equilibria assume the players randomize independently. Chicken shows the cost: a crash one time in nine. Aumann (1974) asked what happens if a trusted device, such as a traffic light, draws a joint profile from a distribution and privately tells each player only its own component.
Let the light choose (C, C), (C, D) or (D, C), each with probability ⅓, and never (D, D). A driver told to dare knows the other was told to swerve, so daring pays 7 against swerving's 6: obey.
A driver told to swerve knows the joint draw was (C, C) or (C, D), equally likely, so the other swerves with conditional probability ½:
Obeying is optimal after every recommendation, so is a correlated equilibrium. It never crashes, and each driver earns more than in the mixed Nash equilibrium:
Think first A public coin picks one of the two pure equilibria, (C, D) or (D, C), with probability ½ each. Is that a correlated equilibrium, and how does it compare with the traffic light?
Yes: told C, a driver knows the other dares, and swerving (2) beats daring (0); told D, daring (7) beats swerving (6). Each driver earns . The traffic light does better, 5 each, because it sometimes sends both drivers the safe recommendation (C, C), which no Nash equilibrium, pure or mixed, ever plays for sure. Here the light beats the mixed equilibrium for both drivers, and every equilibrium in total (10 against at most ). In some games a correlated equilibrium beats every Nash equilibrium for every player: in Shapley's rock–paper–scissors variant (a win pays the winner 2 and the loser 1, a tie pays both 0) the only Nash equilibrium is uniform and pays 1 each, while recommending the six mismatched profiles with equal probability is a correlated equilibrium paying 1.5 each.
Commitment is the other way to escape simultaneous play. In a Stackelberg game a leader announces a mixed strategy and a follower best-responds to it, breaking ties in the leader's favor. Consider a leader with actions U, D and a follower with L, R, paying (leader, follower) at (U, L), at (U, R), at (D, L) and at (D, R). U strictly dominates D for the leader, so the only Nash equilibrium is (U, L), worth 1 to the leader. Committing to D instead makes the follower answer R, worth 2. Committing to U + D leaves the follower indifferent (L and R both pay it ½), so it plays R, and the leader earns .
Commitment never hurts the leader: committing to its Nash strategy leaves among the follower's best responses, and the leader-favorable tie-break does at least as well. In zero-sum games it also never helps, since announcing a maximin strategy still guarantees exactly . An optimal commitment in a two-player normal-form game takes one linear program per follower action (Conitzer & Sandholm, 2006); this is the model behind security games, in which a defender commits to randomized patrols that an attacker observes.
| Solution concept | What the players do | Computing one | Reached by learning? |
|---|---|---|---|
| Nash, two-player zero-sum | Independent mixes, mutual best responses | A linear program | Yes, by time averages of no-regret learners |
| Nash, general-sum | Same | PPAD-complete even for two players: no efficient algorithm is believed to exist | Not by deterministic, continuous-time uncoupled dynamics in every game (Hart & Mas-Colell, 2003); stochastic uncoupled search can, slowly (Foster & Young, 2006) |
| Correlated (CE) | Obey a joint recommendation, given your own part | A linear program in , polynomial in the size of the game table | Yes: empirical play of no-swap-regret learners |
| Coarse correlated (CCE) | Follow the device rather than any fixed action | A linear program | Yes: empirical play of no-external-regret learners |
| Stackelberg | Leader commits, follower best-responds | One LP per follower action | Needs a model of how the follower responds |
Markov games
Every finite discounted Markov game has a Nash equilibrium in stationary policies (Fink, 1964). For two-player zero-sum games, Shapley (1953) showed much more: there is a unique value function , and value iteration finds it if each Bellman backup solves a small matrix game, the stage game of one-step rewards plus discounted values:
is a -contraction in the max norm, because the value of a matrix game moves by at most the largest change in its entries. Playing an equilibrium of each stage game at every state gives an equilibrium of the whole game. With the linear program from before, the algorithm is a few lines:
def shapley_value_iteration(R, P, gamma, sweeps=500):
"""Two-player zero-sum Markov game. R[s]: (m, n) rewards to player 1 in state s;
P[s]: (m, n, S) next-state probabilities. Returns V* and player 1's maximin policy."""
S = len(R)
V = np.zeros(S)
for _ in range(sweeps): # error shrinks by a factor gamma per sweep
V = np.array([solve_zero_sum(R[s] + gamma * P[s] @ V)[1] for s in range(S)])
policy = [solve_zero_sum(R[s] + gamma * P[s] @ V)[0] for s in range(S)]
return V, policyP[s] @ V averages the next-state values for every joint action, giving the stage game's continuation term. Compared with MDP value iteration, the max over actions has become the value of a matrix game.
Now suppose each player simply runs its own single-agent learner, treating the others as part of the environment: independent learners. Fix the others' policies ; then player faces an ordinary MDP with
But the others are learning too, so changes, and with it player 's MDP: the problem is non-stationary. The convergence proofs of single-agent RL no longer apply, replayed experience describes opponents that no longer exist, and the learners can circle each other as in matching pennies. Remarkably, independent learning still works well in many cooperative benchmarks, a puzzle the cooperative lessons take up.
Two players run independent tabular Q-learning in a Markov game. Player 2 stops learning and from then on plays a fixed stationary policy. What happens to player 1's Q-learning, assuming it keeps exploring every action in every state and uses suitably decaying step sizes?
- It still cannot converge, because the game has two players
- It converges to player 2's Q-values
- It converges to the Nash equilibrium of the game
- It converges to the Q-values of a best response to player 2's fixed policy
Show the answer
D. It converges to the Q-values of a best response to player 2's fixed policy
Against a fixed stationary opponent, player 1 faces a fixed MDP with the averaged kernel and reward , and Q-learning's usual guarantee applies: it learns an optimal policy of that MDP, a best response. Non-stationarity comes from the opponent adapting; a frozen opponent is just part of a stationary environment.
Where the Fixed Point lessons go
Key takeaways
- A best response to a fixed opponent strategy can always be pure; a mixed strategy is a best response only if it uses tied actions, so equilibria can be computed from indifference conditions.
- Each player's equilibrium mix is set by the opponent's payoffs: in chicken each driver swerves with probability ⅔ and earns , crashing of the time.
- In zero-sum games maximin equals minimax (von Neumann, 1928). The value is unique, equilibrium strategies are interchangeable, and a linear program, whose dual is the opponent's problem, computes them.
- Correlated and coarse correlated equilibria let a device coordinate play (Nash ⊆ CE ⊆ CCE) and can do better than independent mixing, in some games for every player; Stackelberg commitment never hurts a leader and never helps in zero-sum games.
- Markov games add states: Shapley's value iteration solves a matrix game per state in the zero-sum case, while independent learners face an MDP that drifts as the others learn.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the fully mixed equilibrium of a 2×2 game, what pins down the row player's mixing probability?
- The row player's own payoffs: it mixes to make itself indifferent
- The column player's payoffs: the row player's mix must make the column player indifferent between its two actions
- It is always ½, by symmetry
- It maximizes the row player's expected payoff against every column strategy
Show the answer
B. The column player's payoffs: the row player's mix must make the column player indifferent between its two actions
The column player mixes in equilibrium only if both of its actions pay it the same against the row player's mix, and that equation involves the column player's payoffs and the row player's probability. So each player's mix is set by the other's payoffs, which is why changing your own payoffs can leave your equilibrium mix unchanged.
Why can the linear program for a zero-sum game replace by a minimum over the column player's pure actions?
- Because is linear in , and a linear function on the simplex attains its minimum at a vertex, a pure action
- Because the column player never randomizes in equilibrium
- Because zero-sum games always have pure equilibria
- Because the row player moves first
Show the answer
A. Because is linear in , and a linear function on the simplex attains its minimum at a vertex, a pure action
For fixed , is an average of the pure actions' payoffs, so its minimum is the smallest . That turns the inner problem into linear constraints .
In a zero-sum game, and are both maximin strategies for the row player and is minimax for the column player. What is true of ?
- It is a Nash equilibrium, paying the row player the value
- It may fail to be an equilibrium unless
- It is an equilibrium, but the payoff may differ from
- It is an equilibrium only if the game is symmetric
Show the answer
A. It is a Nash equilibrium, paying the row player the value
guarantees at least against every column strategy, and holds every row strategy to at most , so and neither player can improve: equilibrium strategies of zero-sum games are interchangeable. General-sum games lack this, which is why choosing among their equilibria is a real coordination problem.
How are the sets of Nash equilibria (NE), correlated equilibria (CE) and coarse correlated equilibria (CCE) of a finite game related?
- CCE ⊆ CE ⊆ NE
- NE ⊆ CE ⊆ CCE
- They are always the same set
- CE and NE are disjoint: correlation rules out independence
Show the answer
B. NE ⊆ CE ⊆ CCE
A Nash equilibrium is a correlated equilibrium whose distribution is a product of independent mixes, and the CCE condition is the sum of the CE conditions over the recommended action. The inclusions can be strict: chicken's traffic light is a CE that is not a Nash equilibrium.
In a two-player zero-sum game with value , the row player commits to a mixed strategy and announces it before the column player moves. What is the best the row player can guarantee?
- More than , because commitment always helps the leader
- Less than , because the opponent can exploit the announcement
- Exactly , by announcing a maximin strategy
- It depends on how the column player breaks ties
Show the answer
C. Exactly , by announcing a maximin strategy
Announcing lets the column player pick the column minimizing , so the leader earns , which is at most and equals for a maximin . That is the minimax theorem in another form: in zero-sum games, moving first with a mixed strategy costs nothing and gains nothing.
Go deeper
- Zero-Sum Markov Games · Shapley’s theorem, minimax-Q, and why two-player zero-sum games are tractable.
- Learning Dynamics in Games · Fictitious play, no-regret learning, cycles and last-iterate convergence.
- The Complexity of Equilibria · The PPAD-hardness of Nash equilibria, and correlated equilibria as the tractable alternative.
Further reading
- J. Nash, "Non-cooperative games," Annals of Mathematics 54(2), 286–295 (1951).
- J. von Neumann, "Zur Theorie der Gesellschaftsspiele," Mathematische Annalen 100, 295–320 (1928).
- R. J. Aumann, "Subjectivity and correlation in randomized strategies," Journal of Mathematical Economics 1(1), 67–96 (1974).
- L. S. Shapley, "Stochastic games," Proceedings of the National Academy of Sciences 39(10), 1095–1100 (1953).