Back to

How to run a robot Go player on KGS

For Windows

Copyright © 2005-2016 Hans-Georg Michna.

See also: Learn to play Go 碁



This page has not been maintained for several years and is probably obsolete. Please send me an email when you tried it or when you discover possible improvements.

Instant Bots

If you're not interested in the details and just want to run a couple of bots as quickly as possible on a Windows XP computer, download, unpack the files, and follow the instructions in the read me file.

You will still have to create a KGS account for each bot and edit a few .bat and .ini files, so it's not entirely instantaneous, but you should be able to have some bots running in 5 minutes.

Do not kill a bot while it is playing a game, if you can avoid it.

And please come back to this page later to learn more.


The following description expects that you have some Windows XP experience. For example, if you don't know what a batch file is or how to create one, you may want to enlist the help of a more knowledgeable friend to get your first bot running.

Some help may be available on KGS in Rooms, Social, Computer Go. Just ask there, with luck somebody may answer your question. But please don't overuse this resource. Consider other peoples' time valuable. If you have to ask at every turn, it may be better to give up on this project.

This description assumes that you run Windows XP. On other operating systems the process may be a bit different and may or may not work.

You need an always-on Internet connection like DSL or cable or a very stable (and not too expensive) modem connection to run a KGS Go bot.


Robot Go players, in short, "bots", are machine Go players, running on your computer or any other and opening games, one at a time, playing with humans. KGS makes it simple to run them by providing connector software for Go playing programs.

Bots are just as legitimate Go players as humans are. They follow the rules, and they have their strengths and weaknesses, just like human players.

Some bots are particularly strong in narrow situations, where groups have few liberties. They are often not so strong in situations where life or death is decided early, for example by loose encircling. Human pattern recognition may still be a bit stronger in such situations, but things are changing rapidly as both computer performance and algorithmic knowledge grows.

Bot playing can be boring for stronger players, but it is a challenge for weaker ones. It is possible to play a particular anti-bot style, utilizing the known weaknesses of a particular bot type, but I wouldn't recommend to do that, because it doesn't help against human players, and it may not help with next year's bots.

Bots are quite popular. They are very much in demand and usually in short supply. Be a good person and run one or several on your computer when it is otherwise not fully utilized. On a modern, fast, dual-core computer 5 bots constitute a good, even load. On an older computer you can still run one, two, or three for the benefit of other players, particularly for newbies, who need to establish their rank.


In the following text all words that begin with "my" are examples. Do not use them. Use words of your choosing instead. For example, change myGnuGoBot to the name you want for your bot and myPassword to the secret password with which the bot can log on to KGS.

Watch out for case sensitivity. For example, for Unix/Linux systems and most Java programs, including the ones you're going to use here, boardsize and boardSize are two entirely different things.

Known problems

  1. kgsGtp versions 3.3.12 and later, at least up to 3.3.20, have a bug that makes them babble a debug line, "ACTION IS TO MOVE OR SCORE", over and over while playing. Keep using version 3.3.11. You don't believe that any programmer worth his salt would keep the stupidest possible bug in his program over 10 versions? Check for yourself, if you don't believe me. Apparently programming go software has some pretty bad side effects on the brain.
  2. kgsGtp since early versions prints something like the following every time it begins a custom game: <init>; Starting game as black against ...; WARNING: Opponent has left game. Will give them 5 minutes to return.; Opponent has returned.
  3. kgsGtp doesn't play reliably in auto mode. Sometimes it just doesn't begin to play.
  4. kgsGtp often sees a connection loss between games. Not sure if this causes any further problems or whether this happens when somebody tries to play a game. It seems to be harmless, but is irritating.
  5. When the connection gets interrupted, kgsGtp always waits 5 minutes before trying to reconnect. Obviously kgsGtp should try at least once to reconnect immediately, as some connection losses are brief.

Since I cannot check all of these problems with every new version, please send me an email when you discover that any of these problems has been solved.

Step 1 – Install the Java Runtime Environment

