Back to portfolio
simulation2025

Species Simulator

Real-time ecosystem simulator visualizing predator-prey dynamics with genetic algorithm evolution

TypeScriptHTML5 CanvasVite
Personal Project
2025
Species Simulator

Overview

A real-time ecosystem simulator that visualizes predator-prey dynamics on a grid world. Creatures hunt, forage, reproduce, and die based on energy levels, vision range, and environmental conditions, producing emergent population fluctuations over time. A genetic algorithm layer lets traits evolve across generations, revealing natural selection in action.

Challenge

Simulating believable ecosystem behavior requires balancing dozens of interacting parameters — energy costs, reproduction thresholds, vision ranges, food regrowth rates — where small changes cascade into population booms or crashes. The simulation needed to run smoothly at high speed while rendering thousands of entities on canvas.

Solution

Built with TypeScript and HTML5 Canvas with zero runtime dependencies. Each creature type has configurable parameters (20+ settings) governing behavior, energy, and reproduction. A grass growth system and road placement mechanics shape the environment. Speed controls (1x–10x) allow fast-forward observation of long-term dynamics, and population history charts track species balance over time.

Results

The simulator produces emergent predator-prey cycles matching classic Lotka-Volterra dynamics. The genetic algorithm visualization reveals how traits like speed and vision range evolve under selective pressure. Settings persist via localStorage for iterative experimentation.

Key Features

01Predator-prey population dynamics with real-time visualization
0220+ configurable creature parameters
03Grass growth and foraging system
04Road placement mechanics affecting habitat
05Speed controls (1x–10x) for fast-forward simulation
06Population history charting
07Genetic algorithm evolution visualization
08Settings persistence via localStorage
09Zero external runtime dependencies

Gallery

Species Simulator — genetic algorithm evolution charts