Lesson 1 of 2 · Game Theory
Strategic games and Nash equilibrium
In a strategic game each player's payoff depends on the others' choices; a Nash equilibrium is a state in which no player benefits from changing strategy unilaterally, it can be pure or mixed, and every finite game has at least one mixed equilibrium.
Lesson contents
1 Introduction
When two teams train competing models, two intelligent agents negotiate a price, or two self-driving cars compete for the same lane, the best decision for each side depends on the other's decision. Game theory gives us a precise language for analyzing these situations.
Learning objectives
- Represent a two-player game with two payoff matrices
- Find best responses and pure Nash equilibria
- Compute the mixed equilibrium in 2×2 games with the indifference principle
- Distinguish equilibrium from collective optimality (the prisoner's dilemma)
2 Why study this topic?
Multi-agent systems and multi-agent reinforcement learning rest on equilibrium concepts, generative adversarial networks are a game between a generator and a discriminator, and explaining model decisions with Shapley values (SHAP) comes from cooperative game theory. Understanding Nash equilibrium is the starting point.
3 Theoretical explanation
The game in strategic form
Two players, each with a set of strategies. Matrix A gives the payoffs of the first player (row) and matrix B the payoffs of the second (column). In the prisoner's dilemma (payoffs are years in prison with a negative sign):
| Cooperate | Defect | |
|---|---|---|
| Cooperate | (−1, −1) | (−3, 0) |
| Defect | (0, −3) | (−2, −2) |
Best response and Nash equilibrium
A player's best response is the strategy that maximizes their payoff given the other's strategy. The pair \((i^*, j^*)\) is a Nash equilibrium if each strategy is a best response to the other:
\[A_{i^*j^*} \ge A_{ij^*}\;\forall i,\qquad B_{i^*j^*} \ge B_{i^*j}\;\forall j\]
In the prisoner's dilemma "defect" is better for each player whatever the other chooses, so the only equilibrium is (defect, defect) with payoff \((-2, -2)\), even though (cooperate, cooperate) is better for both. An equilibrium is not necessarily collectively optimal.
Mixed equilibrium
In "matching pennies" there is no pure equilibrium. The solution is for each player to choose randomly with specific probabilities. The indifference principle: in a mixed equilibrium each player makes the opponent indifferent between their two strategies. In a 2×2 game, if the second player plays the first column with probability q:
\[q A_{11} + (1-q)A_{12} = q A_{21} + (1-q)A_{22} \Rightarrow q^* = \frac{A_{22} - A_{12}}{A_{11} - A_{12} - A_{21} + A_{22}}\]
Similarly \(p^*\) from matrix B. In the "battle of the sexes" \(A = \begin{bmatrix}2&0\\0&1\end{bmatrix}\) and \(B = \begin{bmatrix}1&0\\0&2\end{bmatrix}\): two pure equilibria, and a mixed equilibrium \(p^* = 2/3\) and \(q^* = 1/3\).
Nash's theorem
Every finite game (a finite number of players and strategies) has at least one Nash equilibrium in mixed strategies (Nash, 1950). But finding it in large games is computationally hard, which is why learning dynamics that may or may not converge to it are studied.
4 Mathematical definitions
- Nash equilibrium
- A strategy profile in which no player can increase their payoff by changing strategy unilaterally.
- Best response
- The strategy that maximizes a player's payoff given the other players' strategies.
- Mixed strategy
- A probability distribution over the pure strategies.
- Dominant strategy
- A strategy better than the others whatever the other players do.
- Nash equilibrium
- A strategy profile in which no player gains by deviating alone.\[A_{i^*j^*}\ge A_{ij^*},\;B_{i^*j^*}\ge B_{i^*j}\]
- Mixed strategy
- A probability distribution over pure strategies; at equilibrium it is computed with the indifference principle.\[q^*=\frac{A_{22}-A_{12}}{A_{11}-A_{12}-A_{21}+A_{22}}\]
- Best response
- The strategy that maximizes a player's payoff given the other players' strategies.\[\arg\max_i A_{ij}\]
5 The equations
6 Step-by-step worked example
The prisoner's dilemma
Problem: Find the Nash equilibrium in the prisoner's dilemma.
- If the other cooperates: defecting gives 0 versus −1.
- If the other defects: defecting gives −2 versus −3.
- Defection is dominant for both players.
Result: (defect, defect) with payoff (−2, −2)
Mixed equilibrium
Problem: Find the mixed equilibrium of the battle of the sexes.
- \(q^* = (1 - 0)/(2 - 0 - 0 + 1) = 1/3\).
- \(p^* = (2 - 0)/(1 - 0 - 0 + 2) = 2/3\).
Result: \(p^* = 2/3\), \(q^* = 1/3\), and the first player's expected payoff is \(0.6667\)
No pure equilibrium
Problem: Prove that matching pennies has no pure equilibrium.
- In every cell one of them wins 1 and the other loses 1.
- The loser always benefits from changing their choice.
Result: The only equilibrium is mixed, \((1/2, 1/2)\)
7 Practical application in AI
- Multi-agent systems: Reinforcement learning agents in a shared environment sometimes converge to an equilibrium and sometimes cycle around it.
- Mechanism design and auctions: The rules of ad auctions are designed so that truthful bidding is an equilibrium.
- Shapley values: The SHAP measure for explaining models comes from fair payoff division in cooperative games.
8 Interactive lab linked to the lesson
Two-player games with two payoff matrices, pure and mixed Nash equilibria and the two best-response functions; zero-sum games and the minimax theorem; and learning dynamics: simultaneous and alternating gradient descent-ascent, and fictitious play.
Open the Game Theory Lab9 Practice exercises
Review questions for reflection
- Why is (cooperate, cooperate) not an equilibrium in the prisoner's dilemma?
- Why is \(q^*\) computed from the first player's matrix and not the second's?
Common mistakes
- Confusing a Nash equilibrium with the best outcome for everyone.
- Looking for a player's best response in the other player's matrix.
- Assuming that every game has a pure equilibrium.
- Interpreting a mixed strategy as hesitation or ignorance; it is a deliberate random choice that prevents exploitation.
10 Lesson summary
- Nash equilibrium: no one benefits from deviating unilaterally.
- An equilibrium can be worse for everyone than another alternative.
- The mixed equilibrium is computed with the indifference principle.
- Every finite game has a mixed equilibrium.
11 Short quiz
5 questions · 10 minutes · pass mark 60% — passing it completes the lesson.
