08 Swarm Behaviors & Formations · #34 of 46

Cyclic Pursuit

How a leaderless team surrounds a target with only local sensing

You have a wildfire to watch, or a drifting oil slick to box in, and a handful of drones. You want them spread evenly around the thing, and you want them to follow it if it moves. The catch: there is no air-traffic controller. Each drone can see only its one neighbor and the target itself.

Give each one the same two-line order and a clean ring assembles itself around the target. Nobody assigned the positions. The circle just happens.

This is cooperative target encirclement, and it is the everyday job behind the prettier idea of "cyclic pursuit." The rule each agent runs fits on a napkin and has two parts:

  1. Chase your one neighbor. Robot 1 pursues robot 2, robot 2 pursues robot 3, and the last closes the loop by pursuing robot 1. This is what spaces the team out evenly around the loop.
  2. Hold your distance from the target. Each agent senses the target on its own and nudges itself toward a fixed standoff radius: too close, back off; too far, close in. This is what pins the ring onto the target and lets the whole formation track it.

There is no map, no shared clock, no choreographer, and crucially no leader. Yet the team condenses into a regular polygon around the target (five robots trace a pentagon, eight an octagon) and a center that no robot ever computed. Below, you drive it yourself.

8 agents · encircling the target, error

drag the target (◎) to move what the team surrounds · drag any agent to reshape the ring

Try this:

  1. Move the target. Grab the ringed marker (◎) and drag it. The whole formation chases after it and re-wraps around the new spot, even though no single robot was told to follow it. Each one is only holding its own distance.
  2. Count the sides at low N. Drop N to 5 and you get a clean pentagon; bump it to 8 for an octagon. The encircling shape always has exactly as many corners as there are robots.
  3. Crowd it and watch the circle appear. Push N up to 12 or 14 and the polygon's corners blur into a near-perfect circle. A real perimeter looks like a smooth ring precisely because it has many robots on it.
  4. Reshape the ring. Drag any robot off the formation. Its neighbors keep chasing it and it keeps holding its distance from the target, so the ring stretches and then heals back into shape the moment you let go.

Where you would actually use this

The reason this rule earns its keep is that it needs almost nothing. No robot needs a map of where the others are, no robot needs to be told "you take the north side." Each one watches a single neighbor and the target, and the even spacing falls out for free. That makes it the natural fit for any job that is fundamentally surround the thing and keep watching it:

The "spinning polygon" you build below is not the point; it is the signature of a team that has spread itself evenly around a target using nothing but each robot's view of its neighbor and the thing it is guarding.

Why the team orbits instead of piling up

Here is the part that surprises people. If every robot aimed exactly at the neighbor it chases, the loop would just bunch everyone up on one side of the target. The even, endless orbit comes from a deliberate sideways tilt on the chase. We rotate each pursuit vector by an angle θ\theta:

ai=kR(θ)(pi+1pi)a_i = k\, R(\theta)\, (p_{i+1} - p_i)

where aia_i is robot ii's steering toward its neighbor, pi+1pip_{i+1} - p_i is the vector pointing at the agent it chases, kk is the gain, and R(θ)R(\theta) is a rotation. Aim a hair to the side and you can never quite catch the one ahead; you spend forever wheeling around the loop. That perpetual near-miss is the orbit. (The standoff term, which pulls each robot to a fixed distance from the target, is what keeps the wheeling ring locked onto the target instead of drifting off.) The pursuit angle alone decides whether the ring sits still, slides slowly, or spins briskly around the target.

When the chase turns lethal

Nature ran this experiment long before robotics did, and the result is grim. Army ants navigate by following the pheromone trail of the ant ahead: cyclic pursuit, encoded in chemistry. Usually the trail leads somewhere. But if a group loses contact with the main column and the trail happens to close on itself, the loop has no exit.

Muskoxen forming a defensive circle facing outward.
Muskoxen instinctively form a defensive ring facing outward, a leaderless team encircling a center, exactly the formation cyclic pursuit produces. · USFWS, Public domain

