Next: , Previous: GTP applications, Up: GTP


19.4 The Metamachine

An interesting application of the GTP is the concept of using GNU Go as an “Oracle” that can be consulted by another process. This could be another computer program that asks GNU Go to generate future board positions, then evaluate them.

David Doshay at the University of California at Santa Cruz has done interesting experiments with a parallel engine, known as SlugGo, that is based on GNU Go. These are described in http://lists.gnu.org/archive/html/gnugo-devel/2004-08/msg00060.html.

The “Metamachine” experiment is a more modest approach using the GTP to communicate with a GNU Go process that is used as an oracle. The following scheme is used.

This scheme does not produce a stronger engine, but it is suggestive, and the SlugGo experiment seems to show that a more elaborate scheme along the same lines could produce a stronger engine.

Two implementations are distributed with GNU Go. Both make use of fork and pipe system calls, so they require a Unix-like environment. The Metamachine has been tested under GNU/Linux.

Important: If the Metamachine terminates normally, the GNU Go process will be killed. However there is a danger that something will go wrong. When you are finished running the Metamachine, it is a good idea to run ps -A|grep gnugo or ps -aux|grep gnugo to make sure there are no unterminated processes. (If there are, just kill them.)

19.4.1 The Standalone Metamachine

In interface/gtp_examples/metamachine.c is a standalone implementation of the Metamachine. Compile it with cc -o metamachine metamachine.c and run it. It forks a gnugo process with which it communicates through the GTP, to use as an oracle.

The following scheme is followed:

                  stdin             pipe a
       GTP client ----> Metamachine -----> GNU Go
                  <----             <-----
                 stdout             pipe b

Most commands issued by the client are passed along verbatim to GNU Go by the Metamachine. The exception is gg_genmove, which is intercepted then processed differently, as described above. The client is unaware of this, and only knows that it issued a gg_genmove command and received a reply. Thus to the the Metamachine appears as an ordinary GTP engine.

Usage: no arguments gives normal GTP behavior. metamachine --debug sends diagnostics to stderr.

19.4.2 GNU Go as a Metamachine

Alternatively, you may compile GNU Go with the configure option --enable-metamachine. This causes the file oracle.c to be compiled, which contains the Metamachine code. This has no effect on the engine unless you run GNU Go with the runtime option --metamachine. Thus you must use both the configure and the runtime option to get the Metamachine.

This method is better than the standalone program since you have access to GNU Go's facilities. For example, you can run the Metamachine with CGoban or in Ascii mode this way.

You can get traces by adding the command line -d0x1000000. In debugging the Metamachine, a danger is that any small oversight in designing the program can cause the forked process and the controller to hang, each one waiting for a response from the other. If this seems to happen it is useful to know that you can attach gdb to a running process and find out what it is doing.