loading...
running...
How to use
Pick a preset or move the sliders. The key experiment: compare Thin flock, topological with Thin flock, metric, or switch Neighbourhood while the flock flies and watch the polarization curve and the third graph. The orange bird is tracked: the orange lines show exactly which birds it is watching. Click the sky to drop a falcon there (or use the Falcon presets). Space pauses, R resets.
Experiments: (1) set alignment to 0 and see polarization fall to the random level (grey line); (2) raise noise to 7 and watch the order collapse, then lower it; (3) cut the number of starlings to 150 in each neighbourhood mode; (4) narrow the field of view to 120 degrees; (5) switch the roost pull off and let the flock wander; (6) press Scatter headings and measure how quickly it re-aligns for different alignment rates.
Drag to orbit, wheel or pinch to zoom. The reedbed island with its reeds and cattails, the lake, hills, forest, jetty, the starlings (body plus two flapping wings) and the falcon were modelled in Blender 5.2 with baked PBR textures and exported as a Draco-compressed GLB; the flock dynamics is exactly the model of the 2D page.
The science
Murmuration. A starling flock of thousands turns like one body although no bird leads. Every bird follows three local steering rules (Craig Reynolds, 1986/87) using only the few neighbours it watches. The acceleration of bird i is
ai = wS ∑d<rs (1 - d/rs) (ri - rj)/d + wA (<vj> - vi) + wC (<rj> - ri) + roost + wind + walls + falcon
Separation pushes away from birds closer than rs, alignment relaxes the velocity towards the neighbour average (two interacting birds lose their velocity difference as exp(-2 wA t), measured in the checks) and cohesion pulls towards the local centre. Speed is held between vmin (a bird cannot hover) and vmax; the steering acceleration is capped at fmax. Integration is semi-implicit Euler at 1/60 s with every acceleration computed from the old state.
Metric or topological neighbours? Classic boids look at every bird within a fixed radius (metric). Ballerini et al. (PNAS 2008) reconstructed real starling flocks in 3D and found that each bird interacts with a fixed number of about seven nearest neighbours whatever the distance (topological). The difference matters: with a fixed radius the number of neighbours is Nnb = ρ (4/3) π r3, so a thinned-out flock loses its neighbours and frays, while with k = 7 the interaction survives any change of density, which is why real flocks stay cohesive when a predator opens a hole in them. Try the two Thin flock presets. The in-page checks measure the metric count against ρ (4/3) π r3 and confirm that the topological count stays at k.
Order parameters. Polarization φ = |∑ vi/|vi|| / N is 1 for perfect alignment; for N uncorrelated headings in 3D its expectation is √(8/(3π)) / √N (grey line, checked with 1500 random draws). The milling order |∑ (ri - rc) × v̂i| / ∑|ri - rc| is large when the flock rotates as a ring. Random kicks of strength η reproduce the order-disorder transition of the Vicsek model: little noise gives a polarized flock, a lot gives a disordered cloud.
Roost and predator. At dusk starlings gather over their reedbed before dropping into it. The model adds a soft pull towards the roost when a bird is farther than rroost from it. A falcon makes birds within the alarm distance accelerate away by wF (1 - d/R) and fly 30 % faster; the hunting falcon stoops at the nearest bird and breaks off after 3 m without catching anything, so the page is about collective motion, not about predation. Real flocks also show waves of turning that travel faster than any bird flies; here this only emerges weakly.
Efficiency. Searching all N-1 others costs O(N2). A spatial grid with cell size at least the vision radius visits only 3 cells per axis; the k nearest are kept by insertion into a short sorted list. A check compares this with a brute-force sort.
Honest simplifications. Birds are point masses with a heading; the banking and wing beat in 3D are cosmetic, there is no aerodynamics, no energy budget and no lift. The soft walls and the roost pull are numerical devices (real flocks follow terrain, wind and the sun). Flocks here have hundreds of birds, real ones have up to hundreds of thousands. The 2D page is the same model with the vertical axis removed.
In-page checks. (1) grid k-nearest search equals brute force; (2) metric neighbour count equals ρ (4/3) π r3 for random birds; (3) doubling the density doubles it; (4) the topological count is independent of density; (5) alignment-only relaxation follows exp(-2 wA t); (6) order parameter of random headings matches the closed form; (7) no bird leaves the sky box after a long run with a hunting falcon.