As DeepMind publicized its MuZero at the end of last year, once again I became interested in go AI. After googling for a while, I was aware of an open-source go project called “KataGo”. It was built as a side project by a Jane Street researcher — David Wu. Not only could KataGo compete with other well-known AlphaZero-inspired go projects like Leela Zero and Facebook’s ELF, it could also play well in handicap games, games with variable komi, support sound analysis along with go interface like Sabaki and Lizzie, and be efficiently trained by just a few GPUs.
The following is my steps to install and run KataGo in my MacBook Air with only a built-in integrated GPU (Intel HD Graphics 5000):
- Download go interface Sabaki.
- Open terminal and install package manager Homebrew by following its instructions. (Xcode should be updated to the newest version as well)
- Download katago-v1.8.0-opencl-linux-x64.zip, of course there are other fine-tuned KataGo engines for, for example, Windows and CUDA-enabled GPU which don’t suit my situation.
- It seems the weights/trained neural nets are included in the zip file in step 3, so to me there was no need to again download the weights g170e-b20c256x2-s5303129600-d1228401921.bin.gz I use here: https://github.com/lightvector/KataGo/releases/tag/v1.4.5. (The weights here in KataGo v1.8.0 are not the new distributed version but the older one, just as the weights in v1.4.5, I believe)
- Type
brew install katago
in terminal, and the default location your homebrew would install katago is/usr/local/Cellar/katago/
. Next, typels
and you can find your katago version, which is 1.8.0 to me, and enter the folder. Then under it there are 3 important files you would use later on in Sabaki’s engine-setting interface:/usr/local/Cellar/katago/1.8.0/bin/katago
(The main program)/usr/local/Cellar/katago/1.8.0/share/katago/configs/gtp_example.cfg
(not sure about its functions, perhaps it helps KataGo to support Go Text Protocol)/usr/local/Cellar/katago/1.8.0/share/katago/g170-b20c256x2-s4384473088-d968438914.bin.gz
(The weights you’re going to use, you can use other weights of course). - Open Sabaki and click
File -> Game Info -> downward arrow beside Rank -> Manage Engines...
and open up your engine-setting page:
“Enable GTP logging to directory” means the location you’re gonna store your .sgf (smart game format, the file format for recording go moves) files, so you can choose wherever you want. “(Unnamed Engine)” is whatever name you wanna call this go engine, so I called it “KataGo”. The “Path” under the engine name should be the location of KataGo main program, which is /usr/local/Cellar/katago/1.8.0/bin/katago
. And then, on “No arguments” line we’re gonna input gtp -model /usr/loca/Cellar/katago/1.8.0/share/katago/g170e-b20c256x2-s5303129600-d1228401921.bin.gz -congif /usr/local/Cellar/katago/1.8.0/share/katago/configs/gtp_example.cfg
. Finally, we should type our time setting such as time_settings 0 5 1
in “Initial commands (;-separated)”, I’m not sure what the first and third digit means but the second digit means the number of seconds KataGo could use to think on every move.
7. Until now, everything is basically set to start KataGo! Click Close
on the bottom left corner, downward arrow beside Rank -> Attach Engine -> [name of your engine] -> OK
, and we’ll see the engine is initiated like this:
Test KataGo’s Strength — A Handicap Game
As a 1k player on a defunct go-playing platform called Legend Go Server (LGS) 15 years ago, though I’m not sure what my current strength is, I didn’t think a traditional go AI before AlphaGo could beat me in a 9-stone handicap game. So I played black in a 9-stone handicap game against KataGo, and to my surprise, though it should be quite logical, I lost by a big margin (around 20 points):
Test KataGo’s Strength — A White Mirror Game
I’m always curious that if I play white in a typical 6.5-point komi game against AI, what would happen when I apply mirror strategy? I would be pretty disappointed if KataGo intentionally detects it and counterplays it by placing its stone on the very middle, which is J10, even it’s not a reasonable move. But if KataGo plays some Jōseki to create ladder facing middle zone or even it just plays as usual throughout most of the game but is able to play some brilliant moves around middle to crush my mirror strategy, then I would be pretty amazed. (Here are some examples of Ke Jie, currently one of the world best go players, beat former version of Fine Art, a strong go AI built by Tencent and used officially as a training tool of Chinese professional go players, via mirror games: https://zhuanlan.zhihu.com/p/26239586)
Unfortunately, to my surprise again, KataGo was easily beaten by me in a mirror game. Although I’m not sure whether it is because of my not-good-enough hardware or not (oddly speaking, I’ve not yet seen KataGo change its optimal moves even if I let it think longer and search deeper) though logically speaking I originally thought it would be no different to an AI if it only searches for the “optimal moves”. So in the future I plan to spend some time reading the papers of AlphaGo, AlphaGo Zero, and AlphaZero to try to understand how their policy networks find the so-called “interesting moves” and prevent themselves from wasting time on digging into meaningless moves. Here is the mirror game I played against KataGo:
Future Studies and Further Experiments
I’m interested in a few possible ways to improve my KataGo. One is buying eGPU for my MacBook and another way is using GPUs on Google Cloud Platform (GCP) since everyone could have 300 USD quota on their free trial account, though with limited functionality. Currently I’ve changed my free trial account to standard account, though I haven’t used up my 300-dollar gift, and requested for the usage of NVIDIA A100/K80/P100 GPUs, but until now I still couldn’t successfully use GPUs through GCP. If anyone knows how to solve this problem, I’d be excited to know!
Though people in Zhihu, you can think of it as Chinese Quora, generally think AlphaGo Master (2017’s version of AlphaGo compared to 2016’s AlphaGo Lee) and its future versions (some people said Ke Jie has already tested it against AlphaGo Master) aren’t afraid of white mirror games (black mirror games are meaningless because of komi), I’ve never seen a single game of proof.
Another thing I’m curious about is that whether my KataGo has superhuman strength or not, especially if it is better than AlphaGo Lee. Not quite sure how to test it, but I would download those 5 games’ .sgf files of AlphaGo vs. Lee Sedol to analyze them to see what I could discover.
All in all, the following is the to-do list in the future:
- Apply independent GPUs to reinforce KataGo.
- Wait for the newer weights, the distributed version, of KataGo to replace the current old weights.
- Read AlphaGo serial papers.