Backgammon is one of the oldest board games in the world (much older than chess). It is a two-player game, where pieces are moved according to the roll of two dice. If you want to know more about backgammon, Wikipedia article might be a good start.

One of the major questions when playing online backgammon is: Are the dice fair and random? This article will try to answer that question on an example from DailyGammon.

Dailygammon (DG) is a free website for online turn-based backgammon playing, or to quote their own words: DailyGammon is postal chess meets backgammon meets the internet.

Dice rolls on DG are created with a help of famous random.org, which has been proven to be a true random generator (compared to pseudo-random generators) in various statistical analyses. The actual process of creating the dice rolls is explained in DailyGammon’s help, where you can also find the actual Perl script used.

The test I used for testing the randomness of DG dice was Pearson’s chi-squared test. In short, if the test shows P-value of less than 0.05, that means that dice are not behaving randomly; P-values higher than 0.95 would mean that dice are following uniform distribution a bit too closely; if the P-value falls between 0.05 and 0.95, we can say the dice are indeed random.

Data gathering

For this analysis I decided to use the data from my DG matches. Since joining DG in the summer of 2009, I’ve played 2138 matches.

The first step was to write a small script to download match logs for all those matches. The match log looks like this (just a part of it is shown):

3 point match Game 1

JHD : 0 miran : 0

1) 62: 24/18 13/11

2) 42: 8/4 6/4 61: 11/5 6/5

3) 51: 13/8 8/7* 33: 25/22 13/10 6/3 6/3

4) 41: 7/3* 4/3 51: 25/20 10/9

The part shown is a start of a first game of a 3 point match (the match lengths on DG vary from 1 point matches to 25 point matches) between a player called JHD and me. I was first on the roll, rolled 6–2 on the dice and played a 24/18 13/11 move. The next move was from JHD where he rolled 4–2 and played 8/4 6/4. Then I rolled 6–1, he rolled 5–1, etc.

The next step was to extract the dice info from the match logs. Python script was written, which extracted not only the values on the dice, but also the information if it was the first roll of the game (more about the reasons for that a bit later), and who was on roll — me or my opponent.

Some basic stats:

2138 matches played, on average 0.80 matches per day,

16,294 games, on average 7.62 games per match,

606,148 moves in total, or 37.20 moves per game, or 283.51 moves per match.

Data analysis will be divided in two main parts — the analysis of the dice on the first roll of the game, and the analysis of the dice on the other rolls of the game.

First roll

When backgammon is played over the board, every game starts with each player rolling one die and the player who rolled the higher die starts first and plays numbers on those two dice (his and opponent’s). If both players roll the same number on dice, they re-roll until one player rolls a higher die. (When playing online, re-rolling happens behind the scenes.)

The important thing to notice here is there are no doubles (the same number on both dice) on the first roll.

If the dice are fair, each player should be the first on roll 50% of time in the long run. The key words here are the long run, meaning it could happen (and it happens) that one player will start 10 or more times in the row first, but in the long run the things will balance out.

In Figure 1 we can see the number of times each player has been the first on roll, and the black vertical line is the expected value (theoretical number of times each player should start first):

Figure 1: Number of times each player started first

Out of 16 thousand games, I started first 68 times more than my opponents. Does that mean the dice are favouring me? Chi-squared test dismisses that possibility — chi squared value is 0.284, and for one degree of freedom this gives a P-value of 0.594 — meaning this discrepancy in the number of first rolls for each player is quite expected.

Next thing to check is to see if DG favours some rolls on the first roll over the others. The distribution of the dice combinations on the first roll is shown in Figure 2: