Ecology: Predator–Prey
This scenario simulates a classic predator–prey ecosystem (e.g. rabbits and foxes). It’s useful for building intuition about cycles, stability, and cause → effect delays in biological systems.
What you’re simulating
- Prey grows when conditions are favorable.
- Predators increase when prey is abundant.
- As predators rise, prey falls; when prey falls, predators later fall too.
- This feedback loop often produces oscillations instead of a single “steady” outcome.
Run it (web UI)
- Open Examples
- Choose Ecology → Predator–Prey
- Click Run
Run it (local SimUI)
From the B‑Simulant library repo:
pip install "bsim[ui]"
python examples/ecology_simui_demo.py --mode predator-prey --port 8765Open http://localhost:8765/ui/.
What results to expect
- Population over time: prey and predator typically rise and fall in repeating waves.
- Phase space (predator vs prey): often forms a loop (a “cycle”) rather than a straight line.
Parameter presets (and what they mean)
| Goal | Steps | dt | Expected result | What it means |
|---|---|---|---|---|
| Quick preview | 500 | 0.1 | You’ll likely see the start of a rise/fall cycle. | Enough to confirm “it’s alive”, not enough to judge long‑run stability. |
| Standard run | 2,000 | 0.1 | Clear oscillations (waves) in prey and predator. | Classic delayed negative feedback: predators lag prey. |
| Longer horizon | 10,000 | 0.1 | Repeated cycles; you may see drift or damping depending on conditions. | Shows whether the system is robust (persistent cycles) or converges to equilibrium/collapse. |
| Smoother curves | 5,000 | 0.05 | Similar dynamics, but plots usually look smoother. | Smaller dt reduces numerical artifacts; costs more compute. |
What to try (and why)
- Increase Steps: see whether cycles persist, dampen, or explode.
- Change dt: smaller values can look smoother but run slower.
If your UI exposes additional domain controls (for example temperature), use them as “stress tests”. Moving conditions away from a population’s optimum can shrink oscillations, shift the cycle timing, or trigger collapse/extinction.