The Fly, smiling

The Fly, and the brain behind it

The fly brain

The Fly is one of the players in our family's online game room, and nobody wrote its personality. Its moves come from a real fruit fly's brain: a brain the size of a poppy seed, every one of whose neurons and connections has now been mapped. We run that map as a working brain and let it play, first by taste, then with smell and memory too. This is how that works, what it can do, and what it taught us.

138,639neurons
54.5 millionsynapses
3systems we use: taste, smell, memory
5,177Kenyon cells, where it remembers

What the fly brain is

The fruit fly, Drosophila melanogaster, has been one of biology's workhorses for over a century. It shares many of our genes, it learns, it remembers, it fights and courts and navigates, and its brain is small enough that mapping all of it has become possible. In 2024 the FlyWire project finished: one adult female fly's brain, cut into about seven thousand slices and photographed with an electron microscope, every neuron traced through the stack by computers and then checked by hand by hundreds of scientists and volunteers over several years.

The result is a connectome, a complete wiring diagram: 138,639 neurons, 15,091,983 distinct neuron-to-neuron connections, 54,492,920 synapses in all. For every neuron the map also predicts its chemical messenger, its neurotransmitter, which says whether it excites the neurons it talks to or holds them back:

Acetylcholineexcites 91,366
Glutamateinhibits, in this model 24,875
GABAinhibits 19,170
Dopaminemodelled as exciting 737
Serotoninmodelled as exciting 2,282
Octopaminemodelled as exciting 216

More than half of the brain, 77,541 neurons, is the optic lobes that handle vision. The rest is the central brain, sensory neurons coming in from the antennae, mouthparts and body, and a narrow bundle of 1,303 descending neurons that carry commands down the neck. The map is the brain only: the nerve cord in the body that drives legs and wings isn't in it, so our fly has no body. We read its choices off the neurons that would carry them down.

The three systems we use

Our fly uses three of the things a real fly's head does, each in a different place:

antennae smell comes in optic lobes: vision, not used subesophageal zone taste judged: the race labellum taste comes in antennal lobes 53 smell channels mushroom bodies memory: Kenyon cells
A fly's head from the front, simplified and not to scale. Orange: taste. Purple: smell. Green: memory.
  • Taste starts on the labellum, the spongy tip of the proboscis, where taste neurons fire for sugar or for bitter. They feed the subesophageal zone at the bottom of the brain, which decides, in a few synapses, whether to keep eating or back away. This is innate: no learning.
  • Smell starts on the antennae. Each kind of smell receptor sends its neurons to one glomerulus of the antennal lobe, a cluster of about fifty channels, so a smell arrives as a pattern across channels. 53 of them reach the mushroom body well enough to use.
  • Memory lives in the mushroom bodies, where 5,177 Kenyon cells turn each smell into a sparse code, and 90 output neurons read it out as "approach" or "avoid". Dopamine neurons teach them, changing which smells mean food and which mean trouble.

Bringing a wiring diagram to life

A map isn't a brain. To make it do something we use a model published by Philip Shiu and colleagues in 2024, which showed that the whole connectome, simulated simply, predicts real behaviour: switch on sugar-tasting neurons and the simulated brain drives the motor neuron that makes a real fly feed.

Every neuron is a leaky bucket of charge. It rests at −52 millivolts. Each spike from a neuron wired to it adds or removes about a quarter of a millivolt per synapse, the sign set by the sender's transmitter. The bucket leaks back toward rest. If it fills to −45 millivolts, the neuron fires a spike to everything it connects to, resets, and can't fire again for about two milliseconds.

threshold resting spike!spike! incoming spikes from other neurons
An illustration: each tick along the bottom is a spike arriving from another neuron. Close together, they fill the bucket faster than it leaks, and the neuron fires.

That's the whole model: which neurons, how many synapses, which sign, and a few constants shared by every neuron. There are no per-neuron settings to tune and nothing learned. We feed it by making sensory neurons fire at a chosen rate, step all 138,639 neurons forward a tenth of a millisecond at a time, and count the spikes of the neurons we care about. One decision is 0.3 seconds of brain time: 3,000 steps of the whole brain.

Our version of it

