A small experiment in genetic programming · 07 September 2026

Branchwater

Bodies inherited. Behaviors computed.

A toy genetic-programming ecosystem—not realistic DNA, learning during life, or guaranteed progress.

THE COMMON WATER0.0 s

Plants · swimmers colored by lineage · snout: green herbivore, gold omnivore, coral carnivore · click or use the inspectors

64creatures / 180
500plants / 900
0animal births
0animal deaths
0highest generation
0plant births
0plant deaths
—herb / omni / carn

Set the conditions

Independent chance per animal body/diet value, behavior tree, and plant trait at birth. Existing individuals do not change.

Same seed + settings + control timing, same simulation. Speed is limited by your device. Full speed has no real-time target; it yields after short computation batches so controls and rendering can run. Hidden tabs do not advance.

READ AN INDIVIDUAL

A body and two expressions

Choose a swimmer in the pond or use the dropdown.

Its body and program are fixed for life. The same expressions can produce different actions as their inputs change.

Rooted, but evolving

Plants grow using sunlight and reproduce from their own energy. Click a plant or choose its ID to inspect its inherited traits.

Population, not a fitness score

One sample every 2 simulated seconds; at most 120 samples. Extinction is possible. More creatures or larger programs do not mean “better.”

What is actually evolving?

Inherited bodies, programs, and diets

Animal radius (3–8), thrust (20–65), sensor range (30–160), diet (0–1), and two expression trees are fixed for life. Random founders have no built-in chasing policy: turn and drive come only from their programs. This is evolution at birth, not lifetime learning.

Diet is a continuum, not a locked species. Below 0.25 is labeled herbivore; above 0.75 carnivore; the middle omnivore. Descendants can cross these bands. Plant assimilation is 0.8 × (1 − diet)²; meat assimilation is 0.8 × diet². Generalists can use both, less efficiently. The labels do not change the equations.

Food inputs now sense plants. preySin / preyCos / preyNear / preySeen sense the nearest other living animal; any animal can be prey. neighborSin / neighborNear remain available. Bearings are relative to heading, Near is 1 − distance/range, Seen is 1 or 0; absent target inputs are zero. Energy and age are bounded fractions of 180 and 160; noise is seeded −1…1, wave is sin(2 × age).

Constants, inputs, negation, tanh, add, subtract, multiply, min and max form bounded trees: at most 31 nodes and depth 5 each, all intermediate values clamped to −8…8. Both programs use the same sensory snapshot. Displayed values are rounded, not computation. No arbitrary JavaScript is executed.

Plants inherit three traits

Growth (0.5–2), seed dispersal (8–100 world units), and defense (0–1) mutate at birth. Per second, a plant gains sunlight × growth × (1 − defense/2), capped at 60 energy before upkeep of 0.06 + 0.08 × growth² + 0.10 × defense. Defense slows grazing but reduces photosynthesis and costs upkeep.

At energy ≥42, age ≥5 and no cooldown, a plant can seed nearby if capacity remains. Parent and child each retain 45% of pre-birth energy; 10% is lost. Seeds disperse in a random direction up to the parent's dispersal range. Cooldown: 5 seconds. Plants die at zero energy or age 240. There is no automatic reseeding.

Transfers, costs, and limitations

Each tick an animal can graze one contacting plant, draining up to 90 × (1 − diet) / (1 + 4 × defense) energy per second. It can bite one contacting animal, draining up to 60 × diet × (attacker radius / prey radius) per second. Each drain is limited to the target's remaining energy; the eater receives only its assimilation fraction, capped at 200. No carcasses or free energy appear through predation.

Animal upkeep per second:

0.3 + 0.004 × sense + 0.03 × radius² + 0.0008 × thrust² × drive² + 0.001 × total tree nodes

At energy ≥155, age ≥8 and no cooldown, an animal can reproduce if capacity remains. Parent and child each retain 47%; 6% is lost. Cooldown: 8 seconds. Animals die at depleted energy or age 160. Extinction and unstable food webs are possible; no equilibrium or inevitable progress is promised.

The 900 × 560 world wraps. Start: 64 unrelated animals at 90 energy and 500 plants at 24 energy; caps 180 and 900. Sunlight is the only continuing energy source. Plants grow first, animals act sequentially, deaths free slots, then survivors reproduce. Earlier animals can gain an ordering advantage. Killed individuals cannot act again or reproduce; newborns wait until the next tick.

Fixed 1/30-second ticks. Normal speeds process at most 24 ticks per rendered frame. “As fast as possible” runs untimed batches with an 8 ms work budget before yielding (a single tick may exceed it); rendering still follows browser animation frames. It can use substantial CPU. Pause or lower the speed to reduce load; hidden tabs do not advance.