Iterated prisoner's dilemma (source code)

= Iterated prisoner's dilemma

The <iterated prisoner's dilemma> is a <repeated game> with a <prisoner's dilemma> at each round. Earlier choices can change later <best responses>: a present gain from defection may be outweighed by lost future cooperation. A <pure strategy> now specifies an action after every possible observed history, including histories that its own prescribed play would never reach. The horizon, observations, initial actions, and <payoff> convention must be specified before assessing a <Nash equilibrium> or <subgame perfect equilibrium>.

For the following worked example, repeat the <prisoner's dilemma> above infinitely at rounds $t=0,1,\ldots$. Assume public perfect monitoring: after each round both players observe both actions exactly, without error. They share a <discount factor> $0\le\delta<1$ and evaluate a path of stage <payoffs> $u_i(t)$ using the normalized discounted <payoff>
$$
U_i=(1-\delta)\sum_{t=0}^{\infty}\delta^t u_i(t).
$$
The round-zero weight is one before normalization, including when $\delta=0$. A larger <discount factor> gives future <payoffs> more weight; the <geometric series> makes a constant stage <payoff> have the same normalized value. These assumptions and normalization follow https://ocw.mit.edu/courses/6-254-game-theory-with-engineering-applications-spring-2010/5a158a7558165d0e22b5b27fcfa01713_MIT6_254S10_lec15.pdf[Asu Ozdaglar, MIT 6.254, lecture 15, slides 6–15]{ref}. The numerical <payoffs> here are our $3,5,0,1$ example; the lecture uses a different table.

Suppose both players use <grim trigger>: play $C$ initially and while every past action of both players was $C$; after any observed $D$, play $D$ forever. With no <unilateral deviation>, each gets normalized <payoff> $3$. A first <unilateral deviation> to $D$ earns $5$ now, then at most $1$ each round because the opponent switches permanently to <always defect>. The deviator attains that continuation <payoff> by choosing $D$ thereafter. At any history of mutual cooperation, the comparison is therefore
$$
U_{\mathrm{cooperate}}=3,\qquad U_{\mathrm{deviate}}=(1-\delta)5+\delta\cdot1=5-4\delta.
$$
Cooperation is a <best response> precisely when
$$
3\ge 5-4\delta\quad\Longleftrightarrow\quad\delta\ge\frac12.
$$
Equivalently, without normalization the <geometric series> gives
$$
V_{\mathrm{cooperate}}=\frac{3}{1-\delta},\qquad V_{\mathrm{deviate}}=5+\frac{\delta}{1-\delta}.
$$
Multiplying both unnormalized <payoffs> by the same positive factor $1-\delta$ leaves the <best response> comparison unchanged.

\Image[/repeated-prisoners-dilemma-discount-threshold.png]
{title=Repeated prisoner's dilemma: normalized cooperation and first-deviation payoffs cross at discount factor one half}

For example, with <discount factor> $\delta=1/4$, the first <unilateral deviation> gives normalized <payoff> $4>3$, so mutual <grim trigger> is not a <Nash equilibrium>. At $\delta=3/4$, it gives $2<3$, so cooperation is preferable. At $\delta=1/2$ the two <payoffs> tie: the incentive to cooperate is weak, which is sufficient for a <subgame perfect equilibrium>.

The punishment is credible after every history containing a defection: the opponent's <pure strategy> then prescribes $D$ forever, and $D$ remains the stage <best response>, earning $1$ rather than $0$. Together with the cooperative-history comparison, this establishes mutual <grim trigger> as a <subgame perfect equilibrium> for $1/2\le\delta<1$. Delaying the first <unilateral deviation> merely delays the same gain or loss; further cooperation during punishment only lowers the deviator's <payoff>. Mutual <always defect> also remains a <subgame perfect equilibrium>, so patience permits cooperation without making it inevitable.

This calculation assumes an infinite horizon and $\delta<1$; it does not define a discounted <payoff> at $\delta=1$. With a finite, commonly known final round and positive weight on each round, <backward induction> instead gives mutual defection in every round of this stage game. Observational errors change the model too: one mistaken defection permanently activates <grim trigger>. Historical dependence, initial memories, and the <payoff> time convention also affect whether a cooperative rule resists or invades other <pure strategies>; the existing <reactive strategy> and <Tit for tat> discussions concern those additional questions.