An interactive, real-time simulation of slime mold behavior using WebGPU for GPU-accelerated computation and rendering.
This simulation models the behavior of Physarum polycephalum, a single-celled organism that forms intricate network patterns while foraging for food. Each agent follows simple rules:
- Sense - Sample the environment at three points ahead (left, center, right)
- Turn - Rotate toward the direction with the highest trail concentration
- Move - Step forward and deposit a trail marker
- Diffuse & Decay - Trails spread to neighboring cells and fade over time
From these basic rules, complex patterns emerge.
- Bun - Package manager & runtime
- SolidJS - Reactive UI framework
- WebGPU - GPU compute and rendering
- Tailwind CSS - Styling
- Vite - Building & bundling
- Biome - Linting and formatting
Install dependencies:
bun installStart the development server:
bun devThe app will be available at http://localhost:5173
Build using Vite:
bun run buildBuild and run with Docker:
docker build -t slime-mold-simulation .
docker run -p 8080:80 slime-mold-simulationWebGPU is required to run this simulation. Check the MDN docs for current browser support.
Supported browsers include Chrome 113+, Edge 113+, and Safari 18+.
Thanks to Sebastian Lague for inspiring me to create this project.
This project is licensed under the MIT License. Feel free to use, modify, and distribute the code as you see fit.