The screen is divided into 48px cells, and each agent checks only its own cell and the 8 adjacent ones — even with 1000 agents, the flock forms without an exhaustive 1,000×1,000 comparison

1000agents · neighbor checks per frame 0checks Map hash · 3x3 cell scan · requestAnimationFrame