loading...
running...
How to use
Pick a preset or move the sliders; changes to regrowth, energy, birth chance, radii and alertness act immediately, while map, seed and starting counts apply on Reset. Choose a brush tool and click the map to drop wolves or sheep, fertilise grass or cull animals. Watch the sheep, wolf and grass graphs and the phase portrait (a closed loop would mean a perfect cycle). Experiments: remove all wolves; halve the grass regrowth speed; switch on forest refuge; compare the maps. Space pauses, R resets. Wheel or pinch to zoom, drag to pan, double-click to fit. Animal sprites were rendered in Blender from the same models as the 3D page (8 headings, 4 walk frames).
The science
Two layers are shown side by side: a spatial agent-based model (what you see on the map) and the classic Lotka-Volterra mean-field equations (the two lower graphs).
Lotka-Volterra. With prey x (sheep) and predators y (wolves):
dx/dt = a x - b x y dy/dt = d x y - c y
The only interior equilibrium is x* = c/d, y* = a/b. Near it the populations oscillate with period T = 2π/√(a c), and the quantity V = d x - c ln x + b y - a ln y is exactly conserved, so every orbit is a closed loop. The page integrates this system with a 4th-order Runge-Kutta scheme and checks both facts numerically (checks 1 and 2).
The agent model. The map is a 56 x 56 grid (one cell is about 10 m) of meadow, forest, rocky hill and water cells made from a seeded heightfield; animals walk on the largest connected land area. Each tick, in this order: grass that has been eaten counts down its regrowth timer (timer = regrowth time / fertility, fertility 1.0 meadow, 0.45 forest, 0.22 hill); each sheep loses 1 energy, flees the nearest wolf inside its flee radius (with probability = alertness) or otherwise steps toward neighbouring grass, eats the grass on its cell (+ energy per grass eaten, capped at 5x), and may reproduce; then each wolf loses 1 energy, steps toward the nearest sheep inside its hunting radius (or wanders), eats one sheep sharing its cell (+ energy per sheep eaten, capped at 3x), and may reproduce. Sheep breed only with at least 2x their food energy, wolves with at least 1.5x theirs; a birth halves the parent's energy and gives the other half to the newborn. Any animal at zero energy dies.
Energy ledger. Because births only split energy and all gains and losses are booked, the stock must satisfy: energy now = start + injected by the brush + energy eaten - metabolism - energy removed with the dead. Check 3 verifies this exactly on the live run.
Why default runs do not cycle like the equations. The equations have unlimited prey growth. Here sheep are limited by grass, so at the default settings they sit at a grass-limited carrying capacity and wolves interfere with one another when chasing the same sheep; the result is a stable, noisy coexistence with large transients (try Wolf boom and bust) and sudden collapses when you cut the grass (Drought) or the sheep's alertness (Island collapse). The Lotka-Volterra panel has no connection to the agent parameters; it is there to show what the unlimited-prey idealisation would do. Sliding a, b, c, d moves the equilibrium and the loop sizes live.
Simplifications. No age, sex, disease, seasons, territories, packs or slope cost; sheep walk at 0.75 cells per tick unless fleeing (success probability = alertness) while wolves step every tick; the map is procedural, not a surveyed landscape; one tick has no fixed real duration. Real systems (Isle Royale moose-wolf, Yellowstone elk-wolf) show cycles and cascades that depend on many more factors. This is a teaching model, not a forecast.