We rebuilt Shiu's model in PyTorch so it runs many trials side by side and only works on neurons that are actually doing something, which is a few thousand at a time. It matches the original exactly, neuron by neuron. The heavy runs happen on Modal, a cloud computing service; the lounge itself never runs the whole brain (a web server can't do 3,000 steps of 139,000 neurons while you wait). Instead, the brain's answers are measured ahead of time and the lounge looks them up.

Three corrections to the published model

Taste worked out of the box. Smell and memory didn't, and each fix taught us something:

  • Kenyon cells use acetylcholine. The map's chemistry predictions label almost all 5,177 Kenyon cells as dopamine. Experiments show they're cholinergic, so that's how we count them.
  • The antennal lobe's local neurons mostly inhibit. In the published model, one smell channel firing gently set off about 8,300 neurons and lit the same two thirds of all Kenyon cells for every smell: no way to tell smells apart. The cause (pointed out by the FlyBridge project) is that about two thirds of the antennal lobe's local-neuron synapses had been signed as exciting, from mispredicted transmitters. In real flies most of these neurons inhibit. Keeping the 80 that use acetylcholine excitatory and making the rest inhibitory, each smell lights 0.3–2.4% of Kenyon cells, with almost no overlap: a usable nose.
  • Output neurons fire on their own. In the model, a neuron nothing drives is silent. For poker smells, 51 of the 90 mushroom-body output neurons never fired at all, and dopamine learning works by turning an output neuron's response down, which does nothing to a neuron that's already silent. Real ones fire spontaneously. We gave just these 90 a gentle background input, small kicks that leave them idling at about nine spikes a second, and almost all of them came into play.

None of these adds, removes or reroutes a connection: every one is still where FlyWire mapped it. The first two correct which messenger some neurons use; the third adds input from outside the brain, as a real fly's body and chemistry would.

Taste: Farkle

Farkle is a dice game where each turn you choose to roll again, risking everything you've built up, or bank what you have. A fly knows nothing about dice, so we let it taste the turn. Twenty sugar neurons fire while there are dice to roll; twenty bitter neurons fire harder the fewer dice are left and the more points are at stake.

How bitter a Farkle turn tastes, in spikes a second, by dice in hand and points on the turn.
Show the numbers

The decision is a race in the subesophageal zone between two real circuits:

Sugar taste neurons20 · types LB3b–d, LB4b
Bitter taste neurons20 · types LB1a–d
First relayCB0616 · CB0393 · CB0277406 synapses from sugar
The veto: CB0219uses glutamate (inhibits)319 synapses from bitter
Feeding premotorCB0553 · CB0493⊣ held back by CB0219, 366 synapses
Avoidance descending neuronsDNge067 (GABA) · DNpe007 (serotonin)151 synapses straight from bitter
MN9proboscis motor neuron1,523 synapses from premotor
Down the neckto the body, not simulated
Rollkeep eating
Bankback away
Follow the arrows. Blue edges are the feeding route, orange edges are avoidance; the veto, CB0219, is driven by bitter and holds the feeding premotor neurons back. Synapse counts are straight from the FlyWire map.

The whole brain runs for 0.3 seconds and the spikes are counted: if the bitter-driven descending neurons out-fire the feeding motor neuron, it banks; otherwise it rolls. Here is that race at four real moments of a game:

Average firing over 32 runs of each moment. The taste neurons fire at random moments, so the same turn doesn't always come out the same way; the percentage is how often it banked.
Show the numbers

Untrained, with our first guess at the taste, it already scored 424.1 points a turn, better than chance but far too greedy. Training never touched the wiring. An evolution-style search, 480 candidate brains overnight, tuned ten dials around it: six for how dice and points become taste, one for how decisively it must lose its appetite before it banks, and three that turn every synapse of one transmitter up or down together. The big change was glutamate, turned up almost ten times, which makes a bitter "veto" neuron shut feeding down decisively. Think of it as a fly in a particular mood: wary of bitter.

How often it banks, by dice in hand and points on the turn, before and after training. The white tick on each row is where the best possible strategy starts banking. Hover a square for the number.
Show the numbers

The trained fly scores 591.9 points a turn, a little better than the lounge's own Farkle bot (587.6) and close to the best any bank-or-roll strategy can do (593.5). At Farkle it doesn't learn as it plays: every turn is a fresh brain meeting a fresh taste. And the lounge doesn't run 139,000 neurons every time it rolls: the brain was run on every situation in the chart ahead of time, and the lounge looks up how often it banked there.

Taste, smell and memory: poker

