Flock

Coordinated motion without a conductor. When many agents only avoid crowding, match nearby headings and stay near their neighbours, streams, turns and recoveries can appear from above even though no agent carries a map of “the flock.” The sphere is an invitation to watch order as

The idea

Coordinated motion without a conductor. When many agents only avoid crowding, match nearby headings and stay near their neighbours, streams, turns and recoveries can appear from above even though no agent carries a map of “the flock.” The sphere is an invitation to watch order as a gap between local rules and collective form.

Science and concept

The familiar boids model is built from three steering tendencies that answer different local questions.

Separation asks: am I too close to another agent? It produces short-range avoidance. Without it, cohesive attraction can drive agents into implausible overlap.

Alignment asks: which way are nearby agents moving? It changes an agent’s velocity toward the local average. This is the clearest route to directional consensus.

Cohesion asks: where is the local group? It steers an agent toward the local centre of its neighbours. Without it, aligned headings need not preserve a durable spatial group.

These rules are complementary rather than interchangeable. Cohesion without separation encourages collapse. Separation without cohesion encourages dispersal. Alignment without sufficient spatial coupling may produce temporary heading agreement while the population fragments. A flock is therefore not an object inserted into the simulation; it is a continuously maintained compromise between incompatible pressures.

A useful explanatory shorthand is

Compact form: a_i ≈ w_s Ŝ_i + w_a Â_i + w_c Ĉ_i + w_m M̂_i,

where the first three terms denote separation, alignment and cohesion, and the fourth denotes the AL.Floys species-matrix force. This is not a universal biological equation. It is a compact map of the implementation’s steering architecture.

The most revealing conceptual pattern is positive feedback constrained by negative feedback. Alignment is self-reinforcing: once several neighbours move similarly, their shared heading becomes a stronger signal for agents around them. Cohesion keeps those agents close enough for the coupling to persist. Separation prevents the same aggregation from turning into an unbounded pile-up. The ordered state exists between two failures—evaporation and collapse.

This mechanism illustrates emergence in a precise rather than mystical sense. The lower-level rule is a repeated local velocity correction. The higher-level pattern is a spatially extended group with a common direction. No individual is assigned the group’s shape or commanded to occupy a particular point within it. The collective pattern is therefore not directly specified agent by agent, although it remains fully caused by the programmed rules.

A common scientific neighbour is the Vicsek model. Vicsek and colleagues introduced a deliberately stripped-down system in 1995: self-propelled particles move with constant speed, align their direction with nearby particles, and receive angular noise. The model displays a transition from disordered motion to finite collective transport through spontaneous rotational-symmetry breaking. Flock shares the broad question—how local coupling produces global motion—but it is not a Vicsek implementation. AL.Floys uses steering acceleration, variable velocity, explicit separation and cohesion, damping and speed clipping. Its main update does not add the Vicsek model’s per-step angular-noise term.

The comparison is still valuable because it identifies the deeper common idea: macroscopic directional order does not require a macroscopic controller. A global direction can be selected dynamically from local interactions and initial fluctuations.

The choice of neighbourhood is equally important. AL.Floys uses a metric neighbourhood: agents inside a fixed spatial radius contribute to the update, with a smaller radius governing separation. This is computationally clear and visually effective, but it is not a neutral biological fact. Ballerini and colleagues reconstructed three-dimensional starling flocks and found that the birds’ interaction was better described by a topological rule—approximately six or seven neighbours—than by a fixed metric radius. Real flocks can therefore preserve coupling while density changes because “who counts” is defined by neighbour rank rather than metres.

That difference is an important lesson in model reading. A model can capture a generative principle—local interaction producing collective order—while simplifying or getting wrong a specific mechanism by which an animal chooses interaction partners.

AL.Floys also goes beyond the elementary three-rule teaching model. Each agent belongs to a species, and a directed matrix can make one species attract or repel another. Because the matrix is directed, the influence of species A on B need not equal the influence of B on A. This can produce sorting, pursuit and avoidance layered on top of ordinary flocking. The simple ecospheres.ai surface appropriately hides the matrix at first, keeping the canonical triad legible, but advanced interpretation should acknowledge that the current engine is not merely a textbook boids clone.

The world wraps at its edges. An agent leaving the right side re-enters from the left, and neighbour calculations use the shortest wrapped displacement. This toroidal boundary removes walls and corners that would otherwise create artificial accumulation. It also means that the visible rectangle is not a fenced habitat. It is one window onto a repeating world.

Finally, presentation must be separated from dynamics. Directional glyphs, local tails, global trail persistence, speed glow, density glow and velocity vectors make motion easier to read. They are not wakes, aerodynamic vortices, chemical traces or environmental fields. They are visual instruments for perceiving state.

History

