Few animals have been more thoroughly studied than the fruit fly Drosophila melanogaster. Scientists have sequenced its genome, tracked its development from single cell to fully-formed fly, and teased apart the neurons in its brain. They know this fly at the most intimate level, but for all that knowledge, they’ve been operating under one false assumption: that it’s a loner. Drosophila is classified as a solitary species.

“The conventional wisdom in the field was that flies are solitary animals that probably make decisions independently of one another,” says Pavan Ramdya from the University of Lausanne. “But if you watch them in your compost pile or fruit basket, you’ll notice that they often form groups when eating, seeking mates, or laying eggs.”

When animals live in groups, they can unlock incredible behaviours just by interacting with their neighbours according to simple rules. Locusts can form crop-devastating, sun-blocking swarms; starlings can form beautiful murmurations; fish can solve problems as a shoal. Ramdya suspected that the supposedly anti-social flies might also show collective behaviour.

He was right. Through a impressive series of experiments, involving a smorgasbord of cutting-edge techniques, Ramdya showed that flies can collectively flee from a bad smell faster than any individual can by itself. Alone, each fly is only slightly repelled by the odour; together, they run away decisively. Even mutant flies that can’t smell the odour at all can escape if they’re in the presence of smell-sensitive peers.

“It’s a scenario familiar to any big city dweller,” says Leslie Vosshall from Rockefeller University, who studies the senses and nervous systems of insects. “Pushy crowds respond to bad things differently than individual people, because information can flow through the group that compels it to act. It turns out flies are exactly like people in this regard.”

Ramdya first put flies in an arena, half of which had been flooded with carbon dioxide, and used an automatic tracking system to record their movements. Flies supposedly avoid carbon dioxide but isolated insects didn’t seem to care. But as Ramdya added more and more flies, their decisions improved, and they started to rapidly move towards the fresh-air side.

These collective movements are borne of three incredibly simple rules. First, an individual fly walks a little more often when exposed to carbon dioxide, but not in any particular direction. Second, if it moves from fresh air to carbon dioxide, it turns around. Third, if another fly bumps into it, it walks away from the bumper. For a single fly, these rules mean a lot of aimless walking. But in a group, flies that smell carbon dioxide end up bumping their neighbours out of the smelly zone. That’s what Ramdya saw in real life, and he even managed to reproduce the same effect in a computer simulation, by programming virtual flies to obey the same rules.

Even flies that couldn’t smell carbon dioxide ended up in fresh air. “It’s as if the smell-blind flies are milling around oblivious to the bad news, until they are jostled by the normal flies heading for the exits,” says Vosshall.

The flies don’t respond to any old bump. When Ramdya touched them with a small metallic disc, “they would simply shift their legs as if they were annoyed”. They only walked when he lightly grazed the tips of their legs. Only the gentlest of touches would do.

Ramdya even identified the exact neurons in the flies’ legs that drive their group behaviour. He engineered several strains of flies that each produced a nerve-paralysing toxin in a different set of touch-sensitive neurons. One particular strain stopped walking when bumped by its neighbours. Their silenced neurons made them behave like loners, even when they were surrounded.

Ramdya took these flies and swapped the toxin out for a glowing green protein, to label the neurons that had previously been deadened. He then proved that these cells were driving the flies’ collective behaviour by loading them with a light-sensitive protein—he could then make the neurons fire on demand by flashing them with blue light. When he did this, the flies went for walks as if they’d been bumped.

“This is a landmark study of collective behaviour,” says Iain Couzin from Princeton University and the Max Planck Institute for Ornithology. “Never before has it been possible to unweave the intricate coding of social behaviour during collective decision-making.” When it comes to fruit flies, scientists have so many tools and techniques at their disposal that they can really start to understand the origins of collective behaviour—how genes in the fly’s neurons are activated, how those neurons process signals from the fly’s environment, and how they drive individual behaviours that, in turn, lead to swarm behaviour. This is the future of the field, and one that I hinted at in my piece for Wired.

The flies also provide a great example of wisdom of the crowds—where groups make better decisions than individuals. For example, if you ask people to guess the number of beans in a jar, individuals might be wildly out but the average of their guesses will be uncannily accurate. Similarly, each fly imperfectly reacts to the odour, but via simple touches, they can pool their imperfect behaviour and head in the right direction.

A similar process goes on in your head. The 86 billion neurons in the human brain are individually unthinking, and interact with their neighbours according to very simple rules. But together, they can land machines on passing comets, craft works of astonishing beauty, and even unravel the collective behaviours of other creatures.

Reference: Ramdya, Lichocki, Cruchet, Frisch, Tse, Floreano & Benton. 2014. Mechanosensory interactions drive collective behaviour in Drosophila. http://dx.doi.org/10.1038/nature14024