Poker needs what Farkle didn't: knowing who you're playing. A bet from a player who bluffs means something different from the same bet by one who only bets with good cards. So the poker fly keeps the taste circuit for judging its cards and adds smell and memory for judging people.

Taste: is this hand worth the price?

Hand strength is sugar, the price of staying in is bitter, and the same race decides: if the back-away neurons win clearly it folds, if feeding wins clearly it raises, otherwise it calls. This uses the brain exactly as published, without Farkle's tuning. Only the translation from cards to taste was fitted, lightly. Here is the race across every mix of the two:

How much the back-away neurons out-fire the keep-going neuron, by sugar (rows) and bitter (columns), in spikes. Orange leans fold, blue leans call or raise. Nobody trained this.
Show the numbers

Smell: what's going on at the table

Each moment it has to decide is a smell, made of notes. Every player has a scent, one of twelve, assigned by a stable hash of who they are; in a big family two people can share one, as a real fly's nose has a limited palette. Further notes say what that player just did (checked, bet small, bet big, raised, or nothing yet) and what the fly is holding (strong, medium, a draw, or weak). Each note switches on its own few glomeruli, so a moment arrives as a pattern across the antennal lobe.

The momentwho it's facing · what they did · what it's holding
A handful of the 53 glomeruliantennal lobe, smell neurons firing at 220 a second
About 3% of 5,177 Kenyon cellsa different handful for each moment: the mushroom body's code
Approach outputs51 neurons in 5 compartments
Avoid outputs39 neurons in 9 compartments
Approach minus avoid, added to tastetilts it toward going on, or toward folding

The whole spiking brain, run on every one of these smells, gives each its Kenyon-cell code and each output neuron's response. Those 240,634 Kenyon-cell-to-output synapses are where memory is stored.

Memory: dopamine as the teacher

In a real fly, each of the mushroom body's compartments has its own dopamine neurons: reward teachers (called PAM, 307 of them in this map) and punishment teachers (PPL1, 16). When a teacher fires, it weakens the synapses from whichever Kenyon cells were just active onto that compartment's output neurons. Reward weakens the "avoid" side, so the smell becomes more attractive; punishment weakens the "approach" side.

Our fly does exactly that after every hand, for every call or raise it made: dopamine according to how the hand went, landing on the Kenyon cells of that moment's smell. Folds get none, because nobody learns what would have happened. The changes fade, by half every four days without play, and there is one brain for everyone it meets: what it learns about one scent lives alongside what it learns about the others.

The simulated brain itself can't learn: in Shiu's model dopamine is just another exciting signal. So learning happens in a small stand-in for the mushroom body's output side, measured from the whole brain. Each output neuron's rate moves with its Kenyon-cell input, as measured at five synapse strengths for every smell. On learned states it hasn't seen, this stand-in agrees with the whole brain at r = 0.92 (where 1 would be perfect, and about 0.96 is the best possible given the brain's own run-to-run noise).

Teaching it poker

