Repository navigation
The Brain
Every organism carries one. It is only used once the body has an eye — sight is what grants movement — but it is inherited unconditionally, so a lineage that loses its eyes keeps the mind and can regain the use of it.
An Elman recurrent network with three separate weight matrices:
where
RMSNorm with an inheritable gain
| Channel | Meaning | Range |
|---|---|---|
| 0–3 | per-eye valence — what that eye sees, signed | −1…1 |
| 4–7 | per-eye proximity — 1 is touching, 0 is nothing in range | 0…1 |
| 8 | hunger — food collected over food needed | 0…1 |
| 9 | integrity — 1 minus damage over max health | 0…1 |
| 10 | age — lifetime over lifespan | 0…1 |
| 11 | random drive — fresh noise every tick | −1…1 |
Four eyes is the cap. A fifth eye still costs food and still occupies a cell, but its report never reaches the brain — evolution pays for it and gets nothing, which is the intended pressure.
Valence is a hand-set prior on cell types, not a decision. It says what is there in one signed number; the evolved weights decide what to do about it. Killer cells read negative and food reads positive because that is physics, and everything else sits near zero so evolution can assign its own meaning.
Channel 11 is the one input with no external cause. If Win evolves a
connection to it, the creature can wander spontaneously, break a deadlock, or
randomise a patrol; if those weights go to zero, it is deterministic again.
| Index | Action |
|---|---|
| 0–3 | move up, down, right, left |
| 4 |
HOLD — keep the current heading and step |
| 5 |
HALT — stay put, conserve the move |
| 6 |
REVERSE — step backwards without turning the body |
| 7 |
TURN_L — rotate the body and eyes 90° left |
| 8 |
TURN_R — rotate the body and eyes 90° right |
The highest logit wins, provided it clears brainActionThreshold; below that
the creature holds its course.
Turning is separate from moving because an eye's direction is fixed relative to the body. A creature that wants to look somewhere else must spend a move rotating, and the rotation fails if the rotated body would not fit. Without those two channels, organisms strafe — they change heading while staring the same way forever, and eye placement stops being under selection.
At
| Matrix | Size | Parameters |
|---|---|---|
| 16 × 16 | 256 | |
| 16 × 12 | 192 | |
| 9 × 16 | 144 | |
| 16 | 16 | |
| 1 | 1 | |
| total | 609 |
Weights live in one BrainArena of typed arrays indexed by slot, not in
per-organism objects, which is what makes a few thousand brains per frame
affordable. Measured cost at
clampBrainShape, and out-of-range
values are clamped with a notice rather than rejected.