Slimulation
Joosep Suuder, Henri Maandi, Kerli Tasso
This project simulates the behaviour of Physarum Polycephalum, the true slime mold using compute shaders and Godot 4.0. Based on this paper by Jeff Jones.
The algorithm
The algorithm works by generating x amount of particles specified in the UI and keeping track of each individual particle location on the screen and the rotation of any given particle. During runtime the location of each particle is recalculated using the compute shader. Each particle has "sensors" at the right, front and left side, the algorithm looks at the RGB values at each of these locations assigning negative values to channels that are not in this particle's species and a positive value to that which is. (The first species uses the red channel, the second the green channel etc.). It then selects the direction which has the highest weight and then adjusts the rotation of the particle in accordance. Finally a new location for the particle is calculated using the speed parameter and the rotation. In addition a fragment shader dims each pixel on the screen each frame to give each particle a trail which other slimes can follow.
A crude representation of the algorithm decision making
Here you can see different particles and their trails
The UI and parameters
Before starting the program, the user can tweak different parameters for the rendered slime which alter the behaviour of the individual particles.
Parameter | What it does |
---|---|
Number of slime particles | Adjusts the number individual particles on the screen |
Number of slime species | Adjusts the number of different slime species/groups on the screen |
Speed of particles | Adjusts the number of pixels each particle jumps after determining the direction of travel |
Turning speed of particles | Adjusts the amount the particle turns after determining the direction of travel |
Sensor distance | Adjusts the distance at which the sensors sit at the right, front and left side |
Sensor angle | Adjusts the angle at which the sensors sit at |
Generated to mimic the picture above
Simple three group rgb slime
The slime mutating by adjusting the parameters during runtime
A run of the simulation with 5000000 particles can be seen here.
Try it for yourself!
To try the project out for yourself download the .exe file here.
Our repository is available here. Refer to the README file for instructions on how to run the algorithm and see the code.