Running GNU Go on KGS using kgsGtp – or how to play with your own bot

I am now reading Learn to Play Go by Janice Kim i Soo-hyun Jeong. Really nice lecture I must say. However, I was lacking a sparing partner to test some of the concepts presented in the book. This is why I have decided to setup my own, personal Go bot. Note that this tutorial covers macOS only.

——————

What do you need to run your personal Go bot

1. Create a KGS account for your bot: KGS registration
2. Download kgsGtp.jar: download
3. Build GNU Go
4. Prepare ini file
5. Run everything

——————

2. Getting kgsGtp

Make sure to prepare a place for your installation and download kgsGtp

mkdir $HOME/opt/kgs-gpt/3.5.23
cd $HOME/opt/kgs-gpt/3.5.23
curl -O http://files.gokgs.com/javaBin/kgsGtp-3.5.23.tar.gz
tar zxf kgsGtp-3.5.23.tar.gz 
mv kgsGtp-3.5.23/kgsGtp.jar .
rm -rf kgsGtp-3.5.23 kgsGtp-3.5.23.tar.gz

You are almost ready :) Now, to the GNU Go

——————

3. Getting GNU Go

mkdir $HOME/opt/src
cd $HOME/opt/src
curl -O https://ftp.gnu.org/gnu/gnugo/gnugo-3.8.tar.gz
tar zxf gnugo-3.8.tar.gz
cd gnugo-3.8
./configure --prefix=$HOME/opt/usr/local/gnugo/3.8
make
make install

You are now even closer to having your own, personal, GNU Go bot :)

——————

4. Prepare ini file

Make sure to get back to your kgs-gtp location and prepare dedicated ini file.

engine=$HOME/opt/usr/local/gnugo/3.8/bin/gnugo --mode gtp --quiet --cache-size 32
name=this_is_a_user_name_from_step_1
password=this_is_a_password_from_step_1
room=Computer Go
mode=custom
opponent=you_can_put_your_user_name_here
automatch.speed=blitz,medium
automatch.rank=11k
reconnect=true
talk=I'm a computer. Cannot understand English yet.
gameNotes=I can not play :( Waiting for my master.

If you will add opponent settings, your bot will wait for you and will reject games initiated by other users.

——————

5. Running everything

Now, you are really ready to go :)

java -jar kgsGtp.jar config.ini

All that left is to connect to KGS (either via: https://shin.gokgs.com/ or using dedicated client – CGoban 3) and play with your bot. It will wait for you inside Computer Go room. You can always make it wait somewhere else by altering config.ini.

If you want to learn how to customise your bot, simply run kgsGtp.jar with a --help argument like so

> java -jar kgsGtp.jar --help
Usage: gtpClient <properties file> [prop1=val1 [prop2=val2 ...]]
Properties:
  logFile=<file> - Log to file, -nn.log will be appended
  verbose=t|f - Verbose output

  engine=<command> - Execute the command to start the engine and use engine's stdin/stdout to communicate
  gtp.in=<filename> - Read named pipe for data from engine
  gtp.out=<filename> - Write named pipe for data to engine
  engine.port=<port> - Listen at the specified TCP port for connections from the engine

  server.host=<host> - Set host or IP address of KGS
  server.port=<port> - Set TCP port of KGS
  name=<name> - Set user name (required)
  password=<value> - Set password (required)
  room=<room name> - Join this room on startup
  mode=auto - Set up automatch game (default)
    automatch.speed= One or more of blitz,fast,medium - select acceptable speeds for automatch pairing (blitz,fast,medium is default)
    automatch.rank=[30k..1k] - Select estimated rank for automatch pairing (Required if robot is unranked)
  mode=custom - Set up custom open game
    rules=(japanese|chinese|aga|newzealand) - Set rule system to use
    rules.boardSize=<size> - Set board size
    rules.time=<0|m:ss|m:ss+nxm:ss|m:ss+n/m:ss> - Set time system
  mode=tournament - Play in tournament games only
  mode=wait - Wait for opponent to create custom game
    opponent=<name> - Play against this player only
  mode=both - Both automatch and custom open games at the same time
  talk=<text> - Set message we give to anybody who tries to talk to us.
  gameNotes=<text> - Set game notes that appear
  hint.cleanup=<text> - Set notes to opponent about cleanup mode
  hint.noArguing=<text> - Set message to opponent when the game can't be scored
    due to disagreement over dead stones

  -help, -usage - Show this information.