Backgammon Bot by Howard Milano

Contact me (Howard@HowardMilano.com)
© Copyright 2023 Howard Milano

This is a Backgammon Bot driven by a Neural Net. This is an example of AI (Artificial Intelligence), and it's AI that you can make at home on your home computer. All play decisions are made by the Neural Net, I didn't program in any special rules. This Bot plays at an intermediate level, a little better than the reference Backgammon Bot player PubEval, on average it will beat PubEval 54% of the games and also win by points won.

It's very interesting to create a Backgammon Bot and I had a terrific time doing it. However, it's not something everybody can do since you have to know how to program to create the Bot, its Neural Net, its testing enviroment, and the Web Browser UI to play it and show it of.

There is a reference Backgammon Bot player called PubEval, here is the link that describes how to code it. Your Bot is good to very good if it can beat the reference player 50% or more of the games, and also beat it on points.

This is the second version of this Bot. In the first version, I used a basic Neural Net with a special back propagation that uses TD-Learning, see the rules set up by Gerald Tesauro around 1990. Here's a link that explains how to change a Neural Net so it can play Backgammon using TD-Learning.
In this second version, I used a better Numpy based Neural Net and I used classic back propagation. For each test game I recorded the moves and the outcome and then then trained the Neural Net with those moves and that outcome. Repeat about half a million times and you have a Neural Net Bot that can play a decent game.

I mentioned beating the reference player on points. This is not easy, the reference player uses two Neural Nets, one for regular play and one for the racing phase where no checkers can be hit anymore. That means the reference player allows very few backgammon losses (3 points each) and it's a strong player both in regular play and in the end phase.
Many Backgammon Bots, including the one from Tesauro, give equal rewards for both Backgammon and Gammon losses and wins. From experience I can tell you that you will not beat the reference player using equal rewards, you have to force the Neural Net to avoid Backgammon losses as much as possible and turn them into Gammon (2 point loss) or regular losses (1 point loss) instead.

I found that TD-Learning is slow and it didn't seem to reach the optimal maximum state, instead ending up in some local maximum state where it isn't powerful enough to beat the reference player. Classic back propagation with a Numpy based Neural Net that allows processing multiple states in one call, thanks to the matrix processing, proved to be faster and allows the Neural Net to reach an optimal maximum state where it can beat the reference player.

To develop the Backgammon Bot, I programmed it and all supporting code in Java. Once it was done, I wrote a program in TypeScript, which turns into Javascript, that can read the Neural Net, execute the code to run the Bot and show it all in a Web UI where you can interact with the Bot.

A Neural Net with 1 layer of 80 hidden nodes is sufficient. I used the same input as Tesauro, but I added an extra input that turns on when the game is in the racing phase.

Send me an email if you want help writing your own Backgammon Bot.