← Gallery

Flocking

Three rules — keep your distance, match your neighbours, stay with them — and the paths every agent took while obeying them.

Output

A set shares every setting — paper, border, the sketch’s own knobs — and differs only in the seed. Regenerate any one of them without touching the others.

PNG: 4961 × 3508 px at 300 dpi. PDF: vector, RGB, 420 × 297 mm page, no bleed. Printed area 420 × 297 mm.

0 mm

Millimetres of unprinted paper on every side. The piece is composed to fit what is left, not shrunk to fit it.

Flock

240
600

How long the flock is followed for. Length of every trail, and the cost of the render.

Rules

1.60

Steer away from anyone inside the personal space below. Without it the flock collapses to a point.

18
1.10

Steer toward the average heading of the neighbours. This is what makes a flock a flock rather than a crowd.

0.80

Steer toward where the neighbours are, on average.

110

How far an agent can see. Alignment and cohesion use this; separation uses the personal space.

0.05

A random nudge each step. Keeps a settled flock from flying in a dead straight line forever.

Motion

3.0
0.12

The most an agent can change its velocity by in one step. Low is a wide, lazy turn.

Wrapping cuts every trail that crosses an edge, which is honest but reads as damage.

Drawing

1.00
110

Low opacity is what makes the places the flock went twice legible.

Colour

How it works

This is here as the counterweight to the flow field. A flow field is a field: it exists before any of the marks do, it does not change, and two strokes crossing the same place are steered identically. There is no field here at all. Each agent is steered only by whichever other agents happen to be near it at the time, so the shape of the drawing is a record of who was next to whom.

Reynolds’ three rules, from 1986, and there are still only three. Separation: steer away from anyone inside your personal space, weighted by one over the distance so a near miss counts for far more than someone at the edge of it. Alignment: steer toward the average heading of everyone you can see. Cohesion: steer toward where they are, on average. Every murmuration, shoal and swarm in computer graphics since is these three with the weights moved around.

The detail that decides whether it works at all is what "steer toward" means. A rule names the velocity it wants; the force is the difference between that and the velocity the agent has, and the sum of the three is capped, so no single rule can simply overwrite the others. Adding the wanted direction straight on instead — the easy mistake, and the first thing this did — gives agents that drift politely past each other and never form a flock. What is drawn is not the flock but its history: one path per agent, the whole way it went.

R regenerate · S PNG · P PDF