Systems & toolingNewZ-fighting check with a ratchet
Finds z-fighting before anyone sees it flicker.

The HaTac engine’s simulation clock and its portable save files, lifted out whole with no engine and no dependencies.
Game rules register as systems with their own rates (every tick, every third, every quarter second); the clock turns frame time into whole 1/60 s ticks at any frame rate and any speed from ¼× to 16×, with pause, single steps and an interpolation fraction for smooth drawing; every input is a journal entry at a tick, so replaying the journal from a checkpoint gives the same world, tick for tick. Each tick gets a 53-bit fingerprint, the whole world’s and each system’s, with clean systems skipped by a revision counter; firstSimDifference names the first tick and system where two runs part. Independent rules can sleep and settle a long gap in one call. A save is the recipes, the seed, the journal and a few packed checkpoints in one binary file (RSAV, CRC-32, gzip): a worker encodes it, stages it, reads it back and only then publishes it, keeping three verified generations in IndexedDB or a folder; version steps upgrade old files; replayCheck replays a file and names the first checkpoint that differs. Added in the library: one import, the engine’s defaults, a store in memory, hex fingerprints and thumbnail bytes. The demo is a walled kitchen garden with quick save, an autosave at dawn, loading with its hash checked, a timeline you drag back through, playing on from the past, and a replay that matches every tick until a careless rule breaks it.
Measured 28 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 158, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged CPU 0.36–0.38 ms). What ran: Alone at 4×: the garden’s six systems (sky, cistern, twelve beds, 36 bees, the gardener, the market) stepped 240 ticks a second with every published tick fingerprinted (the clean systems skipped by their revisions), a checkpoint every 600 ticks (six kept), and the ledger, the fingerprints and the timeline refreshed four times a second. A quick save is pressed halfway: a thumbnail, the prepared capture, and the hand-off to the save worker (which encodes, gzips and writes to IndexedDB off the main thread). Phones: tiers are being measured next.
Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.
install("sim-saves")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it upFrom HaTac. Adapted from published work, named below.
Hannes Andersson: The HaTac engine’s simulation clock, save files, replay check and their tests (built for his game and proven there); the library’s additions and demo.
Glenn Fiedler, “Fix Your Timestep!”: The accumulator that turns frame time into fixed steps and the interpolation fraction between the last two, which the clock’s frame() and alpha follow.