A Guide to Go AI Programs
In this post, I’ll be teaching you how to install the main AI Go tools of today, at least the freely available ones. These are very valuable items to have at your disposal — after all, who wouldn’t like to have AlphaGo reviewing your own game? 🙂 —, and they do not take that long to install. This guide is composed of 4 tools with different objectives and different pros and cons:
- Leela, to analyze games and play against an AI;
- Lizzie, to analyze games on the spot (without registering the variations);
- Leela + Sabaki (and the ELF and PhoenixGo versions), to play against an AI and make them play against each other;
- Go Review Partner, to analyze games in more detail and in a more automated manner.
Huge thanks to George from the Igo Baduk Weiqi Youtube Channel for the help; and pnprog, author of the Go Review Partner, for the corrections to my mistakes.
Leela
There are two versions of the program, one that contains AlphaGo’s
basic algorithm Leela, and
another, which has the latest version of the algorithm, starting from
scratch, without any prior knowledge of Go:
Leela Zero. For those
who don’t know much about this branch of Go, I would suggest
downloading Leela and playing with it for a bit, the interface is
quite complete and its level is around 9d KGS, i.e., extremely strong,
just as good as a strong insei at least
Leela Zero is an under-construction project. Despite
Deep Mind's last
article’s algorithm — in which AlphaGo Zero learned, by itself
and from scratch, to become even stronger than its last version in
only about 8 hours
This is a graphical interface which makes studying with AIs much more pleasant. Lizzie uses Leela Zero to generate candidates for the next moves, while showing live variations, besides a graph of the winning percentages. Some of the most useful commands are:
- X for showing the commands menu;
- Space for turning the pondering on and off;
- O for opening SGF files;
- A for starting the autoanalysis and specifying the number of variations per move.
Although very pleasant and powerful, Lizzie doesn’t solve the demand problem completely. There are still some imperfections. The biggest flaw would be not having a way to save the variations in the SGF file or even being able to recover them while running the program, this problem with recording makes the software a bit impractical for some purposes. Fortunately, this last issue can be solved in a very automated way with another tool, the Go Review Partner.
Sabaki
Before we continue with the implementation, we must first download the
essential files. An AI is composed basically of two files: its
executable, which contains the algorithm; and its text file, which
contains the calculated parameters of the neural network
The first one is to directly download the best Leela Zero weights, also found in Leela Zero’s GitHub Page, under the section I just want to play right now. The other is to go where they are actually stored. In the site dedicated to Leela Zero, we can find an enormous number of its versions, in each line of the tables, the strength being roughly proportional to the product of the dimensions of the column Size. According to Igo Baduk Weiqi, the 128×6 versions would already be strong enough to give me (1d KGS) 3 handicap stones. However, the fun doesn’t end there. On the table to the right, at some point, we will encounter, with bold percentages, a version with the numbers 83% (this number might change in the future); this is the winning probability of these weights against the best Leela Zero version.
How is that possible? That’s the iteration created by Facebook: ELF. If you wish, you can download its weights directly here. After downloading the files, let’s finally get to the implementation…
There are many possible configurations in Leela’s implementation, but
I will only show here what worked for me — obviously, feel free
to test others
Upon opening Sabaki, go to Engines Manage Engines..., click on Add and name the AI you’re going to implement. Below, you will either type the path to the AI’s executable (.exe) or simply click on the folder symbol and point to the file directly. Next, on the next line, we will need to to provide some specifications for the simulation, besides the path to the text file with the weights (to find the path you can simply click on the path bar from Windows Explorer; but keep in mind that you should avoid paths that use spaces). What worked for me was:
--gtp -w C:\Users\Philippe\Desktop\GoAI\elf_converted_weights.txt -t 2 --noponder --timemanage off
If you have additional GPUs, you can include the command
--gpu 0
or --gpu 1
:
--gtp --gpu 0 --gpu 1 -w C:\Users\Philippe\Desktop\GoAI\elf_converted_weights.txt -t 2 --noponder --timemanage off
Lastly, it is necessary to place the initial commands of the simulation. What I use is simply the time configurations for each move. The second parameter of this command is probably the most important, informing the amount of seconds for each play, therefore; if we wish to make the AI think for only 5 seconds, we will have:
time_settings 0 5 1
Voilà! We now have our first pet AI (maybe two if you’ve also implemented Facebook ELF). To use them, you only need to go to Engines > Attach... and click on the arrows right next to Black and White.
There is still another AI that deserves some attention:
PhoenixGo. At the
beginning of this year, surprisingly, we had a different AI winning
the World AI Go Tournament 2018 PhoenixGo, from
Tencent
The objective of
Go Review Partner
(there is also a
GRP GitHub page) is to automate the AI analysis process. The standard output of the
software is, however, an .rsgf
file and not a
.sgf
file, as usual. The .rsgf
standard was
created to handle files .sgf
files which have a very big
amount of variations, leading to big and almost intractable variation
trees. The GRP itself is able to open them, but, if you want, there
are two alternatives. The first one would be to open them with another
program, MultiGo.rsgf
file to a
.sgf
one through the GRP.
To use the software, you’ll first need to have
Python installed. Pay
attention, though, to the version you’re installing because the more
recent ones will yield errors. Only the 2.7.X versions will work
properly (I use the 2.7.13, for example). If you have Windows, you
only need to download the .msi
file and continue the
installation process normally. If you have another operating system,
installing the TkInter
library is necessary, which can be
achieved through a command like:
sudo apt-get install python python-tk
Next, inside Windows, after downloading one of the
packages
containing an AI, you will only need to open the
GoReviewPartner.exe
file. I warn you, however, that, after several tests, I’ve had
problems with some AIs: some of them were not changing the winning
percentages by more than 1% throughout the whole analysis. I would
suggest starting with the Leela and Leela Zero versions which use no
GPU. If you still have questions and problems related to the GRP, its
creator is available in the Life in 19×19 forum answering comments
inside this
post.
It is possible to test a vast number of AIs with the various software mentioned. For example, we can try to replace the executable inside Lizzie with that of PhoenixGo, along with its weights, to have a new version of Lizzie. Nevertheless, I haven’t had much success with that technique and it seems the reason for the failure is, in fact, my hardware.
On a sidenote, I would like to mention a smartphone app that runs Leela Zero. There are still some imperfections and bugs but it works well in general. The app is called Go Grid Master and has both a free and a paid versions.
Another update is a chinese app that featers AQ and Leela Zero in your phone, try it out.