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.
02One sun, and what grows under it
- Light. A band of light crosses the torus once every 900 ticks, a day. Its contrast breathes over 9,000 ticks, a season. Nothing else comes from outside.
- Growth. In each cell, each tick, one unit of soil becomes food with probability 0.05 times the light times the cell's fertility. Fertility rises with the soil up to four units. A cell holds at most eight units of food.
- Decay and diffusion. A unit of food returns to the soil with probability 0.01. A unit of soil moves to a random neighbouring cell with probability 0.05.
- Rock covers a tenth of the cells. It holds no soil and no body can enter it.
- Mud covers about a fifth. On mud a body keeps 45 per cent of every step.
- Scent. The food field, blurred, is what a head can smell. It reaches about eight cells.
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:
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
- Birth. A newborn has the first three nodes of its genome, paid out of the energy it was given. It grows one more node for each unit of energy above six, until its body is complete.
- Eating. A head over food takes one unit per tick.
- Splitting. A fully grown body whose energy reaches its split threshold (a gene, 24 to 80) gives half of it to a child that appears behind its tail with a mutated genome.
- Biting. When the mouth port is above a half and another body is just ahead, the bite lands half the time and takes one unit of energy, or a node if the victim has no energy left. A bite attempt costs 0.1.
- Death. A body at zero energy, or with fewer than two nodes, dies. Its nodes become food on the cells under them.
Living has a price. Each tick a body loses one unit to the soil with a probability that is the sum of these:
| for | per tick |
|---|---|
| being alive | 0.035 |
| each node | 0.006 |
| each unit of muscle work | 0.02 |
| each unit of the senses a cortex reads | 0.0001 |
| each brain channel | 0.0003 |
| each 256 record cells | 0.01 |
| writing records (16 active cells) | 0.008 |
| each planning replay | 0.001 |
| each slow weight, while it learns | 0.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
- The policy reads the reading, the clock and the last motor and proposes this tick's motor. At birth it is a reflex: the clock drives the muscles in a rhythm and the scent's side tilts it.
- The model reads the reading, the clock and the motor that is about to be executed and predicts how each unit of the reading, and the energy, will change. One tick later it is taught what actually changed.
- Cortices. Each patch is a list of cortices. A cortex is a block of channels that may read only the groups of the reading its mask names (scent, obstacles, self, motion, muscle strains, clock, last motor), with its own slowest memory (8, 32 or 128 ticks). The whole brain still settles and learns as one patch. Who reads what is what evolves.
- Records live in the model: 0 to 1,024 cells, a gene. Each cell reads eight units of the reading and the context, the sixteen most driven cells are the reading's code, and the residual of the prediction is written into exactly those cells.
- Learning in a life. Every eight ticks each patch takes one step on its slow weights over that window, at a rate that is a gene and may be zero, and writes its records.
- Planning. A being whose horizon gene is 1, 2 or 4 imagines that many ticks ahead through its own model and repairs the motor, within a radius of what the policy proposed, toward its drives. The drives are genes: how much it wants the scent ahead and the food under it to rise, pain to fall, speed to rise and energy to rise. It executes the first repaired motor.
- Readback. An imagined improvement is not a fact. The policy learns a repair one tick later, and only if what actually happened beat what the model had predicted for the unrepaired proposal.
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:
| change | probability per birth |
|---|---|
| each life gene steps up or down | 0.10 each |
| a node's position jitters by 0.2 cells | 0.20 per node |
| a node's three grips rescale | 0.12 per node |
| a node is added beside an existing one, half the time with a muscle | 0.12 |
| a limb is mirrored across the body's axis, with its springs and muscles | 0.05 |
| a leaf node is removed | 0.06 |
| a spring becomes a muscle, or stops being one | 0.10 |
| a cross spring joins two nearby nodes | 0.06 |
| a cortex starts or stops reading one group of the reading | 0.05 per patch |
| a cortex of 4 or 8 channels is added | 0.05 per patch |
| a cortex is removed | 0.04 per patch |
| a cortex grows or shrinks by two channels | 0.05 per patch |
| a cortex splits into two that read different groups | 0.03 per patch |
| a slow weight steps by about 0.1 | 0.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
- Click a body to open its card: its shape with the muscles at work, its reading, both patches, its plan, and its prediction against what happened.
- Inspect follows the body beside its whole brain. Every neuron is a sphere sized by its activity. Every weight is a line that shines with the signal it carries this tick. The grid is the record cells, the lit ones are this reading's code. The column in the middle is the motor neurons.
- Colours follow the lineage, or the shape of body and brain, as you choose. The chart in the world card shows the eight largest lineages over time.
- Export chronicle writes what every lineage did every hundred ticks, the events, and genome samples. The example's
why.pyreads that file and says why one lineage took the world.