Install the packages in Project.toml
. Run the schelling_sim.jl
to produce the gif!
At this moment this is how the algorithm implemented here works:
- Initialize a matrix of 0s (empty cells), 1s (group 1), and 2s at random.
- Check how many people are happy according to the
kindshare_thresh
argument inGame
1 - Move all the unhappy individuals to empty cells
- If:
- a given threshold of people are happy (by defualt 100% but can change it using
board_happy_thresh
argument insimulate
) - end the game. - else go back to step 2.
- 1 Individuals are happy if a certain percentage of their neighbours are of the same group as they are. If the share of squares (including empty ones!) around them exceeds
kindshare_thresh
, they are happy.