This simulation is a spatial, agent-based version of the classic predator-prey problem. Rather than solving the Lotka-Volterra differential equations directly, it places hundreds of individual sheep and wolves on a 56×56 map of terrain cells (meadow, forest, rocky hills and water) where every cell carries regrowing grass. Each tick, agents move, feed, lose energy, reproduce probabilistically and die when energy reaches zero, so the familiar oscillating population cycles emerge from purely local rules rather than being imposed by an equation.
The controls set the grass regrowth time, the energy a sheep gains from grazing a cell, the energy a wolf gains per kill, the birth chances, the hunting and flee radii, the sheep's alertness and the simulation speed, and brush tools drop or cull animals on the map. Adjusting them shifts the system between stable coexistence, boom-bust swings and total extinction. This same modelling approach underpins real conservation work, helping ecologists reason about reintroducing apex predators, managing grazing pressure and the resilience of food webs.
What does this simulation actually show?
It shows a small ecosystem of three components: grass, sheep and wolves. Sheep graze grass to gain energy, wolves hunt sheep, and both species expend energy and reproduce. The live chart plots sheep and wolf counts over time so you can watch the characteristic predator-prey cycles, extinction events and recoveries unfold.
How is this different from the classic Lotka-Volterra equations?
The classic model is a pair of continuous differential equations giving smooth, perfectly repeating cycles for two idealised populations. Here each animal is a discrete agent on a grid making local decisions, so the cycles are noisy, can drift, and can collapse to extinction. The aggregate behaviour resembles Lotka-Volterra but emerges bottom-up rather than being prescribed.
What do the controls change?
Grass regrowth time sets how many ticks an eaten meadow cell needs to grow back (forest and hills are slower). Energy per grass eaten is what a sheep takes when it grazes a cell; energy per sheep eaten is what a wolf receives. Birth chances, radii and alertness tune reproduction, hunting and escape. Speed sets how many simulation ticks run per second without altering the dynamics.
Every tick a sheep and a wolf each lose 1 energy. A sheep grazing a cell gains its food-gain value, capped at five times that value. A wolf eating a sheep on its cell gains its food-gain value, capped at three times that value. Any agent whose energy drops to zero or below dies immediately and is removed from the grid.
Reproduction is probabilistic and energy-gated. A sheep with at least twice its food-gain energy reproduces with the chosen birth chance per tick (6% by default); a wolf with at least 1.5 times its food-gain energy reproduces with its own chance (12% by default). When an animal breeds it halves its own energy and places a new agent of the same type on its current cell, so only well-fed animals pass on their lineage.
Each wolf scans its hunting radius (8 cells by default) for the nearest sheep by straight-line distance. If one is found, the wolf steps one tile towards it; otherwise it moves randomly. A kill only happens when a wolf and a living sheep occupy the same cell after movement. Sheep, in turn, scan a flee radius (4 cells by default) and step away from the nearest wolf, succeeding with a probability set by their alertness.
It is a deliberately simplified teaching model, not a quantitative forecast. It captures genuine ecological mechanisms — energy budgets, density-dependent reproduction, predator hunting and prey avoidance — but omits factors such as age, disease, weather, territory and genetics. The qualitative patterns it produces match real predator-prey systems even though the exact numbers are illustrative.
Abundant sheep give wolves plentiful food, so wolves multiply. Growing wolf numbers then crop the sheep faster than they breed, so sheep crash. With little prey, wolves starve and decline, which relieves pressure and lets sheep recover, restarting the loop. This feedback delay between cause and effect is what generates the oscillation.
Because animals only interact within their local radius on a bounded 56×56 map, geography matters. Sheep can survive in pockets the wolves have not yet reached, forming temporary refugia that reseed the population. This spatial structure is exactly what a single set of equations ignores, and it is why this model can show recovery where the non-spatial version would simply go extinct.
If all sheep die, the wolves quickly starve and the status reads Extinct. If wolves vanish but sheep remain, sheep multiply until grass is grazed down, and the status reads No Wolves. The simulation does not reintroduce species automatically, so you can use the Reset and preset buttons to restart with different starting balances of sheep and wolves.
Agent-based predator-prey models like this inform decisions about reintroducing apex predators, such as wolves in Yellowstone, and about setting sustainable grazing or culling levels. By revealing how sensitive an ecosystem is to food availability and predation pressure, they help managers anticipate boom-bust swings and the risk of collapse before intervening in the field.