Next: , Previous: The Go Text Protocol, Up: GTP


19.2 Running GNU Go in GTP mode

To start GNU Go in GTP mode, simply invoke it with the option --mode gtp. You will not get a prompt or any other output to start with but GNU Go is silently waiting for GTP commands.

A sample GTP session may look as follows:

     virihaure 462% ./gnugo --mode gtp
     1 boardsize 7
     =1
     
     2 clear_board
     =2
     
     3 play black D5
     =3
     
     4 genmove white
     =4 C3
     
     5 play black C3
     ?5 illegal move
     
     6 play black E3
     =6
     
     7 showboard
     =7
        A B C D E F G
      7 . . . . . . . 7
      6 . . . . . . . 6
      5 . . + X + . . 5
      4 . . . + . . . 4
      3 . . O . X . . 3
      2 . . . . . . . 2     WHITE (O) has captured 0 stones
      1 . . . . . . . 1     BLACK (X) has captured 0 stones
        A B C D E F G
     
     8 quit
     =8
     

Commands are given on a single line, starting by an optional identity number, followed by the command name and its arguments.

If the command is successful, the response starts by an equals sign (`='), followed by the identity number of the command (if any) and then the result. In this example all results were empty strings except for command 4 where the answer was the white move at C3, and command 7 where the result was a diagram of the current board position. The response ends by two consecutive newlines.

Failing commands are signified by a question mark (`?') instead of an equals sign, as in the response to command 5.

The detailed specification of the protocol can be found at http://www.lysator.liu.se/~gunnar/gtp/. The available commands in GNU Go may always be listed using the command list_commands. They are also documented in See GTP command reference.