by Dirk Brockmann

This explorables is a combination of two models, one that explains the emergence of dynamic patterns and collective behavior in schools of fish or flocks of birds, the second, the Schelling model, captures the geographic segregation of populations of different kinds of individuals. When these two models are combined, a great variety of beautiful dynamic swarming patterns can be generated. These patterns show traces of the generic swarming states like “milling” and segregation effects within these dynamic states.

In essence this explorable combines ideas discussed in explorables “Flock’n Roll”, “Into the dark” and “T. Schelling plays Go”. You’ll get the most out of this explorable if you play with the above explorables first. When you are done with that,…

press Play and keep on reading….

This is how it works

The system is initialized with 300 agents. An agent has a type: say A (black) or B (red) with equal chance. You can also change the number of types up to 4 (A,B,C (white) and D (blue)) by selecting the corresponding choice on the bottom right of the control panel.

Collective Behavior rules

All agents move at a constant speed and change their direction according to three basic rules: 1.) agents try to align with their neighbors, 2.) they avoid collisions, and 3.) they are attracted towards the center of the crowd around them. Plus, there’s a little random noise on their heading (“wiggle”). The details of this model are discussed and explored in Complexity Explorable “Flock’n Roll”.

You can change the swarming parameters with the sliders (attraction radius, alignment radius, noise) on the bottom left of the control panel (leave the default settings for now).

Agents of all types behave in the same way, the movement rules are not influenced by an agent’s type.

Schelling rules

In addition to the movement rules, a simple rule is at work that determines an agent’s happiness. Happiness in turn determines an agent’s speed. By default, happy agents move slowly, whereas unhappy agents move fast. You can change the corresponding speeds with the speed sliders.

What determines an agents happiness? Each agent inspects the type of agents in a Schelling radius. When sufficiently many agents of the same type are in this Schelling neighborhood an agent is happy. For example in a 2-type system, an A-agent is happy if at least 50% of its neighbors are also A-agents. Essentially, when too many agents of different type are around, an agent is unhappy and starts moving faster seeking a happier place.

Observe this

First reset the parameters (button with the circular arrow) to their default values.

Stable milling states

When you press play, you should see that eventually the agents condense quickly into milling states in which agents of one type are slowly moving in the center (they are happy) and fast ones of the other type are circling in the periphery. This is because in a milling state agents in the periphery see “more” agents of the other type, because of the curvature of the circle.

If you switch off the happiness effect you should observe that the milling states become less stable, increase in size and finally collapse. Switch the happiness effect back on to see what dynamic state the system finally approaches.

When you press reset (back arrow) you can start the system again and play with the two speeds and the Schelling radius to see what other swarming patterns are stable.

You can now repeat everything with three or four types by selecting the corresponding choice in the bottom radio box.

Happy little groups

Reset the system (back arrow) and before you press play again, decrease the attraction radius to say a third of the slider width and the alignment radius to a quarter of the full length. You should see that sometimes the swarm collapses into groups of uniform type. In this regime the Schelling model dominates, the effects of the movement rules are smaller and patterns similar to the static system in the Complexity Explorable “T. Schelling plays Go” are observed.

When others make me happy

An interesting set of patterns emerges, if you invert the Schelling model: Instead of being happy if a sufficient number of agents of the same type are around, happiness is achieved when a sufficient number of agents of another type are around. You can inspect the inverted model by switching on the “others make me happy” toggle. See what happens if you do this.

Related Explorables:

The walking head

Pedestrian dynamics

The walking head

Pedestrian dynamics

Horde of the Flies

The Vicsek-Model

Horde of the Flies

The Vicsek-Model


Oscillators that sync and swarm

Janus Bunch

Dynamics of two-phase coupled oscillators