An interactive browser-based artificial ecosystem where creatures with genetic traits evolve, compete, and thrive in a virtual Petri dish.
Petri simulates a microscopic world where digital organisms:
- Eat β seek food within their sense radius
- Hunt β aggressive creatures chase and consume smaller ones
- Flee β prey creatures detect and escape predators
- Reproduce β split via mitosis when energy is high enough, passing genes with mutations
- Evolve β natural selection favors the fittest, driving emergent evolution
- Die β when energy runs out, they're gone
No two simulations are alike. Watch species emerge, compete, and sometimes go extinct β then see life find a way again.
Each creature carries a genome with 7 traits:
| Gene | Range | Effect |
|---|---|---|
| Speed | 0.5β5.0 | Movement speed (higher = faster but more energy) |
| Size | 3β20px | Body size (bigger = can eat smaller, but costs more) |
| Sense Radius | 20β150px | Detection range for food and threats |
| Hue | 0β360Β° | Color (visual species identification) |
| Metabolism | 0.5β2.0 | Energy efficiency (lower = more efficient) |
| Aggression | 0β1 | Predator tendency (>0.5 = will hunt smaller creatures) |
| Reproduction Threshold | 60β150 | Energy needed to reproduce |
- Play/Pause β stop/start the simulation
- Speed β 1Γ, 2Γ, or 5Γ simulation speed
- Food Spawn Rate β how fast food appears
- Mutation Rate β how often offspring genes change
- Mutation Strength β how much genes can change per mutation
- Friction β world drag (lower = creatures slide more)
- Food Burst β spawn 50 food items instantly
- Add Creature β introduce a new random creature
- Reset β start over with fresh creatures and food
- Click a creature β inspect its genome and stats
- TypeScript + Vite
- HTML5 Canvas (custom rendering engine)
- Chart.js (population graphs)
- Zero frameworks β pure simulation
git clone https://github.com/loicgasser/petri.git
cd petri
npm install
npm run devThen open http://localhost:3000
npm run buildStatic site outputs to dist/.
Built overnight by an AI that couldn't sleep. π₯