--- gtp2-spec-draft1.tex Fri Jul 12 16:04:48 2002 +++ gtp2-spec-draft2.tex Sat Oct 12 20:39:42 2002 @@ -4,20 +4,20 @@ \begin{document} \begin{titlepage} - \title{Specification of the Go Text Protocol, version 2, draft 1} - \date{July, 2002} + \title{Specification of the Go Text Protocol, version 2, draft 2} + \date{October, 2002} \author{Gunnar Farneb{\"a}ck} \maketitle \vfill \begin{center} - %FIXME: Do URL better. - http://www.lysator.liu.se/${}_{\tilde{}}\,$gunnar/gtp + \texttt{http://www.lysator.liu.se/\raisebox{-3pt}{\~}gunnar/gtp} \end{center} \vfill \begin{center} \textbf{\huge This is a draft only.} \end{center} \vfill + %FIXME: Is GFDL invoked correctly? Permission is granted to make and distribute verbatim or modified copies of this specification provided that the terms of the GNU Free Documentation License (section \ref{sec:gfdl}) are respected. @@ -30,8 +30,16 @@ \section{Introduction} This document gives a specification of the Go Text Protocol (GTP), version 2. + \subsection{Purpose of the Protocol} +The intention of GTP is to provide a flexible and easy to implement +communication protocol for go programs. The main purpose is to allow +two programs to play each other but it is also useful for regression +testing and communication with a GUI or a go server. Most use cases +require an external support program, but this can be shared between +all programs with GTP support. + \subsection{History} The Go Text Protocol was developed within the GNU Go project, initially to create a framework for automated regression testing and @@ -44,8 +52,56 @@ version 2. \subsection{Communication Model} +\label{sec:communication-model} +The protocol is asymmetric and involves two parties, which we call +controller and engine. The controller is typically some kind of +arbiter or relay and the engine is typically a go playing program. All +communication is initiated by the controller in form of commands, to +which the engine responds. + +The communication channel is assumed to be free from errors (i.e.\ +those are handled at a lower level). Examples are UNIX pipes or TCP/IP +connections. The latter can also be established over an error prone +modem connection by using PPP (Point to Point Protocol) as a transport +layer. + \subsection{Typical Use Cases} -\subsection{Terminology} +%FIXME: Better layout? +\begin{enumerate} +\item Regression testing. \\ + controller (regression script) --- engine \\ + The controller sets up a board position and asks the engine to e.g.\ + generate a move. + +\item Human vs program. \\ + controller (GUI) --- engine \\ + The controller relays moves between the human and the engine and + asks the engine to generate moves. + +\item Program vs program with arbiter. \\ + engine 1 --- controller (arbiter) --- engine 2 \\ + The controller relays moves between the two engines and alternately + asks the engines to generate moves. This involves two different GTP + channels, the first between the controller and engine 1, and the + second between the controller and engine 2. There is no direct + communication between the two engines. The controller dictates board + size, komi, etc. + +\item Program vs program without arbiter. \\ + The same as above except that engine 1 includes the controller + functionality and the first GTP link is shortcut. + +\item Connection between go server and program. \\ + go server --- controller (relay) --- engine \\ + The controller talks to a go server using whatever protocol is + needed and listens for match requests. When one arrives it accepts + it, starts the go engine and issues GTP commands to set up board + size, komi, etc.\ and if a game is restarted it also sets up the + position. Then it relays moves between the server and the engine and + asks the engine to generate new moves when it is in turn. +\end{enumerate} + +% \subsection{Terminology} \subsection{Reference Implementation} The reference implementation for GTP version 2 is GNU Go version 3.4. @@ -53,7 +109,7 @@ reference implementation decides the correct behaviour. Notice, however, that any command available in GNU Go 3.4, but not included in this specification (full list in section \ref{sec:commands}), is to be -considered as a private extension (see section +considered a private extension (see section \ref{sec:private-extensions}). Temporary comment: GNU Go 3.4 is currently under development and GTP @@ -247,8 +303,7 @@ \item \textbf{float} \\ A \texttt{float} is a floating point number representable by a 32 - bit IEEE ??? float. Only the "simple" representation is allowed. - (FIXME: rewrite) + bit IEEE 754 float. \item \textbf{string} \\ A \texttt{string} is a sequence of printable, non-whitespace @@ -256,9 +311,9 @@ \item \textbf{vertex} \\ A \texttt{vertex} is a board coordinate consisting of one letter and - one number, or the string ``pass'', as defined in section - \ref{sec:board-coordinates}. Vertices are not case sensitive. - Examples: ``B13'', ``j11''. + one number, as defined in section \ref{sec:board-coordinates}, or + the string ``pass''. Vertices are not case sensitive. Examples: + ``B13'', ``j11''. \item \textbf{color} \\ A \texttt{color} is one of the strings ``white'' or ``w'' to denote @@ -268,7 +323,7 @@ \item \textbf{move} \\ A \texttt{move} is the combination of one \texttt{color} and one \texttt{vertex}, separated by space. Moves are not case sensitive. - Examples: ``white h10'', ``B F5'', ``w pass''. + Examples: ``white~h10'', ``B~F5'', ``w~pass''. \item \textbf{boolean} \\ A \texttt{boolean} is one of the strings ``false'' and ``true''. @@ -330,7 +385,8 @@ \begin{itemize} \item \texttt{id} is an optional \texttt{int} and must be the same - number as in the corresponding command. + number as in the corresponding command. It may be omitted if and + only if it was omitted in the command. \item \texttt{response} is some collection of entities, separated by space or a single LF, the composition of which varies with the command. The response may be empty. @@ -345,16 +401,24 @@ \begin{itemize} \item \texttt{id} is an optional \texttt{int} and must be the same - number as in the corresponding command -\item \texttt{error\_message} is a \texttt{string*}. + number as in the corresponding command. It may be omitted if and + only if it was omitted in the command. +\item \texttt{error\_message} is a \texttt{string*\&}. \end{itemize} \subsection{Standard Error Messages} +\label{sec:standard-error-messages} + +If the engine receives an unknown or unimplemented command, use the +error message ``unknown~command''. Some commands fail in certain cases +with standardized error messages. Those are listed in the command +descriptions in section \ref{sec:list-of-all-commands}. For other +failures the engine can freely choose error message. \newpage \section{Important Concepts} -FIXME: Rename chapter? +%FIXME: Rename chapter? \subsection{Handicap Placement} @@ -430,29 +494,15 @@ With free placement the handicap stones are set as chosen by the controller or by one of the engines (for normal tournament use the engine playing the black stones would make the choice). The smallest -number of handicap stones is 2. The maximum number requires some -discussion. Let the board size be $N$ and thus the number of vertices $N^2$. +number of handicap stones is 2. The highest number is one less the +number of vertices on the board. However, when the number of handicap +stones becomes very high there is no benefit in additional stones. +Therefore, when asked to choose handicap placement, an engine is +allowed to return a smaller number of stones than requested. This +provision should only be used if the requested number of stones is so +high that a smaller number of stones is believed to guarantee that the +engine cannot possibly lose against any opponent. -The theoretical upper limit for the number of handicap stones is $N^2-1$, -but since this would leave all stones in atari, black is clearly better -off with fewer stones. In fact, for sufficiently large (but smaller than -$N^2-1$) handicaps, black can arrange the stones so that white cannot -possibly form a single living group even if black passes for the entire -game. In particular, with $N^2/2$ stones, black can trivially place the -stones in a chessboard pattern so that white does not have a single -legal move. - -With this in mind, we do allow up to $N^2-1$ handicap stones. However, -an engine asked to choose placement of handicap stones is allowed to -place a smaller number of stones than the one requested, if this is -larger than some threshold. To be more precise, let $m$ be the -threshold and $n$ the requested number of handicap stones. If $n>=m$, -the engine must place $m$ handicap stones and if $n