Skip to content

nitodeco/slime-mold-simulation

Repository files navigation

Slime Mold Simulation

Slime Mold Simulation License

An interactive, real-time simulation of slime mold behavior using WebGPU for GPU-accelerated computation and rendering.

Click here for a live demo

Simulation

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:

  1. Sense - Sample the environment at three points ahead (left, center, right)
  2. Turn - Rotate toward the direction with the highest trail concentration
  3. Move - Step forward and deposit a trail marker
  4. Diffuse & Decay - Trails spread to neighboring cells and fade over time

From these basic rules, complex patterns emerge.

Tech Stack

Development

Setup

Install dependencies:

bun install

Start the development server:

bun dev

The app will be available at http://localhost:5173

Build the project

Build using Vite:

bun run build

Build and run with Docker:

docker build -t slime-mold-simulation .
docker run -p 8080:80 slime-mold-simulation

Browser Support

WebGPU is required to run this simulation. Check the MDN docs for current browser support.

Supported browsers include Chrome 113+, Edge 113+, and Safari 18+.

Attribution

Thanks to Sebastian Lague for inspiring me to create this project.

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute the code as you see fit.

About

An interactive, real-time simulation of slime mold behavior using WebGPU.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published