Schelling's segregation model
Two groups of agents live on a grid. Each agent wants at least some share of its neighbours to be like itself. Anyone below that share moves to a random empty cell. Watch what a mild preference does to the whole neighbourhood.
What to try
- Leave the threshold at 50% and press Run. Watch the "similar neighbours" line. Where does it settle?
- Reset, set the threshold to 30%, run again. Each agent is content with a minority of similar neighbours. Does the grid still sort?
- Set the threshold to 80%. Does the model settle at all? Why might a very strong preference fail to produce a stable pattern?
- Keep the seed fixed and change only the density. What does a nearly full grid do to the number of moves per step?
- Change the seed. Which of your findings survive a different starting grid, and which were luck?
The rules, exactly
- Each cell is empty or holds one agent from group A or group B. The start is random, set by the seed.
- An agent's neighbours are the up to eight cells around it. Empty cells do not count. An agent with no neighbours is content.
- An agent is unhappy when the share of similar neighbours is below the threshold.
- Each step, every agent that was unhappy at the start of the step moves, in random order, to a random empty cell. The cell it leaves becomes available at once.
- "Similar neighbours" is the mean of that share over all agents. "Unhappy" is the share of agents below the threshold. The run stops on its own when nobody moves.