If you use KGS, you already have the Java Runtime Environment. However, the KGS client CGoban runs on version 1.4, but the bot connector requires 1.5 aka version 5 or higher. If you do not have at least JRE 1.5/5 installed, you have to upgrade first. So check your Java version in Control Panel.

If you need the newer version, use the update function of Java or download the latest Java Runtime Environment and install it.

Step 2 – Install the KGS client software

If you don't have it already, download the CGoban client from and install and test it.

You could presumably use the web page Java applet as well, but it is likely better to use the full client.

Step 3 – Download the kgsGtp.jar bot connector

Create a folder for the bot software. In the examples below I will use C:\GnuGoBot. Replace that with your actual folder path. All files mentioned below should go into that folder.

To download the file, rather than running it, right-click on the link, then select Save as ... .

Attention: Version 3.3.12 and, in spite of a software problem report, all versions up to at least 3.3.19 have the same defect that causes it to print a one-line debug message, "ACTION IS TO MOVE OR SCORE", over and over. Right-click here instead: version 3.3.11, or, if a fixed version has appeared, use that. Or tolerate the bad printout, which means that you can't see what's happening, who's playing, etc. The actual playing is OK. Download the broken file anyway to get the topical documentation file.

The normal download site for the latest (so far buggy) software is (the same as for the KGS client). To download, go down to the chapter "GTP client ..." and download kgsGtp.

Unzip the file and put the resulting files into the folder.

You can double-click on the included .xhtml documentation file if you like. If your browser cannot display it with a double-click, rename the file name extension from .xhtml to: .html

But that file is not important at the time being. You can leave it for later.

Step 4 – Download GNU Go


GNU Go is an open source Go playing program with fairly good playing strength, compared to other Go playing programs.

Try to find the latest Windows binary version, for example at You can use the .zip file or, if you have 7z installed, the .7z file.

Unzip the .exe file, put it into the GnuGoBot folder and make sure the filename is: gnugo.exe

On 2007-02-09 the download version was 3.7.10.


The official GNU Go web site is at

Step 5 – Create a batch file to start the bot

Create a new text file and name it: myGnuGoBot.bat

Edit it and insert the following line only:

java -jar kgsGtp.jar myGnuGoBot.ini

Step 6 – Create an ini file

Create an file named myGnuGoBot.ini to set parameters for the bot connector software. This is an example file for kgsGtp version 3.3.11:

engine=gnugo.exe --mode gtp --quiet --cache-size 32
room=Computer Go
talk=I'm a computer. Cannot understand English yet.
gameNotes=Computer program GNU Go

Attention: The options are case sensitive!

Create a new text file, copy the text above into it, and save the file as: myGnuGoBot.ini

An example myGnuGoBot.ini file for a bot that plays automatch games is this:

engine=gnugo.exe --mode gtp --quiet --cache-size 32
room=Computer Go
talk=I'm a computer. Cannot understand English yet.
gameNotes=Computer program GNU Go

You can leave a superset of both sets of commands in the same file. Depending on the mode setting, the settings for the other mode are ignored.

Automatch seems to have a defect, which leads to the bot sometimes entering a game but not playing. If the opponent stays in the game, the bot loses, because the playing time expires.

Step 7 – Create a KGS account for the bot

  1. Start the KGS client software and log on to KGS with the user name myGnuGoBot, but without password, then click on the Guest button. If a user with that name already exists, try another name.
  2. Click on the command User, Register, fill in the form, particularly your email address, and click on the OK button.
  3. Log off from KGS.
  4. Wait for the email from KGS with your password.
  5. Optional: Log on to KGS as myGnuGoBot, this time by entering the bot's name and the new password.
  6. Change the password to: myPassword
  7. Enter additional information, particularly your email address. Describe the bot system briefly in the notes, so other players can learn what kind of bot this is.
  8. Click on the OK button.
  9. Log off from KGS.

Step 8 – Start and test the bot

