Swarm of flies on the left. source
In Seven Samurai – one of the greatest movie of all times, there is a scene where the hired Samurai gather the villagers to instruct them on defending their village. A jittery villager runs away from the crowd and is brought back by Kambei, the aging samurai, who threatens the deserter with dire consequences. He then offers this, and I paraphrase here: An individual can fight a successful war only if he is part of a group. An individual will lose a war by standing alone.
As profound as this sounds, this is well known to birds, fishes, insects and animals that regularly use this ‘Safety in numbers’ strategy to survive (and in the case of fireflies, to advertise). One lives in a group in the hope that one’s neighbors would die in their place. What a lovely thought! Flocking comes naturally to survivors and it is the result of some very simple rules. Consider these rules: 1. Stay together, 2. keep a minimal distance from each other and 3. do your stuff (find food, find mates, etc). With these three rules, it is fairly easy to write a program that plots dots on a screen that flock around just like birds and fishes. Birds and fishes have this programmed into them. This behavior goes deeper than biological organisms. Synchronicity occurs in astonishing ways in physical systems – like laser light where atoms are in synchrony, or two metronomes that are initially out of sync but quickly sync-up when allowed to interact in some physical way. If this sounds interesting, hop over and watch Steven Strogatz talk at TED about How things in nature tend to sync up.