Spatial prisoner's dilemma · evolution of cooperation
Among purely selfish agents, where defecting always pays more than cooperating, can cooperation survive at all — or is it doomed?

▶ Run the simulationSee the measured result
Units: dimensionless (12 ln 2 − 8, Nowak & May's approximate analytic asymptote for the chaotic band; their simulations '≈ 0.318')
How the lab tests it
The spatial prisoner's dilemma (Nowak–May 1992). Cooperators and Defectors on a grid; each plays the PD with its 8 neighbours and itself (C–C=1, C–D=0, D–C=b, D–D=0, temptation 1<b<2), sums the payoff, then copies the best-scoring strategy nearby. Sweep the temptation b and measure the equilibrium cooperator fraction f_C; run one regime live, coloured by the four strategy transitions.
What it checks
cooperation SURVIVES — rescued by space. In a well-mixed crowd defection is the only outcome (f_C→0): a defector always out-earns the cooperators it exploits. But on a lattice, cooperators huddle into CLUSTERS whose interiors prosper and resist invasion, so f_C stays well above zero across the whole 1<b<2 range — and in the chaotic regime near b≈1.9 it locks onto f_C≈0.31 (converging to the Nowak–May value ≈0.318 at larger lattice / longer averaging), the frontier churning forever in the famous 'evolutionary kaleidoscope'. Only at b=2 does cooperation finally collapse. (The survival is itself a finite-size effect: robust on a large grid L≥100, but on small lattices cooperation can stochastically collapse to zero in this chaotic window.) Spatial structure alone — no memory, kinship, or foresight, and the self-game is what lets a lone cooperator pair seed a cluster — lets cooperation persist where rational selfishness says it must die
Prisoner's dilemma calculator (the four payoff conditions, the Nowak-May spatial band with its exact rational edges, and the mean-field refuge that removing space destroys)
Two players, four numbers, and a result everybody knows: defecting is the rational move and both players end up worse off. Put the same game on a grid where each cell copies whichever of its neighbours scored best, and cooperation does not die - it settles at about 31.8% of the lattice and stays there, churning, forever. Nothing was added to get that: no memory of past encounters, no reputation, no kinship, no foresight. Only the fact that a cell's partners are also each other's partners. This page computes the three things that result is made of, and assembles all of them from a neighbourhood size and a temptation rather than storing any. The first is the part usually left to simulation: because a cooperator's score is an INTEGER (one point per cooperating neighbour, plus its game with itself) while a defector's is a multiple of b, the two can only change places at a rational b = (m+1)/k - so the dynamics are piecewise constant in b, and the famous 'spatial chaos' band is literally a gap between two fractions. The lab upstairs found that band's edges by bisecting for them blind, which is the honest way to measure something you have not derived; this page derives them, and the lower one has a closed form nobody here had written down: maximising n/k below 2 forces n = 2k-1, so the largest threshold under 2 is 2 - 1/(floor(z/2)+1), which is 9/5 for a Moore neighbourhood and 5/3 for von Neumann. The band therefore has width exactly 1/(floor(z/2)+1) and closes as the neighbourhood grows - and it closes on the same limit where the mean-field refuge f* = 1/(z(b-1)) vanishes, which is two different formulas saying that locality was the resource all along. The second is the asymptote 12 ln 2 - 8 itself, printed to the last bit a double holds and labelled as what it is: an exact expression for an approximate theory, whose first three digits are physics and whose remaining six are arithmetic. The third is the payoff matrix, classified - and it says that this world's own game is the WEAK prisoner's dilemma rather than the strict one, since setting P = S = 0 makes defection dominant only by a tie, which is precisely what makes the scores integers and the whole rational ladder possible. The control is carried here too, and it dies in one line of algebra: delete the self-game and z*f + 1 = z*f*b loses its only root, so a well-mixed population has no density at which cooperating breaks even and cooperation goes extinct rather than settling low - three orders of magnitude below the lattice, from removing a single term.
lattice scores: a cooperator with m cooperating neighbours gets m+1, a defector with k of them gets k*b (R = 1, S = P = 0, T = b, own game included) · a comparison can only flip at b = (m+1)/k with 1 <= m+1 <= z+1 and 1 <= k <= z · upper band edge = 2 for every z · lower band edge = 2 - 1/(floor(z/2)+1), band width = 1/(floor(z/2)+1) · Moore z = 8: (9/5, 2) · f_C = 12 ln 2 - 8 · mean field: z*f + 1 = z*f*b => f* = 1/(z*(b-1)) · prisoner's dilemma: T > R > P > S; efficiency: 2R > T + S