This is a post about some animations I made, such as these:
The algorithm is simple; this diagram, discussed further here, is pretty much the whole thing. The simulation relies on a large number (~5 million) particles following the given rules. It’s inspired by a computational model for the process that some slime molds (Physarum polycephalum) use to explore space.
The magic is the programming language we use for implementing it, Futhark. Futhark allows you to write ML/Haskell style programs that are highly optimized for GPU execution. It comes with a great blog, surprisingly good documentation, and an attentive maintainer.
My code is here
(it’s all rather hacked together). Run
pip install -r requirements.txt
and follow the Futhark
installation instructions. Then run make slime2.py
and run
using python run.py
(you’ll need to modify this script to
choose an image). My laptop GPU is able to render in the ballpark of a
few million particles and one million pixels at real time.
I have a few ideas for extension:
signal
.Dear reader, if you make anything inspired by this code, I’d love to see it 😁.