Click flag. Red and blue individuals are scattered randomly on a grid. Each moves to a new random position if more than the acceptable % of its neighbors are a different color. Try setting that acceptable level to 50%. Try about 70% Even if no individual wants segregation, massive segregation emerges. We imagine these individuals as two species of crabs, which actually do segregate. This is nobel prize winner Thomas Schelling's famous model of "segregation." Of course, human segregation is far more complex, but Schelling's model shows how segregation can emerge collectively even if no individual wants it.
When Thomas Schelling first proposed this model in 1971, he had no access to fast computers, but used pennies and dimes. That's how simple are the rules of individual's behavior here, but yet something unintended occurs collectively. The behavior rules are simple but sufficient to account for clustering called "segregation." The important point is that no individual wants segregation but yet it emerges collectively.