Birds in a flock, fish in a school, bacteria in a swarm: we usually think they come together because they like it. But what if it's simpler than that: each one seeks food for itself, and the flock just happens?
The agents lived on a grid with 100 hidden "feeding stations." Each agent could only see what was ahead, and could tell whether another agent was there and whether it was satiated. When the vision radius was small, the agents wandered alone. But as the radius increased, their behavior changed dramatically: they would spin in place until they spotted a well-fed companion, then dash toward it. In this way, they clumped together.
Why? If you can't see far, it's easier to search for food yourself. If you can see far, it's easier to watch others: someone has already found food, so go to them. It's like in a supermarket: if you don't know where the item you need is, you search on your own. But if you see a line, you join it, because there must be something good there. So here too: the flock arises from greed, not from a desire to be together.
The Clark–Evans index, used here to quantify aggregation, was proposed in 1954 by ecologists to analyze the spatial distribution of plants and animals.
The idea that complex collective behavior can emerge from simple individual rules without central control echoes the concept of the 'swarm' in Stanisław Lem's novel 'The Invincible', where microscopic machines form destructive structures.