Here is my attempt at implementing the well-known boids.
The static geometry is stored in an octree so that each boid can query its surrounding environment with ray-casts.
The boids are placed in a bounding volume hierarchy of AABBs updated each frame which enables a fast computation of each boid's neighborhood.
There are 500 boids in the simulation, each of them casting 10 rays every frame to detect obstacles. The behavior can be customised, for instance some boids have a longer trail and move alone and faster, whereas the others move together in large flocks. The scene is delimited by a large invisible cube against which the flocks collide.
Some boids can be seen traversing the ground. This can happen when they don't have enough time to turn around.
The color of a boid is computed from its orientation.