loading...
Replicator ODE: strategy shares against generation (dashed line: Hawk-Dove ESS V/C)
Fixation probability of one strategy-1 mutant against N: exact curve, neutral 1/N and Monte Carlo
running...
How to use
Pick a game or a preset, then watch three models start from the same mix of strategies: the deterministic replicator ODE (white dot), a finite population of N individuals evolving by a Moran process (cyan ring) and a spatial lattice where each cell copies a neighbour (purple square).
What to try. (1) Hawk-Dove with V=2, C=4: all three settle near 50% hawks, but the finite population wobbles around it. (2) Prisoner's Dilemma: the ODE and the Moran population lose every cooperator, while the lattice keeps clusters of them alive. (3) Stag Hunt: start at 40% and at 60% stag and see two different endings. (4) Rock-Paper-Scissors with win equal to loss: closed orbits; make win larger than loss for a spiral into the centre and smaller for a spiral out to the corners. (5) Shrink N to 14 with weak selection and watch drift fix a strategy by chance. (6) Press "Run fixation experiment" and compare the green Monte Carlo points with the exact curve.
Click or drag in the simplex (or on the payoff line for two strategies) to choose the starting mix. Click the lattice to paint a patch of the selected strategy and see whether it invades. Space pauses, R resets.
The science
Payoffs. A strategy i earns a(i,j) against j. Hawk-Dove: Hawk vs Hawk (V-C)/2, Hawk vs Dove V, Dove vs Hawk 0, Dove vs Dove V/2. Prisoner's Dilemma: R=3 (both cooperate), S=0 (sucker), T (temptation), P (both defect), with T>R>P>S. Stag Hunt: stag-stag s, stag-hare 0, hare always h with 0<h<s. Rock-Paper-Scissors: +w for a win, -l for a loss, 0 for a tie. Hawk-Dove-Bourgeois: a Bourgeois bird plays Hawk when it owns the resource and Dove when it is the intruder, each role with probability 1/2.
Replicator dynamics (infinite well-mixed population, shares xi):
dx_i/dt = x_i ( f_i(x) - mean_f(x) ), f_i = sum_j a(i,j) x_j, mean_f = sum_i x_i f_iThe ODE is integrated with fixed-step RK4. A rest point is classified from the eigenvalues of the Jacobian on the simplex: stable (filled green), unstable (hollow red), saddle (orange diamond), centre or marginal (yellow). For two strategies the interior rest point is p* = (a22-a12)/((a11-a21)+(a22-a12)); for Hawk-Dove this is V/C. An evolutionarily stable strategy is an asymptotically stable rest point that also resists invasion by rare mutants; for these games the two coincide.
Fisher's theorem for symmetric games. If a(i,j)=a(j,i) the replicator flow climbs the mean payoff: d(mean_f)/dt = 2 Var(f) ≥ 0. The shaded background of the simplex is mean_f; for Rock-Paper-Scissors (not symmetric) the flow circles instead of climbing. With win equal to loss the quantity sum ln x_i is conserved.
Finite population (Moran process). N individuals; each step one individual is chosen to reproduce with probability proportional to fitness exp(beta * payoff), where the payoff is the average against the other N-1 individuals, and one uniformly chosen individual is replaced by the offspring (with a mutation probability the offspring takes a random strategy). N steps are one generation. For two strategies the exact probability that one mutant of strategy 1 takes over is
rho = 1 / ( 1 + sum_{k=1..N-1} prod_{j=1..k} exp( beta (pi_2(j) - pi_1(j)) ) )which equals 1/N with no selection. In the diffusion limit the finite population follows the replicator ODE with time t = beta * generations; the plots overlay the ODE in these units, so any gap is drift (noise of order 1/sqrt(N)).
Spatial lattice. 6,200 cells on a torus. Each cell sums its payoff against its eight Moore neighbours, then adopts the strategy of the best-scoring cell among itself and its neighbours (or, with the Fermi rule, copies one random neighbour with probability 1/(1+exp(-(pi_neighbour-pi_self)/K))). Noise replaces a cell by a random strategy. Space lets clusters of cooperators protect each other, which the well-mixed models cannot show.
Numerical checks run in the page. RK4 against the closed-form logistic solution; the conserved quantity of neutral Rock-Paper-Scissors; the Hawk-Dove attractor V/C; Fisher's theorem by finite differences; and the individual-based Moran simulation against the exact birth-death-chain fixation formula (including the neutral value 1/N).
Honest simplifications. Payoffs are dimensionless illustrations, not measured fitness. Real animals have asymmetric roles, age structure, kin and repeated interactions; the Moran process uses a global competition neighbourhood and exponential fitness for numerical safety. The lattice rules are deterministic imitation (or Fermi imitation) rather than birth-death with genetics. Bird figures in the 3D version are a visual encoding of strategy only.