cadence / patch world / helpBack to the demo

Patch World

A small world of creatures that forage, drink, flee a predator, bear young and die. Berries nourish them in summer and make them sick in winter, and nothing a creature senses says which season it is.

What it shows about CadenceA Cadence brain learns while it lives. Each creature’s brain has real memory and a real state that carry on from moment to moment, and it runs in real time in your browser, like the brain of a living animal. When winter turns the berries poisonous, the learners find out by eating one and learn to leave them. Their frozen twins, the same brains without learning, keep eating.

What you see

On the left, the world seen from above; under it, the controls. On the right, panels that count what happens. Click a creature and its brain opens below, live.

learner ring: energy learning gold glow frozen twin never learns ? random walker no brain predator berry root cache hidden nuts
The creatures and things of the world. A creature turns green while it is sick from a winter berry.

Why it matters

Most neural networks learn once, from a fixed collection of examples, and are then frozen and deployed. In this world such a brain is the frozen twin: it keeps the habits of the summer it was frozen in, and in winter it eats the poisonous berries, again and again.

A learner has the same brain at the start, and it keeps learning for its whole life, from what its own actions bring. Its brain is one continuing state: what it made of the last moment carries into this one, and it remembers what its actions brought in which situations. Nobody tells it that the season turned. It eats a berry, falls sick, and the surprise wakes its learning. Within a few hundred moments it leaves most berries it stands on. When summer returns it tries them again, slowly.

Learning on surprise. A calm learner answers from its settled state, learns nothing and pays for no learning. A surprise (a berry that poisons where berries used to nourish) or a want (too little food) arouses it; then it tries alternatives and learns from the outcome. A robot or a game character in a world that changes under it needs the same.

Evolution on top. A well-fed learner bears a child that inherits a copy of its brain as it is and mutated genes; everything a brain and a body have costs energy every moment. The page’s eight founders are the best survivors of two rounds of such evolution.

What you can do

How it works

A moment

Every moment each creature senses, its brain settles on an action, and it acts. The senses are 38 numbers: for each of four directions the nearest berry, root, leaf, water, predator and other creature within its sense range; what lies underfoot; its energy, thirst, daylight, nausea while a poisoning lasts and the cold of the air; and where it is. The air follows the season slowly, so for a while after a turn it feels like the season before. The actions are north, east, south, west, eat and drink. With every moment the brain also receives what its last action brought: food, water, poison, a bite, or a small cost for eating where there is nothing.

The brain

Each learner is one Cadence brain built with Brain.compose, living through brain.live. Its regions are named for the role they play:

senses
The visual cortex, the insula (the body), taste and touch, and place. They enter through the thalamus.
association cortex
Where the senses, the memory and the motor strip meet and settle together into one agreed state.
prefrontal cortex
The working trace: what the brain made of the last moment, carried into this one.
motor strip
Six neurons, one per action; the brightest after the settle is the action.
striatum
The critic, which judges how good the situation is, and the actor, which picks the action.
dopamine nucleus
After a lesson, gold when the outcome was better than expected, blue when worse. It tells the synapses which way to change.
locus coeruleus
Arousal: surprise and want. Above the creature’s threshold the brain learns.
hippocampus
Memory: what an action brought in a situation, and, with the recall gene, recent moments in slots that light when read.

The brain view replays the settle the action came from, sweep by sweep: neurons light with their activity, fibre tracts glow with the signal their synapses carry (warm excites, cool inhibits) and shimmer white where this moment’s lesson changed synapses.

Learning, memory and costs

Aroused, the brain samples its policy, learns from the outcome through eligibility traces (credit reaches back over its recent actions) and writes the outcome to its associative store. Every part of a creature costs energy every moment: its neurons, a recall memory, its sense range, its speed, its size, and every learning sweep. A creature that stores enough energy bears a child that takes half the energy, a copy of the parent’s brain and mutated genes. Up to 12 learners live at once. Frozen twins and random walkers bear no young; a dead one is replaced.

The founders were bred offline with the same Python code that runs in the page: a nursery world where nobody dies, then two rounds of evolution in the mortal world. The frozen twins carry the founders’ brains as they were at the end of a summer.

The numbers

The season flip, measured in 32 worlds where nobody dies (the eight founders as learners beside their frozen twins, 1,000 moments of summer, then 1,500 of winter). The share of berries eaten when standing on one:

100%50%0% summer, 1,000 moments winter, 1,500 moments frozen twins learners flip
Each point is 100 moments, averaged over 256 learners and 256 twins (evidence/flip.json).
ReadingLearnersFrozen twins
Berries eaten when standing on one, last 100 moments of summer99%97%
… first 100 moments of winter45%98%
… moments 400 to 500 of winter18%97%
… last 100 moments of winter5%96%
Berries eaten per 100 moments, first 300 moments of the first winter, then of the second0.60, 0.320.15, 0.15
Mean age at death in a mortal world without births (95% interval)3,933 (3,554 to 4,290)284 (248 to 324)
Intake per moment, same worlds (random walkers: 0.037)0.2090.069
Learners that outlived their own twin253 of 256

Where the numbers come from, in the demo’s folder of the repository: the season flip, evidence/flip.json; the two winters, evidence/seasons.json; the lifespans and intake, evidence/controls.json. All on fresh world seeds the breeding never used.

On this page the same flip, run by a script on the real page with its own button (tools/promise_flip.py, evidence/promise-flip-20261113.json): in the 300 moments of summer before the flip the learners ate 68 of the 70 berries they stood on (97%); in the 850 moments of winter after it, 27 of 114 (24%; 21% in its first 150 moments and 21% from its 500th moment on); the two frozen twins ate all 15 they stood on in that winter. The page’s world is harder than the measured worlds: learners die and are born through the winter (12 alive at the flip, 3 to 5 in its second half), so the share falls less far than the 5% above.

The page itself (evidence/page-check.json, headless Chromium on an Apple M4): it ran 43.7 moments a second with 12 learners, 2 frozen twins and 2 random walkers in four brain workers, and drew the brain view in 2.5 ms a frame.

Limits