GTP implementation

The complete GTP version 2 spec can be found here: GTP 2 spec The server currently works with GTP version 1 but we highly recommend implementing version 2 as support may not be carried forward.

GTP command syntax

GTP uses the US-ANSI character set and is entirely human readable commands (this is very useful for debugging). The commands are parsed with spaces (dec 32) and delimited with either line feed or carriage return, in the case of client responses two consecutive LF or CR is required (I will use \n in all other locations for delimitation). Some servers (GoGUI) are finiky about using exactly 2 \n in the return. More and it will choke. The GTP protocol implemented as a server request client response.

Server requests are formed:

command_name [arguments]\n

Successful Client responses formed:

= result\n\n

Failed Client responses and errors are formed:

? error message\n\n

We currently do not implement id numbers for commands and have no intention of adding them so you do not need to support them for this competition. If you wish to be completely GTP version 2 compliant though please see the official GTP spec page for details.

GTP move syntax

Board intersections are encoded by a letter plus a number. On a 19x19 board the letters go from A to T, excluding I, from the left to the right. The numbers go from 1 to 19, from the bottom to the top. Thus the lower left corner is called A1, the lower right corner T1, the upper left corner A19, and the upper right corner T19. Smaller boards use the obvious subset of these coordinates. Larger boards, up to 25x25, are handled by extending the letters with U to Z as needed. Boards larger than 25x25 are not supported by the protocol.

A B C D E F G H J\n 9 0 X 9\n 8 0 0 X X 8\n 7 + 0 X 7\n 6 0 X X 6\n 5 0 0 0 5\n 4 0 0 4\n 3 + + X 0 3\n 2 X 0 0 2\n 1 X 0 X 1\n ` A B C D E F G H J \n\n`

GTP commands

The minimum commands needed to interface with our server are: name, version, protocol_version, boardsize, komi, clear_board, play, genmove. We also recommend implementing: known_command, list_commands, quit, showboard.

  • name requests the name of your bot: arg (none) - response (string)

name\n = Random Bot\n\n

  • version requests the version of your bot: arg (none) - response (string)

version\n = 1.2\n\n

  • protocol_version requests which protocol you are implementing: arg (none) - response (int)

protocol_version\n = 2\n\n

  • boardsize sets the current boardsize up to 25x25. We only use 19 currently. arg (int) - response (none)

boardsize 19\n = \n\n

  • komi sets the base points for white. This can be ignored unless you track the score. arg (float) - response (none)

komi 5.5\n = \n\n

  • clear_board tells client to clear board typically for starting a new game: arg (none) - response (none)

clearboard\n = \n\n

  • play tells client to play move at given location for given colour. Remove dead stones and update prisoners accordingly. arg (colour, move) - response (none)

play w F7\n = \n\n

  • genmove requests a move from the client for given colour. Along with all valid moves PASS and RESIGN are allowed. arg (colour) - response (move)

genmove b\n = H18\n\n

  • known_command askes if client recognizes given command. Returns 1 if command is known 0 otherwise. arg (string) - response (bool)

known_command showboard\n = 1\n\n

  • list_commands asks for a list of all known commands. arg (none) - response (string, string, …)

list_commands\n = name version protocol_version boardsize komi clear_board play genmove known_command list_commands quit showboard\n\n

  • quit tells program to terminate. Send response before terminating. arg (none) - response (none)

quit\n = \n\n

  • cputime asks program to return the amount of processing time in seconds as an integer or float. arg (none) - response (float or int)

cputime\n = 1.76\n\n

  • game_score is a added command that reports an ended game’s score back to the client for end user purposes. The proper response to the server is nothing. The bot is free to print the score to the console or a log for later viewing. arg (string: game score) - reponse (none)

game_score W+153.5 =\n\n

  • showboard asks program to display board. Upto client to choose how the board is displayed. Can used CR or LF just not two consecutive ones. arg (none) - response (string …)

showboard\n = \n ` A B C D E F G H J\n 9 0 X 9\n 8 0 0 X X 8\n 7 + 0 X 7\n 6 0 X X 6\n 5 0 0 0 5\n 4 0 0 4\n 3 + + X 0 3\n 2 X 0 0 2\n 1 X 0 X 1\n A B C D E F G H J \n\n`