Hi,
I met a problem that occurs when using GTP with a GUI.
Sometimes it is necessary to interrupt certain commands like genmove.
For example you could want to have your Go engine search for a move for an unlimited amount of time until you (interactively) stop the search. Similarly, if the time limit for searching a move is set to a high value and you played a wrong move, there is no way to interrupt the engine and undo it, you have to wait until the engine returned from genmove before doing that, which can take a long time.
First I thought I could work around this by making the engine handle a SIGINT for interrupting long searches. GoGui uses this approach and defines a GTP extension command gogui_sigint to query the engine at startup, if it can handle SIGINTs, so that it does not terminate engines, that do not handle SIGINT, accidentally.
However, this approach has 2 drawbacks: - Signals are not very portable. - Does not work, if the engine runs on another computer and GTP is used over socket streams.
So here is my proposal how to extend GTP:
- The allowed characters includes the ascii control character ETX (03). - This character is usually ignored and filtered out of the input stream.
The example implementation gtp.c gets a new function int gtp_interrupt() which can be polled by the Go engine during search. It checks the next character of the input stream for ETX and puts it back, if it is another character.
I know this extension sounds a little ugly, but it is the best solution for the problem I could think of. Any comments or other ideas?
- Markus