fly-world
A kitchen counter with fruit on it, a hand that comes down now and then, and a population of fruit flies whose brain is the wiring diagram of a real one.
Every fly in fly-world carries the same brain: the 139,255 neurons of an adult Drosophila melanogaster and the synapses between them, as reconstructed by the FlyWire consortium. A fly sees, smells and tastes the kitchen through that brain, and its body does what the brain's descending neurons say. Flies eat, take off when the hand looms, mate, lay eggs and die. Nobody scores them: the ones that reproduce are the ones whose descendants you see. This page explains how that works and which published work each part is based on.
The model behind it
fly-world is built on the model of this paper:
Correig-Fraga, E., Guimerà, R. & Sales-Pardo, M. Structure alone supports efficient visual computation in the Drosophila visual system.
Preprint (2026), arXiv:2610.10023 [q-bio.NC]. Under review.
The paper couples an anatomically faithful model of the compound eye to the proofread connectome of the adult fly and asks how much visual computation the measured wiring supports. The graph and the geometry of the eye are fixed. Only scalar gains on the existing synapses and neuronal thresholds may be learned, and decisions are read linearly from the Kenyon cells of the mushroom body. With that alone the model discriminates numerosities, colours and orientations, and falls short on shapes that move across the visual field. Compared with randomised connectomes, the biological network is the more accurate one at the same wiring cost, and the randomised networks that beat it do so by using more wire.
The model and its training code are the open library train-your-fly; the analyses of the paper are in the companion connectome repository, and its data are archived on Zenodo.
fly-world uses that model with two differences. Nothing in it is trained: the weights are the synapse counts of the connectome, signed by neurotransmitter. And the output is read from the descending neurons instead of the Kenyon cells, because here the brain has to move a body, not classify an image.
Where each part comes from
| Part | In fly-world | Based on |
|---|---|---|
| Brain model | Three message-passing steps through the connectome at every tick, nothing trained | Correig-Fraga et al., 2026 |
| Wiring | The FlyWire whole-brain connectome and its cell types | Dorkenwald et al., 2024; Schlegel et al., 2024; Matsliah et al., 2024 |
| Eyes | Ommatidia, photoreceptors R1–6, R7 and R8, colour channels | Paulk et al., 2013 |
| Smell | Two antennae, three odours, a search on rising smell | Semmelhack & Wang, 2009; Gaudry et al., 2013; Álvarez-Salvado et al., 2018 |
| Escape | Take-off from a looming hand | Card & Dickinson, 2008; von Reyn et al., 2017; Ache et al., 2019 |
| Mating | Courtship, copulation and the female's receptivity | Hall, 1994; Liu & Kubli, 2003 |
| Evolution | No fitness function, a designed ancestor | Tierra (Ray, 1991) |
| Energy and population | Metabolic costs, a closed energy budget, booms and busts | Kleiber, 1932; Niven & Laughlin, 2008; Nicholson, 1954 |
The brain
The wiring is the FlyWire reconstruction of an adult female brain (Dorkenwald et al., 2024), with the cell types of Schlegel et al. (2024) and, in the optic lobes, of Matsliah et al. (2024). All flies share it, males included: the brain is never told its sex.
One tick of the simulation is a tenth of a second of behaviour. At every tick the activity of the sensory neurons is passed three times through the connectome: each neuron adds up what its presynaptic partners send, weighted by the number of synapses and their sign, a gain common to the whole brain holds the overall level of activity, and a tanh bounds it. Neurons keep nothing from one tick to the next. Three steps are enough for what the eyes and antennae receive to reach the descending neurons. The brain view of the viewer shows these three steps for the selected fly, neuron by neuron.
The connectome ends at the neck. The ventral nerve cord, which in a real fly turns descending commands into leg and wing movements, is not part of it, so a small linear readout of the about 1,300 descending neurons stands for it. It gives six behavioural modes (rest, walk, fly, eat, mate, fight), a turn, and a tumble, which is how much the fly turns at random. The readout is the same for every fly and does not evolve; how it was obtained is told under Evolution.
The senses
Eyes
The eyes follow the account of the fly visual system in the review of Paulk, Millard & van Swinderen (2013). A compound eye has about 750 facets, the ommatidia, and each holds eight photoreceptors. R1–6 carry the rhodopsin Rh1, respond to a broad band of light and feed the motion pathway through the lamina. R7 and R8 sit in the centre, carry the ultraviolet, blue and green rhodopsins (Rh3 to Rh6, in "pale" and "yellow" ommatidia) and feed the colour pathway in the medulla. The projections keep the map of the visual field through the optic lobe.
The model rebuilds that eye from the connectome itself, as in the paper. The positions of the photoreceptor terminals of each eye are projected onto a plane, and a tessellation seeded at the R7 terminals gives every ommatidium its patch of the image. Each photoreceptor then reads the colour that matches its spectral sensitivity, shifted from the fly's ultraviolet-centred range to what a screen can show: R7 reads blue, pale R8 green, yellow R8 red, and R1–6 the overall luminance. About 11,000 photoreceptors of the two eyes are driven this way.
What a fly looks at is a panorama of the kitchen drawn from where it stands, 2 mm above the counter: the walls, the fruit, the other flies and the hand, each with its height and colour, over 345° around the fly and from just below the horizon to the zenith. The two mosaics in a fly's card are what its photoreceptors receive. With some 670 ommatidia per eye, each covers about 6° along the horizon, and a fly 5 cm away is smaller than that. Real flies are short-sighted too.
Smell
Three odours hang in the air: fruit, flies, and the male pheromone cVA. Fruit can be smelled from tens of centimetres, flies only at close quarters. Each fly samples them at its two antennae, and the difference between left and right is the direction of the smell (Gaudry et al., 2013). Each odour drives the olfactory receptor neurons of its own glomeruli on the side of that antenna: fruit goes to DM1, DM2, DM4, VA2 and VM7d, the glomeruli of vinegar and fruit esters (Semmelhack & Wang, 2009), and cVA to DA1. The receptors adapt to what they have been smelling and report, besides how strong an odour is, whether it is rising.
That last signal is what the search for food runs on. A walking fly that goes straight while the smell rises and turns at random when it stops rising climbs to the source without knowing where it is, and walking flies do this (Álvarez-Salvado et al., 2018).
Taste and internal state
A fly standing on fruit tastes it through its sugar-sensing gustatory neurons. Hunger, which is how empty its energy reserve is, enters through a few neuropeptide F and octopamine neurons. Two more inputs make mating possible. The drive to mate enters at the pC1 neurons, where mating state and mate cues converge in both sexes (Wang et al., 2020). Touching a possible mate enters at the mAL interneurons, the first annotated relay in the brain of the pheromone-sensing pathway of the legs (Clowney et al., 2015; Kallman et al., 2015). Without them the brain could not know that it is hungry, that it stands on food, or that a mate is there.
Behaviour
The hand
Every so often a hand comes down over the place where most flies are gathered and kills every fly on the ground beneath it. To a fly it is a pale disc that grows in the upper visual field. Real flies take off from such a looming object in a planned sequence (Card & Dickinson, 2008), triggered by neurons that measure its angular size and speed and drive the giant fibre (von Reyn et al., 2017; Ache et al., 2019). In fly-world the looming has to cross the connectome from the photoreceptors to the descending neurons, and the take-off takes a few ticks, so a fly that notices late is a dead fly.
Mating
The mating ritual comes from Hall (1994). A male fruit fly orients towards the female, taps her, follows her, extends one wing and vibrates it to sing, licks her and attempts to copulate. The female need not do much: she shows that she accepts mostly by slowing down. Copulation lasts about twenty minutes, and there is no courtship in flight.
In fly-world a male in mate mode who faces, within touching distance, a receptive female also in mate mode starts a bout. Both stay still on the ground for 20 ticks, during which the page shows him extending and vibrating a wing. If the bout is not interrupted, sperm is transferred with a probability of one half, and hearts appear. The female stores the sperm for the eggs she will lay and does not mate again for 2,100 ticks, which stands for the week or so that the male's sex peptide keeps a mated female unreceptive (Liu & Kubli, 2003). The circuits behind these decisions in the real fly are reviewed by Dickson (2008). Whether to enter mate mode, and with whom, is decided by the brain.
Food, eggs and death
Fruit arrives in seasons of plenty and of famine, shrinks as it is eaten, and rots. As on real fruit, it is where flies gather, meet and mate (Billeter et al., 2025). A fertilised female standing on fruit with enough reserve lays eggs, and each egg costs her energy. Eggs hatch after 100 ticks and the flies are mature 300 ticks later, the time it takes one to walk across the short side of the counter. A fly dies when its reserve runs out, under the hand, or of old age at around 12,000 ticks.
Evolution
The evolutionary side is inspired by the Tierra project of Tom Ray (Ray, 1991; tomray.me/tierra). Tierra is a virtual computer whose organisms are short machine-code programs that copy themselves, compete for processor time and memory, and mutate. It has no fitness function: a program is fit if it gets copied. From a single hand-written ancestor Ray saw parasites evolve that used the copying code of their neighbours, then hosts immune to them, then smaller and faster replicators, none of which he had asked for.
fly-world keeps that rule. Nothing scores a fly. A genome reaches the next generation if its bearer found fruit, was not under the hand when it came down, and mated.
The ancestor
Tierra did not start from random code. Ray wrote an ancestor of 80 instructions that could already replicate, and everything interesting came from what evolution did to it. Avida does the same (Ofria & Wilke, 2004), and Polyworld ran a conventional genetic algorithm until its population could sustain itself (Yaeger, 1994). Selection can only act on organisms that already survive and reproduce, and a fly with a random readout of its descending neurons does neither.
The ancestor here is that readout. It was fitted once, by imitation: a scripted teacher fly acted in the kitchen while the connectome ran on the fly's own senses, and the readout is the regression from the activity of the descending neurons to what the teacher did. It can only use what the connectome delivers to those neurons. Every founder is born with it, and after the first tick nothing refers to the teacher again.
What evolves
The wiring is fixed. A genome holds two gains for each of the about 8,500 cell types of the brain, one on what the neurons of that type send and one on what they receive, and three traits of the body: its size, how much it turns at random, and how readily it switches from one behaviour to another. An egg takes each of these numbers from its mother or from the father whose sperm she stored, at random, with a small mutation.
That is some 17,000 numbers for a brain of 139,255 neurons. Like a real genome, it is far too small to specify a brain synapse by synapse (Zador, 2019): it can only tune what the wiring already does. And because the readout is frozen, whatever evolution changes in behaviour has to pass through a cell type with a name, or through the body.
Energy and numbers
All the energy in the flies came in as fruit. A fly spends it on a basal metabolism that grows with body mass to the power of three quarters (Kleiber, 1932), on walking or, at a much higher price, flying, and on neural activity itself. Nervous tissue is expensive, enough to shape the evolution of sensory systems (Niven & Laughlin, 2008), and real flies that form long-term memories die sooner when starved (Mery & Kawecki, 2005). A hatchling starts with what its egg cost its mother.
There is no cap on the population. Food holds it, at roughly a hundred flies with the default supply, and not steadily: births follow the fruit within a few hundred ticks while deaths lag by the thousands of ticks that a reserve lasts, which gives the booms and busts that Nicholson (1954) described in his blowflies. If fewer than five flies are left, a window opens and twenty wild flies with the ancestor's genome come in, so that a run does not end; every such rescue is counted.
What is simplified
- Nothing in the brain is trained. The weights are synapse counts, which are not synaptic strengths, and the brain is close to linear. It finds fruit by smell and sight together, but it steers weakly, and one fly reacts to the sight of another only within a centimetre or two.
- The brain has no memory. Neurons keep no state between ticks, so nothing is learned within a life. What changes over generations is in the genome.
- A connectome is not a brain. Neuromodulation, electrical synapses and the dynamics of each neuron are absent (Scheffer & Meinertzhagen, 2021).
- There is no nerve cord and no body mechanics. A linear readout stands for the first, and the body is a point that walks or flies over a flat counter.
- One female connectome serves both sexes. Males and females differ in their bodies and in what their bodies do in
matemode, not in their wiring. - Courtship is one timer. The steps that Hall describes are shown, not simulated one by one, and the one-half chance that a bout transfers sperm is a choice of the model, not a number from the literature.
- Time is compressed. A whole life is about twenty minutes of simulated behaviour and a mating bout two seconds. The timers are set against the time a fly takes to cross the counter, not converted from a real fly's days.
- The air is still. Odours are static clouds around their sources, without wind or plumes, and the sharpening of odour onsets that the antennal lobe performs in the fly (Bhandawat et al., 2007) is done here at the receptors.
- The sky is black and the hand is pale. The photoreceptors of the model do not adapt to the level of light, and on a bright background they would see little else.
Related work
Other models put a fly connectome to work. Lappalainen et al. (2024) train a network constrained by the connectome of the optic lobe to detect motion, and it predicts the responses of individual visual neurons. Shiu et al. (2024) simulate the whole FlyWire brain with spiking neurons and recover feeding and grooming circuits. Cowley et al. (2024) map the units of a deep network onto visual projection neurons of courting males. fly-world differs from these in closing the loop: the brain's output moves a body in a world that feeds back on its senses, and a population of such brains is left to evolve.
Data, code and credits
- Connectome. The FlyWire reconstruction of the FAFB electron-microscopy volume, release v783, with the annotations distributed through Codex. The volume is that of Zheng et al. (2018), the reconstruction of Dorkenwald et al. (2024), the annotations of Schlegel et al. (2024), the synapses of Buhmann et al. (2021) and the neurotransmitter predictions, which give each synapse its sign, of Eckstein et al. (2024).
- Model. train-your-fly (Apache License 2.0).
- Brain view. The "flow" layout orders neurons by how soon a probabilistic traversal of the connectome from the sensory neurons reaches them, the ranking of Schlegel et al. (2021).
- Fly drawing. Adapted from the schematic of flyplotlib (MIT License).
- Software. The simulation runs on PyTorch (Paszke et al., 2019); the page is drawn with PixiJS and three.js.
How to cite
If you use or write about fly-world, please cite the paper it is built on, together with the FlyWire papers its data come from (Dorkenwald et al., 2024; Schlegel et al., 2024):
Correig-Fraga, E., Guimerà, R. & Sales-Pardo, M. (2026). Structure alone supports efficient visual computation in the Drosophila visual system. arXiv preprint, arXiv:2610.10023.
References
- Ache, J. M. et al. (2019). Neural basis for looming size and velocity encoding in the Drosophila giant fiber escape pathway. Current Biology 29, 1073–1081. doi:10.1016/j.cub.2019.01.079
- Álvarez-Salvado, E. et al. (2018). Elementary sensory-motor transformations underlying olfactory navigation in walking fruit-flies. eLife 7, e37815. doi:10.7554/eLife.37815
- Bhandawat, V. et al. (2007). Sensory processing in the Drosophila antennal lobe increases reliability and separability of ensemble odor representations. Nature Neuroscience 10, 1474–1482. doi:10.1038/nn1976
- Billeter, J.-C., Bailly, T. P. M. & Kohlmeier, P. (2025). The social life of Drosophila melanogaster. Insectes Sociaux 72, 127–140. doi:10.1007/s00040-024-00990-3
- Buhmann, J. et al. (2021). Automatic detection of synaptic partners in a whole-brain Drosophila electron microscopy data set. Nature Methods 18, 771–774. doi:10.1038/s41592-021-01183-7
- Card, G. & Dickinson, M. H. (2008). Visually mediated motor planning in the escape response of Drosophila. Current Biology 18, 1300–1307. doi:10.1016/j.cub.2008.07.094
- Clowney, E. J. et al. (2015). Multimodal chemosensory circuits controlling male courtship in Drosophila. Neuron 87, 1036–1049. doi:10.1016/j.neuron.2015.07.025
- Correig-Fraga, E., Guimerà, R. & Sales-Pardo, M. (2026). Structure alone supports efficient visual computation in the Drosophila visual system. arXiv preprint, arXiv:2610.10023.
- Cowley, B. R. et al. (2024). Mapping model units to visual neurons reveals population code for social behaviour. Nature 629, 1100–1108. doi:10.1038/s41586-024-07451-8
- Dickson, B. J. (2008). Wired for sex: the neurobiology of Drosophila mating decisions. Science 322, 904–909. doi:10.1126/science.1159276
- Dorkenwald, S. et al. (2024). Neuronal wiring diagram of an adult brain. Nature 634, 124–138. doi:10.1038/s41586-024-07558-y
- Eckstein, N. et al. (2024). Neurotransmitter classification from electron microscopy images at synaptic sites in Drosophila melanogaster. Cell 187, 2574–2594. doi:10.1016/j.cell.2024.03.016
- Gaudry, Q. et al. (2013). Asymmetric neurotransmitter release enables rapid odour lateralization in Drosophila. Nature 493, 424–428. doi:10.1038/nature11747
- Hall, J. C. (1994). The mating of a fly. Science 264, 1702–1714. doi:10.1126/science.8209251
- Kallman, B. R., Kim, H. & Scott, K. (2015). Excitation and inhibition onto central courtship neurons biases Drosophila mate choice. eLife 4, e11188. doi:10.7554/eLife.11188
- Kleiber, M. (1932). Body size and metabolism. Hilgardia 6, 315–353. doi:10.3733/hilg.v06n11p315
- Lappalainen, J. K. et al. (2024). Connectome-constrained networks predict neural activity across the fly visual system. Nature 634, 1132–1140. doi:10.1038/s41586-024-07939-3
- Liu, H. & Kubli, E. (2003). Sex-peptide is the molecular basis of the sperm effect in Drosophila melanogaster. Proceedings of the National Academy of Sciences 100, 9929–9933. doi:10.1073/pnas.1631700100
- Matsliah, A. et al. (2024). Neuronal parts list and wiring diagram for a visual system. Nature 634, 166–180. doi:10.1038/s41586-024-07981-1
- Mery, F. & Kawecki, T. J. (2005). A cost of long-term memory in Drosophila. Science 308, 1148. doi:10.1126/science.1111331
- Nicholson, A. J. (1954). An outline of the dynamics of animal populations. Australian Journal of Zoology 2, 9–65. doi:10.1071/ZO9540009
- Niven, J. E. & Laughlin, S. B. (2008). Energy limitation as a selective pressure on the evolution of sensory systems. Journal of Experimental Biology 211, 1792–1804. doi:10.1242/jeb.017574
- Ofria, C. & Wilke, C. O. (2004). Avida: a software platform for research in computational evolutionary biology. Artificial Life 10, 191–229. doi:10.1162/106454604773563612
- Paszke, A. et al. (2019). PyTorch: an imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32, 8026–8037.
- Paulk, A., Millard, S. S. & van Swinderen, B. (2013). Vision in Drosophila: seeing the world through a model's eyes. Annual Review of Entomology 58, 313–332. doi:10.1146/annurev-ento-120811-153715
- Ray, T. S. (1991). An approach to the synthesis of life. In C. G. Langton, C. Taylor, J. D. Farmer & S. Rasmussen (eds.), Artificial Life II, Santa Fe Institute Studies in the Sciences of Complexity, vol. X, 371–408. Addison-Wesley.
- Scheffer, L. K. & Meinertzhagen, I. A. (2021). A connectome is not enough – what is still needed to understand the brain of Drosophila? Journal of Experimental Biology 224, jeb242740. doi:10.1242/jeb.242740
- Schlegel, P. et al. (2021). Information flow, cell types and stereotypy in a full olfactory connectome. eLife 10, e66018. doi:10.7554/eLife.66018
- Schlegel, P. et al. (2024). Whole-brain annotation and multi-connectome cell typing of Drosophila. Nature 634, 139–152. doi:10.1038/s41586-024-07686-5
- Semmelhack, J. L. & Wang, J. W. (2009). Select Drosophila glomeruli mediate innate olfactory attraction and aversion. Nature 459, 218–223. doi:10.1038/nature07983
- Shiu, P. K. et al. (2024). A Drosophila computational brain model reveals sensorimotor processing. Nature 634, 210–219. doi:10.1038/s41586-024-07763-9
- von Reyn, C. R. et al. (2017). Feature integration drives probabilistic behavior in the Drosophila escape response. Neuron 94, 1190–1204. doi:10.1016/j.neuron.2017.05.036
- Wang, F. et al. (2020). Neural circuitry linking mating and egg laying in Drosophila females. Nature 579, 101–105. doi:10.1038/s41586-020-2055-9
- Yaeger, L. (1994). Computational genetics, physiology, metabolism, neural systems, learning, vision, and behavior or PolyWorld: life in a new context. In C. G. Langton (ed.), Artificial Life III, Santa Fe Institute Studies in the Sciences of Complexity, vol. XVII, 263–298. Addison-Wesley.
- Zador, A. M. (2019). A critique of pure learning and what artificial neural networks can learn from animal brains. Nature Communications 10, 3770. doi:10.1038/s41467-019-11786-6
- Zheng, Z. et al. (2018). A complete electron microscopy volume of the brain of adult Drosophila melanogaster. Cell 174, 730–743. doi:10.1016/j.cell.2018.06.019