Click anywhere in the canvas to set a goal, click again to unset.



HTML5 implementation of the boids model of coordinated animal motion.
Boids is a computer model of coordinated animal motion such as bird flocks and fish schools. The model consists of three simple rules that describe how an individual boid moves based on the positions and velocities of its nearby boids:
Note that this implementation is a little different from the original model, and doesn’t aim to recreate the exact same behavior. This aims to be an HTML5 visualization of the model that is configurable and performs well with as many boids as possible. The code is open-source and hopefully, easy to read and tweak.
The original model was developed by Craig Reynolds.
It’s all written in coffeescript, a language that compiles into javascript. To improve performance, I used a kd-tree for answering queries of the type “what are the K nearest points to point P”. The kd-tree and the binary heap it requires are also written in coffeescript. The code is on github.
You can configure the simulation to some extend without touching the code or leaving your browser. Click on the option button to the right and you will be presented with certain configuration options that can significantly alter the boids’ behavior. Here’s a more detailed explanation of the sliders:
HTML5 Bird Flocks Simulation
Click for more info