Red and blue agents live in a grid of houses, some of them empty. An agent is happy if at least a chosen share of its neighbors (up to eight) are the same color as itself. Each round, every unhappy agent moves to a random empty house. Press Play and watch what even a mild preference does: the slider starts at 40 percent, meaning an agent is content as long as two in five of its neighbors match. Change it and the mix of neighborhoods changes with it. Click or drag to place and remove agents.

Thomas Schelling, an economist, published this model in the early 1970s to show that strong segregation can arise even when nobody wants it. The status line shows the share of happy agents and how alike the neighbors are on average; start a random mix and the second number climbs well past the preference you asked for. When nobody is unhappy any more the page stops by itself. Neighbors are counted among occupied houses only, so an agent with no neighbors is happy, and the grid does not wrap around.

This page was created with Claude Code.