What happens when everyone wants high-status neighbors, but wealth limits where people can move? This model populates a 36 × 36 toroidal grid. Adjust its density, group composition, and preference for living near one’s own color to explore how economic inequality and homophily interact.
Ready to run
Opposite edges touch. Hover or tap a cell for its frozen, start-of-round values.
Statistics describe the population and its current spatial arrangement.
For color, each group is compared with all other colors and results are population-weighted. For status and wealth, agents are split into fixed lower and upper halves. Dissimilarity and delta use 3×3 tracts; distance-decay isolation uses exact agent-to-agent toroidal distances, scaled so three cell widths equal one distance unit.
The model is a cellular automaton on a 36 × 36 lattice. Its opposite edges touch, making the grid a torus: a cell on the left edge is adjacent to the corresponding cells on the right edge, and the top similarly wraps to the bottom. Each cell has the eight surrounding cells as its Moore neighborhood.
The grid contains 1,296 cells. If the selected vacancy rate is \(v\) percent, the model creates \(N=\operatorname{round}[1296(1-v/100)]\) agents and leaves the remaining cells vacant. The default vacancy rate of 38.3% produces 800 agents and 496 vacancies.
Each color has an adjustable population ratio. These are relative weights rather than percentages: ratios of 2, 1, and 1 allocate approximately 50%, 25%, and 25% of agents to the three colors. The implied percentage and integer agent count appear beneath each color name. The model converts the ratios to integer counts as closely as possible while ensuring that every selected color has at least one agent. Color is categorical; colors have no inherent ordering or distance from one another.
Every agent has continuous wealth and status attributes. Wealth determines which vacant cells an agent can afford. Status represents how desirable that agent is as a neighbor: all else equal, every agent prefers neighborhoods containing agents with higher status.
For agent a in color group g, the attributes are generated as
where \(\varepsilon^W_a\) and \(\varepsilon^S_a\) are independent draws from \(N(0,1)\). The user-selected \(\mu^W_g\) and \(\mu^S_g\) are the expected wealth and status means for group g; both attributes have a within-group standard deviation of 1.
The parameter \(C\in[0,1]\) is the within-color status–wealth correlation. When \(C=0\), status and wealth are independent within each color. When \(C=1\), an agent’s wealth deviation from its group mean completely determines its status deviation. The displayed population correlation is the realized Pearson correlation across all generated agents, so it can differ from \(C\) because of sampling variation and differences between color-group means.
Let \(N(i)\) be the occupied Moore neighbors of cell i, and let \(n_i\) be their number. The status desirability of the cell is
This is a mean rather than a sum. For example, if a cell has one neighbor with status 0.7, adding a second neighbor with status 0.1 lowers its status desirability from 0.7 to 0.4.
For an agent of color g, let \(q_{ig}\) be the proportion of cell i’s occupied neighbors that share color g, and let \(p_g\) be that color’s share of the full population. Color fit is measured relative to random-mixing prevalence, \(q_{ig}-p_g\). If a cell has no occupied neighbors, \(q_{ig}\) is defined as \(p_g\), making its color fit zero.
The agent-specific residential utility of cell i is
The color-preference parameter \(\beta\) is expressed in status units. At \(\beta=0\), agents have no color preference and the extension reduces to the original status-based decision rule. Larger values mean agents are willing to give up more neighborhood status for greater overrepresentation of their own color. With only one color, \(q_{ig}=p_g=1\), so the color term is always zero regardless of \(\beta\).
Every cell receives a fixed exogenous price \(R_i\sim N(0,1)\). At the beginning of a round, the cell’s raw price combines this fixed value with the mean wealth of its occupied neighbors:
Price endogeneity \(E\in[0,1]\) controls the mixture. At \(E=0\), raw prices are entirely exogenous. At \(E=1\), they are entirely determined by neighboring wealth. Intermediate values blend the two.
The model then performs one simultaneous diffusion pass to prevent abrupt price changes between adjacent cells:
where \(M(i)\) contains all eight Moore-neighbor cells, occupied or not. Thus, a cell retains 75% of its raw value and receives 1/32 from each neighbor, for 25% in total. All cells read from the same raw-price field, so iteration order cannot affect diffusion.
At the start of every round, the model calculates and freezes all cell prices, status desirabilities, and color-fit values. It then gives every agent one opportunity to act, using a newly randomized agent order.
An agent may remain in its current residence even when its price has risen above the agent’s wealth. If no vacancy is affordable, the agent is forced to stay. When an agent moves, its destination becomes occupied and its former cell becomes available to agents acting later in the same round. However, both cells retain their start-of-round prices and desirability values until every agent has acted.
After the round, neighborhood values are recalculated from the new arrangement. The simulation converges when a full round produces no moves; otherwise it stops at the selected round limit, which defaults to 2,000. Initialization, agent order, and tie-breaking all use the displayed random seed, so resetting with unchanged settings exactly reproduces a run.
“Neighbor status correlation” and “neighbor wealth correlation” are Pearson correlations across occupied Moore-neighbor pairs. Each adjacency is counted in both directions, and agents with no occupied neighbors do not contribute a pair. Values closer to 1 indicate that similar agents tend to be immediate neighbors, values near 0 indicate little local association, and negative values indicate that dissimilar agents tend to be neighbors.
“Excess same-color neighbors” is the agent-weighted mean of \(q_{ig}-p_g\), expressed in percentage points. A value of zero means same-color exposure matches population prevalence on average; positive values indicate excess same-color exposure. “Population status–wealth correlation” is the realized Pearson correlation between those attributes across all agents; it does not change as agents move.
The 36 × 36 grid is divided into 144 fixed tracts, each containing 3 × 3 cells. For color, every color is treated in turn as the focal group and compared with all other colors; the group-specific results are then averaged using population shares. For status and wealth, agents are permanently divided into lower and upper halves according to their initial attribute ranks, and the two group-specific results are averaged. Color segregation is undefined when only one color exists.
For a focal group, let \(x_i\) and \(y_i\) be its population and the complementary population in tract i, and let \(X\) and \(Y\) be their grid-wide totals. The dissimilarity index measures how unevenly the two groups are distributed:
Distance-decay isolation measures the focal-group share of the spatial environment experienced by an average focal-group agent. Because every agent’s exact cell is known, it is calculated directly from agent-to-agent distances rather than approximating everyone in a tract as living at its centroid:
Here, \(d_{ab}\) is the exact wrapped Euclidean distance between the centers of the cells occupied by agents a and b. Three cell widths equal one distance unit. The focal agent is included with its exact self-distance \(d_{aa}=0\), rather than an approximated within-tract distance. Because this is an isolation rather than a prevalence-adjusted measure, its random-mixing baseline depends on the focal group’s population share.
Finally, delta compares the focal group’s distribution with the distribution of land area:
All tracts have equal area, so \(a_i/A=1/144\). Higher dissimilarity indicates greater unevenness, higher distance-decay isolation indicates more same-group spatial contact, and higher delta indicates that the group occupies a smaller and more concentrated share of the available tract area.