Skip to content
Tutorials Center
My learning

Topics

Lesson 23 of 37 ยท Repeated and Evolutionary Games

The Repeated Prisoner's Dilemma

See how repetition can sustain cooperation in the prisoner's dilemma: finite versus infinite horizons, discounting, tit-for-tat, grim trigger, and a Python simulator.

In a one-shot prisoner's dilemma, defection is the dominant action, and both players end up worse off than if both had cooperated. Yet in real life, neighbors, firms and colleagues often cooperate. The main reason is that they meet again. When today's action affects tomorrow's treatment, the future casts a "shadow" over present choices, and cooperation can become rational.

This lesson builds a small simulator for repeated games, then shows when cooperation can be an equilibrium and when it cannot.

The stage game

We use the standard payoffs for a row player: T (temptation: defect while the other cooperates) = 5, R (reward: both cooperate) = 3, P (punishment: both defect) = 1, S (sucker: cooperate while the other defects) = 0. The ordering T > R > P > S makes defection dominant, and R > (T + S) / 2 makes mutual cooperation better than taking turns exploiting each other.

Cooperate Defect
Cooperate 3, 3 0, 5
Defect 5, 0 1, 1

A repeated game plays this stage game many times. A strategy now depends on the history: what each player did in previous rounds.

A simulator

Each strategy is a function that receives the two histories (own moves and the opponent's) and returns "C" or "D".

Python Playing repeated prisoner's dilemmas

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Tit-for-tat (TFT) cooperates first and then copies the opponent's last move. It is "nice" (never defects first), "retaliating", and "forgiving" (returns to cooperation after the opponent does). Grim trigger is the unforgiving cousin: one defection and it defects forever.

A known end ruins cooperation

Suppose the game is played exactly 10 times and both players know it. On round 10 there is no future, so each plays the dominant action D. Given that round 10 is a defection no matter what, round 9 also has no future consequences, so D again. The same argument runs back to round 1: the only subgame-perfect equilibrium of the finitely repeated prisoner's dilemma is to defect every round. That is backward induction applied to a repeated game, exactly like the centipede game.

The prediction fails in practice when the end is uncertain or far away, and in experiments players cooperate for a while, then defect near the end.

An uncertain end: discounting

Now suppose the game never ends for sure. After each round, it continues with probability delta (a number between 0 and 1); equivalently, future payoffs are discounted by delta each round. The expected number of rounds is 1 / (1 - delta). Payoffs are summed with weights: a payoff x received t rounds from now counts as delta^t times x.

Consider the grim trigger strategy pair. If both follow it, each earns R every round: R / (1 - delta). If a player deviates by defecting once, that round pays T, and then both defect forever, giving P in every later round: T + delta * P / (1 - delta). Cooperation is an equilibrium when

R / (1 - delta) >= T + delta * P / (1 - delta)

which rearranges to delta >= (T - R) / (T - P). With T = 5, R = 3, P = 1 that is delta >= 2 / 4 = 0.5. The more the future matters, the easier cooperation becomes.

Cooperation needs a future

Known last round Defection unravels backward
Unknown end Each round may be followed by another
Patience (delta) How much the future counts
Cooperate if delta is big enough Here delta of at least 0.5

Threat of future punishment replaces the missing one-shot incentive.

1 / 2
Python The critical discount factor

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At exactly 0.5 the two values are equal, and cooperation is only just sustainable.

Simulating a game with a random end

The formulas can be checked by simulation. In each round, the game continues with probability delta. Average the results of many games.

Python Random-length repeated games

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With a low delta, defecting against TFT earns more than cooperating (the sucker round is cheap and the game ends soon). With a high delta, cooperating with TFT beats exploiting it once and facing retaliation.

Other lessons from repetition

  • Credibility of punishment. Grim trigger's punishment is a Nash equilibrium of the infinite game, and in this game it is also subgame perfect: after a defection, both defecting forever is a stage-game equilibrium.
  • Noise. If moves are sometimes misread or mistaken, TFT can enter endless retaliation spirals. More forgiving strategies, like "generous TFT", cope better.
  • Observability. Punishment needs detection. If defections are hard to see, cooperation is fragile.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In a prisoner's dilemma repeated exactly 10 times with a known end, what does subgame-perfect equilibrium predict?

    In the last round defection is dominant; given that, the second-to-last round is effectively last, and so on back to round 1.
  2. 2. With T = 5, R = 3, P = 1, what is the smallest discount factor that sustains cooperation under grim trigger?

    delta >= (T - R) / (T - P) = 2 / 4 = 0.5.
  3. 3. Which describes tit-for-tat?

    TFT starts nice and then mirrors, so it punishes defection but also forgives.
  4. 4. Why does a higher discount factor help cooperation?

    Patient players weigh the loss of future cooperation heavily, which outweighs the one-time gain.

Summary

  • A repeated game lets strategies depend on history, which allows rewards and punishments.
  • A known final round makes defection the only subgame-perfect outcome in a finitely repeated prisoner's dilemma.
  • With an uncertain end or discounting, cooperation can be an equilibrium once delta >= (T - R) / (T - P).
  • Tit-for-tat is nice, retaliating and forgiving; grim trigger never forgives.
  • Noise, observability and patience determine how robust cooperation is.

Next: The Folk Theorem and Repeated-Game Equilibria