How solvedsphinx126/life-simulation works
This repository implements a browser-based ecosystem simulation: users load an XML scenario, the browser creates and configures a Rust/Wasm map, and the simulation advances while the browser renders it. Users can adjust simulation speed and export reports; completed runs are ranked in a leaderboard. The Rust implementation is concentrated in one large source file, so several domain components share that path. The excerpts show the browser-to-Wasm calls and selected simulation behavior, but not every internal interaction.
Main entry points: lib.rs Map and tick · index.js Report export
Components 14
Browser interface
- XML scenario loader
www/index.js - Speed controls
www/index.js - Canvas renderer
www/index.js - Report export
www/index.js - Run leaderboard
www/index.js
Simulation engine
- Map and tick
src/lib.rs - Movement and vision
src/lib.rs - Simulation score
src/lib.rs
Ecosystem domains
- Rocks and obstacles
src/lib.rs - Plant growth
src/lib.rs - Grazer behavior
src/lib.rs - Predator behavior
src/lib.rs - Genes and mating
src/lib.rs
Other components
- Scenario user
Connections 14
- Scenario user → XML scenario loader: loads scenario
www/index.js - Scenario user → Speed controls: sets speed
www/index.js - XML scenario loader → Map and tick: configures map
www/index.js - Speed controls → Canvas renderer: sets delay
www/index.js - Canvas renderer → Map and tick: ticks and reads
www/index.js - Map and tick → Movement and vision: uses movement
src/lib.rs - Map and tick → Rocks and obstacles: stores entities
src/lib.rs - Map and tick → Plant growth: ticks ecology
src/lib.rs - Map and tick → Grazer behavior: ticks ecology
src/lib.rs - Map and tick → Predator behavior: ticks ecology
src/lib.rs - Predator behavior → Genes and mating: mates and births
src/lib.rs - Report export → Map and tick: gets report data
www/index.js - Report export → Run leaderboard: records score
www/index.js - Report export → Simulation score: gets score
www/index.js