This is a version of the famous Schelling's segregation model. In the square city each person (agent) has a home on the grid. Each agent is one of two types, red or blue. Each agent’s measure of happiness is measured by what proportion of people are like them in their local neighborhood. If the agent is unhappy then it moves. The collective behaviour of all the agents produces segregation patterns within the simulated city
Schelling's segregation model can be said to be the first sociology agent-based model (ABM). Schelling took the complex social behaviour of racial segregation and asked whether this behaviour could be captured in a model by using some simple rules. What makes the model exceptional are the range and types of behaviours that this simple model exhibits. These types of behaviours are known as emergent behaviours (i.e., population level patterns of behaviour that can’t be predicted by looking the behaviour of each individual seperately) and this is one of the first models of its type to exhibit this. Many sociological ABMs can trace their lineage back to this model. If you are interested in ABMs for simulating non-communicable disease (NCD) is well worth your while getting to know Schelling's segregation model first.
Schelling's segregation model does not directly address a NCD but social segregation does play a part in a number of NCD issues. For example, take a look at the Auchincloss model example that investigates inequalities in diet in the context of urban residential segregation.
What sets ABMs apart from other modelling methods is the population-level behaviour patterns emerging from rules that apply across the whole model but are enacted by individuals based on local information. In this case we are looking at individuals' choice of home based on just the racial makeup of their very local neighbourhood. The model asks the simple question of what happens to the global level of segregation if individuals make their housing choice based on how many people are like them in the local neighbourhood? ABMs can model systems and ask questions of systems like these because ABMs model each of the different individuals that make up the population.
This is a very simple model. In this version of the model the world is divided into a 40 by 40 grid. Each cell of the grid can either be empty or be occupied by a blue agent or a red agent. Each agent represents a person. Each agent’s neighbourhood consists of the adjacent 8 cells on the grid. At each iteration every agent counts the number of agents in the adjacent 8 other cells on the grid and notes the percentage that are the same colour as themselves. If that percentage is less than globally set level (the person’s preference to live next to people who are similar to themselves) then the agent randomly picks an empty cell and moves there. These are the only rules, and are so simple that Schelling originally did the first models by hand using a paper grid. In the version of the model here the total number of agents in the model is set with the population density slider. The global acceptance value is set with the “% alike” slider. You can change these values and re-run the model with the reset button. Run the model with differing levels of global acceptance. Not how the behaviour changes around 30%.
This is such an important model that along with this web-based javascript version we have added links below to a NetLogo and a Python version
This model demonstrates the effect of local individual decisions on global measurable attributes, like the segregation of a community. These global patterns of behaviour are not immediately obvious from just analysing an individual's behaviour in isolation, and demonstrate the importance of looking at how policies that aim to change to individual behaviours may influence global patterns, including both positive effects or potentially unintended harms.