Three rules for a flock
In 1986 a computer-graphics researcher named Craig Reynolds, working at a company called Symbolics, wanted to animate a flock of birds without drawing every bird by hand. A flock is hard to animate because nobody directs it. So he asked a different question: what does each bird need to do, so that a flock happens? His answer, published in 1987 in the paper “Flocks, Herds, and Schools: A Distributed Behavioral Model,” was a program in which every simulated bird, which he called a boid, follows three rules, in order of precedence, and senses only the neighbors in a small zone around it.
- Collision avoidance (often called separation): steer away from a flockmate that is too close.
- Velocity matching (alignment): steer toward the average heading and speed of your neighbors.
- Flock centering (cohesion): steer toward the average position of your neighbors.
Those are the flocking rules. There is no leader, no plan, and no picture of the whole flock in any boid’s head. Yet the result looks alive. Scattered boids pull together, line up, and fly in a group; the group turns as one, splits to go around a column, and rejoins. Reynolds’s boids flew in his 1987 short film Stanley and Stella in: Breaking the Ice, and the same idea, modified, moved the bats and penguins of the 1992 film Batman Returns. In 1998 Reynolds received an Academy Scientific and Engineering Award for pioneering contributions to three-dimensional computer animation for films. (Some retellings date the model to 1983. The paper and Reynolds’s own account say 1986.)
Try it. The three sliders set how hard each rule pulls. Turn one down to zero and see which rule does what.
Seventy birds, three rules
Press Run. Every bird looks only at neighbors within a short distance. The number below measures how closely the headings agree: 1.00 is perfect agreement.
This toy follows Reynolds’s three rules in the simplest way. With cohesion at zero the group stops pulling together; with separation at zero the birds crowd; with alignment at zero there is no flock at all.
Three details of Reynolds’s paper are worth pointing out. First, the model is deterministic: its author writes that, apart from the randomly chosen starting positions, which he says are not even required, everything else “is completely deterministic and repeatable.” Nothing is left to chance, yet the only practical way to know where the third bird from the left will be after a minute is to run the program. Whether tiny differences in the start grow, as they do in the chaos of Lesson 2, Reynolds never tested; calling boids chaotic is this course’s reading, not his finding. Second, flock splitting is not a special feature. Reynolds notes that models with a central force or a designated leader do not allow a flock to split, while his boids do, because each boid cares only about staying near its own neighbors. Third, the boids do have an explicit way of steering around obstacles; what nobody wrote down is the behavior of the flock as it divides and merges around them.
Real starlings
A model shows that some rules could make a flock. It does not show that birds use them. For that, someone has to measure real birds, and starlings are the best-studied. From the winter of 2005 to 2006, a team of physicists in Rome (the STARFLAG project) photographed starlings gathering at dusk over the trees by the city’s Termini station, using pairs of cameras 25 meters apart on the terrace of a museum, the Palazzo Massimo. From the stereo photographs they reconstructed the position of every bird in flocks of up to 2,600, in three dimensions.
Their main finding, published in 2008, was a surprise. A bird does not respond to every bird within some fixed distance. From the structure of the flocks, the researchers inferred that it responds to about six or seven nearest neighbors on average, however near or far they are. This is a rule of count, not of distance, and the team argued, from simulated predator attacks, that it helps a flock hold together even when it stretches thin or bunches up. Later work found that a change of direction travels through a flock as a wave, at 20 to 40 meters per second, faster than the birds fly (7 to 12 meters per second), so that a turn can sweep through hundreds of birds in under a second; and that the birds’ headings are correlated across the whole flock, over distances that grow with the flock’s size. The real rule is thus a variation on Reynolds’s, and the model gave physicists the right question. Birds that fly in a V, such as geese, are another matter, explained by aerodynamics: in a 2014 study of northern bald ibises, each bird flew where the air rising off the wingtip ahead was strongest, and timed its wingbeats to catch it.
The ants’ short cut
Ants find short paths between nest and food, though no ant knows the map. In a 1989 experiment, Simon Goss, Jean-Louis Deneubourg, and their colleagues in Brussels connected a nest of Argentine ants to a food source by a bridge with two forks in a row, each splitting into a short branch and a long one, and in the same short paper they gave a mathematical model of what the ants did. Argentine ants lay a scent trail of chemical marks, a pheromone, as they walk, and follow the stronger scent. When the long branches were twice as long as the short ones, the ants ended up on the short branches in all 14 trials, mostly with more than four ants in five on them, and under red light, which the ants cannot see, the result was the same: scent, not sight. When the long branches were only 1.4 times longer, the ants chose the short ones in 15 of 18 trials. When the branches were equal, the ants settled on one at random, a different one in different trials.
The mechanism needs no ant that knows anything. At the start, ants take either branch about equally. But these ants mark the trail both going and coming. An ant that took the short branch reaches the food first and is likely to head home over the branch it has just marked, so the short branch carries the marks of a round trip before anyone has come back along the long one. A stronger scent attracts more ants, who add more scent: a loop of positive feedback turns a small head start into a decision. (The scent fades only slowly, over half an hour or more, too slowly to matter in this experiment. When programmers later copied the idea, they made their virtual scent fade on purpose, a negative feedback that lets old choices be forgotten.)
Forty ants, two paths
The nest is on the left and the food on the right. Each ant chooses a path with a chance that grows with the scent already on it. Try making the paths equal, or turning the scent’s evaporation up or down, and run a few new trials each time.
The choice rule has the form Deneubourg and Goss used (the chance of a branch grows with the square of a constant plus its scent). Later work found that single ants respond more nearly in proportion to scent than to its square, so the formula describes the colony better than any one ant. The evaporation setting is the programmers’ addition: the real ants’ scent lasts too long to matter on the bridge.
This is not only a story about ants. Marco Dorigo and his colleagues at the Politecnico di Milano turned the idea into a family of computer methods called ant colony optimization, first described in the early 1990s (Dorigo’s doctoral thesis appeared in 1992) and tested on the traveling-salesman problem, in which virtual ants lay virtual scent on the better routes. It has been used for scheduling and for routing messages through communication networks. Honesty requires a caveat: on the traveling-salesman problem itself, ant systems are not competitive with the best dedicated solvers, and the claim to a lasting place rests on some scheduling and routing problems, not on a general victory.
The same mechanism can also fail, and the failure is instructive. In the bridge experiment, when the short branch was added only after the colony had settled on the long one, the ants switched in only 2 of 18 trials. Early marks had locked in the choice. And in a book of 1921 the naturalist William Beebe, of the New York Zoological Society, described a column of army ants he had come upon in British Guiana, which had closed into a circle about 1,200 feet around; an ant took about two and a half hours to walk it. Ants following the scent of the ants in front had found themselves following their own tails. Beebe found the “mill” at six in the morning; it turned all day and was still moving at midnight. By the next morning it had weakened, and it broke only when a few half-dead stragglers wandered off and others followed their scent into the jungle. Positive feedback is powerful, not wise.
One more story about ants, popular in talks on this subject, deserves a correction. It says that fire ants, caught in a forest fire, roll themselves into a ball and roll through the flames. This course could find no credible source for it. What is documented is remarkable enough: in floods, fire ants link their bodies into a floating raft. In experiments at Georgia Tech in Atlanta, about 3,000 ants dropped on water linked into a flat, water-repellent raft with air trapped beneath it, and such a raft “can float effortlessly for days,” according to the report in PNAS in 2011.
A slime mold and a railway
The next path-finder is not an animal at all: a single cell, big enough to see. Physarum polycephalum, a yellow slime mold, is one huge cell with many nuclei, which spreads across a surface as a network of tubes. (It is sometimes described as a swarm of bacteria, or of amoebas that gather. It is neither, and it does not split into separate cells. The slime mold whose separate amoebas gather when starved is a different organism, Dictyostelium.) In 2000 Toshiyuki Nakagaki, Hiroyasu Yamada, and Ágota Tóth, working in Japan and Hungary, let pieces of Physarum fuse and fill a small maze, with oat flakes at two exits. Within four hours the cell had withdrawn from the dead ends, and four hours later a single tube joined the two foods by the shortest route, give or take a millimeter.
In 2010 Atsushi Tero, Toshiyuki Nakagaki, and colleagues, working in Japan and the United Kingdom, put it to a harder test. On a map 17 centimeters across, bounded by the Pacific coast, they laid 36 oat flakes in the positions of the cities around Tokyo, placed the slime mold at Tokyo, and shone light on the mountains, sea, and lakes, which Physarum avoids. Over about 26 hours it grew a dense web of tubes, then strengthened the busiest and let the rest wither, until what remained looked much like the real rail network. The feedback here is not scent but flow: tubes that carry more flow grow thicker, and the rest shrink.
Some retellings say the slime mold “beat” the engineers. The paper says something more modest and more useful. The slime mold’s networks matched the rail system’s total length and the average length of the shortest route between two cities (the second bar). They were less robust: a single broken link cut off part of the network in 14 to 20 percent of cases for the slime mold, and in only 4 percent for the rail system. People also framed the problem, choosing the cities, the lighting, and the measures. The most useful result is the authors’ mathematical model of the slime mold’s rules: tuned, it gave more benefit for its cost than either network, and they proposed it for designing networks such as wireless mesh networks. (Accounts sometimes place the work at the University of Tokyo in 2008, and feed the slime mold sugar. The authors were at Hokkaido University, the University of Oxford, and Hiroshima University, the food was oat flakes, and the paper appeared in Science on 22 January 2010.)
Wise crowds, foolish crowds
Do human crowds work like this? Sometimes. Late in 1906 the scientist Francis Galton went to a livestock fair in Plymouth, England, where visitors paid sixpence to guess the weight of an ox once it was butchered and dressed. He collected the 787 usable tickets. The middle guess was 1,207 pounds; the ox weighed 1,198, so the crowd’s middle guess was off by less than one percent. The average guess, which Galton worked out a few weeks later, was 1,197 pounds, almost exactly right. (His worksheets, reexamined in 2014, give 1,208 for the middle guess and 1,197 for the weight, which makes the average exact.) Galton was struck enough to publish a note in Nature in March 1907 titled “Vox Populi,” and nearly a century later the journalist James Surowiecki popularized the idea in The Wisdom of Crowds. He proposed four conditions for a wise crowd, a thesis rather than a tested law: diversity of opinion, independence of each person’s judgment, decentralization, and a way of aggregating the answers.
The conditions matter. A 2011 experiment by Jan Lorenz, Dirk Helbing, and colleagues at ETH Zurich asked 144 people to estimate facts, with some allowed to see others’ answers. Even mild social influence narrowed the range of answers without making the group any more accurate: people simply converged on one another. Sharing does not always hurt, though: in a 2017 study by Becker, Brackbill, and Centola, people linked in decentralized networks grew more accurate after seeing their neighbors’ estimates. Course 13 met studies of a group’s “collective intelligence,” in which even taking turns in conversation seemed to matter; later studies disagree on how much, and the popular claim that groups do best when 20 to 80 percent of their members are women appears nowhere in the original paper.
The darkest case, a crowd crush, comes not from foolishness but from density. On 12 January 2006, during the stoning ritual of the Hajj, at least 345 people died (a later Saudi count gave 363) in a crush before the entrance to the Jamarat Bridge in Mina, near Mecca. Dirk Helbing and colleagues later studied video of the crowd. They found that its density locally exceeded ten people per square meter, and that the flow passed from smooth to stop-and-go at about 11:53 in the morning, and to “crowd turbulence” at 12:19, in which waves of pressure moved through the people. What looks like panic, the researchers wrote, begins when the pressure is already unbearable. By the next pilgrimage the pillars had been made elliptical, crowds were counted by camera and kept moving on one-way routes, and a new multi-level bridge was finished before 2009. (Crushes are sometimes said to happen almost every year at Mecca. Major fatal ones came in 1990, 1994, 1998, 2001, 2003, 2004, 2006, and 2015, and none has been reported since 2015, as of November 2026. The toll of 2015, in Mina on 24 September, is disputed: the Saudi count was 769 dead, while a count by the Associated Press reached at least 2,411.)
A milder case is a jam on the highway. It is sometimes said that a city’s traffic is bad because every driver is too clever. Experiments point to something simpler. In 2008 a group of Japanese physicists, led by Yuki Sugiyama, put 22 cars on a circular track 230 meters around and asked the drivers to go at about 30 kilometers per hour. Within about three minutes a jam formed out of nothing, with no bottleneck and no accident, and it traveled backward around the ring at about 20 kilometers per hour, against the direction of the cars. Nobody overtook anybody: each driver simply tried to keep a steady speed and a safe gap, and small slowdowns grew into stopped cars. Lane changes can make traffic worse, but this jam needed none. On 19 January 2013 Rui Jiang and colleagues ran 25 cars, tracked by GPS and forbidden to overtake, along 3.2 kilometers of Chuangxin Avenue in Hefei, China, and found disturbances growing down the line in ways the classic car-following models miss. A simple model from 1992 by Kai Nagel and Michael Schreckenberg, a row of cells with cars that accelerate, brake, and sometimes slow at random, gives the same phantom jams.
From idea to tool
Galton’s averaging now works on machines. In a 2024 study, the pooled forecasts of 12 language models on 31 questions, over a three-month tournament, were statistically indistinguishable from those of 925 human forecasters. Shown the human median, the models improved by 17 to 28 percent, yet averaging human and machine forecasts did better still. As of 2024 this was a single study.
Not every crowd of machines is leaderless. In the record drone shows in China (22,580 drones flown from one computer in Hefei in February 2026, and 33,615 in all in Sichuan that May, as of November 2026), every path is written in advance. Real swarms are still research, like ten palm-sized drones from Zhejiang University that crossed a bamboo forest in 2022 with no GPS and no central controller.
Why did the ants in the double-bridge experiment end up on the short branch?
Closer to home
Chinese has two proverbs about groups, and they pull in opposite directions. 三个臭皮匠,赛过诸葛亮 (sān gè chòu píjiàng, sài guò Zhūgě Liàng) says that three humble cobblers can beat the brilliant strategist Zhuge Liang. 三个和尚没水喝 (sān gè héshang méi shuǐ hē) says that three monks have no water to drink: one monk carries water for himself, two share the carrying, and three each wait for someone else. Read with the research in this lesson, both are right, and the research tells us when: the cobblers win when their guesses are independent and heard, and the monks go thirsty when everyone is waiting on everyone else.
Americans know the same pair in a different dress: a crowd can produce a well-priced stock market and a bubble, “too many cooks” and a good town meeting. The question is never whether to trust a crowd, but what the crowd’s links look like.
Another view
Each example here deserves a second look, and some of them are weaker than the headlines. Boids show that three local rules can produce flocking; they do not show that birds follow those rules. Real starlings track a count of neighbors, not a distance, and quite different rule sets can produce realistic motion, so a model that looks right has not yet explained a flock. The ant equations fit the colony better than the ant, and a real colony can stay locked on the worse route. Ant colony optimization is useful for some problems, not a general solution. The slime mold matched a rail network on cost and travel, lost on resilience, and solved a problem that people had framed; whether to call that “intelligence” depends on how the word is defined. Galton’s ox shows a crowd at its best: when people can copy each other, the effect can shrink, though in some networks sharing helps. And a crush is a matter of density and physics, not of mindless panic. Complexity science is best at showing how things can happen. Showing how they do happen in a given real system takes the slower work of measurement.
What to keep
- A few local rules, each part seeing only its neighbors, can produce a flock, a trail, or a network. The boids model has no leader, no plan, and no randomness after the start, yet the only practical way to know its next move is to run it.
- Positive feedback amplifies a small head start into a decision, and it can lock a choice in: the ants seldom switched to a short cut added late, and an ant mill is the extreme case. Ant algorithms make their scent fade on purpose, so that old choices can be forgotten.
- The same ingredients make crowds that are wise (independent, diverse, decentralized) and crowds that go wrong (copying, phantom jams, deadly density). The difference is the pattern of links and the room to move, not the intelligence of the members.
- Many popular claims here are stronger than the evidence: the slime mold matched, not beat, a rail network; crowd crushes come from density, not “panic”; and a jam needs no clever drivers, only small slowdowns that grow.
Think it over
Your notes are saved in this browser.
Sources and further reading
- Craig W. Reynolds, “Flocks, herds, and schools: a distributed behavioral model,” Computer Graphics 21 (4), 1987, 25–34 (SIGGRAPH ’87).
- Michele Ballerini and colleagues, “Interaction ruling animal collective behavior depends on topological rather than metric distance: evidence from a field study,” PNAS 105 (2008), 1232–1237; Andrea Cavagna and colleagues, “Scale-free correlations in starling flocks,” PNAS 107 (2010), 11865–11870; Alessandro Attanasi and colleagues, “Information transfer and behavioural inertia in starling flocks,” Nature Physics 10 (2014), 691–696; Portugal and colleagues, on V formation in northern bald ibises, Nature 505 (2014), 399–402.
- Simon Goss, Serge Aron, Jean-Louis Deneubourg, and Jacques Pasteels, “Self-organized shortcuts in the Argentine ant,” Naturwissenschaften 76 (1989), 579–581; Jean-Louis Deneubourg and colleagues, “The self-organizing exploratory pattern of the Argentine ant,” Journal of Insect Behavior 3 (1990), 159–168; Andrea Perna and colleagues, “Individual rules for trail pattern formation in Argentine ants,” PLoS Computational Biology 8 (2012), e1002592.
- Marco Dorigo, Vittorio Maniezzo, and Alberto Colorni, “Ant system: optimization by a colony of cooperating agents,” IEEE Transactions on Systems, Man, and Cybernetics B 26 (1996), 29–41; Marco Dorigo and Thomas Stützle, Ant Colony Optimization, MIT Press, 2004.
- Nathan Mlot, Craig Tovey, and David Hu, “Fire ants self-assemble into waterproof rafts to survive floods,” PNAS 108 (2011), 7669–7673; William Beebe, Edge of the Jungle, 1921, chapter “Sequels.”
- Toshiyuki Nakagaki, Hiroyasu Yamada, and Ágota Tóth, “Maze-solving by an amoeboid organism,” Nature 407 (2000), 470; Atsushi Tero and colleagues, “Rules for biologically inspired adaptive network design,” Science 327 (2010), 439–442.
- Francis Galton, “Vox populi,” Nature 75 (1907), 450–451; Wallis, on Galton’s worksheets, Statistical Science 29 (2014), 420 (arXiv:1410.3989); James Surowiecki, The Wisdom of Crowds, Doubleday, 2004; Jan Lorenz, Heiko Rauhut, Frank Schweitzer, and Dirk Helbing, “How social influence can undermine the wisdom of crowd effect,” PNAS 108 (2011), 9020–9025; Becker, Brackbill, and Centola, PNAS (2017).
- Dirk Helbing, Anders Johansson, and Habib Al-Abideen, “Dynamics of crowd disasters: an empirical study,” Physical Review E 75 (2007), 046109; Associated Press count of the 2015 Mina toll, 10 December 2015; Yuki Sugiyama and colleagues, “Traffic jams without bottlenecks,” New Journal of Physics 10 (2008), 033001; Rui Jiang and colleagues, the Hefei platoon experiment, PLoS ONE 9 (2014), e94351; Kai Nagel and Michael Schreckenberg, “A cellular automaton model for freeway traffic,” Journal de Physique I 2 (1992), 2221–2229.
- Anita Woolley, Christopher Chabris, Alex Pentland, Nada Hashmi, and Thomas Malone, “Evidence for a collective intelligence factor in the performance of human groups,” Science 330 (2010), 686–688; Timothy Bates and Shivani Gupta, “Smart groups of smart people: evidence for IQ as the origin of collective intelligence in the performance of human groups,” Intelligence 60 (2017), 46–56; Christoph Riedl and colleagues, “Quantifying collective intelligence in human groups,” PNAS 118 (2021), e2005737118.
- From idea to tool: Schoenegger, Tuminauskaite, Park, Bastos, and Tetlock, Science Advances 10 (45), November 2024 (arXiv:2402.19379); Xin Zhou and colleagues, “Swarm of micro flying robots in the wild,” Science Robotics, 4 May 2022; Guinness World Records pages for the drone records of 3 February 2026 (Hefei) and 20 May 2026 (Sichuan), as of November 2026.