Javascript segregation simulator

A simple agent-based model of racial segregation drawn from Thomas Schelling's work and Allen B. Downey's book Think Complexity. The colourful tiles are "occupied", and at each step we pick a random occupied tile. We check the 8 "neighbours" around the tile, and if the number of neighbours with the same colour is less than a threshold, that agent moves to a random unoccupied space.

These random moves can produce sharply differentiated areas of the two colours over time.

Number of columns:
Number of rows: