Each of the N agents reads only the neighbors inside its perception radius r and sums four steering forces (Reynolds' classic boid model, plus obstacle avoidance) into its acceleration each frame:
separation = -Σ (posⱼ - posᵢ) / |posⱼ - posᵢ|² (push apart)
alignment = mean(velⱼ) - velᵢ (match heading)
cohesion = mean(posⱼ) - posᵢ (pull to center)
goal-seek = nearestGoal - posᵢ (steer toward a beacon)
avoidance = -Σ (posᵢ - obstacleₖ) / dist² for close obstacles
The weighted sum is clamped to a max steering force, added to velocity, then velocity is clamped to a max speed — the same limited-force integration used in real multi-robot flocking controllers. No agent has a global map or central coordinator: the cluster count and shape that emerge are a pure side-effect of these local rules, which is why nudging Cohesion or Separation up or down reorganizes the whole swarm's topology within a few seconds.
- Clusters — connected components of the "close enough to be flocking" graph (edge if two agents are under 1.5r apart), recomputed every frame.
- Goal beacons — the three glowing rings; each agent seeks whichever beacon is currently nearest, then a wide capture radius releases it to the next one, producing slow migration between beacons.
- Obstacles — static disks produce a repulsive inverse-square field, exactly like the Original 3D version's potential-field avoidance, so a wall of obstacles visibly splits one cluster into two.