← back to the world

The rules of Patch World

Patch World has a short list of physical rules and no goal. Nothing in it says crawl, eat or reproduce. Bodies that do those things leave descendants, and the others return to the soil. This page is the whole list.

01One quantity, conserved

The world is a torus of 96 by 96 cells. It holds one quantity, mass, in whole units. At every tick every unit is in exactly one place: the soil of a cell, the food on a cell, or a body. No rule creates or destroys a unit. The page checks this at every tick and shows it in the caption.

soil food a body sunlight decay eating dying the price of living, one unit at a time every unit of mass is always in exactly one of these
The only flows of mass. A body pays for being alive by dropping units into the soil under its head. A dead body becomes food where it lies.

02One sun, and what grows under it

Food follows the sun around the world, and soil gathers where bodies live and die. With no bodies the world settles into a steady drift of green behind the light.

03A body, and why a shape crawls

A body is a graph of nodes joined by springs. A node holds one unit of mass. Some springs are muscles: a muscle's rest length is its resting length times one plus 0.35 times its activation, and the activation follows the brain's motor command with a lag of a half per tick. Each tick the springs are pulled toward their rest lengths in three small steps, bodies closer than 0.6 cells push each other apart, and rock stops a node where it was.

There is no inertia. What moves a body is grip. Every node has a head-ward axis, the direction to its lowest-numbered neighbour. When a node is displaced it keeps a share of the step that depends on the direction:

toward the head: keeps 0.90 away: keeps 0.15 sideways: keeps 0.10 the founders' grips; each of the three is a gene of each node
A ratchet. Pull two such nodes together and let them go, and the pair ends up further toward the head than it started.

Two checks pin the physics down. A body of two nodes and one muscle with the same grip in every direction stays exactly where it is, however it pumps: a motion that looks the same played backwards gets nowhere (the scallop theorem). With the ratchet grip the same body crawls 5.7 cells in 300 ticks. Three nodes with two muscles out of phase move even with a symmetric grip, and 10.5 cells with the ratchet. Shape and timing are everything, which is why both can evolve.

04A life

Living has a price. Each tick a body loses one unit to the soil with a probability that is the sum of these:

forper tick
being alive0.035
each node0.006
each unit of muscle work0.02
each unit of the senses a cortex reads0.0001
each brain channel0.0003
each 256 record cells0.01
writing records (16 active cells)0.008
each planning replay0.001
each slow weight, while it learns0.000004

A bigger body or a bigger brain is always possible. It has to pay for itself in food.

05What a being senses, and what it can do

The reading has twenty units. Twelve senses: the scent of food to the left against the right, the scent ahead, food under the head, rock ahead, another body ahead, its own energy, pain (for three ticks after a bite), the light, the grip of the ground, its speed, its turning, and how much of its body has grown. Then one strain per muscle, for up to eight muscles. The brain also reads a clock, the sine and cosine of a phase that advances at the rate of a gene, and the motor command it gave last tick.

It can do one thing: set nine numbers between minus one and one. Eight are muscle commands. The ninth is the mouth.

06The brain

Every being carries two patches of the same kind, a Cadence RecordPatchNet. A patch keeps a context that fades at a learned rate per channel, reads out linearly from it, and carries a store of records that remember what the readout got wrong at each reading:

retention  l = sigmoid(g + G u)             per channel, how much of the past to keep
context    h = l · h_before + (1 − l) · tanh(B u + b)
output     y = C h + c + record read        the records patch what C h + c got wrong
readingsenses · clock policyproposes the motor modelpredicts the change motor neurons8 muscles · mouth bodyand the world what actually happened is the only teacher a repair
The two patches and the motor neurons, as the inspection view draws them. The motor neurons are the muscles' activations.

A newborn's records are empty and add nothing, so on its first tick it behaves exactly as its inherited weights say. What it learns is what its own body, on this ground, does differently.

07What a child inherits, and what a birth changes

A child inherits its parent's genome: the body graph with every node's position and grips, which springs are muscles, the clock's rate, the split threshold, the motor noise, the drives, the planning horizon and radius, the number of record cells, the learning rates, the list of cortices of each patch, and every slow weight. It inherits no records. Then the genome mutates, each change with its own probability:

changeprobability per birth
each life gene steps up or down0.10 each
a node's position jitters by 0.2 cells0.20 per node
a node's three grips rescale0.12 per node
a node is added beside an existing one, half the time with a muscle0.12
a limb is mirrored across the body's axis, with its springs and muscles0.05
a leaf node is removed0.06
a spring becomes a muscle, or stops being one0.10
a cross spring joins two nearby nodes0.06
a cortex starts or stops reading one group of the reading0.05 per patch
a cortex of 4 or 8 channels is added0.05 per patch
a cortex is removed0.04 per patch
a cortex grows or shrinks by two channels0.05 per patch
a cortex splits into two that read different groups0.03 per patch
a slow weight steps by about 0.10.02 per weight

A new muscle's drive is a copy of the channel that drives the muscle it was copied from, with a shifted clock phase, or with the scent's side reversed for a mirrored limb. New channels read with small random weights and drive nothing until later mutations or learning connect them, so new structure costs before it can help. A body has at most ten nodes and eight muscles, a patch at most 64 channels.

08What is given

Three things come from outside the world. The physics above. The prices. And the founders: the first bodies come from a search that ran outside the world for a shape and a rhythm that crawl and turn toward food, as an adult and as a three-node newborn, and their model was taught by watching their own body move. After tick zero the world never sees that search again. There is no score and no fitness function.

09Night and sleep

One sun crosses the torus every 900 ticks; where its light falls below 0.35 it is night, and in the night a being senses no scent and no food under it. A genome may say sleep. A sleeper writes its model's records by day at a slow rate of zero and keeps up to 32 of the day's windows as cues; when its head is in the dark it emits no motor command, no plan and no bite, and each tick of the night it dreams one kept window through its model's records and takes one slow step on that fixed dream; at dawn it writes every dream back against the moved weights, twice, and forgets the cues. It pays the cue price for every kept window and the replay and slow prices while asleep. A being without the gene keeps acting through the dark and its model learns by day as before. Half the founders sleep; births mutate the gene like any other. Over 20,000 ticks and two seeds the gene loses: sleepers fall from 37 to 1 or 3 percent of the living, their model's late-life error is higher (0.056 to 0.058 against 0.035 to 0.049), and a gene that mutates on in an awake world stays under 6 percent. Sleep pays when the world closes; this one never does.

10Reading the page