This is a flocking simulation using a quadtree data structure to store the positions of the boids. Each frame, each boid checks the positions and speeds of the neighbor boids by querying the quadtree - reducing the need to cycle through all boids.

The stats on the bottom of the draw screen update every 1 second and display the frames per second, the maximum number of neighbor boids checked and the average neighbor boids checked. Both of the later stats are calculated per boid, not a global total of all checks.

As the boids flock more tightly, there are more neighbors checked, so both the max checked and average checked will go up. As a result, the frames per second will go down.

A pink boid means it is in range of another boid. On a large screen, there are 1,000 boids. Each boid has a small chance of picking a new, completely random, direction to go.

Framerate: 0

Max Checked: 0

Average Checked: 0