Digital Ants

Digital Ants

coding experimentation // Processing (Java)

Modelling swarm behaviour

Ant colonies are immensively complex systems. Without a central plan or centralised authority, these tiny insects still are capable of maintaining a society of thousands of individuals. Although an individual ant is incredibly simple and completely incapable of any complex task, put many ants together and their interactions will result in a massively different story. This principle is called ‘emergence’, as in ‘the emergence of complexity from simple elements’.

A RadioLab episode from some time ago got me thinking about how cool it would be to explore emergence in code. As part of my PhD course work, I wrote a piece of code in Processing inspired by Craig Reynolds ‘Boids’ (example). When running this code, a few hundred ‘ants’ appear in the center of the screen and will start exploring their world in the search of food (depicted by cyan circles). However, predators also roam this world and will attempt to hunt the ants. The interplay between the ants and their environment

There are many characteristics that define each ants’ behaviour, such as how close together the ants will walk, how strictly they will follow the trail laid down by other ants, how aggressive they are towards predators etc. In order to try out several alternatives I decided to plug numeric audio features from Spotify’s web API (such as danceability, energy and valence) into the ants’ behaviour.

The result? Wildly variable, digital ant colonies. While one colony would form snaky paths to food sources across the circular landscape, another would form a single, main corridor to the nearest food source. To illustrate further how the songs’ audio features impacted the ants’ behaviour, the cumulatively graphed position of all ants made for a pretty cool comparison too (see below).


Above are some examples of the cumulative paths of all ants in a given colony, cut off after two minutes of runtime. This led to some interesting patterns that emphasised what made each ant colony unique.

Screen Shot 2017-12-02 at 9.45.11 PM.png
Screen Shot 2017-12-02 at 9.50.10 PM.png
  "danceability" : 0.401,
  "energy" : 0.189,
  "key" : 0,
  "loudness" : -11.189,
  "mode" : 1,
  "speechiness" : 0.0287,
  "acousticness" : 0.871,
  "instrumentalness" : 0,
  "liveness" : 0.0968,
  "valence" : 0.357,
  "tempo" : 94.509,
  "type" : "audio_features",
  "duration_ms" : 125320,
  "time_signature" : 4