Skip to content
DRIFTWORK.STUDIO
← Projects
In progress

Takt

A discrete-event model of a production line with three faces — a CLI, a 2D view, and a walkable 3D one — all provably the same simulation.

simulationpythongodot

A discrete-event simulator of a factory production line: stations, buffers, forklifts, inventory, trucks, and the metrics that fall out of running it a thousand times.

One core, three faces

The structural idea, and the only one worth stealing: the simulation has no idea it’s being watched.

There is one SimPy core. It runs headless and knows nothing about rendering. Three viewers attach to it over a TCP/JSON bridge:

  • a CLI for batch runs — sweep a parameter, get a table
  • a 2D view for watching a single run and seeing where things pile up
  • a 3D/VR scene you can walk through the plant in

The reason this matters isn’t the VR. It’s that the walkable scene and the overnight batch run are the same simulation, provably, because neither one contains any simulation logic. There’s no “visual mode” that quietly behaves differently, no drawing code creeping into the model, no second implementation drifting from the first.

The usual failure here is a sim with rendering welded into its loop. Then the headless run is a fork, and the fork is subtly wrong, and you find out months later when the number you trusted was produced by code nobody watches.

Put a socket in the middle and that entire class of bug is gone. The bridge is the enforcement.

Why a bridge and not a library

A bridge over an import, because the 3D viewer is a game engine and the sim is Python, and marrying those in one process is a worse problem than serialising some JSON.

The accidental benefit: the boundary forced the sim’s output to be an explicit, versioned message rather than “whatever the objects happened to expose.” Once the viewer can only see what crosses the wire, the model’s public surface gets designed instead of leaked.

Honest status

Working, and a prototype. ~8,600 lines of Python across the core, viewers, and the plumbing between. It runs, the numbers are plausible, and it has never been validated against a real line’s actual throughput — which is the difference between a simulator and a model of one.

No version control, which is its own small confession.