Skip to content

The deterministic engine

Every Arbitas game runs on a rules engine made from its rules file. The engine is deterministic: given the same rules, the same seed and the same moves, it reaches the same state, on the server, in the browser, today and in a year. Everything else on the platform is built on that.

The engine knows nothing about networks, databases or screens. It answers a few questions about a game’s state:

Question Used for
What is the starting state? Setting up a match from its seat count, variants and seed
Which moves may this seat make now? Move pickers, bots, the server’s checks, and the smoke games at publish
What state does this move lead to? Applying a move, or refusing it as illegal
What may this seat see? Each player’s view, with the hidden parts left out
Is the game over, and who won? Ending the match and recording the result
What is this state’s hash? Checking that two copies of a match agree

A match is its action log: the moves in order, plus the moves the platform makes itself, such as a clock running out or a bot taking over a seat. Replaying the log from the start on the same engine rebuilds every state the match went through.

The rules language rules out everything that could make two runs differ:

  • No clocks, threads or input and output inside the rules. Time reaches a game only as a logged move, such as a clock running out.
  • Whole numbers only. Numbers are 64-bit integers; an overflow is an error, not a silent wrap, and / drops the remainder. There are no floating-point numbers to round differently on different machines.
  • Ordered collections. Every list and map iterates in a fixed order, every sort is stable, and ties go to the first match.
  • One source of randomness. Shuffles and dice draw from a random stream made from the match’s seed, and the engine’s state records how far along the stream it is.
  • Canonical state. A state is encoded the same way everywhere, so its hash is the same in every runtime.
  • A computation budget. Every engine call has a fixed allowance of work, and rules nest only so deep, so no rules file can make a call run forever.

When you publish, Arbitas compiles your rules into a .NET assembly (targeting .NET Standard 2.1, so the same assembly can run in the browser and, later, in Unity), plays seeded smoke games on it, and signs it. The compiler is tested against the rules interpreter, which runs drafts before they’re compiled, so the two give the same results. Each version’s engine is named by its rules’ hash, and a match keeps the engine it started on, even after you promote a newer version.

  • Matches you can trust. The server applies every move with the engine, so a client can’t make an illegal move or change the result.
  • Replays. A finished match’s replay is its log and seed; anyone with them can rebuild the match move by move.
  • Provably fair randomness. When a match starts, the server publishes a hash of its seed (seedCommitment in the match view) and reveals the seed once the match ends, so players can check the shuffles weren’t changed along the way. A game whose rules keep some information secret for good doesn’t reveal its seed, because the seed would give those secrets away.
  • Prediction. The browser runs the same engine, so it can show a move before the server confirms it. See server authority and prediction.