Skip to content

Deterministic co-evolving ecosystem core and CLI - #3

Merged
mahim37 merged 6 commits into
mainfrom
core-sim
Sep 20, 2026
Merged

mahim37 merged 6 commits into
mainfrom
core-sim

Conversation

@mahim37

@mahim37 mahim37 commented Sep 6, 2026 •

Copy link
Copy Markdown
Owner

Adds the new simulation core and command-line tool under crates/. The legacy libs/ and www/ are untouched and still build, test and deploy; they are deleted once the browser app has replaced the site.

What is in

Area Summary
crates/rustywings-core Open-ended co-evolving ecosystem: energy, reproduction and death instead of generations; sparrows eat seeds, hawks eat sparrows; heritable body traits with energy costs; feed-forward brains. Struct-of-arrays agents, counting-sort spatial hash, postcard snapshots, validated config, a standardised learning arena. #![forbid(unsafe_code)], missing_docs on.
crates/rustywings-cli rustywings run / bench / verify / arena / config.
Determinism Owned xoshiro256++ RNG, libm for all transcendentals, no hash maps or threads inside a step. A golden checksum is pinned in the tests and CI runs it on Linux, macOS and Windows. Snapshots resume bit-for-bit.
CI fmt, clippy -D warnings, cargo test --workspace, cross-OS golden test and the arena learning test on every push.

Numbers (native)

Measurement Result
Tests 44 in core (one slow test ignored by default), 120 across the workspace
Ecology, seeds 1 to 4, 60k ticks sparrows 335 to 625, hawks 20 to 138, seeds 80 to 230, zero rescue immigrants
Trait arms race after 60k ticks sparrow field of view about 300°, hawk about 120°
rustywings arena (30k ticks, 3 seeds) evolved sparrows eat 3.4 to 6.5 times more than random ones; CI threshold 1.3
rustywings bench 8.4 ms/tick at about 4,000 birds; 1.7 ms/tick at about 1,100

The first defaults produced a predator overshoot that pinned herbivores to the rescue floor. A 22-variant sweep with the CLI found the adopted set.

Reviewing

  1. crates/rustywings-core/src/world.rs (step and the phase methods), then arena.rs.
  2. cargo test -p rustywings-core and cargo run --release -p rustywings-cli -- arena --seeds 3 --ticks 30000.

Each commit builds and passes its tests on its own.

Start the new simulation crate: an owned xoshiro256++ RNG, math routed
through libm so results are bit-identical on every platform and in wasm, a
pure-arithmetic atan2 for retina binning, a stateless feed-forward brain
evaluator, the retina geometry and a counting-sort spatial hash.

Commit Cargo.lock (the workspace ships binaries) and set release and dev
profiles; opt-level 1 in dev keeps the numeric test suite fast.
Agents are struct-of-arrays so hot loops stream through memory and frames
export as flat copies; removal swap-removes every column in lock step. A
genome is brain weights plus four heritable body traits, each with bounds.
Plants regrow logistically around slowly drifting patches. Config is a
plain serde tree that rejects unknown fields and validates ranges with
dotted-path errors; every field carries its unit in a doc comment.

World::step runs sense, think, eat, move, metabolise, cull, reproduce,
immigrate, regrow, each phase borrowing only the columns it needs. Energy
pays for moving, seeing and living; a bird with enough energy reproduces,
one with none dies, and a species that falls below a floor may receive
immigrants with fresh genomes. Snapshots are postcard with a magic and
version check. A golden checksum for seed 1 at tick 2000 pins behaviour.
A fixed-seed world with plenty of seeds, no reproduction, death or
immigration, where one genome forages for a set number of ticks. The
score is meals eaten, and the ratio of an evolved genome's score to a
random one's is the learning metric CI gates on. An ignored slow test
checks that 40k ticks of evolution beat random by a wide margin.
run writes per-tick stats as CSV or JSON lines and can save a snapshot;
bench reports ms per tick at a chosen population; verify prints the world
checksum for a seed and tick and optionally asserts it; arena evolves a
few seeded worlds in parallel and fails below a learning ratio; config
prints the defaults as JSON to edit and pass back with --config.
Lint and test on every push. The golden checksum test runs on Linux,
macOS and Windows so a seed is proven to mean the same world everywhere,
and the arena job fails if evolved sparrows stop out-foraging random ones.
@vercel

vercel Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rusty-wings Ready Ready Preview Sep 6, 2026 11:06am UTC

Vercel's default runtime for this project reached end of life and preview
builds started failing. The legacy site is untouched otherwise.
@mahim37
mahim37 merged commit c10f92b into main Sep 20, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Preview — 1019f59c Deployed Sep 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant