Physarum Polycephalum aka slime mold is made up of a vast number of individual single cell organisms. These organisms have no brains or intelligence, but complex behaviors emerge when many of them are put together. Depending on their environment they move like what seems to be a much more complex entity.
Here are some great videos about slime molds with some awesome time lapse footage.
Once you have watched those you should hopefully have a better appreciation for the simple slime mold and the rest of this post will make more sense.
Here is one final video showing time lapse footage of various Physarum
Simulating Slime Molds
I have been interested in trying to simulate slime molds fror years now and my interest was once again peaked from seeing Sage Jenson‘s Physarum page here describing his simulations.
Sage was inspired by the paper Characteristics of Pattern Formation and Evolution in Approximations of Physarum Transport Networks.
He gives this simple diagram explaining the steps.
The basic explanation is a bunch of particles move over an area turning towards spots with higher concentrations of a pheromone trail. They also leave a trail as they move. These basic steps create interesting patterns and structures.
Following the principals from Sage and the paper, this is how my take on simulating Physarum works.
1. Create a 2D array that tracks the pheromone trail intensity at every pixel location. Initially all spots are set to 0 intensity. I tried setting various shapes and perlin noise clouds to start, but the moving particles quickly erase any starting shapes and create their own paths so I just start with an empty space. Sage’s examples show interesting patterns and structures when starting with circles or other shapes, so I need to do some more work on start patterns.
2. Create a list of particles with properties heading (direction/angle the particle is moving), x,y (positions), sense angle (how wide the particle looks to the left and right) and sense distance (how far in front the particle looks), turn angle (how quick the particle turns towards the sensed areas). I set the number of particles to match the image width multiplied by the image height. That seems to nicely adjust the particle count when changing image sizes.
3. Main loop
a) Display. For display I scale the minimum and maximum trail values to between 0 and 255 for a gray scale intensity (or to be used as an index into a color palette, but simple gray scale seems to look the best).
b) Each particle looks at the 3 locations in front of it based on the sense angle and distance. You then work out which of the left, front and right spots have the highest concentration of the pheromone trail.
c) Turn the particle towards the highest pheromone intensity. ie if the left spot is highest then subtract turn angle from the particle heading. If the front is highest do not make any change to the particle heading. If the right is highest add turn angle to the particle heading. You can also reverse this process so the particles turn away from the highest pheromone levels.
d) Move the particle forwards by a specified move amount.
e) Deposit an amount of pheromone onto the trail to increase it.
f) Blur the trail array. This simulates the pheromones diffusing over the surface. I use this quick blur with an option for a blur radius between 1 and 5.
g) Evaporate the trail by a small amount. This slowly decays the amount of pheromone.
Repeat the main loop as long as necessary.
See my Physarum Simulations gallery for more images.
Here is a movie with some example results showing the simulations running. For the display the pheromone trail intensities are mapped to a gray scale palette (brighter = higher intensities).
Multiple Species Physarum Simulations
My next idea was to have multiple Physarum types in the same area. For these cases I used 3 sets of Physarum (3 groups of particles with their own unique settings) as shown in the following settings dialog.
Each of the pheromone trail intensities are then converted to RGB color components.
This works but the results are just 3 separate simulations that do not interact. The idea is to have each of the particle types attract to their pheromones, but move away from the other 2 types of pheromones.
The main change is in the pheromone detection and turn code. For the single Physarum simulation the particles look left, forward and right and then turn and move based on the location with the highest pheromone concentration. For 3 particle types they take into account their pheromone concentrations but subtract the pheromone concentrations of the other 2 types. For example if the 3 trail/pheromone arrays are called rtrail, gtrail and btrail, then the red particles pheromones are calculated by using rtrail[x,y]-gtrail[x,y]-btrail[x,y]. The highest concentration of left, forward and right is then turned and moved towards.
More example images can be seen in my Physarum Simulations Gallery.
Here is a sample movie showing some of the multiple species results.
Physarum Image Processing
This was inspired after seeing the following video from Magic Jesus.
A bunch of Physarum particles start on the surface of an image. The particle colors are based on the image color they start on.
After this let them wander around the image area following Physarum simulation rules with a slight change. In this case rather than turning left or right based on a pheromone trail intensity, they turn towards the pixel that is closest in color to themselves.
This is my result after running Physarum simulations on three colorful paintings. The first and third are from Leonid Afremov and the second by Kandinsky (same painting as in Magic Jesus’ example movie).
These would look great on a large wall in a modern art gallery. Playing slowly enough so you could just notice the changing colors (like clouds moving slow enough you don’t notice they change until you look away and back again). The exhibits with those dark rooms you enter and read the little white plaque with a blurb on what it is all about. “The slow interplay of colors represents the human condition and the struggles of how humans still cannot find a peaceful equilibrium of coexistence with themselves and the planet.”
See the following movie for a more detailed explanation of this blog post and the Physarum modes within Visions of Chaos.
Razor1911 used Physarum for their demo La Vie Opportuniste. Note that the executable for this demo is only 4K (4096 bytes) in size!
Both single and multiple species Physarum Simulations and Physarum Pixel Flow are now included with the latest version of Visions of Chaos.