Log on to KGS with your own user name. Go into the Social, Computer Go room.

In Windows Explorer double-click on the myGnuGoBot.bat file and check whether the bot starts and enters the Computer Go room.

Watch your baby. Does it play properly? Does it finish the game properly? Does it become available after the first game and play the next one?

If anything is wrong with the bot, stop it and fix it first. Don't let a faulty bot run.

Step 9 – Stop the bot

It is not a good idea to stop the bot in the middle of a game. You should wait until the game ends.

  Sleep(4000) ; Check every x ms. 8000 was tested and was too long.

  ; Disable user keyboard and mouse:
  If @OSVersion <> "WIN_98" And @OSVersion <> "WIN_ME" Then BlockInput(1)

  $PreviouslyActiveWindow = WinGetHandle("")

  AutoItSetOption("WinTitleMatchMode", 4)
  $Window = WinList("classname=ConsoleWindowClass")
  AutoItSetOption("WinTitleMatchMode", 1)

  $kgsGtpBots = 0 ; Count number of running bots.
  ; Activate each bot window and check for game end string:

  For $i = 1 To $Window[0][0]
    WinActivate($Window[$i][1]); Window handle
    Send("{ESC}! {DOWN 6}{RIGHT}{DOWN 3}{ENTER 2}")
    $WindowText = ClipGet()
    If StringInStr($WindowText, ".gtp.") Then ; kgsGtp bot found.
      If StringInStr(StringRight($WindowText, 99), "Game ended.") Then
        WinKill($Window[$i][1]); Window handle
        $kgsGtpBots += 1 ; kgsGtpBot found and not killed.
  Next; $i
  BlockInput(0) ; Re-enable user keyboard and mouse.
Until $kgsGtpBots = 0

Unfortunately there is no elegant way to tell the bot to stop after the current game. You either have to watch the game or the bot window, like a snake watches a rabbit, or you can use a little helper program, kgsGtpBotStopper.exe (version 2006-11-24, 183 KB), which I wrote in AutoIt.

