Fly brain maze

Real fruit fly brains, wired from the FlyWire connectome, steering flies through a 3D maze.

Drawing
DWG 06
Revision
1.0
Year
2026
Role
Author
Status
Public
Type
Simulation, Neuroscience, Open source
Tools
Python, NumPy, Numba, JavaScript, Web Workers, three.js
The Fly Brain Maze Lab simulator: a 3D maze seen from above with four flies gathered at an orange food ball, coloured walking trails covering the floor, setup sliders on the left and the selected fly's brain with firing rates per region on the right.
Fig. 06.1All four flies at the food after 49 s, including the one that can’t smell it.

Each fly runs a spiking model of the whole adult fruit fly brain, 138,639 neurons and 15 million connections, wired exactly as mapped by FlyWire. It smells food at its two antennae, the activity spreads through the real wiring, and its steering is read from the neurons that turn walking flies. Nothing about the maze is programmed into the brain.

§01Idea

FlyWire mapped every neuron and synapse in an adult fruit fly brain. I wanted to know what that wiring does on its own if you give it a body and a reason to move: put the fly in a maze, put food at the exit, and see whether the copied brain finds it.

The fly smells the food at its left and right antenna. That smell drives its real olfactory receptor neurons, and steering comes out of 40 descending neurons, including DNa01, DNa02 and DNa04, the ones known to turn walking flies.

A 4 by 4 maze 40 seconds into a run: four flies still searching, the start marked by a blue disc, the food by an orange ball, and thin coloured trails where each fly has walked.
Fig. 06.2A 4×4 maze 40 s in. Every fly’s brain runs in its own Web Worker.
The brain panel: the selected fly's brain as a point cloud of neurons in their real positions on a dark background, chips for the four flies, and a turning meter.
Fig. 06.3One fly’s brain. Each dot is a neuron in its real place, lit when it fires.

§02What is real

The brain is copied, not designed. These parts come straight from published data.

  1. 01

    Wiring

    The FlyWire v783 connectome (Dorkenwald et al. 2024, Schlegel et al. 2024): every neuron and synapse.

  2. 02

    Neuron model

    The leaky integrate-and-fire model and settings from Shiu et al. 2024 in Nature, checked by reproducing their result that sugar taste neurons drive the MN9 feeding motor neuron.

  3. 03

    Senses

    Vinegar-tuned olfactory receptor neurons for food, pheromone receptor neurons for other flies, and small-object visual neurons for seeing them, with walls blocking the view.

§03What I had to add

Closing the loop between a brain and a body took a few modelling choices, each one stated in the repo.

  1. A

    Synapse fatigue

    Without it the antennal lobe’s local neurons drive each other into runaway firing. Short-term depression, which is documented in the fly antennal lobe, stops it.

  2. B

    Steering readout

    With the brain held still, I played smell from the left, the right and both sides and recorded all 1,303 descending neurons. The 40 that best tell left from right became one steering signal, fit on two recordings and checked on a third.

  3. C

    Body

    The fly walks at a fixed 8 mm/s with some random wandering and turns away from walls. The brain only decides which way to turn.

§04Smell vs no smell

The same 3×3 maze, start top left, food at the star. The fly that can smell reaches the food; the flies without smell wander.

Four top-down plots of the same maze with a fly's walking path in blue. In the first, the fly that can smell walks from the start to the food star in 22 seconds. In the other three, flies without smell cover the start corridors in dense scribbles and never reach the food.
Fig. 06.4Left: the fly that can smell, at the food in 22 s. The other three can’t smell and never get there.

§05Results

No smell
Found the food in 12 of 24 mazes (3×3, 90 s limit)
Smell, steering gain 6
10 of 12, median 48 s
In the browser
14 of 16 with smell and 6 of 16 without (60 s limit)
Speed
One fly runs at roughly real time on a laptop

§06Can a weaker fly gain from a group?

One fly had its food smell removed and ran the same 16 mazes alone, with three normal flies, and with three normal flies that mark the food once they reach it. With only the copied wiring the group doesn’t help: pheromone input hardly reaches the steering neurons, and seeing another fly mostly makes a fly turn away. With the food mark, the weaker fly usually arrived within about 15 s of the first normal fly.

Bar chart: the fly that can't smell food reached it in 11 of 16 mazes alone, 9 of 16 with three normal flies, and 14 of 16 with three normal flies plus a food mark to follow.
Fig. 06.516 random mazes, 90 s limit, same fly and maze in each setup.

§07Try it

The browser version needs no install: it runs every fly’s brain in Web Workers, works like a PhET simulation, and lets you change the maze, the number of flies, smell, steering and individuality, or switch off whole brain regions. A Solo vs Pack mode races one fly against a group. The Python app adds presets, replays and a brain panel for every fly.

Next · DWG 01Young Man’s Services →