## The Schelling model

Let's concentrate initially on the 1-dimensional variant of the model, then it will be easy to extend to the 2-dimensional case.

One begins with a large number
n of
nodes (individuals) arranged in a circle. Each node is initially assigned a *type,* and has probability 0.5 of being of type α and probability 0.5
of being of type β (the types of distinct individuals being independently distributed). We fix a parameter w, which specifies the 'neighbourhood' of each
node in the following way: at each point in time the neighbourhood of the node u, is the set containing u and the w-many closest neighbours on both sides --
so the neighbourhood consists of 2w+1 many nodes in total.
The second parameter τ is a real in the interval [0,1], and specifies the proportion of a
node's neighbourhood which must be of their type before they are happy. So, at any given moment in time, we define u to be *happy * if at least τ (2w+1)
of the nodes in its neighbourhood are of the same type as u.
One then considers a discrete time process, in which, at each stage, one pair of unhappy individuals of opposite types are selected uniformly at random and are given the
opportunity to swap locations. We work according to the assumption that the swap will take place as long as each member
of the pair has at least as many neighbours of the same type at their new location as at their former one
(note that for τ ≤ 0.5 this will automatically be the case). The process ends when (and if) one reaches a stage at
which there are no longer unhappy individuals of both types.

As an example, let's suppose that n=16 (although normally we'll be interested in much larger numbers of course), w=2 and τ=0.6.
Then the initial configuration might look like this:

At the first stage, we might then select the two nodes indicated in the first image below, which then swap,
causing a configuration as depicted in the second image:

At the second stage, we might then select the two nodes indicated in the first image below, which then swap,
causing a (final) configuration as depicted in the second image:

Now for the two dimensional model, we consider instead the nodes to be arranged in a grid formation. The neighbourhood of a node u, is now the set of all nodes whose horizontal and vertical distances from u, are both at most w.