fly-world documentation ← back to the kitchen

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

PartIn fly-worldBased on
Brain modelThree message-passing steps through the connectome at every tick, nothing trainedCorreig-Fraga et al., 2026
WiringThe FlyWire whole-brain connectome and its cell typesDorkenwald et al., 2024; Schlegel et al., 2024; Matsliah et al., 2024
EyesOmmatidia, photoreceptors R1–6, R7 and R8, colour channelsPaulk et al., 2013
SmellTwo antennae, three odours, a search on rising smellSemmelhack & Wang, 2009; Gaudry et al., 2013; Álvarez-Salvado et al., 2018
EscapeTake-off from a looming handCard & Dickinson, 2008; von Reyn et al., 2017; Ache et al., 2019
MatingCourtship, copulation and the female's receptivityHall, 1994; Liu & Kubli, 2003
EvolutionNo fitness function, a designed ancestorTierra (Ray, 1991)
Energy and populationMetabolic costs, a closed energy budget, booms and bustsKleiber, 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

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

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