This top-down simulation runs a real multi-agent formation-control law, not a scripted animation: every drone is a point-mass agent that each frame computes its own acceleration from a proportional position-error term toward its assigned slot in a virtual structure, a consensus term that shares shape-relative error with nearby drones so the whole swarm agrees on the structure together, and an inverse-cube collision-avoidance repulsion that keeps any two drones from ever colliding. Switching between Line, Circle and Grid only changes each drone's assigned offset from the moving formation centre — the control law underneath is identical in every mode, and you can watch the formation error telemetry genuinely fall as the swarm converges. Click or drag on the canvas to relocate the formation, or hit "Scramble positions" to see the swarm re-converge into the current shape entirely from the consensus and error-correction terms above, with zero pre-baked positions.
Unlike a flocking/Boids swarm that only reacts to local neighbours, this simulator drives each drone with a genuine formation-control law drawn from multi-robot coordination research: a proportional-derivative term steers every drone toward its own assigned slot in a virtual structure, a consensus term shares each drone's positional error with nearby drones so the swarm agrees on where the structure actually sits, and an inverse-cube repulsion term keeps any two drones from colliding as they manoeuvre.
Because only the assigned slot offsets change between Line, Circle and Grid — never the control law itself — you can watch the same three-term dynamics genuinely converge to each shape from any starting configuration, including after "Scramble positions" randomises every drone across the canvas.
What makes this different from a Boids flocking simulation?
Boids reacts only to local neighbours with separation/alignment/cohesion rules and has no notion of an assigned position. Here every drone is explicitly assigned a slot offset in a shared virtual structure and runs a real position-error control law toward that exact slot, plus a consensus term that lets neighbouring drones agree on the structure's true location together — the formation is a control target, not an emergent side effect.
Each drone computes its own error relative to its assigned slot (current position minus goal offset). The consensus term averages the difference between this drone's error and its neighbours' errors and steers to reduce that difference. This is the core idea behind consensus-based multi-agent formation control: agents don't just chase a fixed point independently, they cooperatively agree on where the whole structure is.
Any two drones closer than the avoidance radius feel a repulsive force that grows sharply (roughly as the inverse cube of distance) as they approach. Because this force only activates at short range and adds linearly to the other two control terms, it nudges drones apart without fighting the formation-tracking or consensus terms once they're clear of each other.
Position gain (k_p) scales how hard each drone is pulled toward its own assigned slot — higher values converge faster but can overshoot before damping settles them. Consensus gain (k_c) scales how strongly each drone's error is corrected toward its neighbours' errors — raising it makes the swarm behave more like a rigid structure that moves together; lowering it toward zero lets drones converge to their slots independently.
It reads "yes" once the mean formation error (average distance from each drone to its assigned goal slot) drops below 6 px and the mean speed drops below 8 px/s — meaning the swarm has genuinely settled into the target shape rather than still actively correcting.
It is a 2D point-mass simplification — no thrust, mass, drag, or altitude — but the control structure itself (proportional-derivative slot tracking, consensus/virtual-structure coordination, and short-range collision avoidance) mirrors the real building blocks used in multi-UAV formation-flight research and swarm robotics.