Slime PCB

A GPU slime-mold simulation that grows over real PCB geometry — each net a species, pads as food, traces as spawn points.

2025 Python · Taichi · KiCad github.com/osbo/slime-pcb

Slime PCB

A GPU slime-mold (Physarum) simulation that grows over real printed-circuit-board geometry.

load_pcb.py loads a KiCad .kicad_pcb board and runs a multi-agent slime simulation across it — every electrical net becomes its own species of slime that grows out from its existing copper toward its pads, while repelling every other net.

How it works

The board is rasterized into a simulation grid (cells down to 0.1 mm). The board outline (Edge.Cuts) sets the bounding box, and the board edges become obstacles.

Every net on the PCB is mapped to a slime species:

  1. Spawn — agents are seeded along the net's existing traces, inheriting each trace's local direction and bifurcating along it. Agent count scales with total trace length (~2000 agents per cm).
  2. Food — the net's pads emit an attractant pheromone, so each net's slime is pulled toward the points it has to connect.
  3. Sense → steer → move — the classic Physarum loop: each agent samples pheromone in three directions, turns toward its own species' trail, steps forward, and deposits pheromone. The pheromone field decays and diffuses every step.
  4. Repulsion — agents are pushed away from other species' pheromone, so distinct nets grow into separate, non-overlapping networks.

The agent and pheromone-field updates run as Taichi compute kernels on the GPU (Metal backend). Each copper layer is simulated and drawn independently in a live window showing agents, pheromone trails, pads, and the original traces.

Stack

  • Python — orchestration
  • Taichi (Metal) — GPU agent + pheromone-field kernels
  • pcbnew — KiCad's Python API for board geometry, nets, pads, and traces
  • NumPy — grid and array handling

Running it

Set the pcb_file path near the top of load_pcb.py to a .kicad_pcb file and run it in a KiCad Python environment. Live controls: A pause/play · S restart · D / Esc exit.

License

MIT — see LICENSE.