Craig Reynolds presented “Flocks, Herds, and Schools: A Distributed Behavioral Model” at SIGGRAPH in 1987. The immediate problem was computer animation: complex aggregate motion was difficult to script convincingly if every animal path had to be authored. Reynolds replaced global choreography with independent actors guided by local perception and simple behaviours. The aggregate motion became the output of a distributed simulation rather than a prewritten formation.

That intervention mattered beyond graphics. It offered a particularly clear computational example of bottom-up organisation: global-looking structure could be generated by actors that knew only their surroundings. The boid became a standard example in artificial life, agent-based modelling, robotics, games and complexity education.

In 1995, Tamás Vicsek and colleagues moved the question toward statistical physics. Their simpler constant-speed alignment model treated collective transport as an order–disorder transition. This abstraction made it possible to study symmetry breaking, noise and scaling without importing the full behavioural vocabulary of animals.

Empirical collective-behaviour research then returned to the assumptions hidden inside the models. Ballerini and colleagues’ 2008 starling study supplied a particularly important correction: the relevant neighbourhood in real flocks appeared topological rather than metric. The intellectual sequence is therefore not “a simple model explained birds.” It is more productive:

behavioural animation → abstract theory of collective motion → quantitative testing of interaction assumptions

Flock belongs to that lineage as a computational demonstration of distributed organisation, not as the final biological theory of flocking.

What this simulates

Aspect Current implementation
Entities / field Discrete boid agents; there is no continuous environmental field.
State Position, velocity and species for each agent.
Update mechanism Separation + alignment + cohesion + directed species interaction produce acceleration; acceleration updates velocity; velocity is damped and capped; position advances.
Neighbourhood / interaction range Fixed metric neighbour radius, with a smaller separation radius; candidates are accelerated through a spatial hash.
Boundary conditions Toroidal wrap in position and shortest-distance neighbour calculations.
Randomness Seeded initial placement, initial velocity and spawning. The ordinary flock update has no explicit Vicsek-style angular-noise term.
Numerical approximation Real-time explicit stepping with frame scaling, velocity damping and a hard maximum speed.
Rendering interpretation Agent glyphs, speed-sensitive scale, tails, motion persistence, glow, optional density layer and velocity vectors. These are visual encodings.
Implementation-specific extension Multiple species and a directed species-pair attraction/repulsion matrix.
Public simple controls Population, Separation, Alignment, Cohesion, Max speed, plus selected visual controls.
Public tools Force, Spawn, Brush and Erase.

The central implementation distinction is that AL.Floys computes steering dynamics, not aerodynamic motion. There is no pressure field, lift, drag from air, collision geometry, perception occlusion or three-dimensional flight.

What to look for

Directional ordering — many headings become one

At first, nearby agents may point in unrelated directions. Alignment causes local headings to converge; cohesion keeps those locally aligned groups in contact. The result is a large region with nonzero mean direction, illustrating symmetry breaking and distributed consensus.

Finite spacing — together without collapse

A coherent group retains visible space between agents. This is not incidental decoration: it is the negotiated result of short-range separation opposing longer-range cohesion. The pattern makes stabilising negative feedback perceptible.

Fission and fusion — the flock has no stored membership

A group may divide around a disturbance or because local neighbourhoods lose contact, then later merge with another group. The event reveals that “the flock” is not represented as a persistent object. It exists only while interaction maintains it.

Turning propagation — information travels through neighbours

A local perturbation can spread outward as nearby agents adjust and become new signals for their neighbours. No broadcast command is sent to the whole population. Macroscopic reorientation emerges through local propagation.

Recovery — order resides in the rule, not the formation

A repelling gesture can tear a coherent school apart. When the disturbance ends, the same rules can reassemble ordered motion, often in a new shape. The system repairs a regime rather than restoring a blueprint.

Species sorting and pursuit — the AL.Floys extension becomes visible

Different colours may cluster, avoid or chase one another. This behaviour does not follow from the canonical triad alone; it reflects the directed species matrix layered into the engine.

How to explore

First 30 seconds

  1. Open Parameters and load Balanced flock.
  2. Ignore the entire screen for a moment and follow one local group. Notice whether heading agreement appears before the group becomes spatially compact.
  3. Move Alignment from 1.0 to 0. Wait long enough for the existing organisation to decay; do not change another parameter immediately.
  4. Restore Alignment to 1.0 and watch coherence rebuild.
  5. Load Tight school, choose the repelling form of Force through Steer, and cut across the centre of a group. Watch whether order recovers without returning to the same geometry.

Three experiments

Experiment Question Do Watch for Why it matters
Alignment without command Is common direction imposed globally? Balanced flock → set Alignment to 0 → wait → restore 1.0. Loss and recovery of directional coherence. Demonstrates neighbour-coupled consensus without a leader.
The anti-collapse balance Why does a flock neither evaporate nor condense into one point? Keep Separation fixed; move Cohesion from low to high in several steps. Fragmented local groups, then increasingly compact persistent groups. Shows that the flock is a balance between competing rules.
Perturbation and repair Is the visible formation stored anywhere? Load Tight school; apply a strong repelling Force across its centre; release. Rupture, turning waves and reorganisation into a different shape. Shows regime recovery rather than blueprint restoration.

