Predator-Prey Simulation — Specification

Overview

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.

Grid

Entity Tiers

Tier Color Eats
Plant Green — (producer)
Prey Red Plants
Predator Blue Prey and Plants
Super-predator Yellow Prey and Predators

Time Model

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.

Entity Behaviors

Plants

Animals (Prey, Predators, Super-predators)

Colors: - Preys are red - Predators are blue - Super Predators are yellow

Energy

Movement

Eating

Reproduction

Configuration Parameters (with defaults)

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

UI

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)

Open Questions