Swarm behaviour, or swarming, is a collective behaviour exhibited by animals of similar size which aggregate together, perhaps milling about the same spot or perhaps moving en masse or migrating in some direction. As a term, swarming is applied particularly to insects, but can also be applied to any other animal that exhibits swarm behaviour. The term flocking is usually used to refer specifically to swarm behaviour in birds, herding to refer to swarm behaviour in quadrupeds, shoaling or schooling to refer to swarm behaviour in fish. Phytoplankton also gather in huge swarms called blooms, although these organisms are algae and are not self propelled the way animals are. By extension, the term swarm is applied also to inanimate entities which exhibit parallel behaviours, as in a robot swarm, an earthquake swarm, or a swarm of stars.
From a more abstract point of view, swarm behaviour is the collective motion of a large number of self-propelled entities. From the perspective of the mathematical modeller, it is an emergent behaviour arising from simple rules that are followed by individuals and does not involve any central coordination. Swarm behaviour was first simulated on a computer in 1986 with the simulation program boids.This program simulates simple agents (boids) that are allowed to move according to a set of basic rules. The model was originally designed to mimic the flocking behaviour of birds, but it can be applied also to schooling fish and other swarming entities.