🐺 Wolf-Sheep Predation
Spatial agent-based ecology simulation. Sheep eat grass, wolves hunt sheep — watch Lotka-Volterra population cycles emerge from simple local rules.
Grass Regrowth 5
Sheep Food Gain 18
Wolf Food Gain 50
Speed (ticks/frame) 2
120
Sheep 🐑
25
Wolves 🐺
100%
Avg Grass
0
Tick
Stable
Status
Lotka-Volterra Agent Model — Unlike the classic differential equation version, this spatial simulation runs individual agents on a grid. Sheep wander, eat grass, and reproduce when well-fed. Wolves hunt nearby sheep, gain energy from each kill, and reproduce too. Both lose energy each tick and die when depleted. Classic population cycles emerge: sheep multiply → wolves multiply → sheep depleted → wolves starve → sheep recover. Watch for spatial patterns: wolves create local "grazing refugia" where sheep survive to replenish the population.

About Wolf-Sheep Predation

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 50×50 toroidal grid where every cell carries a regrowing grass value from 0 to 100. 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 four sliders set grass regrowth per tick (1–12), the energy a sheep gains from grazing a cell (5–35), the energy a wolf gains per kill (20–80) and the simulation speed (1–8 ticks per frame). 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.

Frequently Asked Questions

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 four sliders control?

Grass Regrowth sets how much each cell replenishes per tick (1 to 12). Sheep Food Gain is the energy a sheep takes when it grazes a cell (5 to 35). Wolf Food Gain is the energy a wolf receives per sheep eaten (20 to 80). Speed sets how many simulation ticks are computed per animation frame (1 to 8), changing how fast time passes without altering the dynamics.

How do agents gain and lose energy?

Every tick a sheep loses 1 energy and a wolf loses 3. A sheep grazing a cell gains up to its Food Gain value, capped at 100 total. A wolf eating a sheep on its cell gains the Wolf Food Gain value, capped at 120. Any agent whose energy drops to zero or below dies immediately and is removed from the grid.

When and how do animals reproduce?

Reproduction is probabilistic and energy-gated. A sheep with at least 40 energy reproduces with a 4% chance per tick; a wolf with at least 70 energy reproduces with a 2.5% chance. 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.

How do wolves find and catch sheep?

Each wolf scans a hunting radius of 8 cells for the nearest sheep using a Manhattan-distance search. 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 of 5 cells and step away from the nearest wolf.

Is the model physically or ecologically accurate?

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.

Why do the populations cycle up and down?

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.

What is the role of the spatial grid?

Because animals only interact within their local radius on a wrapping 50×50 grid, 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.

What happens if a species goes 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.

How does this relate to real-world conservation?

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.