Boids is a steering algorithm written by Craig Reynolds in 1986, simulating animal flocking behavior. Boids are programmatic objects with three functions: separation, alignment, cohesion.
The light blue animated screen above is written in Processing, and run on the web through HTML5. The screen refreshes 30 times per second. With every refresh, each of the 150 triangular boids compares its location (x,y coordinate) and velocity (speed and direction) with the location and velocity of the closest boids in the flock. Using their three rules, each boid updates its vector and moves to a new location. Here is a simplified version of the code:
Here is my version of the code, just slightly modified from the sample code found here. My boids have a lower maxspeed, and in the borders() function, they hit walls instead of wrapping around. To run this code and modify it for yourself: download Processing, copy/paste the code, and hit play.