loading...
running...
How to use
Pick a preset, then press Play (Space pauses, R resets). The map shows grazers coloured by coat (pale to dark), foxes, grass and soil. Choose a click tool to inspect a grazer, add hunters, repaint the soil darker or paler, or cull grazers. Hover any slider for a tip.
What to try
- Camouflage. "Camouflage: dark soil": watch p rise toward 1 as pale grazers are eaten. Then paint the soil pale and watch the reversal.
- Drift vs selection. "Neutral drift (small N)" with seeds 1 to 10: p wanders and hits 0 or 1. Raise "Grazers at start" and drift weakens.
- Hardy-Weinberg. "Hardy-Weinberg test": observed Dd stays on the dashed 2pq curve. Turn selection on and it leaves.
- Speciation. "Allopatric split": the wall, a dark east and a pale west. Watch Fst rise; open the gap to 20 m and it falls again.
- Boom and bust. "Predator-prey cycles": the grazers-vs-hunters phase portrait loops.
- Arms race. "Arms race: fast runners": the mean speed trait climbs; raise the running cost and it stops.
3D: drag to orbit, wheel to zoom, camera buttons for presets and follow cameras. Models and baked PBR textures are made in Blender; Three.js r160 renders them.
The science
An island-sized agent-based model. Grass grows in 64 x 64 cells; grazers eat it, carry a diploid coat gene (alleles d pale and D dark, shade = copies of D / 2) and a heritable speed trait; hunters (foxes) see their prey against the soil colour. Everything below is computed by the model you are watching; the 3D scene only draws it.
Camouflage selection. A grazer with coat shade c on soil of darkness b has visibility
v = 0.28 + 0.72 min(1, |c - b| / 0.7)
and a hunter within 1.3 m captures it at rate k = 3.2 K v s_H / (s_H + 0.55 s_G) (K = predation strength, s = speed traits). Better-matched coats survive longer, so the allele frequency p of D drifts toward the soil shade. For two types with relative fitnesses the replicator equation is
dp/dt = p (f_D - f_mean) = s p (1 - p) => p(t) = p0 e^(st) / (1 - p0 + p0 e^(st))
The panel reports the slope of logit(p) per generation (about 36 s here), which estimates the selection coefficient s of the current environment.
Hardy-Weinberg. With random mating and no selection, mutation or drift, genotype frequencies are
f(dd) = q^2, f(Dd) = 2pq, f(DD) = p^2, q = 1 - p
The chi-square statistic sum (O - E)^2 / E (1 degree of freedom) against these expectations is shown live; strong selection, a barrier or assortative mating push the observed Dd frequency away from 2pq.
Genetic drift. In a finite population the allele frequency does a random walk, Var(dp) = p q / 2N, and heterozygosity decays as
H_t = H_0 (1 - 1/2N)^t
Use "Neutral drift (small N)" and repeat with different seeds: the allele fixes or is lost, at random.
Population structure and speciation. The wall splits the island into west and east demes. Their differentiation is
F_st = (H_T - H_S) / H_T, H_T = 2 p_bar q_bar, H_S = mean of 2 p_i q_i
Different soils (selection), little gene flow (narrow gap) and assortative mating all raise F_st, the first steps toward two species. The model does not produce true speciation (no new reproductive barrier genes), only the divergence that precedes it.
Food web. Grass follows logistic growth dB/dt = r B (1 - B/K) + seed, with capacity K = 4 x fertility (wet lowlands are richest). Grazers and hunters form a predator-prey pair; in the simplest continuous form
dx/dt = a x - b x y, dy/dt = d x y - c y, V = d x - c ln x + b y - a ln y = const
the conserved quantity V is verified numerically below. In the agent model hunters stop for a rest after a chase and a kill, so cycles are damped and noisy rather than perfectly periodic.
Speed trait and the breeder's equation. Speed is inherited as the midparent value plus noise (not tied to a single gene). The response to selection obeys R = h^2 S; here narrow-sense heritability is roughly 1 for the midparent rule, so the mean follows the selection differential. Faster grazers escape better but pay a running cost proportional to speed squared.
Honest simplifications. One coat locus with two alleles; no dominance (shade is additive); asexual hunters; fixed lifespans; the time unit (1 generation about 36 s) is arbitrary; hunters do not evolve; predator vision and capture rules are a toy model, not fitted to any species. The terrain, animals and plants are illustrative, not a specific real ecosystem. The checks below test the maths (Hardy-Weinberg, replicator, drift, Lotka-Volterra) independently of the live run.