6 Learning in games
An equilibrium describes mutually consistent behavior. It does not, by itself, explain how players arrive at that behavior. We now study repeated interaction: players choose strategies, observe feedback, and update their choices. The update rule and the information available to each player become part of the learning model.
We retain a finite normal-form game \(\left(N,(S_i)_{i\in N},(u_i)_{i\in N}\right)\), with \(\mathbf S=\prod_i S_i\). The same game is played repeatedly, with no change in its utility functions. As before, \(u_i\) denotes utility at a pure profile and \(U_i\) denotes expected utility.
From offline computation to online interaction
In Lecture 3, an analyst supplied a solver with the game and asked for an equilibrium. Support enumeration and homotopy continuation produced intermediate calculations, rather than strategies adopted by the players. The linear programs in Section 4.3.3 and Section 5.6 likewise computed a solution before its use. Double Oracle algorithm is iterative, but its iterations solved and expanded an internal computational model of the game.
These are offline methods: their purpose is to calculate a solution from a game description. An online method instead specifies what each player does as interaction unfolds. Performance depends on the feedback received after earlier decisions. Learning rules can also be run in a simulator and used as offline computational methods. The distinction concerns the role of an iteration and the information it uses.
Learning rules use different information about the game. For each update rule, we specify what players know and what feedback they receive.
| Rule | Information needed by player \(i\) | What the update uses |
|---|---|---|
| Best response | Own payoff function and opponents’ current strategies | A best response to the current profile |
| Fictitious play | Own payoff function and opponents’ strategy counts | A best response to empirical frequencies |
| Regret matching | Own payoff vector for all strategies, received after play | Accumulated payoff differences |
None of these rules requires the player to know the other players’ payoff functions. In the last row, the feedback can be supplied as a vector of payoffs. Alternatively, the player can reconstruct it from their own payoff function and the observed opponents’ strategies.
A Python notebook demonstrating learning in games is available on GitHub or can be opened in Colab.
6.1 Best-response dynamics
6.1.1 Sequential updates
Recall that
\[ \operatorname{BR}_i(\mathbf s_{-i}) =\underset{s_i\in S_i}{\operatorname{argmax}} u_i(s_i,\mathbf s_{-i}). \]
Only one player changes strategy at a time. A player already best responding keeps their current strategy. Every actual update therefore strictly improves the updating player’s payoff. The choice of the next updating player and the choice among best responses can affect the trajectory and its endpoint.
If the algorithm stops, its terminal profile is a pure Nash equilibrium. However, the algorithm may cycle.
In the next section we identify the class of games for which the sequential best-response dynamics terminates.
6.1.2 Potential games
Some games have a common function that records every unilateral utility change (Monderer and Shapley 1996b).
The matches changes in the utility of the player who moves, with the other strategies held fixed. A simple special case is a common-payoff game, where every player has the same utility function.
Proof. The inequalities defining a pure Nash equilibrium are \[u_i(\mathbf s^*)\ge u_i(s_i,\mathbf s_{-i}^*).\] By the definition of a potential game, these are exactly the inequalities stated above for \(P\). \(\square\)
Thus, every global maximizer of \(P\) is an equilibrium, but an equilibrium need not globally maximize \(P\). This also proves that every potential game has a pure Nash equilibrium.
6.1.3 Convergence of best responses
Proof. Start at any profile \(\mathbf s^0\). Whenever the algorithm updates player \(i\), that player’s current action is not a best response. Replacing it by a best response therefore gives
\[ P(\mathbf s^{t+1})-P(\mathbf s^t) = u_i(\mathbf s^{t+1})-u_i(\mathbf s^t)>0. \]
Thus the potential strictly increases at every update, so the algorithm cannot return to a profile it has already visited. Since there are only \(|\mathbf S|\) profiles, it can make at most \(|\mathbf S|-1\) updates. At its terminal profile, every player must be best responding, so it is a pure Nash equilibrium. \(\square\)
Players need not know \(P\) to use best responses; the potential is a tool for analyzing their joint behavior. The proof also explains two restrictions. Allowing moves between tied best responses would remove strict increase. Allowing simultaneous updates would remove the unilateral-change condition. In the coordination game, simultaneous best responses cycle from \((a,b)\) to \((b,a)\) and back.
Two familiar examples of potential games follow:
This example shows that the existence of pure equilibrium does not ensure convergence.
6.1.4 An application: congestion on two routes
Congestion games are an important class of potential games (Rosenthal 1973). Consider two drivers who choose routes \(e_1\) and \(e_2\). The travel costs are
\[ c_1(1)=1,\quad c_1(2)=3,\qquad c_2(1)=c_2(2)=2. \]
Here \(c_e(k)\) is the cost of route \(e\) when \(k\) drivers use it. Each driver aims to minimize their own travel cost by picking \(e_1\) or \(e_2\). To express this objective in our framework, where players maximize utility, we define utility as the negative of travel cost: \[ u_i(\mathbf s) = -c_{s_i}(n_{s_i}(\mathbf s)), \] where \(s_i\) is the route chosen by driver \(i\) and the load \(n_{s_i}(\mathbf s)\) counts all drivers using that route. This gives payoffs
\[ \begin{array}{c|cc} & e_1 & e_2 \\ \hline e_1 & -3, -3 & -1, -2 \\ e_2 & -2, -1 & -2, -2 \end{array} \] A potential is
\[ P(\mathbf s)=-\sum_{e\in\{e_1,e_2\}} \sum_{k=1}^{n_e(\mathbf s)}c_e(k). \]
This game has two pure equilibria in which the drivers use separate routes.
| Profile | \((n_{e_1},n_{e_2})\) | Alice’s cost | Bob’s cost | \(P\) |
|---|---|---|---|---|
| \((e_1,e_1)\) | \((2,0)\) | \(3\) | \(3\) | \(-4\) |
| \((e_1,e_2)\) | \((1,1)\) | \(1\) | \(2\) | \(-3\) |
| \((e_2,e_1)\) | \((1,1)\) | \(2\) | \(1\) | \(-3\) |
| \((e_2,e_2)\) | \((0,2)\) | \(2\) | \(2\) | \(-4\) |
6.1.5 Cycling with misleading frequencies
In the matching-pennies cycle, each player uses \(H\) and \(T\) equally often. Their empirical marginals therefore approach the uniform mixed equilibrium, even though the current profile keeps changing. This situation is special to those payoffs. Consider the following zero-sum modification of matching pennies:
\[ \begin{array}{c|cc} & H & T \\ \hline H & 1000 & -1 \\ T & -1 & 1 \end{array} \]
The same four sequential best responses still form a cycle since Bob always prefers a mismatch, while Alice always prefers a match. Along repeated cycles, each player’s empirical frequencies again approach \((1/2,1/2)\). However, the unique mixed equilibrium is
\[ p_A^*(H)=p_B^*(H)=\frac{2}{1003}. \]
Thus averaging sequential best responses need not produce a Nash equilibrium, even in a two-player zero-sum game. This motivates fictitious play, in which players best respond to the empirical distributions of their opponents’ past actions rather than to their current actions.
6.2 Fictitious play
Best-response dynamics reacts to the opponents’ current strategies. Fictitious play instead reacts to the frequencies of their past strategies. The players act simultaneously in each round and observe the outcome afterward. No player sees the opponents’ current strategies before choosing.
6.2.1 Empirical distributions of play
After \(T\ge1\) rounds, player \(i\)’s empirical distribution is
\[ \widehat p_i^T(s_i) =\frac1T\sum_{t=1}^T\mathbf1\{s_i^t=s_i\}, \qquad s_i\in S_i. \]
Thus \(\widehat p_i^T(s_i)\) is the fraction of past rounds in which action \(s_i\) was used. Counts suffice to maintain it:
\[ \widehat p_i^{T+1}(s_i) =\widehat p_i^T(s_i) +\frac{\mathbf1\{s_i^{T+1}=s_i\}-\widehat p_i^T(s_i)}{T+1}. \]
There is also an empirical joint distribution over complete profiles:
\[ \mu^T(\mathbf s) =\frac1T\sum_{t=1}^T\mathbf1\{\mathbf s^t=\mathbf s\}, \qquad \mathbf s\in\mathbf S. \]
Its marginals are \(\widehat p_i^T\). In general, \(\mu^T(\mathbf s)\ne\prod_i\widehat p_i^T(s_i)\), since taking the product of marginals loses correlations between strategies played in the same round.
For example, consider a history alternating \((a,a)\) and \((b,b)\) in the coordination game. After an even number of rounds, \(\mu^T\) gives probability \(1/2\) to each diagonal profile and zero to mismatches. Each marginal is uniform, but their product gives probability \(1/4\) to all four profiles. The average realized utility is \(3/2\) per player, while independently sampling these marginals gives expected utility \(3/4\). This example describes the difference between the distributions, without assuming a particular learning rule generated that history.
6.2.2 The update rule
In fictitious play, a player uses each opponent’s past action frequencies to estimate that opponent’s mixed strategy. The player then chooses a best response to these estimates. The estimates are updated after every round, which allows the player to respond to opponents who are themselves adapting.
To calculate a best response, the player uses their own payoff function and the opponents’ empirical action frequencies. Knowledge of the opponents’ payoff functions or learning rules is unnecessary. If several actions maximize expected payoff, a specified tie-breaking rule determines which one is chosen.
6.2.3 A run in matching pennies
Use the matching-pennies matrix from Section 6.1. Initialize at \((H,H)\) and let both players choose \(H\) whenever indifferent.
| Round \(t\) | Alice’s action | Bob’s action | \(\widehat p_A^t(H)\) | \(\widehat p_B^t(H)\) |
|---|---|---|---|---|
| 1 | \(H\) | \(H\) | \(1\) | \(1\) |
| 2 | \(H\) | \(T\) | \(1\) | \(1/2\) |
| 3 | \(H\) | \(T\) | \(1\) | \(1/3\) |
| 4 | \(T\) | \(T\) | \(3/4\) | \(1/4\) |
| 5 | \(T\) | \(T\) | \(3/5\) | \(1/5\) |
| 6 | \(T\) | \(T\) | \(1/2\) | \(1/6\) |
| 7 | \(T\) | \(H\) | \(3/7\) | \(2/7\) |
| 8 | \(T\) | \(H\) | \(3/8\) | \(3/8\) |
Define \(\alpha=\widehat p_A^T(H)\) and \(\beta=\widehat p_B^T(H)\). The saddle-point gap is
\[ g(\alpha,\beta) =\max_{a_A}U_A(a_A,\widehat p_B^T) -\min_{a_B}U_A(\widehat p_A^T,a_B) =|2\beta-1|+|2\alpha-1|. \]
It is zero exactly at the equilibrium. It need not decrease at every round.
The strategies keep changing. What approaches equilibrium is the pair of empirical distributions, rather than the pure profile in the latest round.
6.2.4 What convergence means
Write \(E\subseteq\boldsymbol\Delta\) for the set of mixed Nash equilibria in a fixed game. Convergence of a sequence of profiles \(\widehat{\mathbf p}^{1},\widehat{\mathbf p}^{2},\dots\) to the equilibrium set means
\[ \operatorname{dist}(\widehat{\mathbf p}^{T},E)\longrightarrow0, \qquad T\longrightarrow\infty, \]
where distance is measured from the empirical mixed-strategy profile to the nearest Nash equilibrium using the Euclidean norm. If the game has several equilibria, the empirical profile may keep moving among their neighbourhoods without settling at a single point. Equivalently, whenever a subsequence of empirical profiles converges, its limit is a Nash equilibrium. This also says that its maximum deviation incentive from Section 3.1 tends to zero: for every \(\epsilon>0\) and all sufficiently large \(T\), the empirical profiles \(\widehat{\mathbf p}^{T}\) are \(\epsilon\)-Nash equilibria.
More generally, in any game, if the empirical mixed-strategy profiles generated by fictitious play converge, their limit is a Nash equilibrium.
Proof. Suppose a strategy \(s_i\) is not a best response to \(\mathbf p_{-i}^*\). Some other strategy then gives a strictly larger expected payoff. By continuity, this strict inequality remains true for all sufficiently large \(T\) and empirical profiles \(\widehat{\mathbf p}^{T}\). Thus, fictitious play never selects \(s_i\) again. The finitely many earlier uses of \(s_i\) have frequency tending to zero, so \(p_i^*(s_i)=0\). Every action in the support of \(p_i^*\) is consequently a best response to \(\mathbf p_{-i}^*\), which is the support characterization of Nash equilibrium. \(\square\)
6.2.5 Shapley’s fictitious-play counterexample
Fictitious play may fail to converge in a general finite game.
6.3 Regret minimization
Fictitious play asks which action is best against an estimated model of the opponents. Regret minimization asks a different question: how much better could I have done by using one fixed action throughout the observed history?
6.3.1 External regret: one fixed alternative
Fix a player \(i\) and a learning rule used by this player. The rule uses the available history, feedback, or a probability distribution from which an action is sampled. We evaluate the performance of player \(i\)’s learning rule through the received payoffs. Each opponent of player \(i\) may use a different learning rule.
In round \(t\), player \(i\) chooses action \(s_i^t\) according to their learning rule, while the opponents choose the profile \(\mathbf s_{-i}^t\), producing \(\mathbf s^t\). We assume that the opponents choose without observing \(s_i^t\); they may use the history of earlier rounds.
To evaluate player \(i\)’s choice, consider an alternative action \(s_i\in S_i\) and hold the opponents’ actions fixed at their actual choices \(\mathbf s_{-i}^t\). The instantaneous payoff difference for player \(i\) is
\[ r_i^t(s_i)=u_i(s_i,\mathbf s_{-i}^t)-u_i(s_i^t,\mathbf s_{-i}^t). \]
If player \(i\)’s rule randomizes, the sampled actions and hence \(\rho_i(T)\) are random. The guarantee must then specify a mode of convergence, such as convergence in expectation or almost surely.
After observing all \(T\) rounds, we ask which single action would have given player \(i\) the highest total payoff if used in every round against the opponents’ recorded choices. This is the best fixed action in hindsight. The comparison keeps those choices unchanged, even if the opponents’ rules would have reacted differently to another history of player \(i\)’s actions. Choosing a different alternative for each round would define a stronger benchmark. If player \(i\) did at least as well as every fixed action, their external regret is zero.
Allowing player \(i\) to compare with a fixed mixed strategy gives the same benchmark. Its cumulative expected payoff is a weighted average of the cumulative payoffs from fixed pure actions, so it cannot exceed the payoff of the best one.
6.3.2 Regret matching
Regret matching (Hart and Mas-Colell 2001) assigns probability to strategies in proportion to their positive accumulated regrets. The algorithm describes the decisions and updates of a single player \(i\).
The opponents may adapt to earlier play, but they cannot observe and react to the player’s current private sampled action before choosing their own strategies.
The finite-time bound is in expectation, not a bound for every sampled history. It says that expected external regret is sublinear in \(T\), so expected average regret vanishes. The almost-sure statement is the stronger asymptotic conclusion. Neither statement requires the opponents to use regret matching or to behave optimally.
6.3.3 The zero-sum case
For matrix games, vanishing external regret makes the empirical marginals approach Nash equilibrium strategies. Write \(u=u_1=-u_2\) and let \(\overline u_T=T^{-1}\sum_tu(\mathbf s^t)\) be the average realized payoff. By the definiton of regret and linearity,
\[ \begin{aligned} \max_{s_1}U(s_1,\widehat p_2^T)-\overline u_T&\le\rho_1(T),\\ \overline u_T-\min_{s_2}U(\widehat p_1^T,s_2)&\le\rho_2(T). \end{aligned} \]
Adding them gives the saddle-point gap
\[ \max_{a_1}U(a_1,\widehat p_2^T) -\min_{a_2}U(\widehat p_1^T,a_2) \le\rho_1(T)+\rho_2(T). \]
As in Section 4.8.5, this gap is the sum of the two players’ deviation incentives at the empirical mixed profile. Therefore \(\rho_1(T)+\rho_2(T)\le\epsilon\) certifies an \(\epsilon\)-Nash equilibrium. If both players have no external regret, the gap tends to zero. However, current strategies and current sampling distributions need not converge.