Selfish Herd
Animals bunch up to shrink their domains of danger, and the ones left at the edge are caught most.
- Animal
- Last strike
Each animal's domain of danger is the ground nearer to it than to any other; a strike takes the animal whose domain holds the point, so animals at the edge carry the most risk. Tap to strike, or with Predator on Stalk, drag the predator toward the herd.
How is Selfish Herd working for you?
About Selfish Herd
- Model
- Domains of danger (Hamilton 1971) and movement rules (Viscido, Miller and Wethey 2002)
- Herd
- 30–200 animals on a field 1,000 units across
- Edge risk
- Edge animals take about two thirds of random strikes
- Rules
- Nearest neighbor, crowded horizon, group center (King et al. 2012)
- Reach
- Domains cut off at 80 units, the distance a predator covers
Selfish Herd simulates why animals bunch together when a predator comes, and who pays for it. In 1971 William Hamilton gave each animal a domain of danger: the part of the ground nearer to it than to any other animal. A predator that appears at a random point takes the nearest animal, so the larger an animal's domain, the likelier it is to be caught, and each animal can lower its own risk by moving closer to others. Here the domain is each animal's Voronoi cell, cut off 80 units away, the distance a predator covers.
Animals at the edge of the herd have the largest domains. In a herd of 100 scattered over the middle of the field, the domains of edge animals average about 7,000 to 8,000 units² against about 3,000 to 3,500 for those inside, and random strikes take edge animals about two thirds of the time though they are about a quarter of the herd. A strike or a stalking predator makes the animals within 250 units flee for 300 steps by the chosen movement rule, and the herd packs together.
How it packs depends on the rule. Hamilton's own rule, heading for the nearest neighbor, pairs animals up and leaves the mean domain about where it was: the dilemma of the selfish herd that Viscido, Miller and Wethey examined in 2002. Their local crowded horizon rule, which weighs nearer neighbors more, cut the mean domain to about a quarter to a third within 300 steps here, in local groups. Heading for the herd's center, as sheep tracked by GPS did when a dog approached in King and colleagues' 2012 study, packs one herd and cuts it to about a sixth.
How to use Selfish Herd
- Pick a preset. Strike at random strikes a random point within reach of the herd every 1,500 steps. Approaching predator sends a predator walking toward the herd from the west. Nearest neighbor only uses Hamilton's rule. Each preset starts a new run.
- Read the domains. Each animal's domain of danger is drawn as a flat cell, brighter the larger it is; edge animals have the brightest. The red ring marks the last strike.
- Strike or stalk. With Predator on Strike, tap the field to strike there: the animal whose domain holds the point is caught and the animals round it flee. With Predator on Stalk, drag the red predator to steer it.
- Compare the rules. Movement rule sets where a fleeing animal heads: its nearest neighbor, its neighbors weighted by nearness, or the herd's center. Flight speed sets how fast it runs. The ? beside a setting explains it.
- Read the result. The readout gives the animals left, the mean domain of danger, the share of all domains held by the most exposed tenth, and the catches at the edge and inside; the chart follows the mean domain and the distance to the nearest neighbor.
- Start again or export. Restart starts again from t = 0 with the same herd; Reset also returns every setting to its default. The second chart compares the share of catches taken at the edge with the edge animals' share of the area, the share a strike at a random point would take, and the run log records each run after 20 catches. Save a PNG, record 8 seconds, or record 30 s from the start.
Frequently asked questions
What is the selfish herd theory?
The idea that herds form because each animal moves closer to others to lower its own risk, not to help the group. William Hamilton proposed it in 1971: a predator that appears at a random point takes the nearest animal, so an animal with less ground nearer to it than to any other is safer.
What is a domain of danger?
The part of the ground nearer to an animal than to any other animal, so the area where a predator appearing would take that animal first (Hamilton 1971). In geometry it is the animal's Voronoi cell. Here it is cut off 80 units away, and the domains of edge animals average more than twice those inside.
Why are animals at the edge of a herd in more danger?
Because their domains of danger are larger: nothing shields them on the outer side. In this simulation random strikes take edge animals about two thirds of the time, though they are about a quarter of the herd.
Do animals really move to the center of a herd under threat?
Sheep do. King and colleagues (2012) tracked a flock by GPS and found a strong attraction toward the center of the flock as a herding dog approached, a pattern a simple model re-created. The Group center rule here follows that finding.
Is this a scientific model?
It is a teaching model of Hamilton's domains of danger and of the movement rules Viscido, Miller and Wethey compared in 2002. Its numbers are model settings, not measurements: the field of 1,000 units, the 80-unit reach of a predator, the 250 units at which animals take fright and their speeds.
References
- Hamilton, W. D. (1971). Geometry for the selfish herd. Journal of Theoretical Biology 31(2), 295–311.
- Viscido, S. V., Miller, M., & Wethey, D. S. (2002). The dilemma of the selfish herd: the search for a realistic movement rule. Journal of Theoretical Biology 217(2), 183–194.
- King, A. J., Wilson, A. M., Wilshin, S. D., Lowe, J., Haddadi, H., Hailes, S., & Morton, A. J. (2012). Selfish-herd behaviour of sheep under threat. Current Biology 22(14), R561–R562.





