Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Direct Reciprocity

Sustained cooperation over time depends on players remembering past interactions and responding to them appropriately. This chapter begins with Axelrod’s computer tournaments, which identified strategies that succeed in the iterated Prisoner’s Dilemma, before focusing on reactive strategies: a tractable class that conditions only on the opponent’s last move.

A choice between a cooperate button and a defect button.

Figure 1:Cooperate or defect: in a repeated encounter each player presses one button at a time, with an eye on how the other has played before. Direct reciprocity studies how such conditional responses sustain cooperation.

Motivating Example: Research Collaboration

Alice and Bob are researchers who meet regularly to share results before submitting papers. At each meeting, each can choose to:

The payoff structure is that of a Prisoner’s Dilemma: mutual sharing is best collectively, but each individual has a short-term incentive to withhold. The Folk Theorem tells us that cooperation can be sustained in an infinitely repeated game: but it does not say how.

In practice, Alice and Bob remember only the last meeting. Alice might decide: “I’ll share if you shared last time, but withhold if you withheld.” This memory-one approach, conditioning solely on the previous round’s outcome, is both cognitively realistic and mathematically tractable.

This chapter asks: which reactive strategies actually sustain cooperation, and what are their long-run payoffs?

Theory

We start by giving a more general definition of Example: Prisoners’ Dilemma. This game captures the fundamental structure of direct reciprocity in a repeated game setting.

Definition: Prisoner’s Dilemma


The Prisoner’s Dilemma is the two-player symmetric game:

A=(RSTP)B=(RTSP)A = \begin{pmatrix} R & S\\ T & P \end{pmatrix}\qquad B = \begin{pmatrix} R & T\\ S & P \end{pmatrix}

with the constraints:

T>R>P>S2R>T+ST > R > P > S \qquad 2R > T + S

Example: Simplified Prisoner’s Dilemma

Under what conditions is the following game a Prisoner’s Dilemma?

A=(1μ1+μ0)B=ATA = \begin{pmatrix} 1 & -\mu \\ 1 + \mu & 0 \end{pmatrix}\qquad B = A^T

This requires 1+μ>11 + \mu > 1 and 0>μ0 > -\mu, both of which hold for μ>0\mu > 0. The constraint 2R>T+S2R > T + S gives 2>12 > 1, which always holds. This parametrisation is convenient: μ>0\mu > 0 is the only condition needed.

Axelrod’s Tournaments


In 1980, Robert Axelrod organised a computer tournament for the iterated Prisoner’s Dilemma Axelrod, 1980.

A second tournament with 62 submissions followed Axelrod, 1980. With participants now aware of TFT’s success, many strategies were designed specifically to counter it. TFT won again.


These results suggested four principles for successful cooperation:

Definition: Reactive Strategy


A reactive strategy in the Prisoner’s Dilemma is a pair (p,q)[0,1]2(p, q) \in [0, 1]^2 where:


The first move is typically set separately (often cooperate), since there is no prior history.

Example: Common Reactive Strategies

Strategy(p,q)(p, q)Description
Always Cooperate (AllC)(1,1)(1, 1)Cooperates regardless of opponent’s action
Always Defect (AllD)(0,0)(0, 0)Defects regardless of opponent’s action
Tit For Tat (TFT)(1,0)(1, 0)Copies opponent’s last move exactly
Generous TFT (GTFT)(1,ϵ)(1, \epsilon)TFT but occasionally forgives a defection
Random(1/2,1/2)(1/2, 1/2)Cooperates with probability 1/21/2 regardless of context
Generous Reciprocator(0.9,0.3)(0.9, 0.3)Strongly reciprocates cooperation; sometimes forgives
Suspicious Reciprocator(0.7,0.1)(0.7, 0.1)Cautiously cooperative; rarely forgives defection

Definition: Markov Chain of Two Reactive Strategies


When players with reactive strategies (p,q)(p, q) and (p,q)(p', q') play an infinitely repeated Prisoner’s Dilemma, the pair of actions at each round defines a Markov chain with state space S={CC,CD,DC,DD}\mathcal{S} = \{CC, CD, DC, DD\}.

The transition matrix PR4×4P \in \mathbb{R}^{4 \times 4}, with rows and columns ordered as (CC,CD,DC,DD)(CC, CD, DC, DD), is:

