The Schelling model is one of the early agent-based automata models used to
study the formation of black and white communities. As racist as it may sound,
it does make sense that a population would naturally segregate into a community
with common traits. A more general treatment would probably consider multiple
layers such as proximity to a workplace, nationality.
In this model, cells on an $n\times n$ lattice would represent space on the map.
A cell may be EMPTY or occupied. When occupied, it can take on two values,
BLACK or WHITE, representing the race of agents. We initialize the lattice
grids with percent_emptyEMPTY cells and percent_whiteWHITE cells.
In [1]:
All agents moves along the grid until it comes within contact of other agents.
The agent looks at its neighborhood (in this case, a Moore neighborhood), and if
the number of similar neighbors exceeds a threshold, the agent will settle down
and stop moving. The rules stated are contained and executed within the function
place_indiv().
In [2]:
We will run this code for all agents at every timestep until all agents settle
down. At the same time, we are going to save a snapshot of the state of the
lattice after every 3 timesteps. This is to save on memory since there will be a
lot of timesteps before all agents settle down.
In [3]:
The video below shows the evolution of the Schelling model through time. We can
clearly see that from a randomly arranged lattice of BLACK and WHITE agents,
communities are formed. It would probably be interesting to characterize the
size distributions of these communities.