DE EN FR ES IT

Multiplayer

Deterministic simulation

Also: determinism, lockstep simulation

A deterministic simulation is game logic that always computes exactly the same result from the same inputs, no matter which machine runs it or when. It underpins fair resolution, input-based replays and many networking schemes.

Background

In real-time strategy, determinism has long been the standard for multiplayer: instead of sending the state of thousands of units, every machine sends only its commands and all of them simulate in lockstep. That only works if every machine computes bit for bit the same thing.

The enemies of determinism are inconspicuous: floating-point maths that rounds slightly differently on different hardware, random numbers without a shared seed, the order in which a hash table returns its entries, and anything tied to the clock or the frame rate. A single divergent bit causes a desync and the matches drift apart.

Determinism pays off even without networking: logic that depends only on its inputs can be pinned down with unit tests, simulated in bulk and reproduced exactly when a bug is reported.

How we do it

FaxFight’s fight resolution (FightEngine.php) runs entirely on the server and uses no random values. Hits, blocks, momentum (+1 damage after a block), the penalty for repeating last round’s zone, the special attack and counter damage all follow from the moves and the character stats alone. Unit tests in tests/Unit/FightEngineTest.php lock that behaviour in.

Because the engine is pure logic, the faustpost:balance command can run it thousands of times with random strategies; it generates those moves from a fixed seed, so the balancing run is reproducible too. The Wurzelwerk engine’s runtime likewise depends only on data and inputs, which is what automated playtesting relies on.

Related terms