100,000 matches before the first player: how we test our game rules
Why the computer plays every game 100,000 times before release: a test for every rule, reference matches, repeatable dice, and real numbers from both cafés.

A player will forgive a button that looks a bit off, or a colour in the wrong place. A player will never forgive a table that gets a rule wrong. If the backgammon board allows an illegal move once, or the dominoes count a hand wrongly once, trust in the whole game is gone. That is why the part we spend the most time on is not the art and not the sound. It is testing.
In an earlier note we described how every rule is written into an approved document before any code exists. This one is about what happens next: how we make sure the code does exactly what the document says, in every situation, including the ones that come up once every few months.
Three layers of testing
Every game we make passes through three kinds of tests, and each kind catches a different kind of mistake.
First, a test for every rule. Before we write the code that applies a rule, we write its test. "If this checker is trapped, this move is illegal." "If the hand is played in Sun, the cards rank like this." "A marble on a safe square cannot be captured." The test fails at first, because there is no code yet; then we write the least code that makes it pass. This is test-driven development, and its real value is that every clause of the rules document ends up with a guard that wakes up if someone breaks it later.
Second, reference matches. We record complete matches, move by move, and keep their outcome as a reference. Any later change to the code must reproduce exactly the same outcome for those matches. If something changes by accident, the test fails at once and points to the first move where the result diverged. If the change is intended, we record the reference again and write that down plainly in our decision log.
Third, the computer plays on its own. This is the layer that catches what nobody thought of. A small program plays complete matches with random moves, but every move must come from the list of legal moves that the rules engine itself provides. After each move it checks many things: that the turn passed correctly, that no piece appeared or vanished, that the score makes sense, and that the match eventually ends instead of looping forever.
Why 100,000?
Because rare situations really are rare. In backgammon, some positions only appear when the dice fall in a particular order after a checker has been trapped in a particular place. In a thousand matches such a position may never show up. In a hundred thousand, the chance that it slips through unseen becomes very small.
To give a sense of scale: the 100,000 matches of Tawla Ada alone came to about 25.7 million turns. Mahbusa took 17.2 million, and Tawla 31 about 52.8 million. Dominoes ran 23.5 million turns head to head and 31.8 million with four players. For the Gulf majlis, the computer played 100,000 games of Baloot, with 762,000 hands and 26.3 million moves, and 100,000 games of Jakaroo, with 46.6 million moves. Carrom is heavier, because every shot runs a full physics simulation, so we played 3,000 matches with 885,000 shots. Not one of those matches contained an illegal move.
Dice that repeat exactly
What makes all of this possible is that the dice and cards in our games are not "random" in the way you might imagine. They come from a number generator that, given the same starting point, produces the same numbers in the same order every time. If match number 73,412 out of the 100,000 lands in a strange position, we can replay it exactly, move by move, and watch it until we understand it.
The same idea keeps the phone and the server in agreement. In online tables the server is the referee, and the phone computes legal moves with the very same rules engine, so both reach the same result. For Carrom in particular, we wrote the physics using only simple operations, addition, subtraction, multiplication, division and square roots, so that every device computes the same path for the striker and no phone ever "sees" a different shot from the one the server saw.
A rules engine kept apart
To keep testing quick and simple, each game's rules live in a part of the code that knows nothing about the screen, sound, networking or files. It holds no shared state and never reads the clock. It takes the state of the table and a move, and returns a new state. That is what lets us run millions of turns in seconds without opening the app at all.
The opponents are tested too
The café regulars you play against have their own tests. Legal moves are not enough: the hard opponent must really be hard, and the easy one really easy. Over 10,000 matches, our strongest regular beat the weakest about 96 to 97% of the time at backgammon, 77% at head-to-head dominoes and 86% with four players. The average decision takes less than a millisecond, so nobody is left waiting.
When the document itself is silent
Sometimes the computer finds a situation the written rules simply do not cover. A real example: in two-player dominoes, if the double six is still in the boneyard and nobody holds it, who opens? The approved rules did not say, so we chose the most sensible answer: the player with the highest double opens, and if nobody has a double, the player with the heaviest tile. We wrote that decision into the rules document and the decision log, so anyone can see why the game behaves that way. For Carrom, a few deliberate simplifications are written down the same way, rather than left as surprises.
When a test fails
The best thing about random matches is that their failures are useful. When a match fails, the program does not just say "something is wrong". It prints the starting number of the generator, the game, the turn where the error happened and the move that was played. With that number we replay the exact same match on anyone's machine and turn it into a permanent test. Every mistake is caught once and becomes a new guard. Over time the test suite grows out of real mistakes, not only out of the ones we expected.
One gate before every change
All of this runs from one script that must come back green before any change goes in: static analysis, every test, code coverage (at least 90% of the rules code, and we are above 98%), and a quick round of random matches for every game. If anything is red, the change does not go in. Full stop.
This may sound like a lot for a game of backgammon. The idea is simple, though: we want you at the table worrying about nothing but the dice. The rules are our job. If you would like to read the rules we test against, they are in the Zezo Café game guides.
