Aquarium was a test for a Boid* like class, especially difficult due to the large amount of Boids. The required computing power is very high because involves for some rules a nboids ^ 2 calculations. For this reason I chose a stochastic sampling where each boid doesn’t consider all the other boids to compute its status, but only a random subset of the whole group, not necessarily composed by the closest boids. The calculations become: nboid * maxsamplings (maxsamplings is a fraction of nboids); hence they grow linearly with the boids number. After some experiments, I found a value for maxsamplings around 20, this allows a good coherence for medium and very large crowd as well, with a good frame rate.
*Boid is a term invented by Craig Reynolds in 1986 and refers to a kind of artificial-life creature, driven by a small number of very simple rules that lead to an emergent lifelike flocking behavior. The rules are: 1) Boids try to fly towards the centre of mass of neighbouring boids, 2) Boids try to keep a small distance away from other boids, 3) Boids try to match velocity with near boids.