HomeSociety & EconomicsGame Theory

🎮 Game Theory

Interactive evolutionary game theory simulation: agents play Prisoner's Dilemma on a grid. Watch how cooperation emerges, how Tit-for-Tat invades defectors, and which strategies survive. Adjust payoffs, noise, and strategy mix.

Society & Economics3DModerate60 FPS
game-theory ↗ Open standalone

About Evolutionary Game Theory

This simulation runs the spatial Prisoner's Dilemma on a toroidal grid of agents (40×40 by default). Each round, every cell plays the dilemma against all eight of its Moore-neighbourhood neighbours and accumulates a payoff from the matrix T > R > P > S. Agents then evolve by imitation: each copies the strategy of whichever neighbour (including itself) scored highest that round, with a small chance of random mutation.

The sliders set the four payoffs — Temptation, Reward, Punishment and Sucker — while others adjust grid size, simulation speed and noise (mutation rate). Five strategies compete: Always Cooperate, Always Defect, Tit-for-Tat, Pavlov (Win-Stay Lose-Shift) and Random. The same logic explains cooperation in climate treaties, arms races, antibiotic-resistance ecology and corporate price wars, where individual incentives clash with collective benefit.

Frequently Asked Questions

What does this simulation actually show?

It shows how cooperation can emerge, collapse or cycle when many agents repeatedly play the Prisoner's Dilemma on a grid. Each coloured cell is an agent running one of five strategies, and over successive rounds the more successful strategies spread across the population through imitation.

How does the evolution rule work?

After every round each agent looks at its own score and the scores of its eight neighbours, then adopts the strategy of whichever one earned the most points that round. This "imitate the best neighbour" rule is a standard form of spatial evolutionary dynamics — no genetics or reproduction, just copying of successful behaviour.

What do the T, R, P and S sliders control?

They set the four payoffs of the dilemma: Temptation (defect against a cooperator), Reward (mutual cooperation), Punishment (mutual defection) and Sucker (cooperate against a defector). A genuine dilemma needs T > R > P > S, and ideally 2R > T + S so that mutual cooperation beats alternating exploitation.

What are the five strategies?

Always Cooperate (green) and Always Defect (red) ignore the opponent. Tit-for-Tat (blue) repeats the neighbour's last move towards it. Pavlov, or Win-Stay Lose-Shift (purple), keeps its move if the last payoff was good and switches if it was poor. Random (amber) cooperates or defects with a 50/50 coin flip each interaction.

Why does Tit-for-Tat usually do so well?

In Robert Axelrod's 1980 tournaments Tit-for-Tat beat 62 rival strategies because it is nice (never defects first), retaliatory (punishes defection at once), forgiving (returns to cooperation immediately) and clear. On a grid, clusters of TFT agents shield one another from exploitation, letting cooperation hold a foothold even amid defectors.

What is the difference between a Nash equilibrium and a Pareto optimum here?

In a one-shot game mutual defection is the Nash equilibrium: neither player can gain by switching alone. Mutual cooperation is the Pareto optimum: you cannot improve one agent without harming the other. The tragedy of the dilemma is that rational self-interest drives players to the worse, Nash outcome.

What does the noise slider do?

Noise sets a mutation rate, from 0 to 20 per cent. After the imitation step, each agent has that probability of instead adopting a randomly chosen strategy. A little noise keeps the system from freezing into a single absorbing state and lets new strategies be re-seeded so the dynamics stay lively.

Is the spatial structure important?

Yes. Because agents only interact with eight immediate neighbours rather than the whole population, cooperators can form protective clusters whose interior members all cooperate and score well. This local structure is exactly why cooperation survives spatially when it would be wiped out in a well-mixed population.

What do the presets do?

All Defectors seeds a sea of defectors with a tiny TFT core to test invasion; TFT Invasion uses a larger cooperative cluster; Pavlov World fills the grid mostly with Pavlov agents; and Mixed starts from a weighted blend of all five strategies. They are quick ways to explore which configurations let cooperation take hold.

How accurate is this compared with real game theory?

The payoff matrix, strategy definitions and Nash and Pareto analysis are faithful to standard theory, and the imitate-best dynamic is a recognised model used by Nowak and May. It is a simplified teaching tool, though: real ecologies involve continuous strategies, memory of many past rounds and reproduction rather than pure copying.

Where does the Prisoner's Dilemma appear in the real world?

It models any situation where private incentives undermine shared gains: nations emitting carbon despite a collective interest in restraint, rivals locked in arms races, bacteria producing public goods that cheaters exploit, and firms tempted to undercut a mutually profitable price. The simulation hints at how repetition and structure can rescue cooperation.

⚙ Under the hood

Evolutionary Prisoner's Dilemma on a spatial grid. Strategies ALL-D, ALL-C, TFT, Grim Trigger and Random compete; the payoff matrix drives selection each round.

Canvas 2DGame TheoryEvolutionPrisoner's Dilemma

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)