This simulation models the classic predator-prey relationship as an agent-based system rather than as smooth equations. Hundreds of individual prey and predator particles wander a 2D arena, interacting through purely local spatial rules: predators detect prey within a vision range, chase the nearest one, and consume it on contact. From these microscopic encounters, the macroscopic, phase-shifted population oscillations described by the Lotka-Volterra model emerge spontaneously, with a live chart tracking both populations over time.
The sliders set the prey birth rate alpha (per prey, per frame), the predator energy drain gamma per frame, the eat radius in pixels, the energy gained per kill, and an overall speed multiplier. You can also choose the starting prey and predator counts. The system underpins real ecology, fisheries management and resource economics, illustrating why over-harvesting a prey species or removing predators can drive a coupled population to boom, crash or extinction.
What is the Lotka-Volterra predator-prey model?
It is a pair of coupled equations describing how two interacting populations change over time: prey grow when undisturbed and decline when eaten, while predators grow when prey is plentiful and decline when it is scarce. The result is repeating, out-of-phase oscillations where predator peaks lag behind prey peaks.
How does this simulation produce those oscillations?
Instead of solving equations directly, it runs hundreds of individual particles with simple local rules. Predators seek and eat nearby prey to gain energy, lose energy each frame, and starve when prey runs out. Prey reproduce stochastically. These individual behaviours collectively reproduce the classic cyclic population dynamics.
What do the alpha and gamma sliders control?
Alpha is the prey birth rate: each frame, every prey has that probability of spawning an offspring nearby, so higher alpha means faster prey growth. Gamma is the predator energy drain per frame; a larger gamma makes predators starve more quickly between meals, shifting the balance toward the prey.
Eat radius is the pixel distance within which a predator can consume a prey on contact. Energy gain per eat is how much energy a successful kill adds, fuelling reproduction once a predator exceeds its energy threshold. The speed multiplier scales how fast all particles move, and the initial sliders set the starting prey and predator counts.
Predators can only multiply once there is abundant prey to eat, so their rise lags the prey boom. As predators become numerous they over-consume the prey, the prey crash, and predators then starve. With prey pressure relieved, prey recover and the cycle repeats with a characteristic phase shift.
It is a qualitative teaching model rather than a precise ecological forecast. It faithfully captures the emergent cyclic behaviour and phase shift of real predator-prey systems, but it ignores factors like age structure, habitat heterogeneity, disease and carrying-capacity details. A prey cap of 600 prevents unbounded growth.
Because this is a finite, stochastic, particle-based system, random fluctuations can push a population to zero, after which it cannot recover. If prey vanish, predators soon starve; if predators vanish, prey grow toward their cap. The idealised continuous equations never reach zero, but discrete agents can, which is more realistic.
Each predator scans for prey within a fixed vision range using a spatial grid for fast neighbour lookup, then steers toward the nearest one. If a prey falls inside the eat radius, the predator consumes it, gaining energy. When a predator's energy passes its reproduction threshold it splits, passing half its energy to the offspring.
The chart plots recent population history, sampled every ten frames, with the green line for prey and the red line for predators. Watching the two lines rise and fall in alternation is the clearest way to see the Lotka-Volterra cycle emerge from the underlying particle interactions.
They inform fisheries and wildlife management, pest and biological-control strategies, and conservation planning, and analogous equations appear in epidemiology and economics. They help explain why removing a predator or over-harvesting a prey species can destabilise an ecosystem and trigger boom-bust cycles or collapse.
Hundreds of prey and predator particles interact through spatial rules, producing the classic Lotka-Volterra population oscillations. Watch predator booms follow prey booms in a never-ending cycle.
Prey reproduce when well-fed, predators hunt nearby prey. When prey is scarce, predators starve. This creates the characteristic phase-shifted oscillation seen in real ecosystems.
Adjust reproduction and hunting rates. Watch the population chart oscillate. Classic Lotka-Volterra dynamics emerge from individual particle interactions.
The Lotka-Volterra equations were independently derived by Alfred Lotka (1910, for chemical reactions) and Vito Volterra (1926, to explain fish populations in the Adriatic Sea).