Skip to the interactive
ExplainerTools Watch the 34-second film

Collective motion · interactive

How do a few turns become one direction?

Model · local headings, no cohesion

Each arrow is one agent; its trail shows its last 8 updates. The circle is the selected arrow’s neighborhood. It averages those headings, turns part of the way toward the average, then gets a random kick somewhere in the yellow wedge. Tap any arrow to follow it. The box wraps at its edges.

1 See

Each arrow only looks at the few arrows near it. How could 64 small, local turns add up to one shared direction?

2 Change

3 Understand

Watch the 34-second film
Model notes and sources

Model: 64 point agents in a square box of side L = 1 that wraps at every edge (periodic boundaries). Each update moves every agent 0.01 L. An agent’s neighborhood is every agent within R = 0.12 L, measured the short way across the wrapping edges, and it includes the agent itself. There is no limit on the number of neighbors. All agents update together from the same old state. Agent i finds the circular mean θ̄i of the headings in its neighborhood and turns to θi′ = θi + a · wrap(θ̄i − θi) + 0.35 ξi. Here wrap(·) takes the shorter way around, into [−π, π), and ξi is a seeded random number between −1 and 1. Only then does every agent step 0.01 L along its new heading. If the headings in a neighborhood cancel exactly, the agent keeps its old heading before the kick.

The Alignment knob is a. At 0 an agent ignores its neighbors, and only random kicks of at most 0.35 rad (about 20°) turn it. At 1 it takes its neighbors’ average heading plus a kick: the alignment-with-noise rule of Vicsek and colleagues, with their noise amplitude η = 0.7. Values in between are a teaching interpolation, not a parameter from the original paper. The order P = |(1/64) Σ eiθ| is the length of the average of the 64 unit headings. It is 1 when all headings match and 0 when they cancel. Independent random headings give about 0.11 on average.

Eight-seed check: one comparison, fixed before any run was seen. The seeds are 3, 17, 41, 73, 101, 211, 307 and 499. For each seed, the same starting positions, the same headings and the same stream of random kicks run once at alignment 0 and once at 1. After 1,000 warm-up updates, P is averaged over the next 500. Your browser runs these 16 runs after the page opens and shows each seed’s average, the mean and the range; the film shows the same calculation. One frame, or one run, can wobble, so the comparison is between averages. The live stage uses seed 3, and Restart replays it from the same start with the same kicks.

Not modeled: body size, collisions, attraction or cohesion, leaders, blind spots, speed changes, obstacles, surroundings, and anything fitted to real animals. A shared heading here does not mean a tight group: arrows can point the same way while spread across the box. This toy is not evidence that alignment alone explains bird flocks, fish schools or insect swarms. Between updates, each arrow is drawn on the straight path the model moved it along.

Sources: T. Vicsek, A. Czirók, E. Ben-Jacob, I. Cohen and O. Shochet, “Novel type of phase transition in a system of self-driven particles,” Physical Review Letters 75, 1226 (1995): arXiv cond-mat/0611743; doi:10.1103/PhysRevLett.75.1226. C. W. Reynolds, “Flocks, herds, and schools: a distributed behavioral model,” SIGGRAPH ’87, doi:10.1145/37401.37406, for flocking built from local rules. A related, independently made explorable is Dirk Brockmann’s Horde of the Flies (Complexity Explorables). Its design and code were not used here.

An ExplainerTools Original. Alignment rule after Vicsek et al. (1995).

Keep exploring

Up next

  1. Interactive · ScienceDoes a prism create a rainbow?
  2. Interactive · ScienceWhy does oxygen let go?
  3. Interactive · ScienceWhy are the northern lights green?