Thousands of simple agents flock and scatter. Order from three local rules.
Play with the forces and watch the flock come together or fall apart.
Eight puzzles, from easy to hard. Can you steer the swarm?
Ask a question, run an experiment, see if the numbers agree.
Each dot is an agent following three local rules: steer away from crowding neighbours, align with their average heading, and move toward their average position. Nobody choreographs the flock. The coherent motion you see is an emergent property of thousands of agents reacting only to those near them.
This is a boids model, the canonical demonstration that collective order can arise from simple decentralised behaviour. Separation, alignment, and cohesion are weighted forces; small changes to their balance shift the system between scattered noise, tight swarms, and fluid, bird-like flocking. An order parameter measures how aligned the agents are at any moment.
swarm is one of several interactive simulations in the petri-labs collection, each exploring how complex behaviour emerges from simple rules.