deterministic state machines pay for themselves
updated Jun 11, 2026
The riichi game engine is one GameState value and pure (state) → state functions — no mutation, no hidden globals. It felt like over-discipline at first. It paid for itself three times over.
Testing: a pure function tests with no framework and no DOM — exactly what a rules engine with hundreds of edge cases needs. Concurrency: AI turns interleave asynchronously, and with no in-place mutation a value captured earlier can’t change under you. And the one I didn’t see coming — everything downstream came for free. Because the engine is deterministic, a game saves as a tiny seed-plus-inputs tape that re-derives byte-for-byte. From that same substrate I got replay, export to a standard log format, and tile-level post-game review — none of which I designed up front.
Determinism isn’t a constraint you pay for; it’s a substrate you build on. Make the core a pure state machine, and the features you haven’t thought of yet get easier.
the hub · warm terminal