pdlab prisoner's dilemma gen 0 · fC 1.000 · b 1.90

What this page is. The interactive companion to a game-theory final project on the Prisoner's Dilemma: one game taken through rationality, selection, noise and learning. Everything here is computed in the page or taken from the canonical run of the pdlab Python package. The full derivations and proofs are in the report (PDF, 49 pages); the code, tests and reviews are in the repository. Scroll to operate it; the lattice behind the panels is a real simulation and scrolling is its clock.

Payoffs · one-shot game

The Prisoner's Dilemma, live.

Edit any cell. Every threshold on this page follows the matrix; every simulation result is the canonical one from the pdlab Python package, cross-checked against the axelrod library.

they cooperatethey defect
you cooperate
R · reward
S · sucker
you defect
T · temptation
P · punishment

Editing a cell updates every threshold on the page.

δ* Grim = (T−R)/(T−P)
δ* TFT = max((T−R)/(T−P), (T−R)/(R−S))
(P−S)/(T−P), the after-DD ceiling

Python, canonical matrix: δ*Grim = , δ*TFT = .

Opponent · hidden

Round 1. The hidden strategy has already chosen.

Pick one. Whatever you do, the matrix cell you land in lights up.

0 you · 0 them

Behind this panel: a 99 × 99 lattice of cooperators with one defector in the middle. It has not moved yet. Scroll.

Finite horizon · backward induction

200rounds still cooperative, of 200

Two hundred rounds against the same opponent, and both of you know it. In the last round nothing follows, so defecting is simply better. Both of you can see that.

So round 199 is the last one where behaviour can still matter. Except that it cannot, because round 200 is already lost. Defect there too.

Every round falls to the one after it, all the way back to the first. The unique subgame-perfect outcome of a known-length game is mutual defection from the opening move.

Take the end away and the arithmetic changes. With a continuation probability δ the future is worth 1/(1−δ) rounds, and patience has a price you can compute.

Play · 17 opponents

Your hand on the lever.

Pick an opponent and play twenty rounds.

you

them

Score · per round

rounds0
you0.0 total · 0.00 / round
them0.0 total · 0.00 / round
your cooperation raten/a

Auto-play a policy to compare with the Python tournament matrix.

Scored with the canonical payoffs . The matrix you edited drives the theory benches, not this one, so the comparison with Python stays exact.

Tournament · round robin

Nice strategies finish first.

Eighteen strategies, 200 rounds, ten repetitions, self-play included. Score is mean payoff per round. Pick the noise level and the cards re-rank.

Pairwise · row's payoff

Hover a cell.

Read-out

Nice means never the first to defect. The bar under each score is that strategy's cooperation rate.

Spatial · Nowak & May 1992

0generation
fraction cooperating fC1.000
Python, b ∈ (1.8, 2), 200 generations
Python, same b, asynchronous (L = )

Each cell plays the weak dilemma (R = 1, T = b, P = S = 0) with its eight neighbours and itself, then copies its best-scoring neighbour. Ties keep the incumbent. Synchronous, periodic. Scroll to advance the generation.

Population · replicator dynamics

Why Tit-for-Tat survives, and when.

ALLC, ALLD and TFT in the repeated game with δ = . Drag the start point. The dashed edge is a line of neutral fixed points; the dot on the ALLD edge is the invasion threshold.

0.00% TFT is enough to tip a defector world, x* = 1/17
cooperation survives from
start
at t = 80
verdict
eigenvalues at ALLD
eigenvalues at TFT
ESS
Finite populations: Moran fixation of one TFT (Python)
Nexact ρsimulatedneutral 1/N

Under mutation the eighteen-strategy Moran process spends most of its time near .

Noise · memory-one Markov chain

ε = 0.000implementation error per move, swept by scroll

Eight strategies playing themselves, exact long-run payoff from the stationary distribution. At ε = 0 they all sit on R = 3, except the ones that were never nice.

One slip and Tit-for-Tat falls to (T + R + P + S)/4 = 9/4, for any ε > 0: the chain it drives is doubly stochastic. Pavlov and generous TFT lose only a multiple of ε.

The live column on the right is computed here from the 4 × 4 chain at the swept ε; the curves are Python's. They agree to the printed precision.

Live at this ε · self-play

Who profits · zero-determinant

Extort-2 pins every opponent to sX − P = 2 (sY − P) without noise. A Q-learner facing it ends near per round while the extortioner takes . Noise on the extortioner breaks the pin.

opponentlearneropponent

Evolution under noise · dominant strategy

Prompt · same engine, on demand


      
numbers: results/canonical.json · run 5 report (PDF) repository pdlab · Python 3.11 · this page is one file