Flocking is a emergent behaviour achieved through local agent-to-agent interaction rules. This flocking implementation simply employs the local rules specified for flocking by Craig Reynolds on his Boids website.
To summarise the three local rules employed are as follows:
Its all about neighbours. The aspect I wanted to highlight in this implementation is that the global behaviour observed is controlled by each agents local interactions with its neighbours. The underlying API if flexible and can be easily extended for more complex environments, interactions and multiple swarms. There are control parameters for the agents for things like maximum speed, acceleration, total agents.
More interesting are the parameters to control the local neighbourhood rules. These configuration parameters include total neighbours to evaluate, size of each agents personal space boundary. Another interesting feature is that each agents personal space boundary can be displayed, which immediately aids in explaining their current behavioural patterns.

The download contains a ready to run binary, as well as the source code. Download the file from here.