rm-hull / boids.cljs
Last updated

Boids, originally written by Craig Reynolds in 1986, is an artificial live program which simulates flocking birds (but in this case just in 2D). It is an example of emergent behaviour; that is, the complexity of Boids arises from the interaction of individual agents adhering to a set of simple rules, (i) separation: steering to avoid crowding local flockmates, (ii) alignment: steer towards the average heading of local flockmates, and (iii) cohesion: steer to move toward the average position (center of mass) of local flockmates. Aside from painting to the canvas (via the render! function), the ClojureScript below is purely functional in nature.

Fork me on GitHub!