Mastering Backgammon

How to Prove Your Bot Doesn't Cheat
by Bill Robertie
This article originally appeared on Pokernews.com, October 10, 2006.

Last time I asserted that bots don't cheat. However, I won't insist that you take my word for it. The two best-selling commercial backgammon bots, Jellyfish and Snowie, both contains tools that allow you to prove to yourself (if you're suspicious) that they don't cheat. In this column I'll show you how to do exactly that.

(Since Jellyfish is the best-selling program, I'll use Jellyfish in my examples. However, the general procedure is exactly the same in Snowie.)

Pseudo-Random Numbers

First, a key point. The random numbers generated by a computer program are not random numbers. Instead, they are what are called pseudo-random numbers. There's a small but important difference between the two.

A string of genuine random numbers is usually generated by a physical process, like radioactive decay. A string of genuine random numbers obeys certain rules.

  1. All digits are equally represented.

  2. You can't predict future digits from past digits.

  3. No matter how much you know about the physical system that generated the numbers, you still can't predict the digits in the string.

Pseudo-random numbers obey the first two conditions, but not the third. When a computer generates pseudo-random numbers, it starts by selecting a single number, called the seed. (This is usually done by performing an arithmetical operation on the digits of the system clock.) The seed is typically a number between zero and 65535.

Once the seed is selected, a random number string of any length can be generated. For any seed, this string is unique. In other words, if you start with the same seed, you will always get the same string of random numbers. This sounds like a drawback, and it is in a very theoretical sense. Practically, however, pseudo-random numbers are just as useful for almost any purpose as true random numbers, and they happen to have the great advantage that you can use them to determine if a program is cheating or not.

Let's show how this would work with Jellyfish. (The same method would work with Snowie.) Let's start by running the program. Invisibly to the user, Jellyfish now selects a seed by consulting the system clock, and uses that seed to generate a string of random numbers. To see the seed, click on "View" and then click "Seed". The seed and counter (just a count of where you are in the string of random numbers generated by the seed) are now displayed at the bottom right corner of the window. In my case, the seed is 27370 and the counter is zero. If I shut Jellyfish off and start it again, I'll get a new seed, of course, but the counter will be zero in that case too.

Now I'll start playing a game. Let's watch what happens.

Jellyfish wins the opening roll with a 4-3, and plays 13/9, 24/21. Standard play.

Now I roll 6-5, and play 24/13.

Jellyfish rolls a nice shot, 4-4, and plays 24/20, 13/5, 9/5.

I now roll 6-6, and play four men from the 13-point to my 7-point.

Jellyfish rolls 6-3, and moves 20/11. If you're following along, the position on your board should look like this, with me having the Black pieces and Jellyfish as White:

Diagram 1.
Jellyfish (White)
has just played 20/11.

I now roll 5-2 and play 6/1, 24/22.

Jellyfish rolls 5-2 and hits, 8/3* and 13/11.

I roll 4-1, playing Bar/21 and 7/6.

Jellyfish rolls 4-3, hitting and covering with 8/4* 6/3.

I roll 6-3 and fan. The position now looks like this:

Diagram 2.
I just fanned with a 6-3.

At this point, Jellyfish doubled and I passed. The counter now reads 10, as ten dice rolls have occurred in the game.

So now we know the first ten random dice throws if the seed starts at 27370 and the counter starts at zero. Let's reset Jellyfish to those values and try another game. To reset, click on "View", then "Settings", then click the "Dice" tab. The seed is correct (it's still 27370), but change the counter back to zero.

Now click the yellow dice button to start a new game.

Once again, Jellyfish rolls 4-3 and plays 24/21, 13/9.

Once again we roll 6-5, but this time, we're going to play it differently. Since we believe Jellyfish's next roll is 4-4, and our subsequent roll is 6-6, we can take advantage of that knowledge by playing 24/18, 6/1*! Now Jellyfish's 4-4 will miss us completely and our 6-6 will be a powerhouse. (Of course, if Jellyfish "cheats", it will give itself a different number than 4-4 to take advantage of our stupid play.) So we play the silly-looking 24/18, 6/1*. Here's the position.

Diagram 3.
Black has just played 6-5
by moving 24/18, 6/1*.

Sure enough, Jellyfish rolls 4-4 again, and plays bar/21, 13/5, 9/5. Note that since Jellyfish could look ahead and see that my next roll was going to be 6-6, it could exploit that knowledge by hitting on the 1-point this turn. But it doesn't.

I now roll 6-6, as expected, and play 24/18, 13/7(3).

Jellyfish rolls 6-3, and plays 13/4. Here is the position:

Diagram 4.
White (Jellyfish)
has just played 13/4.

Now I roll 5-2, as in the first game. Normally I would keep my anchor on the 18-point and play something like 13/8, 13/11 here. But in the first game, Jellyfish's next roll was another 5-2. If Jellyfish is going to roll 5-2, I can break my anchor and try to cash in on my racing advantage without fear of being hit. So I play 18/13, 18/16! Brilliant, unless Jellyfish decides to "cheat" and change its roll.

But it doesn't. Jellyfish dutifully rolls 5-2 again and plays 8/3, 6/4.

The next few moves are routine. I roll 4-1 and play 16/11. Jellyfish rolls 4-3 and plays 6/3, 6/2. I roll 6-3 and play 11/5, 8/5. Let's look at this last position:

Diagram 5.
Black has just
played 11/5, 8/5.

The counter now reads 10, just as in the first game. Notice that all the dice rolls were exactly the same as before. In fact, we were able to exploit that fact to make otherwise foolish plays, knowing what Jellyfish's next roll was. We gave Jellyfish several opportunities to "cheat", but it didn't. It simply mechanically generated the dice rolls that were predetermined once the seed was set.

You could repeat this test as many times as you wanted, experimenting with the dice sequences resulting from different seeds. Once you've written down the rolls for a given seed, of course, you can win almost every game from Jellyfish if you wish, by exploiting upcoming rolls as we did in this game. (Fun at first, but pretty boring after awhile.)

Conclusion:  Your programs play extremely well, but they don't cheat. Use them to improve your game, but don't let paranoid fantasies get the better of you.


Next time:  Handling the High Anchor Games.

See:  More articles by Bill Robertie

Return to:  Backgammon Galore