Simulates each density for 1500 steps and plots the time-averaged order parameter against the density, with the no-interaction baseline.
The science
Setup. N locusts walk at speed v around a ring of circumference L = 10 (arbitrary length units; density ρ = N/L), each either clockwise (+1) or anticlockwise (−1). This is a one-dimensional caricature of the ring-arena experiments used to study locust marching, where the group stays disordered at low density and abruptly marches together once crowded.
Rule. At each step an agent re-orients at random with probability η (noise); otherwise it adopts the majority direction among all agents within distance r, itself included (a tie keeps its direction). Then x ← x + s v Δt on the ring. No attraction or repulsion, only directional alignment.
Order parameter. φ = |∑si|/N: 1 for everyone marching the same way, about √(2/(πN)) for independent random directions (the plotted baseline, from the half-normal mean of a sum of N coin flips). Crowding raises the number of neighbours within r, ⟨k⟩ = (N−1)2r/L; with few neighbours the majority is dominated by noise, with many a locust copies a stable local majority and domains of the same direction grow and merge. The space-time diagram shows these domains as coloured bands.
Closed-form checks. (1) All-to-all limit (r = L/2) starting ordered: each step a fraction η of the agents is randomised and the rest follow the global majority, so φ → 1 − η. (2) Pure noise (η = 1): ⟨φ2⟩ = 1/N exactly. (3) The average number of neighbours measured from the positions equals (N−1)·2r/L for a uniform scatter.
Simplifications. Synchronous updates, no real locust biology (no hunger, cannibalism, serotonin gregarisation, sound or smell), no turning delay or speed variation, periodic one-dimensional space. The transition is smooth because N is finite; no critical density is claimed for real locusts, and all numbers are model units. Illustrative educational model.