Neural Petri Dish

Initializing...
FPS: -- Step: 0 Brush: DRAW r=10 RUNNING [H] Help
Controls
Mouse Draw / Erase / Noise
1 / 2 / 3 Switch brush mode
+/- Scroll Brush size
Space Pause / Resume
N Single step (paused)
R Reset
C Center seed
X Random seed
S Toggle stats
H Toggle help
V Hidden channels
Touch to draw · Tap buttons above for controls
huh?

What is this?

This is a Neural Cellular Automaton (NCA) — a tiny neural network that runs independently in every cell of a grid, reading only its immediate neighbors. Despite having no global coordination, the cells collectively grow and maintain complex patterns from a simple seed.

How it works

Each cell holds 16 channels: 3 visible (RGB) and 13 hidden "thought" channels. Every step, each cell:

  1. Perceives its neighborhood using Sobel gradient filters (no learning needed)
  2. Decides a small update via a 2-layer neural network (48 → 128 → 16)
  3. Updates stochastically — only ~50% of cells fire each step, preventing synchronization artifacts

The update rule was trained in PyTorch to regenerate target patterns from damage. This page runs the trained weights in WebGL2 fragment shaders at 60fps, with the same math as the Python original.

Try it

Architecture

16 NCA channels are stored as 4 RGBA float16 textures on the GPU, double-buffered for ping-pong rendering. The 128-unit hidden layer is computed across 4 shader passes (32 units each) with delta accumulation. Sobel perception, stochastic masking, and brush interaction are separate shader passes. Total: ~8K learned parameters per model.