Hint: You can make the bot windows very small (but don't minimize them)if at least you want to see more other things on your screen. The bot stopper still works that way.

The program was a very quick and dirty little job and a first attempt, so don't expect too much of it. Every few seconds it has to look at all bot windows, give each one the focus and copy its text to look for the game end message. When it sees the message at the bottom, it kills the bot and then, after the last bot has been killed, it kills itself.

This means, unfortunately, that you can't do any significant work on the computer while this program runs, because it will temporarily block your input and change window focus every few seconds. If you have to use the computer, you can stop the stopper by right-clicking on its system tray (System Notification Area, usually in the lower right, in the taskbar) and tell it to exit. Then the bots keep running, but at least you can do something on your computer, and you can restart the bot stopper at any time later again.

You cannot start it through Remote Desktop and then log out or minimize its window, because it needs the open user interface window. On your local computer you essentially have to start it, then go away and do something else while remaining logged on.

All known limitations in short:

Since this program is so new and hasn't been widely tested, I am grateful for any report about its success or failure. Please send me a brief email about your experience, good or bad.

I understand that a better procedure for stopping bots is being discussed for a future release of kgsGtp, but that's been so for a long time, so don't hold your breath.

Information for programmers: A better way to control a bot may be to execute it and hook into its stdout, watching for the game ending message. One possible way would be a web page with Javascript or VBScript code that starts bots, hooks into their stdout and displays stdout on the web page, so the user can still see the output. When the user clicks a button, the program should wait for the game end message and kill each bot when the game end message appears. I haven't got around to program that yet. If anybody does this, please let me know.

Start options

Low priority

If you are absolutely certain that no other tasks hog all processor cores in your computer for longer than a few seconds, you can start GNU Go in low priority, thus:

start "myGnuGoBot" /belownormal java -jar kgsGtp.jar myGnuGoBot.ini

The first parameter, "myGnuGoBot", is not essential and can be left out as well. It only puts the name of the bot in the title bar of its command line window. This helps to distinguish bots if you run more than one.

Multiple bots on one computer

On a 2 GHz or faster processor you can have two bots running at the same time, or even three, but with the increasing number of bots their playing speed varies a lot, because  at some times all three are thinking at the same time, lowering their speed to 1/3. On a dual core processor things are much more relaxed. 5 bots are no problem at all, because the phases when all 5 are thinking at the same time are quite rare. You could probably run 6, if you wanted to push it.

If you want an extra start file to start several bots with one double-click of the mouse, you can use a line like this (write all into one line of a batch file):

for %%a in (myGnuGoBot1 myGnuGoBot2 myGnuGoBot3) do start /min %%a

This requires that you have a .bat and an .ini files for each of the bots.

If you want to make sure the bots are started exactly in sequence, you have to wait a few seconds after starting each bot, thus (write all into one line of a batch file):

for %%a in (myGnuGoBot1 myGnuGoBot2 myGnuGoBot3) do sleep 2 & start /min %%a

This requires that you have a program named sleep.exe that waits a few seconds.

Bot tuning

The engine line in the ini file contains the GNU Go switch --cache-size 32. I don't know whether this is a good choice, but I think that a larger cache can't hurt. Since the default is --cache-size 8, I would think that much larger cache sizes are useless, but I don't know.

I have also experimented with the --level switch and have increased it up to --level 16. I don't think you can go higher than 16, because at this level GNU Go can already think about a single move for several minutes if the situation on the board is complex. I believe that at --level 17 or higher GNU Go will begin to lose games by running out of time even if it has a very fast processor all to itself. For slower processors don't even try --level 16.

Another phenomenon is that at these higher levels GNU Go may get a lower rank on KGS, even though it plays more strongly. The cause of this is not known. My guess is, if GNU Go sees that it could defeat a move, it will not play that move, even though the move might work against a weaker opponent. In other words, GNU Go never hopes that its opponent makes a mistake. So at a higher --level setting GNU Go will no longer try moves that it would more ignorantly play at, say, the default --level 10, and get through with them against weaker opponents.

My general recommendation is to leave out the --level switch and let GNU Go play at its default --level 10. This will put much less load on your computer, so you can run three bots on a single reasonably fast computer at the same time, and will create a nicer playing experience for its human opponents, faster play, for example.

GNU Go's best playing time seems to be around 10 to 15 minutes, depending on the speed of your processor. 5 times 15 seconds byoyomi is also sufficient, but don't go below that if your computer runs two or three bots or other tasks at the same time, because of the varying calculation times. With only a single bot on an otherwise empty computer you could go lower, but that can be quite unpleasant for the human opponent, because GNU Go often plays end games extremely fast, a move in a split second.

Additional information

A documentation for the older kgsGtp 3.3.8 options is available here:

If you plan to run your bot for longer than just a few days, you can tell the KGS administrators at the name of your bot and ask them to set it to ranked. If you use kgsGtp, then they have the means to allow or deny it, because kgsGtp contains discriminating code. (If you used a KGS interface not controlled by KGS, then KGS could not know whether the player is a bot or a human.) In spite of computers being legitimate Go players and very popular opponents with a stable strength, their decision to allow or deny them to be ranked remains arbitrary. In early 2007 they tended to discriminate against computers. Perhaps some of them find it too humiliating to see computers labelled with a higher strength than themselves.

Give your bot a nice picture. Stop it, log on manually as the bot, and upload a JPG picture of max. 141 x 200 pixels and max. 7 KB. (These were the limitations in early 2007.)

Neither GNU Go nor kgsGtp are entirely reliable. They sometimes stop because of an internal error or they crash or hang. You have to look after your baby from time to time, perhaps once a day, to make sure everything is still running.

If you find any mistakes or omissions or if you have any proposals for the improvement of this page, please send me an email.

Happy bot playing—Hans-Georg

Back to


hits since 2007-11-01
Free PHP scripts by

Map Visitors
Visitor locations since 2006-12-04