Brain v4, live in your browser
This is brain v4's real code (compiled to WebAssembly) and its trained minds, learning live in your browser. It was never trained on your layout; everything it does here it learns during this life.
By default you see the full brain: four specialist parts (each a 420 KB mind; two share one mind file) and the learned router that picks which part lives the life. You can switch to the single 420 KB mind (v4_meta3) to compare them on the same room.
Tap or drag on the room to add or remove walls. Drag the green food or the S (where each try starts) to move them.
Steps to the food, one bar per try, the latest 120. The line is the mean of the last 10.
What is going on
- What it senses, 24 numbers a thought, the layout of the task family it was raised on: the direction to the food (a unit arrow that points straight through walls), where it is, whether it just bumped into something, and the reward it just felt. It does not see the walls: it learns of one only by running into it.
- What it does: two numbers that move it. At the start of every life its moves are turned by a random quarter turn and given a random speed, so it first has to find out which way its own moves take it.
- A try ends when it reaches the food (reward 1) or runs out of time (4 × the length of the shortest way round the walls ÷ its speed, plus 20 thoughts). Then it starts again at S. There is no other reward and nothing tells it where to go.
- Memory of moves: the single mind carries a small whole-life memory of moves that failed (where it was, which way it moved, and then nothing changed, or it felt a loss) and leans firmly away from repeating them there. In the full brain this memory belongs to one part: the fourth part is the place part with its own whole-life memory of moves that failed and moves that paid, speaking only while that part acts (its body map is told the move actually made).
- A taste for the new (new, full brain only): beside the full brain sits a small counter of what it has sensed in this life. A place sensed for the first time adds 0.1 to the reward the acting part's mind is given, the hundredth time 0.01; nothing else is touched (the memories of moves, the parts' maps and the router see the true reward). In our research gym, on lives never used before, the full brain with it scored 0.489 against 0.468 without on 10 kinds of task it never trained on (+0.021, ahead in 3 of 3 blocks, 384 lives a kind; detours 0.25 to 0.35, water maze 0.74 to 0.79, foraging 0.89 to 0.93), with no kind of task worse, under a rule written before the run. On this page's room it changes nothing we can measure: with the way map both versions reach the food in 100% of the last quarter of their tries in all four presets (16 lives each), with the same number of steps. The single mind does not have it: tested the same way on three independently raised minds it helped detours and foraging but hurt the water maze (0.63 to 0.59; for this page's mind 0.64 to 0.55), and it did not pass its rule, so it stays off there.
- Way map (new): both brains carry a memory of places for the whole life, keyed by their own sense of where they are (the room cut into 10 × 10 cells). Nothing of your room is given to it. From its own moves it learns how its acts move it, which ways are open (it walked them), which are walls (a move that did nothing), how many cells each place it walked was from the food once it has found it, and which places it has tried without getting anywhere. It stays silent until a move has failed or two tries in a row ran out of time; from then on it tells the acting mind where to head next (the direction sense is rewritten to point at the next cell) and steers the move along that way. Inside a maze it is this map that does the steering; the minds' own steering is too coarse for corridors one cell wide. Tick Show its map to watch it: green cells are the way it remembers to the food (stronger nearer the food), red bars are ways that failed (thick: a wall it is sure of), the dashed square is the cell it is heading for.
- Learning happens only in this life: the minds' raised weights stay fixed and what they learn lives in their fast links and recurrent state, as in our benchmark. Reset brain starts a fresh life from the same mind files.
- The full brain has four specialist parts, each a whole mind lived its own way: the place part (raised with a place-finding task, with a learned map of how its moves change what it senses), the body-map part (the same kind of map, switched on and off by its own chooser), the base mind (v4_meta3) and the place part with its memory of moves (above). Only one part acts at a time. The life starts on the place part while the router watches: after 5, 10, 20, 40, 80 and 160 thoughts it compares what it has sensed so far with its memory of 1,600 earlier worlds (each lived by all four parts), and as soon as the nearest ones clearly say which part did best there, that part lives the rest of the life (with a short trial: back to the place part if the new one earns less than expected). A start unlike anything it remembers keeps the place part. The router panel shows this as it happens. Of the routers we tested, this is the best: it scores above the router with three parts both on kinds of task it never trained on and on familiar ones, at least level with the best single part on the new kinds and well above it on the familiar ones.
- What to expect: in every preset it should reach the food within its first few tries and then walk nearly the shortest way, try after try. In our runs of this page's own code (16 lives of 12,000 thoughts for each brain, the share of the last quarter of a life's tries that reached the food): wall in the way 100% (full brain) and 100% (single mind) with the map, against 48% and 78% without; simple maze 100% (full brain) and 100% (single mind) with the map, against 53% and 39% without; diagonal wall 100% (full brain) and 100% (single mind) with the map, against 51% and 58% without; empty room 100% (full brain) and 100% (single mind) with the map, against 100% and 98% without. Draw a wall across its way and watch the remembered way being dropped and a new one found; move the food and the map notices that its arrow no longer points where it did and starts over. The corridor maze (one-cell corridors and dead ends) was measured in the research gym rather than on this page: there the single mind's four raisings with the map reached the food in 100% of the last quarter of their tries (384 lives, every one of them), against 16% without it. What it does not do yet: if you take a wall away, it keeps to the longer way it knows and does not look for the shortcut. Switch between the full brain and the single mind to compare them: the switch starts a new life in the same room, with the same turn and speed for its moves.
- What is the map's and what is the minds', said plainly: the numbers above are the brain with its way map. Without the map (the page as it was) walls were its weak spot, and the single mind did a little better with them than the full brain. The map's rules are written by hand, like the memory of moves; what it knows of this room it learns in this life. A mind that walks a maze by its own steering, reading the map only as a sense, is the next step.
On whole kinds of task it never trained on, the single mind's recipe (with its memory of moves) scores 0.51 ± 0.04 across three independent raisings, against 0.076 for tuned PPO after the same experience (results). This page measures only what you see above.
How it runs: brain v4's C core and its parts (unchanged), the router (the research program's own code for this setting, four parts) and a C port of the gym's field rules are compiled to one WebAssembly file (about 300 KB) that thinks in a Web Worker; the mind files are loaded as they are. Checks: on the same inputs the WebAssembly build gives bit-identical acts to the native build (single mind: 100,000 thoughts; full brain: 20,000); on the same gym lives the WebAssembly router makes the same choices, at the same thoughts, with the same results as the research program; and the ported field gives the same senses and rewards as the gym's own nav and detour code. The way map is the research branch's own file: with it switched off the build gives the same acts as before to the last bit, and with it on the WebAssembly build gives the same acts as the native build (single mind 100,000 thoughts, full brain 20,000, and lives with a wall added). The memory of moves is the research branch's own code: with it, single parts give the research gym's results to the last digit, the native router gives the research router's own choices and results with all four parts, and the WebAssembly build matches the native build made with the same C maths library (with another C library, rounding in its sine, cosine and arctangent differs in the last bit, so lives can drift apart; the results stay alike).