Look at this :

in opengl : http://tothpaul.free.fr/sources.php?opengl.flock3d

the same but in 2d (gdi) : http://www.riversoftavg.com/flocking.htm