A browser-based predator-prey simulation rendered in a single HTML file using JavaScript. The grid displays a canvas with a live population chart alongside it.
| Tier | Color | Eats |
|---|---|---|
| Plant | Green | — (producer) |
| Prey | Red | Plants |
| Predator | Blue | Prey and Plants |
| Super-predator | Yellow | Prey and Predators |
Discrete ticks (turn-based). Each tick, all entities act once in tier order (plants first, then prey, predators, super-predators). Processing order within a tier is randomized each tick to avoid directional bias.
Colors: - Preys are red - Predators are blue - Super Predators are yellow
Energy
Movement
Each tick, an animal scans a configurable sight radius for the nearest food target. Default to the neighbouring cells only.
If a food target is visible, the animal moves one cell toward it (Manhattan-distance step).
If no food is visible, the animal performs a random walk (moves to a random adjacent empty cell, or stays put if all neighbours are occupied).
Eating
Reproduction
| Parameter | Default |
|---|---|
| Grid size | 100 |
| Initial plant count | 500 |
| Plant spread probability | 0.03 |
| Plant regeneration probability | 0.00 |
| Initial prey count | 100 |
| Initial predator count | 30 |
| Initial super-predator count | 5 |
| Animal sight radius | 5 cells |
| Prey initial energy | 20 |
| Predator initial energy | 30 |
| Super-predator initial energy | 40 |
| Energy gained by eating a plant | 5 |
| Energy gained by eating an animal | 20 |
| Reproduction energy threshold | 40 |
| Reproduction energy cost | 15 |
| Ticks per second | 10 |
Simulation speed - Ticks per second (1–60, default 10)
Population — initial counts - Grid size (number input, 20–200, default 100) - Initial plant count (0–5000, default 500) - Initial prey count (0–500, default 100) - Initial predator count (0–200, default 30) - Initial super-predator count (0–50, default 5)
Plant dynamics - Plant spread probability (0.001–0.500, default 0.03) - Plant regeneration probability (0–100 %, default 0 %): chance per tick that a dead-plant cell spontaneously regrows into a new plant
Animal energy - Prey initial energy (5–60, default 20) - Predator initial energy (5–80, default 30) - Super-predator initial energy (5–100, default 40) - Energy gained by eating a plant (1–30, default 5) - Energy gained by eating an animal (5–50, default 20)
Reproduction - Reproduction energy threshold (10–100, default 40) - Reproduction energy cost (5–50, default 15)
Behaviour - Animal sight radius (1–15 cells, default 5)