Server authority and prediction
Arbitas is server-authoritative: the server holds each match’s real state, applies every move with the game’s engine, and keeps the match’s log. A client only asks. That way no player can cheat by changing their client, and every player sees the same match.
A move’s round trip
Section titled “A move’s round trip”- The client submits a move for its seat, with the match version it was looking at (
baseVersion) and a sequence number of its own (clientSeq). - The server checks it. Is it this seat’s turn, or may the seat act now? Is the version still current? Do the rules
accept the move? A refusal comes back as a rejection with a code, such as
notYourTurn,staleVersionorillegalMove. - The server applies it with the engine, appends it to the match’s log, and moves the version on by one. A move is confirmed only once it’s written to the log.
- Every seat gets its own delta: the move, the state as that seat may see it, and the state’s hash. Two seats can get different deltas for the same move, because each sees only its own hidden information. Spectators get the public view.
Each match has a single writer on the server, so its moves have one order and one version number, however many players
send moves at once. Resending a move with the same clientSeq is recognized as the same move, so a client can safely
retry after a dropped connection.
The real-time protocol carries all of this over a WebSocket; asynchronous clients can use the Player API’s match endpoints instead.
Prediction
Section titled “Prediction”Waiting for the server makes every move feel slow, so the hosted web player predicts. It runs the game’s own engine in the browser, in a Web Worker, and for a game without hidden information or a random setup it keeps the whole state, rebuilt from the match’s log:
- When the player moves, the browser applies the move at once and shows the result as pending.
- When the server’s delta arrives, the browser compares the server’s state hash with its own. If they match, the move is confirmed. If they don’t, it rolls back to the last confirmed state and applies the server’s move.
- If the move was rejected, the prediction is dropped.
A game that hides information can’t be predicted this way: the browser doesn’t know the hidden parts, such as the order
of a deck. For those games the web player shows the server’s view of the seat and builds moves from the list of legal
moves the server sends with each update (moves in the match view and in each delta), so a move shows once the server
has applied it.
Staying in step
Section titled “Staying in step”- Versions. Every update carries the match’s version. A client that reconnects asks for the updates after the last version it has, and the server sends them in order.
- Hashes. Every update carries the state’s hash, so a client that rebuilds the state can tell at once if it has drifted from the server.
- Same engine everywhere. A match is pinned to one engine version, named by its rules’ hash, and the web player loads that exact engine. Promoting a new version never changes a match already being played.