The poker fly plays in a simulator built on the lounge's own poker rules, against four opponents with known habits: a bluffer who bets big with anything, a rock who bets big only with a strong hand, a calling station who calls everything, and the lounge's house bot. Each test plays the same cards with learning on and off, so the difference is what learning earns. (The first test of this smell-and-dopamine learning was simpler: at rock-paper-scissors, a dozen smells and the plainest rule were enough for it to learn a player's habits. Poker was much harder.) Getting it to earn anything took several steps, each fixing what the last one revealed:

StepWhat changedGain from learning
Version 2 smells, first learning ruledopamine only ever weakens synapses; counts how often a choice pays−1.08
A rule that learns how muchdopamine says better or worse than expected−0.71
Output neurons fire on their ownbackground input, recalibrated on the whole brain+0.07
A steadier baselinethe unlearned brain measured three times, not once+0.20
Steadier learninglearn more slowly, act on it more firmly+0.31
Smell the situation, not the optionwho, what they did, what it holds: no shared note for the choice+0.55
Control: a perfect readoutthe fly's own Kenyon-cell codes, every cell free to learn+0.72
Control: a perfect noseone independent memory per situation+0.88

Big blinds a hand, learning on minus learning off, averaged over the four opponents. From the third step on, settings were chosen on one set of cards and measured on four others, so they aren't tuned to the test.

  • How often, not how much. The first rule, dopamine weakening synapses until they can't weaken any more, learned how often a choice pays. Poker pays in amounts: small frequent wins and rare big losses look alike to it. Its smells did teach it the right lessons about people (call the bluffer, fold to the rock), but it lost chips doing so.
  • Better or worse than expected. The mushroom body's outputs feed back onto its own dopamine neurons: 8,545 synapses in this map, onto all 23 of its teacher types. That loop lets dopamine signal a surprise rather than a plain win or loss, and lets opposite dopamine undo an old lesson, as real flies do when a memory stops being true. Learning then stops once expectation matches the average payoff: it learns amounts. With a perfect nose, this rule wins against every opponent. Through the fly's own mushroom body, it didn't.
  • Silent neurons can't learn. The controls showed the smells were fine and the output side was the problem: most output neurons never fired for a poker smell. That's the spontaneous-firing correction above. Afterwards, 62 output neurons could be moved by learning instead of 30, and learning broke even.
  • A steadier baseline. The stand-in had been built on one measurement of the unlearned brain, and that measurement was noisy enough to blur a third of what learning changes. Averaging three doubled what learning earns.
  • Steadier learning. Against the house bot it still lost. Every situation against one player shares that player's scent, so one lucky or unlucky hand swung its feelings about every situation at once, and it ended up calling the house bot's big bets, which lose about 14 big blinds on average. Learning more slowly, and leaning on what it has learned more firmly, fixed that.
  • Smell the situation, not the choice. Until now each smell included a note for the option the fly was weighing, and every situation used the same one, so that note's Kenyon cells carried the overall average into all of them. A real fly smells the world, not its own choices. Dropping the note, and giving its channels to "what they did" and "what it holds", made situations against one player far easier to tell apart: the gain from learning rose from +0.31 to +0.55 at its best, and from +0.31 to +0.50 even at the old settings.

Where it stands: learning now earns about +0.55 big blinds a hand over the same fly not learning, and it gains against all four, on every set of cards we tried: +0.57 against the bluffer, +0.11 against the rock, +0.95 against the calling station, +0.59 against the house bot. That's about two thirds of what a perfect nose would get from the same information, and three quarters of what a perfect readout of its own Kenyon cells would, so what's left is mostly on the output side.

It now plays at the lounge's hold'em tables, with this version-3 brain, still learning from every hand. There is one memory for everyone it meets, kept between games and fading by half every four days without play, and after each hand the table shows the lesson that surprised it most.

What this is, and isn't

  • It is a real fly's complete wiring, simulated neuron by neuron, deciding with the circuits a fly uses to decide whether to eat, and learning with the circuit a fly uses to learn what smells mean.
  • The neurons are simple. Leaky buckets, one shared set of constants, no chemistry beyond "excite" or "inhibit". Real neurons are far richer.
  • Learning is a stand-in. The whole brain can't change its synapses in this model, so memory lives in a small layer measured from it, and the rule for how dopamine computes a surprise is our choice: the feedback wiring is there, but its signs are mixed.
  • At hold'em, one brain learns everybody. Twelve scents go round, so in a big family some people smell alike to it, and what it learns about one rubs off on the other.
  • At Farkle it only decides when to bank. Which dice to keep comes from the same rules the lounge's Farkle bot uses.
  • The translation is ours. Turning dice and cards into sugar and bitter, and table moments into smells, are decisions we made. The fly does the weighing.
  • It's one fly, a female. Every fly is a little different, and the male brain, with its own circuits for courtship and aggression, has since been mapped too.
  • It isn't conscious, and it isn't really a fly: no body, no hunger, no eyes in use.

Credits

The brain map: the FlyWire Consortium. Dorkenwald et al., "Neuronal wiring diagram of an adult brain", and Schlegel et al., "Whole-brain annotation and multi-connectome cell typing of Drosophila", both Nature 2024, shared under a Creative Commons Attribution licence.

The whole-brain model: Shiu et al., "A Drosophila computational brain model reveals sensorimotor processing", Nature 2024.

Memory that can be undone by opposite dopamine: Felsenberg et al., "Re-evaluation of learned information in Drosophila", Nature 2017. The antennal-lobe correction was prompted by the FlyBridge project.

Farkle training: CMA-ES, an evolution strategy by Nikolaus Hansen. Simulated with PyTorch, on a laptop and on Modal.

This page last updated Oct 26, 2026, 9:36 AM PDT.