T-018: Eggs, mutation and asexual reproduction
Goal
Organisms make offspring, with mutation, inside the world. See docs/DESIGN.md section 7.
Scope
- Gonad cells save energy and matter, then release an egg: one cell with a mutated copy of the genome and a yolk. Egg size and the age or size at which breeding starts are genes.
- Eggs are physical objects: they drift, sink or float, can be eaten, and hatch into a growing body through the development code from T-010.
- Mutation is applied when the genome is copied, using the operators from T-010.
- Birth and death hooks that T-019 will log.
Done when
- ☐ A seeded population of simple light-fed bodies reproduces for many generations without dying out or filling the world, on at least 3 of 5 seeds, with default params. If it cannot be made stable, report what goes wrong. T-023 does the deep tuning.
- ☐ Matter audit from T-017 still holds.
Added 2026-12-02: what the genome hands you (from T-010)
Read docs/GENOME.md. The mutation operators, their evolving rates, the genome store and
the egg-to-body growth all exist and are tested.
egg_matterandmaturityare genome-wide genes reserved for you. Nothing reads them.- The growth code cannot release a cell. Releasing one is reproduction, so it is yours.
- How does a new world get its first genomes? Nobody has decided.
Genome::randomexists for tests: 39% of what it makes is a single cell, and a few proportions inside it are fixed numbers that are not inParams, which breaks principle 7. Decide how a world is founded (for example from the simplest thing that can breed, or from a random spread), put every number inParams, and write the decision indocs/DESIGN.md. The founding must not smuggle in a body plan: principle 1. - Default mutation rates give about one mutation per copy of a three-gene genome. That is a starting guess for the tuning campaign (T-023), not a finding.
Added 2026-12-02: the lineage log is ready for you (from T-019)
docs/ARCHITECTURE.md section 18 documents the hooks. In short:
- Call
lineage::birth(w, slot, &parents)in the same step you spawn the organism. Any number of parents. Capture each parent withParent::of(w, slot)while it is alive. - Call
lineage::death(w, slot, cause, other_uid)before the despawn. Cause numbers come in blocks owned by each module, so you add yours without editinglineage/. lineage::breedis a stand-in for reproduction used by tests. Replace its uses with the real thing where that makes sense, and keep the tests' coverage.- A birth costs about 13 bytes in the log when the genome is unchanged and about 45 with a mutated genome. A child that mixes genes from two distant parents costs about 95, which matters for sexual reproduction later (T-030).
Added 2026-12-02: the economy is ready for you (from T-017)
Read docs/METABOLISM.md, at least sections 1, 2 and 6 and the table "What other modules
call". In short:
- Paying for an egg:
metabolism::withdraw(w, parent, matter, energy), thendevelop::spawn_eggwith the same amounts. To save up for one, setorgs.metabolism.want_matterandwant_energy, as growth does. - Founding a world:
metabolism::seed_egg(w, genome, pos, matter, energy)takes the matter out of the water and reports the founder to the lineage log. A real run must showAudit::exempt == 0: no body outside the economy. - Worlds from genomes are outside the economy today.
runner run --genomes(T-065) makes bodies with endless energy, like the test soup. That was right for a testbed and is wrong for a breeding world. Giverunner runa way to found a world inside the economy throughseed_egg, from the same sources (files, random, mutants), and keep the testbed form for tests and benchmarks. The first long run (T-044) starts from your founding. - Most random bodies cannot feed themselves. 15 of 40 founder body plans could not live on light alone with the first prices. A founding that depends on luck will often give a dead world. That is information for your founding decision, not a reason to pick body plans by hand (principle 1).
- Time scales with the first prices: bodies live 20 to 26 days in the light, about 80,000 steps. Prices are a first working set. T-023 tunes them; say what you had to change to get a population that lasts.
- A stand-in for breeding exists in
crates/sim/examples/metabolism_lab/audit.rs: a body that holds enough for an egg pays for one and the egg is laid beside it, half the time with one mutation. It was there so the audit had births and deaths. Replace it with the real thing and keep the audit's coverage: 0 quanta of drift over a long run with real births. - Deaths by starvation are already reported to the lineage log (cause 16). You report births, and any death of your own (an egg that fails, for example) with your own cause numbers.