Emergence: When Simple Rules Create Complex Behaviour
· KH Solve
In the above video, we are simulating one million points, each following three simple rules and coloured according to the direction they are moving in. There's no central controller, no choreography, no communication beyond "what's near me right now?". Yet from this chaos, complex dynamics and structure miraculously appears: streams, swirls, and coherent flocks that move as if guided by a single mind.
This is emergence: complex global behaviour arising from simple local interactions. It's how starlings form murmurations, how neurons create consciousness, how markets find prices, and how ant colonies solve optimisation problems no individual ant could comprehend.
It's also one of the most important concepts in modern AI and complex systems, thought to describe the ever-growing capabilities of LLMs and AI systems.
The Setup
In 1986, Craig Reynolds was trying to animate flocking birds for film. Hand-animating hundreds of birds was impractical. Training a neural network wasn't an option (this was 1986). So he asked a different question: what if each bird just followed simple rules about its neighbours?
He called them "boids" (bird-oid objects), and the three rules he discovered remain the foundation of swarm simulation today:
- Separation: Steer to avoid crowding neighbours
- Alignment: Steer towards the average heading of neighbours
- Cohesion: Steer towards the average position of neighbours
That's it. Three rules. Each boid looks at its local neighbourhood, applies these three steering forces, and moves. There's no sophisticated algorithm. There's no leader. There's no plan. Yet flocks appear and complicated (and convincingly bird-like) dynamics emerges.
The Rules
Let's go through each rule in detail. In the diagrams below, the blue boid is the one we're calculating forces for, and the rose coloured boids are its neighbours.
Rule 1: Separation
No one likes being crowded. Separation ensures boids maintain personal space by steering away from neighbours that get too close.
For a boid at position , we examine all neighbours within a separation radius . The separation force points away from each neighbour, weighted by inverse distance (closer neighbours push harder):
where is the set of neighbours within the separation radius.
Without separation: Boids collapse into a single point. With only separation: Boids explode outward, dispersing uniformly.
Rule 2: Alignment
Birds in a flock tend to fly the same direction. Alignment steers each boid towards the average velocity of its neighbours.
For neighbours within perception radius :
We compute the average velocity of neighbours, then steer towards it. This creates the parallel motion that makes flocks look coordinated.
Without alignment: Boids move randomly, no coherent direction. With only alignment: Parallel streams, but no grouping.
Rule 3: Cohesion
Flocks stay together. Cohesion steers each boid towards the centre of mass of its neighbours, providing the attractive force that keeps the group from dispersing.
Without cohesion: Aligned streams that gradually drift apart. With only cohesion: Collapse to a tight cluster with no coordinated motion.
Emergence
Each rule alone produces degenerate behaviour. The magic only happens when you start to combine them:
where , , and are weights controlling the relative strength of each behaviour.
Separation prevents collision. Alignment creates coordination. Cohesion prevents dispersion. The tension between these forces produces the rich, organic motion we see in real flocks: stay together but not too close, move together but avoid collisions.
No boid knows about the flock. Each boid only knows about its immediate neighbours. Yet the flock exists. It moves, splits, and reforms as a coherent whole. The whole is greater than the sum of its parts.
Scaling to One Million
The naive implementation of a boid simulation is , where every boid checks every other boid to find its neighbours and apply its steering. With a million boids, that's distance calculations per frame, or over per second at 60 FPS, yikes.
The simple solution here is spatial hashing. We subdivide the world into a grid of cells sized to match the perception radius. Each boid is assigned to its cell. To find neighbours, a boid only checks its own cell and the 26 adjacent cells (in 3D). This reduces neighbour lookup from to where is the local density, which is actually typically constant regardless of total population.
At KH Solve, we are experts in general purpose GPU programming and so combined with massively parallel computation, we can simulate one million boids at interactive frame rates on consumer hardware.
Why This Matters
Emergence isn't just a party trick for computer graphics. It's a fundamental principle that appears across domains:
Swarm intelligence: Ant colony optimisation, particle swarm optimisation, and genetic algorithms all exploit emergent behaviour to solve problems no individual agent could handle.
Neural networks: Individual neurons are simple threshold units. Billions of them, connected with learned weights, exhibit what we call intelligence. The intelligence isn't in any single neuron; it emerges from their interaction.
Markets: No central planner sets prices. Millions of individual actors, each pursuing their own interests with local information, somehow coordinate to allocate resources across a global economy. The price emerges.
Multi-agent AI: As AI systems become more capable, we're increasingly deploying them in groups. Understanding how complex behaviour emerges from simple agent interactions becomes critical for predicting and controlling system behaviour.
The lesson of emergence is simple: you don't need a grand plan or sophisticated systems to produce complex behaviour. You don't need a central controller. You don't need intelligent components. You need the right simple rules, applied locally, at scale.
We Can Help
Complex systems don't require complex solutions. They require understanding. At KH Solve, we specialise in finding the simple rules that drive complex behaviour, whether that's optimising multi-agent systems, building scalable simulations, or understanding emergent patterns in your data.
Let's talk about what we can build together.
References
- Reynolds, C. W. (1987). Flocks, herds and schools: A distributed behavioral model. ACM SIGGRAPH Computer Graphics, 21(4), 25-34. Paper