Brain v4 foraging with a hunter
This is brain v4's real code (compiled to WebAssembly) and its trained minds, learning live in your browser. It senses the way to its food and, when the hunter is near, the way to the hunter; it must reach food without being caught, and first find out which way its own moves take it. Tap the field to scatter food: it goes after your pellets in the order you dropped them.
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. Switch to the single 420 KB mind (v4_meta3) to compare them; the switch starts a new life with the same draws.
Tap the field to drop food. The food it is after is your first pellet; when it is eaten (or the try runs out of time) the next one takes its place. With no pellets left the task places food itself.
Steps per try, the latest 120; orange: not a good try (caught by the hunter, too slow, or out of time). The line is the mean of the last 10.
What is going on
- What it senses: the direction to its food, the direction to the hunter (stronger when near), where it is, bumps and the reward it just felt. What it does: two numbers move it; each life its moves are turned by a random quarter turn and given a random speed. The hunter moves at half its speed toward it.
- A try ends at the food (reward 1) or when time runs out; being caught costs 1 and the hunter is put back at least 1 away. A "good try" reached the food in time without being caught.
- The full brain has four specialist parts, each a whole mind: the place part, the body-map part, the base mind (v4_meta3) and the place part with its memory of moves. Only one 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 with its memory of 1,600 earlier worlds, 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 it earns less than expected). 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.
- 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 place part with its own whole-life memory of moves that failed and moves that paid, speaking only while that part acts.
- Learning happens only in this life: the minds' raised weights stay fixed and what they learn lives in their fast links and recurrent state. Reset brain starts a fresh life.
- What to expect: early tries wander while it finds out how its moves turn; then it runs for the food and around the hunter. In our runs here (64 lives each) the full brain was well ahead: 72% of its tries good against 41% for the single mind.
How it runs: the same WebAssembly file and mind files as the room demo (shared, so your browser loads them once). The task is Brain Gym's own forage code, unchanged; your edits change its state between two thoughts. On the same inputs the WebAssembly build gives bit-identical acts to the native build built with the same C maths library, and the router and the memory of moves give the research programs' own results.