I've just finished this simple flocking behavior demo based on the 3 Reynolds rules: separation, cohesion and alignment. It was part of a coursework for the Strategy & Intelligent Games module I"m taking here in Kingston University. I know it's not precisely pretty but at least the boids are moving in a nice way. It's written in C++ using the despicable Open Scene Graph library (such an uncomfortable API).

Features:

  • 3 Reynolds rules: separation, cohesion and alignment.
  • Collision avoidance.
  • User interaction: dynamic mouse seeking or avoidance.
  • Steering behaviors blending.
  • Configurable parameters using an XML options file.

Most of the algorithms have been extracted from the Artificial Intelligence for Games book written by Ian Millington and John Funge. If you"re interested in the topic it's totally a must read, I strongly recommend it.