NEW SITE + PORTFOLIO + NEWSLETTER @ sagejenson.com

All images / gifs in this post are from my implentation of a Physarum transport model (described below).

This February I spent a bit of time simulating slime mold (Physarum polycephalum). I saw some incredible posts by Georgios Cherouvim with reference to a 2010 paper by Jeff Jones, “Characteristics of pattern formation and evolution in approximations of Physarum transport networks.” When I read the paper, I was excited to learn that the model combined continuum and agent-based simulation systems in a way that I hadn't seen before. In this post I try to describe some of the concepts behind the system, and give an overview of how it functions.

There are two requirements of efficiency in foraging behavior: 1.) to search a maximal area and 2.) to optimize transport distance. Physarum polycephalum is a unicellular multinucleate organism that excels at these two competing tasks through the mechanisms of growth, movement, and area reduction. When the organism can choose to travel through two different paths to a destination, the emergent behavior allows it to effectively find shortest paths. This allows Physarum to navigate mazes, develop optimal road-like systems and solve other path-finding problems.



The model postulated by Jones employs both an agent-based layer (the data map) and a continuum-based layer (the trail map). The data map consists of many particles, while the trail map consists of a 2D grid of intensities (similar to a pixel-based image). The data and trail map in turn affect each other; the particles of the data map deposit material onto the trail map, while those same particles sense values from the trail map in order to determine aspects of their locomotion.

Each particle in the simulation has a heading angle, a location, and three sensors (front left, front, front right). The sensor readings effect the heading of the particle, causing it to rotate left or right (or stay facing the same direction). The trail map undergoes a diffusion and decay process every simulation step. A simple 3-by-3 mean filter is applied to simulate diffusion of the particle trail, and then a multiplicative decay factor is applied to simulate trail dissipation over time. The diagram below describes the six sub-steps of a simulation tick.


Many of the parameters of this simulation are configurable, including sensor distance, sensor size, sensor angle, step size, rotation angle, deposition amount, decay factor, deposit size, diffuse size, decay factor, etc. For a more detailed description check out the original paper.

There are several substantial differences between the model as described by Jones and my implementation. In Jones’s original paper there is a collision detection step that ensures that there is at most one particle in each grid square. For my implementations I usually ignored this step, preferring the patterns that arose without it. However, this step is crucial for exact mimicry of the behavior of Physarum polycephalum, as it approximates a sort of conservation of matter. Also (conveniently) this collision detection removes any sort of sequential dependence, allowing for increased computational parallelism.

I also added a contagion behavior that alters properties of the simulation. When a particle is infected, it lays down an infected trail which then spreads to other particles. The gif below is an example of such an infected system, with the contagion spreading from the center of the image.



I implemented the model in C++ and GLSL using openFrameworks. All of the computation and rendering happen on the GPU, which stores both the particle information and the trail map. The simulation runs in real-time on a GTX 1070, with most of the examples comprised of between 5 and 10 million particles.

Thanks for reading, feel free to email me with any more questions. I hope to post a CPU version of the system described in the Jones paper soon.