/cournia.com/dev/null - scriptable flocking home
scriptable flocking April 2003

I've always been fascinated by Craig Reynolds boids. So, I though I'd take a try at writing a flocking simulator. I decided it would be cool if each boid was individually controlled by a small LUA script and a file full of parameters. After some hacking, I wrote a C++ framework to render out a LUA simulated world. Some screenshots:

     

Each boid's script is only given its position, speed, and heading as input. The script is also able to query the engine for a list of friends and enemies within the boid's field of view. As output, the script sends the engine a desired speed and heading. In the images above, the red boid's have large fields of view and move slowly, this allows them to stick together in a large group. In contrast, the blue boids have small fields of view and move quickly, resulting in a flock that moves in a long line. To make things interesting, when the two flocks are in each others' field of view, individual boids may become afraid a run away!

I'm pretty happy with the results. The flocks move smoothly and dance around each other in spectacular fashion. All that's left for me to implement is for the flocks to be able to attack each other. May the strongest flock win!

  index