Skip to content
QuickKit 100% free · no login

Home › Browser AI & Simulations › Fly Brain Simulator (Toy Model)

Fly Brain Simulator (Toy Model)

Runs in your browserFree · no sign-up

A virtual insect smells food with two antennae. Its small network of spiking neurons starts untrained and learns from reward to steer toward the odour.

Food eaten
0
Steps
0
Food per 1,000 steps
0.0

Network activity

Advertisement

A toy brain, honestly labelled

This is an educational simulation inspired by how small insect brains turn smells into movement. It is not a model of a real fruit fly. The real Drosophila brain has around 140,000 neurons, and its complete wiring diagram, the connectome, was published in 2024 after years of work. Here, a virtual fly has two odour sensors, sixteen spiking neurons and two motor units. The point is to show, in a form you can watch, how a nervous system can learn a useful behaviour from a simple reward signal.

What the fly senses and does

Each food source releases an odour that fades with distance. The fly's two antennae sit slightly to the left and right of its head and measure the odour where they are. Like real sensory neurons that adapt to background levels, the sensors respond to the difference between the two sides on a logarithmic scale. These signals drive a layer of leaky integrate-and-fire neurons with fixed random wiring: each neuron's voltage leaks away over time, rises with input and, when it crosses a threshold, fires a spike and resets. In the activity view, neurons flash yellow when they spike. The spikes feed two motor units that turn the fly left or right while it walks forward.

How it learns

In learning mode, the connections from the spiking neurons to the motor units start near zero, so the fly wanders randomly. A little random noise is added to the motor commands, and the simulation keeps an eligibility trace recording which neurons were active when each random nudge happened. After each step, a reward signal compares the odour at the fly's body with the previous step: getting closer to food is good, moving away is bad. Like the dopamine signals that gate learning in insect and mammal brains, this single number tells every connection whether its recent contribution helped. Connections that pushed in a rewarded direction get stronger; others weaken. This rule is known as node perturbation, a simple form of reward-modulated learning.

What to look for

  • Run learning mode at a higher speed and watch the food-per-1,000-steps figure rise as the fly starts turning toward odour.
  • Compare with the hard-wired brain, where each side's neurons drive the opposite turn, like a Braitenberg vehicle, and with the random brain.
  • Click in the arena to drop extra food and watch the fly respond.

In our tests over many runs, the learning fly typically ends up finding food several times more often than the untrained one. Everything is computed in your browser, a few kilobytes of JavaScript with no external libraries.

Frequently asked questions

Is this a real fruit fly brain?

No. It is a toy model with sixteen spiking neurons, inspired by insect navigation. A real fly brain has about 140,000 neurons.

How does the fly learn?

Random motor noise plus a reward signal for moving up the odour gradient strengthens the connections that helped, a reward-modulated learning rule.

What is a spiking neuron?

A model neuron whose voltage builds up with input and leaks away; when it crosses a threshold it fires a spike and resets.

What is a connectome?

A complete map of the connections between neurons in a nervous system, such as the fruit fly connectome published in 2024.

Does the simulation use the internet?

No. It runs entirely in your browser.

More free tools