FreeSimulationNo signup

Spatial Cooperation Simulator

Prisoner's dilemma on a grid. One parameter decides whether cooperation survives.

Ready
Step 0 / 0
Agents: 0
Group AGroup BEmpty
10/s

Parameters

1.40

Sharp phase transition near T = 1.50.

12
0.500
01

Tweak parameters, then press Reset to apply.

What you just saw

In well-mixed populations, defection always wins the prisoner's dilemma. But on a 2D grid, cooperators can survive by clustering — the edge of a cooperator cluster loses to defectors, but the interior is safe, and the cluster as a whole outgrows defector patches. There's a sharp phase transition near T = 1.50: below it, cooperation dominates; above it, defection sweeps the grid.

The science behind it

Martin Nowak and Robert May introduced this model in Nature in 1992. It was one of the first convincing demonstrations that spatial structure — not kin selection, reciprocity, or reputation — is enough to sustain cooperation in a prisoner's dilemma. It became the foundation of an entire field studying the evolution of cooperation on networks, including modern results on heterogeneous scale-free networks (Santos & Pacheco, 2005).

Try these experiments

  1. 1. Cooperator-dominated

    Settings: temptation=1.4

    What to look for: Cooperators survive in stable clusters. Fraction stabilizes around 0.6–0.8.

  2. 2. Edge of chaos

    Settings: temptation=1.50

    What to look for: Noisy, turbulent boundaries. The cooperator fraction oscillates and the pattern looks alive.

  3. 3. Defection wins

    Settings: temptation=1.7

    What to look for: Defection sweeps the grid in ~20 steps. No cooperator clusters survive.

Sprint 1 scaffold. Full long-form article, references, and FAQ will land in the content sprints (3–6). The simulation above is already wired to the production worker.
SimLab

Run this at 100x scale

Spatial cooperation runs in your browser up to 6,400 agents. With SimLab, the same model runs on GPU at 10M+, with ensemble parameter sweeps and publication-ready output.

from scirouter import SciRouter
client = SciRouter(api_key="sk-sci-...")
result = client.simulation.run(
    model="cooperation",
    params={"grid_size": 1000, "temptation": 1.45,
            "initial_cooperator_fraction": 0.5},
    steps=500, seed=42,
)

Related simulations

Frequently asked questions

Why does spatial structure save cooperation?

A cooperator surrounded by other cooperators scores high from every interaction. A defector surrounded by other defectors scores near zero. Clusters of cooperators can out-score the defector cells on the boundary, even though each individual defector beats each individual cooperator in pairwise play.

What exactly is T?

The temptation payoff — what a defector gets when playing against a cooperator. Cooperators against cooperators score 1; cooperators against defectors score 0; defectors against defectors score 0. When T > 1, defection pays better against cooperators than cooperation pays against itself. When T crosses ~1.50, defection wins the spatial battle too.