The ants march in a closed ring, each dutifully chasing the one in front, around and around with no way out. Biologists call it an ant mill, or a death spiral: the column rotates until the ants drop from exhaustion. The same simple rule that builds a graceful rotating formation in your simulator is, in the wild, a self-organized way to march a thousand insects to death. Emergent behavior does not care whether the outcome is elegant or fatal.

Why some angles spiral in, some orbit, and some blow up

Write the rotation explicitly:

R(θ)=[cosθsinθsinθcosθ]R(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}

Stack all the robot positions into one big state vector and the dynamics become linear: p˙=k(R(θ)C)p\dot{p} = k\,(R(\theta) \otimes C)\,p, where CC is the cyclic coupling matrix that encodes "each robot is pulled toward the next one." Because the coupling is circulant, its eigenvalues are known in closed form, and the system's stability comes down to where those eigenvalues land in the complex plane.

The real part of each eigenvalue controls contraction; the imaginary part controls rotation. That split is exactly what the pursuit angle tunes:

  • Negative real part: the formation contracts. With a pure straight-at-target chase, it collapses to the centroid.
  • Pure imaginary: no contraction, just rotation: a fixed-radius orbit that never decays.
  • Positive real part: the formation expands and the chase diverges.

For nn robots the formation stays bounded and well-behaved when

k>0,θ(π2,π2)k > 0, \quad \theta \in \left(-\tfrac{\pi}{2}, \tfrac{\pi}{2}\right)

Push θ\theta past ±π/2\pm\pi/2 and a robot is accelerating away from the neighbor it chases: the loop loses its grip and the swarm flies apart. The whole rich zoo of behaviors lives in that one rotated matrix.

The encirclement demo above adds one more term to this bare chase: a radial spring that pulls each agent toward a fixed standoff distance from the target. That term sets where the ring lives (locked onto the target, even as it moves), while the rotated cyclic chase still does all the even spacing and spinning. Spacing from the neighbor, position from the target, neither needing a leader.

Why the inward path is always a logarithmic spiral

The four-bug chase has a clean answer, and it is the same shape that shows up in a nautilus shell and the arms of a galaxy: the logarithmic spiral, also called the equiangular spiral.

Picture one beetle and the corner of the square as it shrinks. As the bugs march, the four of them always sit on a smaller, rotated square. Each bug keeps walking at the same fixed angle relative to the line running out from the center. For the square that angle is 45°45°, because each corner of a square sits 45°45° off the side it chases along. A curve that crosses every ray from a central point at one constant angle is, by definition, an equiangular spiral:

r(ϕ)=r0eϕcotαr(\phi) = r_0\, e^{-\phi \cot\alpha}

Here rr is the distance to the center, ϕ\phi is the angle swept, and α\alpha is that fixed crossing angle. Because α\alpha stays constant the whole way in, the spiral is self-similar: zoom in on the path near the center and it looks identical to the whole thing. The bug winds around the center infinitely many times, yet covers only a finite distance, because the radius dies away exponentially.

For a general regular polygon of nn bugs the crossing angle is α=π2πn\alpha = \tfrac{\pi}{2} - \tfrac{\pi}{n}, and the length each bug walks before the meeting comes out to the starting radius divided by sinπn\sin\tfrac{\pi}{n}. For the square (n=4n = 4) that is R/sin45°=R2R/\sin 45° = R\sqrt{2}, exactly the side of the square, which is why the four-bug walk equals one side length. More bugs means a flatter spiral, a longer winding path, and a slower collapse, the same trend you feel in the demo when straight-at-target chasing makes a crowded ring crawl toward its centroid.

Key takeaways

There is no architect here. No robot holds the blueprint of the pentagon it helps trace, just as no ant in the mill knows it is walking in a circle to its death. The shape, graceful or fatal, is simply what chasing adds up to.

That is the quiet lesson of swarms: order does not require a mind to design it. Sometimes it only requires that everyone agree to follow the one in front.

full glossary →