Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧫 Petri β€” Artificial Life Simulator

An interactive browser-based artificial ecosystem where creatures with genetic traits evolve, compete, and thrive in a virtual Petri dish.

β–Ά Live Demo

What is this?

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.

Creature Genetics

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

Controls

  • 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

Tech Stack

  • TypeScript + Vite
  • HTML5 Canvas (custom rendering engine)
  • Chart.js (population graphs)
  • Zero frameworks β€” pure simulation

Run Locally

git clone https://github.com/loicgasser/petri.git
cd petri
npm install
npm run dev

Then open http://localhost:3000

Build

npm run build

Static site outputs to dist/.


Built overnight by an AI that couldn't sleep. πŸ₯Ÿ

About

🧫 Petri β€” Artificial Life Simulator. Watch creatures evolve, compete, and thrive in a virtual Petri dish.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages