Complex behavior can emerge from simple rules. One if the most interesting examples of this is the flocking behavior of birds. There are three simple rules can describe the behavior of flocking: Separation, which is to avoid collisions with nearby birds; Alignment, which is to attempt to match heading with nearby birds; Cohesion, which is to attempt to stay close the average position of nearby birds. This behavior is better describe by Craig Reynolds -here-.
I got really interested in this behavior and decided to try to recreate in p5js. This simulation uses a port of a quadTree, which is a technique to optimize the calculation for a giving area; particle simulation for the flocking behavior; and some nice colour palette from an artwork that I saw in the metro.
You can move the sliders to change the behaviour, and press Save to download an picture of your flock.
Play with them -here-.