fly.fawzi.xyz

MaleCNS v1.0 · electron-microscopy connectome · 2026-11-02

A fruit fly's brain is playing
a game I wrote for it.

166,700 neurons. 25.6 million synapses, every weight measured by slicing one fly into 40-nanometre sections. Nothing in it was trained for this. It flies a three-lane runner, dodges trains, and scores about 164 metres a run. Not great. Not random either.

166,700
neurons
25.6M
synapses
0
trained weights
164 m
mean run

Watch it play

This is not a video. Every time you reload, a fresh episode is generated on a two-core VPS: the connectome runs step by step and streams each frame here as it is computed, so you are watching the fly decide, roughly live. The right panel is what its giant-fibre escape neurons were doing at that instant. Pick a different decoder, or ask for another run — the brain never remembers the last one.

connecting to the connectome…

Who is actually playing?

Same brain, same game, four different ways of turning its spikes into moves. Every run is a fresh episode; hitting an obstacle ends it.

Bar chart: metres survived by policy
Mean metres survived. Dots are individual runs. plain GIF of the clean run →
policymeanbestrunsfull 18 s
random93 m98 m20
giant-fibre reflex88 m171 m60
linear readout on the brain164 m216 m62
oracle (knows the future)216 m216 m22

The reflex loses. Jumping out of the way when the giant fibre fires scored 88 metres — no better than pressing keys at random. The same neuron was perfect in the simpler test below. A ballistic escape reflex is a panic button, not a navigator: in a runner it fires too late, and in two of those runs it never fired at all.

What wins is a linear decoder. Take the activity of all 1,314 descending neurons, apply principal components and ridge regression, and the signal is already there: which lane is safe, roughly. Two of six runs survived the full 18 seconds. Nothing in the connectome changed — the readout just learned to read what the wiring was already doing.

How the loop closes

  1. The game writes a scene

    Three lanes, obstacles sweeping in at 12 units per second, tall blocks and low barriers. The game knows nothing about the fly.

  2. The eye turns it into optic-lobe drive

    Angular growth feeds LPLC1/LPLC2, close-range threat feeds LC4, on the side the obstacle is really on. This encoder ships with the simulation package — it is the part that is mine, and it is the part to be suspicious of.

  3. The connectome runs

    20 ms of simulated time per step, every neuron and synapse accounted for. Measured on this box: about 14 ms of CPU per step, roughly 70 steps a second — faster than the 50 a second the game needs, which is why the run can stream at full speed. No GPU, no training, no backpropagation.

  4. A readout reads the descending neurons

    One linear model predicts a target lane, a second predicts a jump. That prediction is the only thing that ever touches the keyboard.

Stated plainly: the eye is mine, the wiring is the fly's, and the readout is a two-layer linear model. "The fly plays" means the frozen connectome carries a decodable signal for what to do — not that it learned the game.

First, the control experiment

Before trusting any of the above: does a single spike from the connectome actually move a body? One threat, one correct answer, and a lesion to prove causation.

Arena experiment: projectiles aimed at a virtual fly
A projectile is aimed to cross the fly's flight path at 2.5 s. The fly's only motor output is the giant fibre DNp01; one spike is one escape jump.
conditionclosest approachhitscorrect side
sees it (sensitive eye)28.7 cm0 / 66 / 6
sees it (conservative eye)14.6 cm1 / 65 / 6
blind4.1 cm3 / 63 / 6
giant fibre silenced0.0 cm6 / 6—

The lesion is the point. Silence that one neuron and the fly is hit every single time, at exactly zero clearance. Not a correlation — a cause.

What this does not show

The machine

simulation

MaleCNS v1.0
166,700 neurons
25.6M synapses
20 ms steps
0.55× real time on 2 vCPU

game

3 lanes · 12 u/s
blocks must be dodged
barriers can be jumped
216 m = survived

source

/opt/flybrain/subway.py
/opt/flybrain/arena.py
/opt/flybrain/export_replay.py