Change one conceptual variable at a time. The Randomize scope selector can hold visuals steady while changing conceptual settings, but controlled slider changes are better for causal comparison.

Parameters that teach

Parameter What it really controls Increase it Decrease it What to watch
Separation Strength of short-range crowd avoidance. Greater spacing and stronger local deflection. Denser packing and more overlap pressure. Inter-agent distance and group texture.
Alignment Coupling to nearby average velocity. Faster and stronger directional ordering. Restless or fragmented headings. Mean group direction and turning propagation.
Cohesion Steering toward the local centre of neighbours. More compact, persistent groups. Greater fragmentation and dispersal. Fission, fusion and group lifetime.
Max speed Hard velocity ceiling, not motivation or fitness. Faster reorganisation and less legible transients. Slower, easier-to-read adjustment. The timescale of response after disturbance.
Neighbour radius (advanced) Which agents count as interaction partners. Larger connected interaction regions. More local, fragmented coordination. Spatial scale of common motion.
Species matrix (advanced) Directed attraction or repulsion between species classes. Entry-specific rather than globally “more.” Entry-specific. Sorting, chasing and asymmetric avoidance.
Trail persistence (visual) How long previous drawings remain visible. Longer apparent paths. Cleaner instantaneous state. Never interpret this as physical memory in the agents.

The first five public conceptual controls are Population, Separation, Alignment, Cohesion and Max speed. Neighbour geometry and the species matrix belong to the advanced engine surface.

Presets as experiments

Balanced flock

The reference regime. It gives the three steering tendencies enough room to be distinguished and should be the baseline for single-variable experiments.

Tight school

Stronger alignment and cohesion create a compact, legible ordered group. It is the best preset for perturbation-and-recovery experiments because the initial collective is unmistakable.

Nervous swarm

A faster, less stabilised regime. It is most useful as a contrast to Tight school: the same broad model can occupy a restless, fragmented state when the steering balance changes.

Recommended learning order: Balanced flock → Tight school → Nervous swarm.

Presets change several values at once and should therefore be described as regimes, not as clean demonstrations of one cause. Use sliders after loading a preset when the goal is inference.

Interactions

  • Force changes velocities locally. Attraction gathers agents; repulsion disrupts them. It is the strongest scientific interaction because it acts as a controlled perturbation to an existing collective.
  • Spawn inserts new agents. It changes density and introduces agents that must be incorporated into nearby motion.
  • Brush changes the species of existing agents. Because species selects a row in the directed interaction matrix, this can alter dynamics rather than merely recolour the field.
  • Erase removes agents. It can cut communication pathways and divide a group.

The interaction lesson is not simply “the field responds to the pointer.” It is that collective order can be tested by perturbing local state and observing whether macroscopic organisation survives, propagates or reforms.

What this does not mean

Flock is not a complete biological theory of bird, fish or mammal movement. It contains no wing aerodynamics, hydrodynamic wake, visual occlusion, attention limit, fatigue, predation strategy, body geometry, physiology or three-dimensional environment. Its fixed metric interaction radius also differs from evidence that starlings use a roughly topological neighbourhood.

It should not be called a Vicsek model. The two systems share an interest in local interaction and global order, but their update rules differ materially.

The simulation supports one strong conclusion: local behavioural coupling can be sufficient to produce coherent collective motion. It does not establish that real flocks use exactly these three terms or exactly this neighbourhood rule.

Why it belongs

Flock establishes one of ecospheres.ai’s foundational ideas: coordination can exist without a coordinator. It is the clean reference case for local information becoming global order. Later spheres can then add different generators: Particle Life removes alignment and replaces it with type-dependent forces; Ecosystem adds scarcity, birth and death; Swarmalators will couple motion to internal phase.

Sources

Foundational and primary sources

  1. Craig W. Reynolds, “Flocks, Herds, and Schools: A Distributed Behavioral Model,” Computer Graphics 21(4), 25–34 (SIGGRAPH 1987). Author-hosted paper.
  2. Tamás Vicsek, András Czirók, Eshel Ben-Jacob, Inon Cohen and Ofer Shochet, “Novel Type of Phase Transition in a System of Self-Driven Particles,” Physical Review Letters 75, 1226–1229 (1995). DOI: 10.1103/PhysRevLett.75.1226.
  3. Michele Ballerini et al., “Interaction ruling animal collective behavior depends on topological rather than metric distance: evidence from a field study,” PNAS 105(4), 1232–1237 (2008). DOI: 10.1073/pnas.0711437105.

Modern scientific context

  1. Iain D. Couzin and Jens Krause, “Self-Organization and Collective Behavior in Vertebrates,” Advances in the Study of Behavior 32, 1–75 (2003). Useful broader review of animal collective behaviour and model assumptions.
Enter this field →