What you just saw
Wolves hunt sheep, sheep graze grass, grass slowly regrows after being eaten. The three populations rise and fall in offset cycles — exactly the Lotka-Volterra oscillation. When sheep are abundant, wolves proliferate; when wolves peak, sheep crash; when sheep are scarce, wolves starve; grass recovers; sheep bounce back. No equations — just individual animals deciding whether to eat, reproduce, or starve.
The science behind it
The predator-prey pattern was first described mathematically by Alfred Lotka (1925) and Vito Volterra (1926) as coupled ODEs. The agent-based version here (wolf-sheep-grass) is one of NetLogo's flagship demonstrations and has become a canonical teaching example. Unlike the ODE version, the spatial agent-based model exhibits extinctions, refugia, and fronts — effects invisible to the well-mixed equations.
Try these experiments
1. Classic oscillation
Settings: defaults
What to look for: Offset sine-like waves in sheep and wolf populations.
2. Wolf extinction
Settings: wolf_reproduce_rate=0.02
What to look for: Wolves die out, sheep explode to carrying capacity limited by grass.
3. Total collapse
Settings: wolf_reproduce_rate=0.08 sheep_reproduce_rate=0.02
What to look for: Wolves over-hunt, sheep crash, wolves starve. Both populations extinct.
Run this at 100x scale
Predator-prey runs in your browser up to 190 animals agents. With SimLab, the same model runs on GPU at 1M+ animals, with ensemble parameter sweeps and publication-ready output.
from scirouter import SciRouter
client = SciRouter(api_key="sk-sci-...")
result = client.simulation.run(
model="predator_prey",
params={"grid_size": 500, "initial_sheep": 10_000,
"initial_wolves": 2_000,
"sheep_reproduce_rate": 0.04, "wolf_reproduce_rate": 0.05},
steps=1000, seed=42,
)Related simulations
Sugarscape Wealth Simulator
The Epstein–Axtell economy. Heterogeneous agents harvest sugar under lookup rules; watch Pareto wealth distribution emerge.
Boids Flocking Simulator
Reynolds' three-rule boids model. Thousands of birds, three simple rules, emergent murmurations. The visual payoff of ABM.
Spatial Cooperation Simulator
Prisoner's dilemma on a 2D lattice. Nudge the temptation parameter past 1.50 and watch defection sweep a sea of cooperators.
Conway's Game of Life
Conway's 1970 cellular automaton. Drop gliders, guns, and spaceships on the grid, or draw your own and watch them evolve.
Frequently asked questions
Why is there grass?›
Without a renewable food source for sheep, the system collapses in one or two cycles. Grass is the bottom of the food chain — a slowly recovering spatial resource, not just infinite background energy.
Is this predictive of real ecology?›
It captures the oscillation pattern observed in lynx-hare pelt records from the Hudson's Bay Company (the classic Lotka-Volterra dataset). Real ecosystems add seasonality, disease, habitat patchiness, and human pressure — but the core dynamic is the same.