M=(ppp(1p)(1p)p(1p)(1p)qpq(1p)(1q)p(1q)(1p)pqp(1q)(1p)q(1p)(1q)qqq(1q)(1q)q(1q)(1q))M = \begin{pmatrix} pp' & p(1-p') & (1-p)p' & (1-p)(1-p') \\ qp' & q(1-p') & (1-q)p' & (1-q)(1-p') \\ pq' & p(1-q') & (1-p)q' & (1-p)(1-q') \\ qq' & q(1-q') & (1-q)q' & (1-q)(1-q') \\ \end{pmatrix}

where rows correspond to the current state and columns to the next state.


The entry MssM_{ss'} is the probability of transitioning from state ss to state ss'. For example, from state CDCD (player 1 cooperated, player 2 defected): player 1 now cooperates with probability qq (their opponent defected), while player 2 now cooperates with probability pp' (their opponent cooperated).

Theorem: Long-Run Average Payoffs via Stationary Distribution


If the Markov chain defined by (p,q)(p, q) and (p,q)(p', q') is ergodic (see Appendix A3), it has a unique stationary distribution π=(πCC,πCD,πDC,πDD)\pi = (\pi_{CC}, \pi_{CD}, \pi_{DC}, \pi_{DD}) satisfying:

πM=πsSπs=1\pi M = \pi \qquad \sum_{s \in \mathcal{S}} \pi_s = 1

The long-run average payoffs are then:

uˉ1=RπCC+SπCD+TπDC+PπDD\bar{u}_1 = R\,\pi_{CC} + S\,\pi_{CD} + T\,\pi_{DC} + P\,\pi_{DD}
uˉ2=RπCC+TπCD+SπDC+PπDD\bar{u}_2 = R\,\pi_{CC} + T\,\pi_{CD} + S\,\pi_{DC} + P\,\pi_{DD}

Theorem: Steady-State Distribution for Two Reactive Strategies


When both players use strictly non-deterministic reactive strategies (0<p,q,p,q<10 < p, q, p', q' < 1), the stationary distribution has a closed form. Define:

r1=pqr2=pqr_1 = p - q \qquad r_2 = p' - q'

and:

s1=qr1+q1r1r2s2=qr2+q1r1r2s_1 = \frac{q' r_1 + q}{1 - r_1 r_2} \qquad s_2 = \frac{q r_2 + q'}{1 - r_1 r_2}

Then the unique stationary distribution is:

π=(s1s2,  s1(1s2),  (1s1)s2,  (1s1)(1s2))\pi = \bigl(s_1 s_2,\; s_1(1-s_2),\; (1-s_1)s_2,\; (1-s_1)(1-s_2)\bigr)

and the long-run average payoffs are:

uˉ1=Rs1s2+Ss1(1s2)+T(1s1)s2+P(1s1)(1s2)\bar{u}_1 = R\,s_1 s_2 + S\,s_1(1-s_2) + T\,(1-s_1)s_2 + P\,(1-s_1)(1-s_2)
uˉ2=Rs1s2+Ts1(1s2)+S(1s1)s2+P(1s1)(1s2)\bar{u}_2 = R\,s_1 s_2 + T\,s_1(1-s_2) + S\,(1-s_1)s_2 + P\,(1-s_1)(1-s_2)

The values s1s_1 and s2s_2 are the long-run cooperation probabilities of each player. The stationary distribution factorises as a product of marginals, so the players’ long-run actions are independent despite their strategies being correlated round-to-round.

Proof

Verify by direct substitution: set π=(s1s2,s1(1s2),(1s1)s2,(1s1)(1s2))\pi = (s_1 s_2,\, s_1(1-s_2),\, (1-s_1)s_2,\, (1-s_1)(1-s_2)) and confirm πM=π\pi M = \pi holds with the transition matrix from the definition above:

πM=(s1s2,s1(1s2),(1s1)s2,(1s1)(1s2))P\pi M = (s_1 s_2,\, s_1(1-s_2),\, (1-s_1)s_2,\, (1-s_1)(1-s_2)) P

After carrying out the multiplication, each component of πM\pi M reduces to the corresponding component of π\pi when s1s_1 and s2s_2 satisfy the given expressions. The algebra is routine but lengthy.

Example: Long-run payoffs for two reactive strategies

Consider the contractor Prisoner’s Dilemma with R=3,S=0,T=5,P=1R=3, S=0, T=5, P=1, and two reactive strategies:

From state CCCC: player 1 cooperates with p=0.9p=0.9, player 2 with p=0.7p'=0.7:

CCCC:0.63,CCCD:0.27,CCDC:0.07,CCDD:0.03CC \to CC: 0.63,\quad CC \to CD: 0.27,\quad CC \to DC: 0.07,\quad CC \to DD: 0.03

From state CDCD: player 1 cooperates with q=0.3q=0.3, player 2 with p=0.7p'=0.7:

CDCC:0.21,CDCD:0.09,CDDC:0.49,CDDD:0.21CD \to CC: 0.21,\quad CD \to CD: 0.09,\quad CD \to DC: 0.49,\quad CD \to DD: 0.21

From state DCDC: player 1 cooperates with p=0.9p=0.9, player 2 with q=0.1q'=0.1:

DCCC:0.09,DCCD:0.81,DCDC:0.01,DCDD:0.09DC \to CC: 0.09,\quad DC \to CD: 0.81,\quad DC \to DC: 0.01,\quad DC \to DD: 0.09

From state DDDD: player 1 cooperates with q=0.3q=0.3, player 2 with q=0.1q'=0.1:

DDCC:0.03,DDCD:0.27,DDDC:0.07,DDDD:0.63DD \to CC: 0.03,\quad DD \to CD: 0.27,\quad DD \to DC: 0.07,\quad DD \to DD: 0.63

So the full transition matrix is:

M=(0.630.270.070.030.210.090.490.210.090.810.010.090.030.270.070.63)M = \begin{pmatrix} 0.63 & 0.27 & 0.07 & 0.03 \\ 0.21 & 0.09 & 0.49 & 0.21 \\ 0.09 & 0.81 & 0.01 & 0.09 \\ 0.03 & 0.27 & 0.07 & 0.63 \\ \end{pmatrix}

Since all four parameters are strictly interior, we apply the closed-form theorem. With r1=0.90.3=0.6r_1 = 0.9 - 0.3 = 0.6 and r2=0.70.1=0.6r_2 = 0.7 - 0.1 = 0.6:

s1=0.1×0.6+0.310.6×0.6=0.360.64=916s2=0.3×0.6+0.10.64=0.280.64=716s_1 = \frac{0.1 \times 0.6 + 0.3}{1 - 0.6 \times 0.6} = \frac{0.36}{0.64} = \frac{9}{16} \qquad s_2 = \frac{0.3 \times 0.6 + 0.1}{0.64} = \frac{0.28}{0.64} = \frac{7}{16}

The stationary distribution is:

π=(916716,  916916,  716716,  716916)=(63256,  81256,  49256,  63256)\pi = \left(\frac{9}{16} \cdot \frac{7}{16},\; \frac{9}{16} \cdot \frac{9}{16},\; \frac{7}{16} \cdot \frac{7}{16},\; \frac{7}{16} \cdot \frac{9}{16}\right) = \left(\frac{63}{256},\; \frac{81}{256},\; \frac{49}{256},\; \frac{63}{256}\right)

Long-run average payoffs:

uˉ1=363+081+549+163256=4972561.94\bar{u}_1 = \frac{3 \cdot 63 + 0 \cdot 81 + 5 \cdot 49 + 1 \cdot 63}{256} = \frac{497}{256} \approx 1.94
uˉ2=363+581+049+163256=6572562.57\bar{u}_2 = \frac{3 \cdot 63 + 5 \cdot 81 + 0 \cdot 49 + 1 \cdot 63}{256} = \frac{657}{256} \approx 2.57

The Suspicious Reciprocator earns a higher long-run payoff. Despite cooperating less, their lower generosity extracts value from the Generous Reciprocator’s willingness to forgive defections.

Exercises

Programming

Computing the Stationary Distribution of a Reactive Strategy Pair

Given the transition matrix PP for two reactive strategies, the stationary distribution satisfies πP=π\pi P = \pi. We can find it by solving the linear system (PTI)πT=0(P^T - I)\pi^T = 0 subject to πi=1\sum \pi_i = 1.

import numpy as np

def reactive_transition_matrix(p, q, p_prime, q_prime):
    """
    Build the 4x4 transition matrix for reactive strategies (p,q) and (p',q').
    States are ordered: CC, CD, DC, DD.
    """
    M = np.array([
        [p * p_prime,       p * (1 - p_prime),       (1 - p) * p_prime,       (1 - p) * (1 - p_prime)],
        [q * p_prime,       q * (1 - p_prime),       (1 - q) * p_prime,       (1 - q) * (1 - p_prime)],
        [p * q_prime,       p * (1 - q_prime),       (1 - p) * q_prime,       (1 - p) * (1 - q_prime)],
        [q * q_prime,       q * (1 - q_prime),       (1 - q) * q_prime,       (1 - q) * (1 - q_prime)],
    ])
    return M

def stationary_distribution(M):
    """
    Compute the stationary distribution of a transition matrix M.
    """
    n = M.shape[0]
    A = (M.T - np.eye(n))
    A[-1, :] = 1
    b = np.zeros(n)
    b[-1] = 1
    return np.linalg.solve(A, b)

# Generous Reciprocator vs Suspicious Reciprocator
p, q = 0.9, 0.3
p_prime, q_prime = 0.7, 0.1

M = reactive_transition_matrix(p, q, p_prime, q_prime)
print("Transition matrix:")
print(np.round(M, 4))

pi = stationary_distribution(M)
print("\nStationary distribution (CC, CD, DC, DD):")
print(np.round(pi, 4))
Transition matrix:
[[0.63 0.27 0.07 0.03]
 [0.21 0.09 0.49 0.21]
 [0.09 0.81 0.01 0.09]
 [0.03 0.27 0.07 0.63]]

Stationary distribution (CC, CD, DC, DD):
[0.2461 0.3164 0.1914 0.2461]
# Compute long-run average payoffs
R, S, T, P = 3, 0, 5, 1

u1_bar = R * pi[0] + S * pi[1] + T * pi[2] + P * pi[3]
u2_bar = R * pi[0] + T * pi[1] + S * pi[2] + P * pi[3]

print(f"Long-run average payoff for Player 1: {u1_bar:.4f}")
print(f"Long-run average payoff for Player 2: {u2_bar:.4f}")
Long-run average payoff for Player 1: 1.9414
Long-run average payoff for Player 2: 2.5664

Using the Axelrod Library

The axelrod Python library Knight et al., 2016 provides over 240 strategies and tools to run reproducible tournaments, extending Axelrod’s original experiments to much larger and more diverse strategic populations.

Studying Reactive Strategies

The Axelrod library provides axl.ReactivePlayer, which takes the reactive strategy parameters (p,q)(p, q) directly, matching the notation used throughout this chapter.

The following code runs a long match between the Generous Reciprocator (p,q)=(0.9,0.3)(p, q) = (0.9, 0.3) and the Suspicious Reciprocator (p,q)=(0.7,0.1)(p', q') = (0.7, 0.1) from the example above and compares the result to the closed-form payoffs.

import axelrod as axl
import numpy as np

generous = axl.ReactivePlayer(probabilities=(0.9, 0.3))
suspicious = axl.ReactivePlayer(probabilities=(0.7, 0.1))

match = axl.Match([generous, suspicious], turns=10000, seed=0)
match.play()
u1, u2 = match.final_score_per_turn()
print(f"Simulated:   Generous={u1:.4f}, Suspicious={u2:.4f}")
print(f"Theoretical: Generous={497/256:.4f}, Suspicious={657/256:.4f}")
/home/runner/work/gtb/gtb/.venv/lib/python3.14/site-packages/axelrod/strategies/zero_determinant.py:25: SyntaxWarning: "\m" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\m"? A raw string is also an option.
  &s_{min} &= -\min\\left( \\frac{T - l}{l - S}, \\frac{l - S}{T - l}\\right) <= s <= 1
Simulated:   Generous=1.9477, Suspicious=2.5772
Theoretical: Generous=1.9414, Suspicious=2.5664

Exploring Wider Populations

Reactive strategies are a subclass of memory-one strategies, which condition on the full previous outcome (a1,a2){C,D}2(a_1, a_2) \in \{C, D\}^2 rather than just the opponent’s last action. The Axelrod library includes many built-in memory-one strategies.

import axelrod as axl
import numpy as np

# Some notable memory-one strategies included in the library
players = [
    axl.TitForTat(),       # reactive: (p, q) = (1, 0)
    axl.ZDGTFT2(),         # generous zero-determinant strategy
    axl.ZDExtortion(),     # extortionate zero-determinant strategy
    axl.Cooperator(),      # reactive: (p, q) = (1, 1)
    axl.Defector(),        # reactive: (p, q) = (0, 0)
]

tournament = axl.Tournament(
    players=players, turns=200, repetitions=20, seed=0
)
results = tournament.play(progress_bar=False)
print("Ranking:")
for rank, name in enumerate(results.ranked_names):
    print(f"  {rank + 1}. {name}")
Ranking:
  1. Defector
  2. ZD-Extortion: 0.2, 0.1, 1
  3. Tit For Tat
  4. ZD-GTFT-2: 0.25, 0.5
  5. Cooperator

The Axelrod library documentation includes a tutorial showing how to replicate Axelrod’s original 1980 tournament, providing a reproducible starting point for exploring how strategy performance depends on the composition of the population.

Notable Research

The seminal empirical work on direct reciprocity is due to Robert Axelrod Axelrod, 1980Axelrod, 1980, synthesised in his widely cited book Axelrod, 1984. As described in Section 3, Axelrod’s tournaments established Tit For Tat as the canonical cooperative strategy and produced four heuristics for successful play.

Subsequent work has challenged these heuristics. The development of the Axelrod Python library Knight et al., 2016 enabled systematic and reproducible analysis across a far greater population of strategies. In particular, Glynatsi et al., 2024 studied 45,600 tournaments across diverse strategic populations and parameter regimes, finding that the original heuristics do not generalise. The revised empirical findings suggest:

The observation that being envious can be beneficial echoes a landmark theoretical result. Press & Dyson, 2012 introduced zero-determinant strategies, memory-one strategies that can unilaterally enforce linear payoff relationships, including extortionate dynamics. This paper was described by MIT Technology Review as having set “the world of game theory on fire.”

However, Hilbe et al., 2013 and Knight et al., 2018 showed that extortionate strategies do not tend to survive under evolutionary dynamics, tempering the initial excitement and reinforcing the importance of adaptability.

Conclusion

This chapter examined how cooperation can emerge in pairwise repeated interactions. Axelrod’s tournaments identified Tit For Tat as the canonical cooperative strategy and produced four heuristics for successful play. These heuristics have since been challenged: modern computational work, enabled by large-scale reproducible tournaments, finds that what succeeds depends heavily on the strategic population and game parameters.

The theoretical core of the chapter is the reactive strategy framework. When two players use reactive strategies, their interaction defines a Markov chain over outcome pairs, and the stationary distribution gives long-run average payoffs. This connects the intuitions from Axelrod’s tournaments to a rigorous mathematical foundation.

Table 1 summarises the key concepts.

Table 1:Summary of key concepts in direct reciprocity

ConceptDescription
Prisoner’s DilemmaA symmetric game where Defect dominates but mutual cooperation is socially optimal
Reactive strategy (p,q)(p, q)Cooperates with probability pp after C, qq after D
Tit For TatCooperates first, then copies opponent’s last move
Markov chain of strategiesStates are outcome pairs; transitions determined by (p,q)(p,q) and (p,q)(p',q')
Stationary distributionLong-run fraction of time spent in each state
Long-run average payoffPayoff weighted by stationary distribution
Zero-determinant strategiesMemory-one strategies enforcing linear payoff relationships
Axelrod’s tournamentsEmpirical tournaments establishing TFT’s success and four cooperation heuristics


Solutions

References
  1. Axelrod, R. (1980). Effective choice in the prisoner’s dilemma. Journal of Conflict Resolution, 24(1), 3–25.
  2. Axelrod, R. (1980). More effective choice in the prisoner’s dilemma. Journal of Conflict Resolution, 24(3), 379–403.
  3. Knight, V. A., Campbell, O., Harper, M., Langner, K. M., Campbell, J., Campbell, T., Carney, A., Chorley, M., Davidson-Pilon, C., Glass, K., & others. (2016). An open framework for the reproducible study of the iterated prisoner’s dilemma. Journal of Open Research Software, 4(1).
  4. Axelrod, R. (1984). The Evolution of Cooperation. Basic Books.
  5. Glynatsi, N. E., Knight, V., & Harper, M. (2024). Properties of winning Iterated Prisoner’s Dilemma strategies. PLOS Computational Biology, 20(12), e1012644.
  6. Press, W. H., & Dyson, F. J. (2012). Iterated Prisoner’s Dilemma contains strategies that dominate any evolutionary opponent. Proceedings of the National Academy of Sciences, 109(26), 10409–10413.
  7. Hilbe, C., Nowak, M. A., & Sigmund, K. (2013). Evolution of extortion in iterated prisoner’s dilemma games. Proceedings of the National Academy of Sciences, 110(17), 6913–6918.
  8. Knight, V., Harper, M., Glynatsi, N. E., & Campbell, O. (2018). Evolution reinforces cooperation with the emergence of self-recognition mechanisms: An empirical study of strategies in the Moran process for the iterated prisoner’s dilemma. PloS One, 13(10), e0204981.