This model was invented in the mid 1980's by Craig Reynolds and demonstrates 'emergent behaviour'. This is not a very well defined term, but it basically means that you get more out of the model than you would expect, upon less than careful scrutiny of the equations. I find this to be the case with all but the simplest sets of equations.
Each bird in the flock is aware of a number of its closest neighbours and it tries to achieve certain things with those neighbours: It tries to get to the centre of its neighbours while keeping the sum of distances to the neighbours equal to a particular value It tries to match velocities with its neighbours while also generally trying to fly East and maintain its preferred speed It tries not to hit obstructions (the green vertical bars). Some of the trailing birds are not always too good at this.
These requirements are modelled as a set of second order non-linear differential equations (i.e. the acceleration of a bird is calculated at each time step, thus enabling calculation of the new velocity and then the position).
Anyway, here it is:
Click on the applet to restart the simulation