The original paper[0], published in '86, in addition to being a huge step forward over contemporary graphics techniques, is extremely comprehensible and an excellent read. It also goes into some detail about collision avoidance, which is hard to see in the browser demo (boids will avoid the mouse but not in a very large area), and goal seeking, which isn't in it. It ends with a fairly eyebrow-raising testament to the increase in computer power over the last two and a half decades:<p>"This report would be incomplete without a rough estimate of the actual performance of the system. With a flock of 80 boids, using the naive O(N^2) algorithm (and so 6400 individual boid-to-boid comparisons), on a single Lisp Machine without any special hardware accelerators, the simulation ran for about 95 seconds per frame. A ten-second (300 frame) motion test took about eight hours of real time to produce."<p>[0] <a href="http://www.red3d.com/cwr/papers/1987/boids.html" rel="nofollow">http://www.red3d.com/cwr/papers/1987/boids.html</a>
I once programmed a swarm simulation as a project for a course I attended. You can set various parameters of the swarm and introduce a predator which can try to eat inidividuals of the swarm. You then can set a bunch of escape strategies. This was pretty much fun when I wrote it.<p>Just uploaded it to my bitbucket repository in case anyone is interested.<p><a href="https://bitbucket.org/mlux/swarm-simulation" rel="nofollow">https://bitbucket.org/mlux/swarm-simulation</a>
This is covered very well (a long with many other <i>neat</i> algorithms) in The Computational Beauty of Nature[1], one of those books I keep coming back to<p>[1] <a href="http://mitpress.mit.edu/books/FLAOH/cbnhtml/" rel="nofollow">http://mitpress.mit.edu/books/FLAOH/cbnhtml/</a>
I made a boids implementation in WebGL a while back<p><a href="http://www.cs.rit.edu/~bpd9116/WebGLU/examples/boids/boids.html" rel="nofollow">http://www.cs.rit.edu/~bpd9116/WebGLU/examples/boids/boids.h...</a>
The visual demonstration is rather hypnotizing to watch. This algorithm is an example how seemingly intelligent behaviour roots in just a handful of simple rules. In this way it kind of reminds me of Conway's Game of Life: A few simple rules stimulating stunningly complex behaviour.
My friend actually recently released an Android game based on exactly this: <a href="https://play.google.com/store/apps/details?id=co.uk.iceroad.complexcity.floqua" rel="nofollow">https://play.google.com/store/apps/details?id=co.uk.iceroad....</a>
Here's a CoffeeScript port of this algorithm I did awhile ago.<p><a href="https://gist.github.com/3733089" rel="nofollow">https://gist.github.com/3733089</a><p>and a demo:<p><a href="http://wsb.im/flocking/index.html" rel="nofollow">http://wsb.im/flocking/index.html</a><p>Definitely fun stuff to play around with.
Woah! Super cool idea. So many ways you can take this to a new level. Also, if anyone is looking to contribute to some open source, this would be a great opportunity as there is lots of epic optimization problems in this algorithm to work on.<p>For example, whats the fastest data structure/algorithm to make searching for neighbours?
<a href="http://proceduralgraphics.blogspot.com.au/2010/06/flock-in-cloudy-blue-sky.html?m=1" rel="nofollow">http://proceduralgraphics.blogspot.com.au/2010/06/flock-in-c...</a><p>In straight js and canvas, with bird silhouettes and Perlin sky
Bat swarms and game AI aside, what are the real world applications of something like this? It strikes me as significantly less useful than say a neural net.