cleaned up old CVS left overs
[xboard.git] / engine-intf.html
1 <html>\r
2 <head>\r
3 <title>Chess Engine Communication Protocol</title>\r
4 </head>\r
5 \r
6 <body>\r
7 <hr noshade size="2">\r
8 <h1>Chess Engine Communication Protocol</h1>\r
9 <h1><font color=green>Discussion Proposal</font></h1>\r
10 <h2><a href="http://www.tim-mann.org/">Tim Mann</a> &amp; <a href="http://home.hccnet.nl/h.g.muller/winboardF.html">H.G.Muller</a></h2>\r
11 <p>\r
12 Version 2; implemented in xboard/WinBoard 4.2.1 and later.<br>\r
13 Changes since version 1 are indicated in <font color=red>red</font>.<br>\r
14 Changes for WinBoard 4.3.xx are indicated in <font color=green>green</font>.<br>\r
15 Proposed changes, implemented only in alpha versions are indicated in <font color=blue>blue</font>.\r
16 <hr noshade size="2">\r
17 \r
18 <ul>\r
19 <li><a href="#1">1. Introduction</a>\r
20 <li><a href="#2">2. Connection</a>\r
21 <li><a href="#3">3. Debugging</a>\r
22 <li><a href="#4">4. How it got this way</a>\r
23 <li><a href="#5">5. WinBoard requires Win32 engines</a>\r
24 <li><a href="#6">6. Hints on input/output</a>\r
25 <li><a href="#7">7. Signals</a>\r
26 <li><a href="#8">8. Commands from xboard to the engine</a>\r
27 <li><a href="#9">9. Commands from the engine to xboard</a>\r
28 <li><a href="#10">10. Thinking Output</a>\r
29 <li><a href="#11">11. Time control</a>\r
30 <li><a href="#12">12. Analyze Mode</a>\r
31 <li><a href="#13">13. Idioms and backward compatibility features</a>\r
32 </ul>\r
33 \r
34 <hr noshade size="2">\r
35 \r
36 <h2><a name="1">1. Introduction</a></h2>\r
37 \r
38 <p>\r
39 This document is a set of rough notes on the protocol that xboard and\r
40 WinBoard use to communicate with gnuchessx and other chess engines.\r
41 These notes may be useful if you want to connect a different chess\r
42 engine to xboard.  Throughout the notes, "xboard" means both xboard\r
43 and WinBoard except where they are specifically contrasted.\r
44 </p>\r
45 \r
46 <p>\r
47 There are two reasons I can imagine someone wanting to do this: \r
48 </p>\r
49 <ol>\r
50 <li>You have, or are developing, a chess engine but you don't want to\r
51 write your own graphical interface. \r
52 <li>You have, or are developing,a chess engine, and you want to\r
53 interface it to the Internet Chess Server.\r
54 </ol>\r
55 \r
56 <p>\r
57 In case (2), if you are using xboard, you will need to configure the\r
58 "Zippy" code into it, but WinBoard includes this code already.  See\r
59 the file <a\r
60 href="http://www.tim-mann.org/xboard/zippy.README">zippy.README</a>\r
61 in the xboard or WinBoard distribution for more information.\r
62 \r
63 </p>\r
64 \r
65 <p>\r
66 These notes are unpolished, but I've attempted to make them complete\r
67 in this release.  If you notice any errors, omissions, or misleading\r
68 statements, let me know.\r
69 </p>\r
70 \r
71 <p>\r
72 I'd like to hear from everyone who is trying to interface their own\r
73 chess engine to xboard/WinBoard. Please join the mailing list for \r
74 authors of xboard/WinBoard compatible chess engines and post a message \r
75 about what you're doing. The list is now hosted by Yahoo Groups; you \r
76 can join at <a href="http://groups.yahoo.com/group/chess-engines" \r
77 >http://groups.yahoo.com/group/chess-engines</a>, or you can read the\r
78 list there without joining.  The list is filtered to prevent spam.\r
79 </p>\r
80 <p>\r
81 <font color=green>\r
82 Note that the WinBoard 4.3.xx line was developed independently of the\r
83 original GNU project, by H.G.Muller.\r
84 If you have questions about WinBoard 4.3.xx, or want to report bugs in it,\r
85 report them in the appropriate section of the \r
86 <a href="http://www.open-aurec.com/wbforum/">WinBoard forum</a>.\r
87 </font>\r
88 </p>\r
89 \r
90 <h2><a name="2">2. Connection</a></h2>\r
91 \r
92 <p>\r
93 An xboard chess engine runs as a separate process from xboard itself,\r
94 connected to xboard through a pair of anonymous pipes.  The engine\r
95 does not have to do anything special to set up these pipes.  xboard\r
96 sets up the pipes itself and starts the engine with one pipe as its\r
97 standard input and the other as its standard output.  The engine then\r
98 reads commands from its standard input and writes responses to its\r
99 standard output.  This is, unfortunately, a little more complicated to\r
100 do right than it sounds; see <a href="#6">section 6</a> below.\r
101 </p>\r
102 \r
103 <p>\r
104 And yes, contrary to some people's expectations, exactly the same\r
105 thing is true for WinBoard.  Pipes and standard input/output are\r
106 implemented in Win32 and work fine.  You don't have to use DDE, COM,\r
107 DLLs, BSOD, or any of the other infinite complexity that\r
108 Microsoft has created just to talk between two programs.  A WinBoard\r
109 chess engine is a Win32 console program that simply reads from its\r
110 standard input and writes to its standard output.  See sections \r
111 <a href="#5">5</a> and <a href="#6">6</a> below for additional details.\r
112 </p>\r
113 \r
114 <h2><a name="3">3. Debugging</a></h2>\r
115 \r
116 <p>\r
117 To diagnose problems in your engine's interaction with xboard, use the\r
118 -debug flag on xboard's command line to see the messages that are\r
119 being exchanged.  In WinBoard, these messages are written to the file\r
120 WinBoard.debug instead of going to the screen.\r
121 </p>\r
122 \r
123 <p>\r
124 You can turn debug mode on or off while WinBoard is running by\r
125 pressing Ctrl+Alt+F12.  You can turn debug mode on or off while xboard\r
126 is running by binding DebugProc to a shortcut key (and pressing the\r
127 key!); see the instructions on shortcut keys in the xboard man page.\r
128 </p>\r
129 \r
130 <p>\r
131 While your engine is running under xboard/WinBoard, you can send a\r
132 command directly to the engine by pressing Shift+1 (xboard) or Alt+1\r
133 (WinBoard 4.0.3 and later).  This brings up a dialog that you can type\r
134 your command into.  Press Shift+2 (Alt+2) instead to send to the\r
135 second chess engine in Two Machines mode.  On WinBoard 4.0.2 and earlier,\r
136 Ctrl+Alt is used in place of Alt; this had to be changed due to a conflict\r
137 with typing the @-sign on some European keyboards.\r
138 </p>\r
139 \r
140 <h2><a name="4">4. How it got this way</a></h2>\r
141 \r
142 <p>\r
143 Originally, xboard was just trying to talk to the existing\r
144 command-line interface of GNU Chess 3.1+ and 4, which was designed\r
145 for people to type commands to.  So the communication protocol is very\r
146 ad-hoc.  It might have been good to redesign it early on, but because\r
147 xboard and GNU Chess are separate programs, I didn't want to force\r
148 people to upgrade them together to versions that matched.  I\r
149 particularly wanted to keep new versions of xboard working with old\r
150 versions of GNU Chess, to make it easier to compare the play of old\r
151 and new gnuchess versions.  I didn't foresee the need for a clean\r
152 protocol to be used with other chess engines in the future.\r
153 </p>\r
154 \r
155 <p>\r
156 Circumstances have changed over the years, and now there are many more\r
157 engines that work with xboard.  I've had to make the protocol\r
158 description more precise, I've added some features that GNU Chess\r
159 does not support, and I've specified the standard semantics of a few\r
160 features to be slightly different from what GNU Chess 4 does.\r
161 </p>\r
162 \r
163 <p>\r
164 <font color=red>\r
165 This release of the protocol specification is the first to carry a\r
166 version number of its own -- version 2.  Previous releases simply\r
167 carried a last-modified date and were loosely tied to specific \r
168 releases of xboard and WinBoard.  The version number "1" applies\r
169 generally to all those older versions of the protocol.\r
170 </font>\r
171 \r
172 <font color=red>\r
173 <p>Protocol version 2 remains compatible with older engines but has\r
174 several new capabilities.  In particular, it adds the \r
175 "feature" command, a new mechanism for making backward-compatible\r
176 changes and extensions to the protocol.  Engines that do not support a\r
177 particular new feature do not have to use it; new features are not\r
178 enabled unless the engine specifically requests them using the feature\r
179 command.  If an engine does not send the feature command at all, the\r
180 protocol behavior is nearly identical to version 1.  Several new\r
181 features can be selected by the feature command in version 2,\r
182 including the "ping" command (recommended for all engines), the\r
183 "setboard" command, and many optional parameters.  Additional features\r
184 will probably be added in future versions.\r
185 </p>\r
186 \r
187 <p>\r
188 <font color=green>\r
189 If it is necessary to have a separate name, \r
190 it would be best to refer to the protocol including the green additions as version 2f.\r
191 I really don't think it is a different protocol from version 2, though.\r
192 I just tried to clarify some ambiguities in the original definition,\r
193 now that the WinBoard 4.3.xx line has implemented them in a specific way.\r
194 The hand-shaking protocol for features as defined in protocol 2 perfectly\r
195 allows addition of an occasional new features without any need for stepping up the protocol version number,\r
196 and I think refraining from the latter would enormously lower the barrier for actual\r
197 implementation of these features in engines.\r
198 <br>\r
199 The two really new things are the engine debug comments, and the "nps" command.\r
200 The former merely tries to regulate an extremely common existing pactice \r
201 of having engines dump debug messages on WinBoard in an unprotected way, \r
202 as usually you get away with that.\r
203 </font>\r
204 \r
205 </font>\r
206 \r
207 <h2><a name="5">5. WinBoard requires Win32 engines</a></h2>\r
208 \r
209 <p>\r
210 Due to some Microsoft brain damage that I don't understand, WinBoard\r
211 does not work with chess engines that were compiled to use a DOS\r
212 extender for 32-bit addressing.  (Probably not with 16-bit DOS or\r
213 Windows programs either.)  WinBoard works only with engines that are\r
214 compiled for the Win32 API.  You can get a free compiler that targets\r
215 the Win32 API from <a href="http://sources.redhat.com/cygwin/"\r
216 >http://sources.redhat.com/cygwin/</a>.  I think DJGPP 2.x should also\r
217 work if you use the RSXNTDJ extension, but I haven't tried it.  Of\r
218 course, Microsoft Visual C++ will work.  Most likely the other\r
219 commercial products that support Win32 will work too (Borland, etc.),\r
220 but I have not tried them.  Delphi has been successfully used to write\r
221 engines for WinBoard; if you want to do this, Tony Werten has donated\r
222 some <a href="http://www.tim-mann.org/winboard/delphi.txt" >sample\r
223 code</a> that should help you get started.\r
224 </p>\r
225 \r
226 <h2><a name="6">6. Hints on input/output</a></h2>\r
227 \r
228 <p>\r
229 Beware of using buffered I/O in your chess engine.  The C stdio\r
230 library, C++ streams, and the I/O packages in most other languages use\r
231 buffering both on input and output.  That means two things.  First,\r
232 when your engine tries to write some characters to xboard, the library\r
233 stashes them in an internal buffer and does not actually write them to\r
234 the pipe connected to xboard until either the buffer fills up or you\r
235 call a special library routine asking for it to be flushed.  (In C\r
236 stdio, this routine is named <tt>fflush</tt>.)  Second, when your engine tries\r
237 to read some characters from xboard, the library does not read just\r
238 the characters you asked for -- it reads all the characters that are\r
239 currently available (up to some limit) and stashes any characters you\r
240 are not yet ready for in an internal buffer.  The next time you ask to\r
241 read, you get the characters from the buffer (if any) before the\r
242 library tries to read more data from the actual pipe.\r
243 </p>\r
244 \r
245 <p>\r
246 Why does this cause problems?  First, on the output side, remember\r
247 that your engine produces output in small quantities (say, a few\r
248 characters for a move, or a line or two giving the current analysis),\r
249 and that data always needs to be delivered to xboard/WinBoard for\r
250 display immediately.  If you use buffered output, the data you print\r
251 will sit in a buffer in your own address space instead of being\r
252 delivered.\r
253 </p>\r
254 \r
255 <p>\r
256 You can usually fix the output buffering problem by asking for the\r
257 buffering to be turned off.  In C stdio, you do this by calling\r
258 <tt>setbuf(stdout, NULL)</tt>.  A more laborious and error-prone\r
259 method is to carefully call <tt>fflush(stdout)</tt> after every line\r
260 you output; I don't recommend this.  In C++, you can try\r
261 <tt>cout.setf(ios::unitbuf)</tt>, which is documented in current\r
262 editions of "The C++ Programming Language," but not older ones.\r
263 Another C++ method that might work is\r
264 <tt>cout.rdbuf()-&gt;setbuf(NULL, 0)</tt>.  Alternatively, you can\r
265 carefully call <tt>cout.flush()</tt> after every line you output;\r
266 again, I don't recommend this.\r
267 </p>\r
268 \r
269 <p>\r
270 Another way to fix the problem is to use unbuffered operating system\r
271 calls to write directly to the file descriptor for standard output.\r
272 On Unix, this means <tt>write(1, ...)</tt> -- see the man page for write(2).\r
273 On Win32, you can use either the Unix-like <tt>_write(1, ...)</tt> or Win32\r
274 native routines like <tt>WriteFile</tt>.\r
275 </p>\r
276 \r
277 <p>\r
278 Second, on the input side, you are likely to want to poll during your\r
279 search and stop it if new input has come in.  If you implement\r
280 pondering, you'll need this so that pondering stops when the user\r
281 makes a move.  You should also poll during normal thinking on your\r
282 move, so that you can implement the "?" (move now) command, and so\r
283 that you can respond promptly to a "result", "force", or "quit"\r
284 command if xboard wants to end the game or terminate your engine.\r
285 Buffered input makes polling more complicated -- when you poll, you\r
286 must stop your search if there are <em>either</em> characters in the buffer\r
287 <em>or</em> characters available from the underlying file descriptor.\r
288 </p>\r
289 \r
290 <p>\r
291 The most direct way to fix this problem is to use unbuffered operating\r
292 system calls to read (and poll) the underlying file descriptor\r
293 directly.  On Unix, use <tt>read(0, ...)</tt> to read from standard input, and\r
294 use <tt>select()</tt> to poll it.  See the man pages read(2) and select(2).\r
295 (Don't follow the example of GNU Chess 4 and use the FIONREAD ioctl to\r
296 poll for input.  It is not very portable; that is, it does not exist\r
297 on all versions of Unix, and is broken on some that do have it.)  On\r
298 Win32, you can use either the Unix-like <tt>_read(0, ...)</tt> or the native\r
299 Win32 <tt>ReadFile()</tt> to read.  Unfortunately, under Win32, the function to\r
300 use for polling is different depending on whether the input device is\r
301 a pipe, a console, or something else.  (More Microsoft brain damage\r
302 here -- did they never hear of device independence?)  For pipes, you\r
303 can use <tt>PeekNamedPipe</tt> to poll (even when the pipe is unnamed).\r
304 For consoles, \r
305 you can use <tt>GetNumberOfConsoleInputEvents</tt>.  For sockets only, you can\r
306 use <tt>select()</tt>.  It might be possible to use\r
307 <tt>WaitForSingleObject</tt> more \r
308 generally, but I have not tried it.  Some code to do these things can\r
309 be found in Crafty's utility.c, but I don't guarantee that it's all\r
310 correct or optimal.\r
311 </p>\r
312 \r
313 <p>\r
314 A second way to fix the problem might be to ask your I/O library not\r
315 to buffer on input.  It should then be safe to poll the underlying\r
316 file descriptor as described above.  With C, you can try calling\r
317 <tt>setbuf(stdin, NULL)</tt>.  However, I have never tried this.  Also, there\r
318 could be problems if you use <tt>scanf()</tt>, at least with certain patterns,\r
319 because <tt>scanf()</tt> sometimes needs to read one extra character and "push\r
320 it back" into the buffer; hence, there is a one-character pushback\r
321 buffer even if you asked for stdio to be unbuffered.  With C++, you\r
322 can try <tt>cin.rdbuf()-&gt;setbuf(NULL, 0)</tt>, but again, I have never tried\r
323 this.\r
324 </p>\r
325 \r
326 <p>\r
327 A third way to fix the problem is to check whether there are\r
328 characters in the buffer whenever you poll.  C I/O libraries generally\r
329 do not provide any portable way to do this.  Under C++, you can use\r
330 <tt>cin.rdbuf()-&gt;in_avail()</tt>.  This method has been reported to\r
331 work with \r
332 EXchess.  Remember that if there are no characters in the buffer, you\r
333 still have to poll the underlying file descriptor too, using the\r
334 method described above.\r
335 </p>\r
336 \r
337 <p>\r
338 A fourth way to fix the problem is to use a separate thread to read\r
339 from stdin.  This way works well if you are familiar with thread\r
340 programming.  This thread can be blocked waiting for input to come in\r
341 at all times, while the main thread of your engine does its thinking.\r
342 When input arrives, you have the thread put the input into a buffer\r
343 and set a flag in a global variable.  Your search routine then\r
344 periodically tests the global variable to see if there is input to\r
345 process, and stops if there is.  WinBoard and my Win32 ports of ICC\r
346 timestamp and FICS timeseal use threads to handle multiple input\r
347 sources.\r
348 </p>\r
349 \r
350 <h2><a name="7">7. Signals</a></h2>\r
351 \r
352 <p>Engines that run on Unix need to be concerned with two Unix\r
353 signals: <tt>SIGTERM</tt> and <tt>SIGINT</tt>.  This applies both to\r
354 engines that run under xboard and (the unusual case of) engines that\r
355 WinBoard remotely runs on a Unix host using the -firstHost or\r
356 -secondHost feature.  It does not apply to engines that run on\r
357 Windows, because Windows does not have Unix-style signals.\r
358 <font color=red>\r
359 Beginning with version 2, you can now turn off the use of\r
360 either or both\r
361 signals.  See the "feature" command in <a href="#6">section 9</a> below.\r
362 </font>\r
363 </p>\r
364 \r
365 <p>First, when an engine is sent the "quit" command, it is also given\r
366 a <tt>SIGTERM</tt> signal shortly afterward to make sure it goes away.\r
367 If your engine reliably responds to "quit", and the signal causes\r
368 problems for you, you should either ignore it by calling\r
369 <tt>signal(SIGTERM, SIG_IGN)</tt> at the start of your program,\r
370 or disable it with the "feature" command.</p>\r
371 \r
372 <p>Second, xboard will send an interrupt signal (<tt>SIGINT</tt>) at\r
373 certain times when it believes the engine may not be listening to user\r
374 input (thinking or pondering).  WinBoard currently does this only when\r
375 the engine is running remotely using the -firstHost or -secondHost\r
376 feature, not when it is running locally.  You probably need to know\r
377 only enough about this grungy feature to keep it from getting in your\r
378 way.\r
379 </p>\r
380 \r
381 <p>\r
382 The <tt>SIGINT</tt>s are basically tailored to the needs of GNU Chess 4\r
383 on systems where its input polling code is broken or disabled.\r
384 Because they work in a rather peculiar way, it is recommended that you\r
385 either ignore <tt>SIGINT</tt> by having your engine call\r
386 <tt>signal(SIGINT, SIG_IGN)</tt>, or disable it with the "feature"\r
387 command.</p>\r
388 \r
389 <p>\r
390 Here are details for the curious.  If xboard needs to send a command\r
391 when it is the chess engine's move (such as before the "?" command), \r
392 it sends a <tt>SIGINT</tt> first.  If xboard needs to send commands when it is\r
393 not the chess engine's move, but the chess engine may be pondering\r
394 (thinking on its opponent's time) or analyzing (analysis or analyze\r
395 file mode), xboard sends a <tt>SIGINT</tt> before the first such command only.\r
396 Another <tt>SIGINT</tt> is not sent until another move is made, even if xboard\r
397 issues more commands.  This behavior is necessary for GNU Chess 4.  The\r
398 first <tt>SIGINT</tt> stops it from pondering until the next move, but on some\r
399 systems, GNU Chess 4 will die if it receives a <tt>SIGINT</tt> when not \r
400 actually thinking or pondering.\r
401 </p>\r
402 \r
403 <p>\r
404 There are two reasons why WinBoard does not send the Win32 equivalent\r
405 of <tt>SIGINT</tt> (which is called <tt>CTRL_C_EVENT</tt>) to local\r
406 engines.  First, the Win32 GNU Chess 4 port does not need it.  Second, I\r
407 could not find a way to get it to work.  Win32 seems to be designed\r
408 under the assumption that only console applications, not windowed\r
409 applications, would ever want to send a <tt>CTRL_C_EVENT</tt>.\r
410 </p>\r
411 \r
412 <h2><a name="8">8. Commands from xboard to the engine</a></h2>\r
413 \r
414 <p>\r
415 All commands from xboard to the engine end with a newline (\n), even\r
416 where that is not explicitly stated.  All your output to xboard must\r
417 be in complete lines; any form of prompt or partial line will cause\r
418 problems.\r
419 </p>\r
420 \r
421 <p>\r
422 At the beginning of each game, xboard sends an initialization string.\r
423 This is currently "new\nrandom\n" unless the user changes it with the\r
424 initString or secondInitString option.\r
425 </p>\r
426 \r
427 <p>\r
428 xboard normally reuses the same chess engine process for multiple\r
429 games.  At the end of a game, xboard will send the "force" command\r
430 (see below) to make sure your engine stops thinking about the current\r
431 position.  It will later send the initString again to start a new\r
432 game.  If your engine can't play multiple games, you can disable reuse\r
433 <font color=red>\r
434 either with the "feature" command (beginning in protocol version\r
435 2; see below) or \r
436 </font>\r
437 with xboard's -xreuse (or -xreuse2) command line\r
438 option.  xboard will then ask the process to quit after each game and\r
439 start a new process for the next game.\r
440 </p>\r
441 \r
442 <dl>\r
443 <dt><strong>xboard</strong>\r
444 <dd>This command will be sent once immediately after your engine\r
445 process is started.  You can use it to put your engine into "xboard\r
446 mode" if that is needed.  If your engine prints a prompt to ask for\r
447 user input, you must turn off the prompt and output a newline when the\r
448 "xboard" command comes in.\r
449 <p>\r
450 \r
451 <dt><font color=red><strong>protover N</strong></font>\r
452 <dd><font color=red>\r
453 Beginning in protocol version 2 (in which N=2), this command will\r
454 be sent immediately after the "xboard" command.  If you receive some\r
455 other command immediately after "xboard" (such as "new"), you can\r
456 assume that protocol version 1 is in use.  The "protover" command is\r
457 the only new command that xboard always sends in version 2.  All other\r
458 new commands to the engine are sent only if the engine first enables\r
459 them with the "feature" command.  Protocol versions will always be\r
460 simple integers so that they can easily be compared.\r
461 \r
462 <p>Your engine should reply to the protover command by sending the\r
463 "feature" command (see below) with the list of non-default feature\r
464 settings that you require, if any.\r
465 \r
466 <p>Your engine should never refuse to run due to receiving a higher\r
467 protocol version number than it is expecting!  New protocol versions\r
468 will always be compatible with older ones by default; the larger\r
469 version number is simply a hint that additional "feature" command\r
470 options added in later protocol versions may be accepted.\r
471 </font>\r
472 <p>\r
473 \r
474 <dt><font color=red><strong>accepted</strong></font>\r
475 <dt><font color=red><strong>rejected</strong></font>\r
476 <dd><font color=red>\r
477 These commands may be sent to your engine in reply to the "feature"\r
478 command; see its documentation below.\r
479 </font>\r
480 <p>\r
481 \r
482 <dt><strong>new</strong>\r
483 <dd>Reset the board to the standard chess starting position.  Set\r
484 White on move.  Leave force mode and set the engine to play Black.\r
485 Associate the engine's clock with Black and the opponent's clock with\r
486 White.  Reset clocks and time controls to the start of a new game.\r
487 Use wall clock for time measurement.\r
488 Stop clocks.  Do not ponder on this move, even if pondering is on.\r
489 Remove any search depth limit previously set by the sd command.\r
490 <p>\r
491 \r
492 <dt><strong>variant VARNAME</strong>\r
493 <dd>If the game is not standard chess, but a variant, this command is\r
494 sent after "new" and before the first move or "edit" command.  Currently\r
495 defined variant names are:\r
496 \r
497 <table>\r
498 <tr align="left"><th>wildcastle<td>Shuffle chess where king can castle from d file\r
499 <tr align="left"><th>nocastle<td>Shuffle chess with no castling at all\r
500 <tr align="left"><th>fischerandom<td>Fischer Random\r
501 <tr align="left"><th>bughouse<td>Bughouse, ICC/FICS rules\r
502 <tr align="left"><th>crazyhouse<td>Crazyhouse, ICC/FICS rules\r
503 <tr align="left"><th>losers<td>Win by losing all pieces or getting mated (ICC)\r
504 <tr align="left"><th>suicide<td>Win by losing all pieces including king,\r
505 or by having fewer pieces when one player has no legal moves (FICS)\r
506 <tr align="left"><th><font color=red>giveaway</font>\r
507 <td><font color=red>Win by losing all pieces including king,\r
508 or by having no legal moves (ICC)</font>\r
509 <tr align="left"><th>twokings<td>Weird ICC wild 9\r
510 <tr align="left"><th>kriegspiel<td>Kriegspiel (engines not supported)\r
511 <tr align="left"><th>atomic<td>Atomic\r
512 <tr align="left"><th>3check<td>Win by giving check 3 times\r
513 <tr align="left"><th><font color=green>xiangqi</font>\r
514 <td><font color=green>Chinese Chess (9x10 board)</font>\r
515 <tr align="left"><th><font color=green>shogi</font>\r
516 <td><font color=green>Japanese Chess (9x9 bord)</font>\r
517 <tr align="left"><th><font color=green>capablanca</font>\r
518 <td><font color=green>Capablanca Chess (10x8 board, with Archbishop and Chancellor)</font>\r
519 <tr align="left"><th><font color=green>gothic</font>\r
520 <td><font color=green>Gothic Chess (10x8 board, same with better opening setup)</font>\r
521 <tr align="left"><th><font color=green>falcon</font>\r
522 <td><font color=green>Falcon Chess (10x8 board, with two Falcon pieces)</font>\r
523 <tr align="left"><th><font color=green>shatranj</font>\r
524 <td><font color=green>ancient Arabic Chess, with Elephants and General in stead of B and Q</font>\r
525 <tr align="left"><th><font color=green>courier</font>\r
526 <td><font color=green>Courier Chess (12x8 board, a medieval precursor of modern Chess</font>\r
527 <tr align="left"><th><font color=green>knightmate</font>\r
528 <td><font color=green>King moves as Knight and vice versa</font>\r
529 <tr align="left"><th><font color=green>berolina</font><td>\r
530 <font color=green>Pawns capture straight ahead, and move diagonally</font>\r
531 <tr align="left"><th><font color=green>janus</font><td>\r
532 <font color=green>Janus Chess (10x8, with two Archbishops)</font>\r
533 <tr align="left"><th><font color=green>caparandom</font>\r
534 <td><font color=green>shuffle variant like FRC (10x8 board)</font>\r
535 <tr align="left"><th><font color=green>cylinder</font>\r
536 <td><font color=green>Pieces wrap around between side edges, like board is a cylinder</font>\r
537 <tr align="left"><th><font color=blue>super</font>\r
538 <td><font color=blue>Superchess: a shuffle variant with 4 fairy pieces on 8x8 board</font>\r
539 <tr align="left"><th>unknown<td>Unknown variant (not supported)\r
540 </table>\r
541 <p>\r
542 \r
543 <dt><strong>quit</strong>\r
544 <dd>The chess engine should immediately exit.  This command is used\r
545 when xboard is itself exiting, and also between games if the -xreuse\r
546 command line option is given (or -xreuse2 for the second engine).\r
547 See also <a href="#7">Signals</a> above.\r
548 <p>\r
549 \r
550 <dt><strong>random</strong>\r
551 <dd>This command is specific to GNU Chess 4.  You can either ignore it\r
552 completely (that is, treat it as a no-op) or implement it as GNU Chess\r
553 does.  The command toggles "random" mode (that is, it sets random =\r
554 !random).  In random mode, the engine adds a small random value to its\r
555 evaluation function to vary its play.  The "new" command sets random\r
556 mode off.\r
557 <p>\r
558 \r
559 <dt><strong>force</strong>\r
560 <dd>Set the engine to play neither color ("force mode").  Stop clocks.\r
561 The engine should check that moves received in force mode are legal\r
562 and made in the proper turn, but should not think, ponder, or make\r
563 moves of its own.\r
564 <p>\r
565 \r
566 <dt><strong>go</strong>\r
567 <dd>Leave force mode and set the engine to play the color that is on\r
568 move.  Associate the engine's clock with the color that is on move,\r
569 the opponent's clock with the color that is not on move.  Start the engine's\r
570 clock.  Start thinking and eventually make a move.\r
571 <p>\r
572 \r
573 <dt><font color=red><strong>playother</strong></font>\r
574 <dd>\r
575 <font color=red>\r
576 (This command is new in protocol version 2.  It is not\r
577 sent unless you enable it with the feature command.)\r
578 Leave force mode and set the engine to play the color that is <i>not</i> on\r
579 move.  Associate the opponent's clock with the color that is on move,\r
580 the engine's clock with the color that is not on move.  Start the opponent's\r
581 clock.  If pondering is enabled, the engine should begin pondering.\r
582 If the engine later receives a move, it should start thinking and eventually\r
583 reply.\r
584 </font>\r
585 <p>\r
586 \r
587 <dt><strong>white</strong>\r
588 <dd>\r
589 <font color=red>\r
590 (This command is obsolete as of protocol version 2, but is still\r
591 sent in some situations to accommodate older engines unless you disable it \r
592 with the feature command.)\r
593 </font>\r
594 Set White on move.  Set the engine to play Black.  Stop clocks.\r
595 <p>\r
596   \r
597 <dt><strong>black</strong>\r
598 <dd>\r
599 <font color=red>\r
600 (This command is obsolete as of protocol version 2, but is still\r
601 sent in some situations to accommodate older engines unless you disable it \r
602 with the feature command.)\r
603 </font>\r
604 Set Black on move.  Set the engine to play White.  Stop clocks.\r
605 <p>\r
606 \r
607 <dt><strong>level MPS BASE INC</strong>\r
608 <dd>Set time controls.  See the <a href="#11">Time Control</a> section below.\r
609 <p>\r
610   \r
611 <dt><strong>st TIME</strong>\r
612 <dd>Set time controls.  See the <a href="#11">Time Control</a> section\r
613 below. \r
614 <p>\r
615 \r
616 <dt><strong>sd DEPTH</strong>\r
617 <dd>The engine should limit its thinking to DEPTH ply.\r
618 <font color=green>The commands "level" or "st" and "sd" can be used together in an orthogonal way.\r
619 If both are issued, the engine should observe both limitations:</font>\r
620 In the protocol, the "sd" command isn't a time control.  It doesn't\r
621 say that your engine has unlimited time but must search to exactly the\r
622 given depth.  It says that you should pay attention to the time\r
623 control as normal, but cut off the search at the specified depth even\r
624 if you have time to search deeper.  If you don't have time to search\r
625 to the specified depth, given your normal time management algorithm,\r
626 then you will want to stop sooner than the given depth.\r
627 <p>\r
628 The "new" command should set the search depth back to unlimited.  This\r
629 is already stated in the spec.  The "level" command should not affect\r
630 the search depth.  As it happens, xboard/WinBoard currently always\r
631 sends sd (if needed) right after level, but that isn't part of the\r
632 spec.\r
633 <p>\r
634 \r
635 <dt><font color=green><strong>nps NODE_RATE</strong></font>\r
636 <dd><font color=green>The engine should not use wall-clock time to make its timing decisions,\r
637 but an own internal time measure based on the number of nodes it has searched\r
638 (and will report as "thinking output", see <a href="#10">section 10</a>),\r
639 converted to seconds through dividing by the given NODE_RATE.\r
640 Example: after receiving the commands "st 8" and "nps 10000",\r
641 the engine should never use more that 80,000 nodes in the search for any move.\r
642 In this mode, the engine should report user CPU time used (in its thinking output), \r
643 rather than wall-clock time.\r
644 This even holds if NODE_RATE is given as 0,\r
645 but in that case it should also use the user CPU time for its timing decisions.\r
646 The effect of an "nps" command should persist until the next "new" command.\r
647 </font>\r
648 <p>\r
649 \r
650 <dt><strong>time N</strong>\r
651 <dd>Set a clock that always belongs to the engine.  N is a number in\r
652   centiseconds (units of 1/100 second).  Even if the engine changes to\r
653   playing the opposite color, this clock remains with the engine.\r
654 <p>\r
655 \r
656 <dt><strong>otim N</strong>\r
657 \r
658 <dd>Set a clock that always belongs to the opponent.  N is a number in\r
659 centiseconds (units of 1/100 second).  Even if the opponent changes to\r
660 playing the opposite color, this clock remains with the opponent.\r
661 <p>\r
662 If needed for purposes of board display in force mode (where the\r
663 engine is not participating in the game) the time clock should be\r
664 associated with the last color that the engine was set to play, the\r
665 otim clock with the opposite color.\r
666 </p>\r
667 <p>\r
668 <font color=green>This business of "clocks remaining with the engine" is apparently so ambiguous\r
669 that many engines implement it wrong.\r
670 The clocks in fact always remain with the color.\r
671 Which clock reading is relayed with "time", and which by "otim", is determined by which side the engine plays.\r
672 Note that the way the clocks operate and receive extra time (in accordance with the selected time control)\r
673 is not affected in any way by which moves are made by the engine, which by the opponent, and which were forced.\r
674 </font>\r
675 </p>\r
676 <p>\r
677 <font color=red>\r
678 Beginning in protocol version 2, if you can't handle the time and\r
679 otim commands, you can use the "feature" command to disable them; see\r
680 below.  \r
681 </font>\r
682 The following techniques from older protocol versions also\r
683 work: You can ignore the time and otim commands (that is, treat them\r
684 as no-ops), or send back "Error (unknown command): time" the first\r
685 time you see "time".\r
686 </p>\r
687 \r
688 <dt><strong>MOVE</strong>\r
689 <dd>See below for the syntax of moves.  If the move is illegal, print\r
690 an error message; see the section "<a href="#9">Commands from the engine to\r
691 xboard</a>".  If the move is legal and in turn, make it.  If not in force\r
692 mode, stop the opponent's clock, start the engine's clock, start\r
693 thinking, and eventually make a move.\r
694 <p>\r
695 When xboard sends your engine a move, it normally sends coordinate\r
696 algebraic notation.  Examples:\r
697 <p>\r
698 <table>\r
699 <tr align="left"><td>Normal moves:<td>e2e4\r
700 <tr align="left"><td>Pawn promotion:<td>e7e8q\r
701 <tr align="left"><td>Castling:<td>e1g1, e1c1, e8g8, e8c8\r
702 <tr align="left"><td>Bughouse/crazyhouse drop:<td>P@h3\r
703 <tr align="left"><td>ICS Wild 0/1 castling:<td>d1f1, d1b1, d8f8, d8b8\r
704 <tr align="left"><td>FischerRandom castling:<td>O-O, O-O-O (oh, not zero)\r
705 </table>\r
706 \r
707 <p>\r
708 <font color=green>\r
709 Note that on boards with more than 9 ranks, counting of the ranks starts at 0.\r
710 </font>\r
711 </p>\r
712 <p>\r
713 <font color=red>\r
714 Beginning in protocol version 2, you can use the feature command\r
715 to select SAN (standard algebraic notation) instead; for example, e4,\r
716 Nf3, exd5, Bxf7+, Qxf7#, e8=Q, O-O, or P@h3.  Note that the last form,\r
717 P@h3, is a extension to the PGN standard's definition of SAN, which does\r
718 not support bughouse or crazyhouse.\r
719 </font>\r
720 </p>\r
721 \r
722 <p>\r
723 xboard doesn't reliably detect illegal moves, because it does not keep\r
724 track of castling unavailability due to king or rook moves, or en\r
725 passant availability.  If xboard sends an illegal move, send back an\r
726 error message so that xboard can retract it and inform the user; see\r
727 the section "<a href="#9">Commands from the engine to xboard</a>".\r
728 </p>\r
729 \r
730 <dt><font color=red><strong>usermove MOVE</strong></font>\r
731 <dd><font color=red>\r
732 By default, moves are sent to the engine without a command name;\r
733 the notation is just sent as a line by itself.\r
734 Beginning in protocol version 2, you can use the feature command\r
735 to cause the command name "usermove" to be sent before the move.\r
736 Example: "usermove e2e4".\r
737 </font>\r
738 </p>\r
739 \r
740 <dt><strong>?</strong>\r
741 <dd>Move now.  If your engine is thinking, it should move immediately;\r
742   otherwise, the command should be ignored (treated as a no-op).  It\r
743   is permissible for your engine to always ignore the ? command.  The\r
744   only bad consequence is that xboard's Move Now menu command will do\r
745   nothing.\r
746 <p>\r
747 It is also permissible for your engine to move immediately if it gets\r
748 any command while thinking, as long as it processes the command right\r
749 after moving, but it's preferable if you don't do this.  For example,\r
750 xboard may send post, nopost, easy, hard, force, quit,\r
751 <font color=red>\r
752 or other commands\r
753 </font>\r
754 while the engine is on move.\r
755 </p>\r
756 \r
757 <dt><font color=red><strong>ping N</strong></font>\r
758 <dd>\r
759 <font color=red>\r
760 In this command, N is a decimal number.  When you receive the command,\r
761 reply by sending the string <strong>pong N</strong>, where N is the\r
762 same number you received.  Important: You must not reply to a "ping"\r
763 command until you have finished executing all commands that you\r
764 received before it.  Pondering does not count; if you receive a ping\r
765 while pondering, you should reply immediately and continue pondering.\r
766 Because of the way xboard uses the ping command, if you implement the\r
767 other commands in this protocol, you should never see a "ping" command\r
768 when it is your move; however, if you do, you must not send the "pong"\r
769 reply to xboard until after you send your move.  For example, xboard\r
770 may send "?" immediately followed by "ping".  If you implement the "?"\r
771 command, you will have moved by the time you see the subsequent ping\r
772 command.  Similarly, xboard may send a sequence like "force", "new",\r
773 "ping".  You must not send the pong response until after you have\r
774 finished executing the "new" command and are ready for the new game to\r
775 start.\r
776 \r
777 <p>\r
778 The ping command is new in protocol version 2 and will not be sent\r
779 unless you enable it with the "feature" command.  Its purpose is to\r
780 allow several race conditions that could occur in previous versions of\r
781 the protocol to be fixed, so it is highly recommended that you\r
782 implement it.  It is especially important in simple engines that do\r
783 not ponder and do not poll for input while thinking, but it is needed in all\r
784 engines.  \r
785 </p>\r
786 </font>\r
787 \r
788 <dt><strong>draw</strong>\r
789 <dd>The engine's opponent offers the engine a draw.  To accept the\r
790 draw, send "offer draw".  To decline, ignore the offer (that is, send\r
791 nothing).  If you're playing on ICS, it's possible for the draw offer\r
792 to have been withdrawn by the time you accept it, so don't assume the\r
793 game is over because you accept a draw offer.  Continue playing until\r
794 xboard tells you the game is over.  See also "offer draw" below.\r
795 <p>\r
796 \r
797 <dt><strong>result RESULT {COMMENT}</strong>\r
798 <dd>After the end of each game, xboard will send you a result command.\r
799 You can use this command to trigger learning.  RESULT is either 1-0,\r
800 0-1, 1/2-1/2, or *, indicating whether white won, black won, the game\r
801 was a draw, or the game was unfinished.  The COMMENT string is purely\r
802 a human-readable comment; its content is unspecified and subject to\r
803 change.  In ICS mode, it is passed through from ICS uninterpreted.\r
804 Example: <pre>result 1-0 {White mates}</pre>\r
805 <p>\r
806 Here are some notes on interpreting the "result" command.  Some apply\r
807 only to playing on ICS ("Zippy" mode).\r
808 </p>\r
809 \r
810 <p>\r
811 If you won but did not just play a mate, your opponent must have\r
812 resigned or forfeited.  If you lost but were not just mated, you\r
813 probably forfeited on time, or perhaps the operator resigned manually.\r
814 If there was a draw for some nonobvious reason, perhaps your opponent\r
815 called your flag when he had insufficient mating material (or vice\r
816 versa), or perhaps the operator agreed to a draw manually.\r
817 </p>\r
818 \r
819 <p>\r
820 You will get a result command even if you already know the game ended\r
821 -- for example, after you just checkmated your opponent.  In fact, if\r
822 you send the "RESULT {COMMENT}" command (discussed below), you will\r
823 simply get the same thing fed back to you with "result" tacked in\r
824 front.  You might not always get a "result *" command, however.  In\r
825 particular, you won't get one in local chess engine mode when the user\r
826 stops playing by selecting Reset, Edit Game, Exit or the like.\r
827 </p>\r
828 \r
829 <dt><font color=red><strong>setboard FEN</strong></font>\r
830 <dd><font color=red>\r
831 The setboard command is the new way to set up positions, beginning\r
832 in protocol version 2.  It is not used unless it has been selected\r
833 with the feature command.  Here FEN is a position in Forsythe-Edwards\r
834 Notation, as defined in the PGN standard.</font>\r
835 <font color=green>Note that this PGN standard referred to here\r
836 only applies to normal Chess;\r
837 Obviously in variants that cannot be described by a FEN for normal Chess,\r
838 e.g. because the board is not 8x8, other pieces then PNBRQK participate, \r
839 there are holdings that need to be specified, etc., \r
840 xboard will use a FEN format that is standard or suitable for that varant.\r
841 In particular, in FRC or CRC, WinBoard will use Shredder-FEN or X-FEN standard,\r
842 i.e. it can use the rook-file indicator letter to represent a castling right \r
843 (like HAha) whenever it wants, but if it uses KQkq, this will always refer \r
844 to the outermost rook on the given side.</font>\r
845 <font color=red>\r
846 \r
847 <p><i>Illegal positions:</i> Note that either setboard or edit can\r
848 be used to send an illegal position to the engine.  The user can\r
849 create any position with xboard's Edit Position command (even, say,\r
850 an empty board, or a board with 64 white kings and no black ones).\r
851 If your engine receives a position that it considers illegal, \r
852 I suggest that you send the response "tellusererror Illegal position",\r
853 and then respond to any attempted move with "Illegal move" until\r
854 the next new, edit, or setboard command.</p>\r
855 </font>\r
856 <p>\r
857 \r
858 <dt><strong>edit</strong>\r
859 <dd>\r
860 <font color=red>\r
861 The edit command is the old way to set up positions.  For compatibility\r
862 with old engines, it is still used by default, but new engines may prefer\r
863 to use the feature command (see below) to cause xboard to use setboard instead.\r
864 </font>\r
865 The edit command puts the chess engine into a special mode, where\r
866 it accepts the following subcommands:\r
867 <table>\r
868 <tr align="left"><th>c<td>change current piece color, initially white\r
869 <tr align="left"><th>Pa4 (for example)<td>place pawn of current color on a4\r
870 <tr align="left"><th>xa4 (for example)<td>empty the square a4 (not used by xboard)\r
871 <tr align="left"><th>#<td>clear board\r
872 <tr align="left"><th>.<td>leave edit mode\r
873 </table>\r
874 <font color=red>\r
875 See the Idioms section below for additional subcommands used in\r
876 ChessBase's implementation of the protocol.\r
877 </font>\r
878 \r
879 <p>The edit command does not change the side to move.  To set up a\r
880 black-on-move position, xboard uses the following command sequence:\r
881 </p>\r
882 <pre>\r
883     new\r
884     force\r
885     a2a3\r
886     edit\r
887     &lt;edit commands&gt;\r
888     .\r
889 </pre>\r
890 \r
891 <p>\r
892 This sequence is used to avoid the "black" command, which is now\r
893 considered obsolete and which many engines never did implement as \r
894 specified in this document.\r
895 </p>\r
896 \r
897 <p>\r
898 After an edit command is complete, if a king and a rook are on their\r
899 home squares, castling is assumed to be available to them.  En passant\r
900 capture is assumed to be illegal on the current move regardless of the\r
901 positions of the pawns.  The clock for the 50 move rule starts at\r
902 zero, and for purposes of the draw by repetition rule, no prior\r
903 positions are deemed to have occurred.\r
904 <font color=green>\r
905 In FRC or CRC, any rook and king put on the back rank should be considered to\r
906 have castling rights, even if it later becomes apparent that they cannot be both in the\r
907 initial position, because the position just set up is asymmetric.\r
908 It is upto WinBoard to find work-around in cases where this is not desired,\r
909 similar to the "black kludge" shown above, by setting up an earlier position,\r
910 and then do a move to destroy castling rights or create e.p. rights.\r
911 (Don't bet your life on it...)\r
912 </font>\r
913 </p>\r
914 \r
915 <dt><strong>hint</strong>\r
916 <dd>If the user asks for a hint, xboard sends your engine the command\r
917 "hint".  Your engine should respond with "Hint: xxx", where xxx is a\r
918 suggested move.  If there is no move to suggest, you can ignore the\r
919 hint command (that is, treat it as a no-op).\r
920 <p>\r
921 \r
922 <dt><strong>bk</strong>\r
923 <dd>If the user selects "Book" from the xboard menu, xboard will send\r
924 your engine the command "bk".  You can send any text you like as the\r
925 response, as long as each line begins with a blank space or tab (\t)\r
926 character, and you send an empty line at the end.  The text pops up in\r
927 a modal information dialog.\r
928 <p>\r
929 \r
930 <dt><strong>undo</strong>\r
931 <dd>If the user asks to back up one move, xboard will send you the\r
932 "undo" command.  xboard will not send this command without putting you\r
933 in "force" mode first, so you don't have to worry about what should\r
934 happen if the user asks to undo a move your engine made.  (GNU Chess 4\r
935 actually switches to playing the opposite color in this case.)\r
936 <p>\r
937 \r
938 <dt><strong>remove</strong>\r
939 <dd>If the user asks to retract a move, xboard will send you the\r
940 "remove" command.  It sends this command only when the user is on\r
941 move.  Your engine should undo the last two moves (one for each\r
942 player) and continue playing the same color.\r
943 <p>\r
944 \r
945 <dt><strong>hard</strong>\r
946 <dd>Turn on pondering (thinking on the opponent's time, also known as\r
947 "permanent brain").  xboard will not make any assumption about what\r
948 your default is for pondering or whether "new" affects this setting.\r
949 <p>\r
950 \r
951 <dt><strong>easy</strong>\r
952 <dd>Turn off pondering.\r
953 <p>\r
954   \r
955 <dt><strong>post</strong>\r
956 <dd>Turn on thinking/pondering output.  \r
957 See <a href="#10">Thinking Output</a> section.\r
958 <p>\r
959 \r
960 <dt><strong>nopost</strong>\r
961 <dd>Turn off thinking/pondering output.\r
962 <p>\r
963   \r
964 <dt><strong>analyze</strong>\r
965 <dd>Enter analyze mode.  See <a href="#12">Analyze Mode</a> section.\r
966 <p>\r
967 \r
968 <dt><strong>name X</strong> <dd>This command informs the engine of its\r
969 opponent's name.  When the engine is playing on a chess server, xboard\r
970 obtains the opponent's name from the server. \r
971 <font color=red>\r
972 When the engine is\r
973 playing locally against a human user, xboard obtains the user's login\r
974 name from the local operating system.  When the engine is playing\r
975 locally against another engine, xboard uses either the other engine's\r
976 filename or the name that the other engine supplied in the myname\r
977 option to the feature command.  By default, xboard uses the name\r
978 command only when the engine is playing on a chess server.  Beginning\r
979 in protocol version 2, you can change this with the name option to the\r
980 feature command; see below.\r
981 </font>\r
982 <p>\r
983 \r
984 <dt><strong>rating</strong>\r
985 <dd>In ICS mode, xboard obtains the ICS opponent's rating from the\r
986 "Creating:" message that appears before each game.  (This message may\r
987 not appear on servers using outdated versions of the FICS code.)  In\r
988 Zippy mode, it sends these ratings on to the chess engine using the\r
989 "rating" command.  The chess engine's own rating comes first, and if\r
990 either opponent is not rated, his rating is given as 0.  \r
991 <font color=red>\r
992 In the future this command may also be used in other modes, if ratings\r
993 are known.\r
994 </font>\r
995 Example: <pre>rating 2600 1500</pre>\r
996 <p>\r
997 \r
998 <dt><font color=red><strong>ics HOSTNAME</strong></font>\r
999 <dd><font color=red>\r
1000 If HOSTNAME is "-", the engine is playing against a local\r
1001 opponent; otherwise, the engine is playing on an Internet Chess Server\r
1002 (ICS) with the given hostname.  This command is new in protocol\r
1003 version 2 and is not sent unless the engine has enabled it with\r
1004 the "feature" command.  Example: "ics freechess.org"\r
1005 </font>\r
1006 <p>\r
1007 \r
1008 <dt><strong>computer</strong>\r
1009 <dd>The opponent is also a computer chess engine.  Some engines alter\r
1010 their playing style when they receive this command.\r
1011 <p>\r
1012 \r
1013 <dt><font color=red><strong>pause</strong></font>\r
1014 <dt><font color=red><strong>resume</strong></font>\r
1015 <dd><font color=red>(These commands are new in protocol\r
1016 version 2 and will not be sent unless feature pause=1 is set.  At\r
1017 this writing, xboard actually does not use the commands at all, but it\r
1018 or other interfaces may use them in the future.)\r
1019 The "pause" command puts the engine into a special state where it\r
1020 does not think, ponder, or otherwise consume significant CPU time.\r
1021 The current thinking or pondering (if any) is suspended and both\r
1022 player's clocks are stopped.  The only command that the interface may\r
1023 send to the engine while it is in the paused state is "resume".  The\r
1024 paused thinking or pondering (if any) resumes from exactly where it\r
1025 left off, and the clock of the player on move resumes running from\r
1026 where it stopped.\r
1027 </font>\r
1028 <p>\r
1029 \r
1030 <dt><font color=blue><strong>memory N</strong></font>\r
1031 <dd><font color=blue>\r
1032 This command informs the engine on how much memory it is allowed to use maximally, in MegaBytes.\r
1033 On receipt of this command, the engine should adapt the size of its hash tables accordingly.\r
1034 This command does only fix the total memory use,\r
1035 the engine has to decide for itself \r
1036 (or be configured by the user by other means) \r
1037 how to divide up the available memory between the various tables it wants to use \r
1038 (e.g. main hash, pawn hash, tablebase cache, bitbases).\r
1039 This command will only be sent to engines that have requested it through the memory feature,\r
1040 and only at the start of a game,\r
1041 as the first of the commands to relay engine option settings just before each "new" command.\r
1042 </font>\r
1043 <p>\r
1044 \r
1045 <dt><font color=blue><strong>cores N</strong></font>\r
1046 <dd><font color=blue>\r
1047 This command informs the engine on how many CPU cores it is allowed to use maximally.\r
1048 This could be interpreted as the number of search threads for SMP engines. \r
1049 (Threads that do not consume significant amounts of CPU time, like I/O threads, need not be included in the count.)\r
1050 This command will only be sent to engines that have requested it through the smp feature.\r
1051 The engine should be able to respond to the "cores" command any time during a game,\r
1052 but it is allowed to finish a search in progress before procesing the command.\r
1053 (Obeying the command should take priority over finishing a ponder search, though.)\r
1054 In any case it will be sent at the start of every game\r
1055 as the last command to relay engine option settings before the "new" command.\r
1056 </font>\r
1057 <p>\r
1058 \r
1059 <dt><font color=blue><strong>egtpath TYPE PATH</strong></font>\r
1060 <dd><font color=blue>\r
1061 This command informs the engine in which directory (given by the PATH argument)\r
1062 it can find end-game tables of the specified TYPE.\r
1063 The TYPE argument can be any character string which does not contain spaces.\r
1064 Currently <strong>nalimov</strong> and <strong>scorpio</strong> are defined types, \r
1065 for Nalimov tablebases and Scorpio bitbases, respectively,\r
1066 but future developers of other formats are free to define their own format names.\r
1067 The GUI simply matches the TYPE names the engine says it supports \r
1068 with those that the user supplied when configuring xboard.\r
1069 For every match, it sends a separate "y" command.\r
1070 The PATH argument would normally (for Nalimov) be the pathname of the directory the EGT files are in,\r
1071 but could also be the name of a file, or in fact anything the particular EGT type requires.\r
1072 It is upto the developer of the EGT format to specify the syntax of this parameter.\r
1073 This command will only be sent to engines that have told the GUI they support EGTs of the given TYPE\r
1074 through the egt feature.\r
1075 It will be sent at the start of each game, before the "new" command.\r
1076 </font>\r
1077 <p>\r
1078 \r
1079 <dt><font color=blue><strong>option NAME[=VALUE]</strong></font>\r
1080 <dd><font color=blue>\r
1081 This command changes the setting of the option NAME defined by the engine \r
1082 (through an earlier feature command)\r
1083 to the given VALUE.\r
1084 XBoard will in general have no idea what the option means,\r
1085 and will send the command only when a user changes the value of this option through a menu,\r
1086 or at startup of the engine \r
1087 (before the first 'cores' command or, if that is not sent, the first 'new' command)\r
1088 in reaction to command-line options.\r
1089 The NAME echoes back to the engine the string that was identified as an option NAME\r
1090 in the feature command defining the option.\r
1091 The VALUE is of the type (numeric or text or absent) that was implied by the option type\r
1092 specified in this feature command,\r
1093 i.e. with 'spin' and 'check' options VALUE will be a decimal integer (in the latter case 0 or 1),\r
1094 with 'combo' and 'string' options VALUE will be a text string,\r
1095 and with 'button' and 'save' options no VALUE will be sent at all.\r
1096 </font>\r
1097 </dl>\r
1098 \r
1099 <h3>Bughouse commands:</h3>\r
1100 \r
1101 <p>\r
1102 xboard now supports bughouse engines when in Zippy mode.  See\r
1103 <a href="http://www.tim-mann.org/xboard/zippy.README"\r
1104 >zippy.README</a> for information on Zippy mode and how to turn on the\r
1105 bughouse support.  The bughouse move format is given above.  xboard\r
1106 sends the following additional commands to the engine when in bughouse\r
1107 mode.  \r
1108 Commands to inform your engine of the partner's game state may\r
1109 be added in the future.\r
1110 </p>\r
1111 \r
1112 <dl>\r
1113 <dt><strong>partner &lt;player&gt;</strong>\r
1114 <dd>&lt;player&gt; is now your partner for future games.  Example: <pre>partner mann</pre>\r
1115 <p>\r
1116 \r
1117 <dt><strong>partner</strong>\r
1118 <dd>Meaning: You no longer have a partner.\r
1119 <p>\r
1120 \r
1121 <dt><strong>ptell &lt;text&gt;</strong>\r
1122 <dd>Your partner told you &lt;text&gt;, either with a ptell or an ordinary tell.  \r
1123 <p>\r
1124 \r
1125 <dt><strong>holding [&lt;white&gt;] [&lt;black&gt;]</strong>\r
1126 <dd>White currently holds &lt;white&gt;; black currently holds &lt;black&gt;.\r
1127   Example: <pre>holding [PPPRQ] []</pre>\r
1128 \r
1129 <dt><strong>holding [&lt;white&gt;] [&lt;black&gt;] &lt;color&gt;&lt;piece&gt;</strong>\r
1130 <dd>White currently holds &lt;white&gt;; black currently holds &lt;black&gt;, after\r
1131   &lt;color&gt; acquired &lt;piece&gt;.   Example: <pre>holding [PPPRQ] [R] BR</pre>\r
1132 </dl>\r
1133 \r
1134 <h2><a name="9">9. Commands from the engine to xboard</a></h2>\r
1135 \r
1136 <p>\r
1137 <font color=red>\r
1138 In general, an engine should not send any output to xboard that is not\r
1139 described in this document.  As the protocol is extended, newer\r
1140 versions of xboard may recognize additional strings as commands that\r
1141 were previously not assigned a meaning.\r
1142 </font>\r
1143 </p>\r
1144 \r
1145 <dl>\r
1146 <dt><font color=red>\r
1147 <strong>feature FEATURE1=VALUE1 FEATURE2=VALUE2 ...</strong> \r
1148 </font>\r
1149 \r
1150 <dd><font color=red>\r
1151 Beginning with version 2, the protocol includes the "feature"\r
1152 command, which lets your engine control certain optional protocol\r
1153 features.  Feature settings are written as FEATURE=VALUE, where\r
1154 FEATURE is a name from the list below and VALUE is the value to be\r
1155 assigned.  Features can take string, integer, or boolean values; the\r
1156 type of value is listed for each feature.  String values are written\r
1157 in double quotes (for example, <tt>feature myname="Miracle Chess\r
1158 0.9"</tt>), integers are written in decimal, and boolean values are\r
1159 written as 0 for false, 1 for true.  Any number of features can be set\r
1160 in one feature command, or multiple feature commands can be given.\r
1161 \r
1162 <p>\r
1163 Your engine should send one or more feature commands immediately after\r
1164 receiving the "protover" command, since xboard needs to know the\r
1165 values of some features before sending further commands to the engine.\r
1166 Because engines that predate protocol version 2 do not send "feature",\r
1167 xboard uses a timeout mechanism: when it first starts your engine, it\r
1168 sends "xboard" and "protover N", then listens for feature commands for\r
1169 two seconds before sending any other commands.  To end this timeout\r
1170 and avoid the wait, set the feature "done=1" at the end of your last\r
1171 feature command.  To increase the timeout, if needed, set the feature\r
1172 "done=0" before your first feature command and "done=1" at the end.\r
1173 If needed, it is okay for your engine to set done=0 soon as it starts,\r
1174 even before it receives the xboard and protover commands.  This can be\r
1175 useful if your engine takes a long time to initialize itself.  It\r
1176 should be harmless even if you are talking to a (version 1) user\r
1177 interface that does not understand the "feature" command, since such\r
1178 interfaces generally ignore commands from the engine that they do not\r
1179 understand.\r
1180 </p>\r
1181 \r
1182 <p>\r
1183 The feature command is designed to let the protocol change without\r
1184 breaking engines that were written for older protocol versions.  When\r
1185 a new feature is added to the protocol, its default value is always\r
1186 chosen to be compatible with older versions of the protocol that did\r
1187 not have the feature.  Any feature that your engine does not set in a\r
1188 "feature" command retains its default value, so as the protocol\r
1189 changes, you do not have to change your engine to keep up with it\r
1190 unless you want to take advantage of a new feature.  Because some\r
1191 features are improvements to the protocol, while others are meant to\r
1192 cater to engines that do not implement all the protocol features, the\r
1193 recommended setting for a feature is not always the same as the\r
1194 default setting.  The listing below gives both default and recommended\r
1195 settings for most features.\r
1196 </p>\r
1197 \r
1198 <p>\r
1199 You may want to code your engine so as to be able to work with\r
1200 multiple versions of the engine protocol.  Protocol version 1 does not\r
1201 send the protover command and does not implement the feature command;\r
1202 if you send a feature command in protocol version 1, it will have no\r
1203 effect and there will be no response.  In protocol version 2 or later,\r
1204 each feature F that you set generates the response "accepted F" if the\r
1205 feature is implemented, or "rejected F" if it is not.  Thus an engine\r
1206 author can request any feature without having to keep track of which\r
1207 protocol version it was introduced in; you need only check whether the\r
1208 feature is accepted or rejected.  This mechanism also makes it\r
1209 possible for a user interface author to implement a subset of a\r
1210 protocol version by rejecting some features that are defined in that\r
1211 version; however, you should realize that engine authors are likely to\r
1212 code for xboard and may not be prepared to have a feature that they\r
1213 depend on be rejected.\r
1214 </p>\r
1215 \r
1216 <p>\r
1217 Here are the features that are currently defined.\r
1218 </p>\r
1219 </font>\r
1220 \r
1221 <dl>\r
1222 <dt><font color=red>\r
1223 <strong>ping</strong> (boolean, default 0, recommended 1)\r
1224 </font>\r
1225 <dd><font color=red>\r
1226 If ping=1, xboard may use the protocol's new "ping" command;\r
1227 if ping=0, xboard will not use the command.\r
1228 </font>\r
1229 \r
1230 <dt><font color=red>\r
1231 <strong>setboard</strong> (boolean, default 0, recommended 1)\r
1232 </font>\r
1233 <dd><font color=red>\r
1234 If setboard=1, xboard will use the protocol's new "setboard" command\r
1235 to set up positions; if setboard=0, it will use the older "edit" command.\r
1236 </font>\r
1237 \r
1238 <dt><font color=red>\r
1239 <strong>playother</strong> (boolean, default 0, recommended 1)\r
1240 </font>\r
1241 <dd><font color=red>\r
1242 If playother=1, xboard will use the protocol's new "playother" command\r
1243 when appropriate; if playother=0, it will not use the command.\r
1244 </font>\r
1245 \r
1246 <dt><font color=red>\r
1247 <strong>san</strong> (boolean, default 0)\r
1248 </font>\r
1249 <dd><font color=red>\r
1250 If san=1, xboard will send moves to the engine in standard algebraic\r
1251 notation (SAN); for example, Nf3.  If san=0, xboard will send moves in\r
1252 coordinate notation; for example, g1f3.  See MOVE in \r
1253 <a href="#8">section 8</a> above for more details of both kinds of notation.\r
1254 </font>\r
1255 \r
1256 <dt><font color=red>\r
1257 <strong>usermove</strong> (boolean, default 0)\r
1258 </font>\r
1259 <dd><font color=red>\r
1260 If usermove=1, xboard will send moves to the engine with the\r
1261 command "usermove MOVE"; if usermove=0, xboard will send just the move,\r
1262 with no command name.\r
1263 </font>\r
1264 \r
1265 <dt><font color=red>\r
1266 <strong>time</strong> (boolean, default 1, recommended 1)\r
1267 </font>\r
1268 <dd><font color=red>\r
1269 If time=1, xboard will send the "time" and "otim" commands to\r
1270 update the engine's clocks; if time=0, it will not.\r
1271 </font>\r
1272 \r
1273 <dt><font color=red>\r
1274 <strong>draw</strong> (boolean, default 1, recommended 1)\r
1275 </font>\r
1276 <dd><font color=red>\r
1277 If draw=1, xboard will send the "draw" command if the engine's opponent\r
1278 offers a draw; if draw=0, xboard will not inform the engine about\r
1279 draw offers.  Note that if draw=1, you may receive a draw offer while you\r
1280 are on move; if this will cause you to move immediately, you should set\r
1281 draw=0.\r
1282 </font>\r
1283 \r
1284 <dt><font color=red>\r
1285 <strong>sigint</strong> (boolean, default 1)\r
1286 </font>\r
1287 <dd><font color=red>\r
1288 If sigint=1, xboard may send SIGINT (the interrupt signal) to\r
1289 the engine as <a href="#7">section 7</a> above; if sigint=0, it will\r
1290 not.\r
1291 </font>\r
1292 \r
1293 <dt><font color=red>\r
1294 <strong>sigterm</strong> (boolean, default 1)\r
1295 </font>\r
1296 <dd><font color=red>\r
1297 If sigterm=1, xboard may send SIGTERM (the termination signal) to\r
1298 the engine as <a href="#7">section 7</a> above; if sigterm=0, it will\r
1299 not.\r
1300 </font>\r
1301 \r
1302 <dt><font color=red>\r
1303 <strong>reuse</strong> (boolean, default 1, recommended 1) \r
1304 </font>\r
1305 <dd><font color=red>\r
1306 If reuse=1, xboard may reuse your engine for multiple games.  If\r
1307 reuse=0 (or if the user has set the -xreuse option on xboard's command\r
1308 line), xboard will kill the engine process after every game and start\r
1309 a fresh process for the next game.\r
1310 </font>\r
1311 \r
1312 <dt><font color=red>\r
1313 <strong>analyze</strong> (boolean, default 1, recommended 1)\r
1314 </font>\r
1315 <dd><font color=red>\r
1316 If analyze=0, xboard will not try to use the "analyze" command; it\r
1317 will pop up an error message if the user asks for analysis mode.  If\r
1318 analyze=1, xboard will try to use the command if the user asks for\r
1319 analysis mode.\r
1320 </font>\r
1321 \r
1322 <dt><font color=red>\r
1323 <strong>myname</strong> (string, default determined from engine filename)\r
1324 </font>\r
1325 <dd><font color=red>\r
1326 This feature lets you set the name that xboard will use for your\r
1327 engine in window banners, in the PGN tags of saved game files, and when\r
1328 sending the "name" command to another engine.\r
1329 </font>\r
1330 \r
1331 <dt><font color=red>\r
1332 <strong>variants</strong> (string, see text below)\r
1333 </font>\r
1334 <dd><font color=red>\r
1335 This feature indicates which chess variants your engine accepts.\r
1336 It should be a comma-separated list of variant names.  See the table\r
1337 under the "variant" command in <a href="#8">section 8</a> above.  If\r
1338 you do not set this feature, xboard will assume by default that your\r
1339 engine supports all variants.  (However, the -zippyVariants\r
1340 command-line option still limits which variants will be accepted in\r
1341 Zippy mode.)  It is recommended that you set this feature to the\r
1342 correct value for your engine (just "normal" in most cases) rather\r
1343 than leaving the default in place, so that the user will get an\r
1344 appropriate error message if he tries to play a variant that your\r
1345 engine does not support.</font>\r
1346 <br>\r
1347 <font color=green>If your engine can play variants on a deviating board size,\r
1348 like capablanca on an 8x8 board, or capablanca crazyhouse,\r
1349 it can list them amongst the variants with a prefix spcifying board size plus\r
1350 holdings size, like 8x8+0_capablanca or 10x8+7_capablanca.\r
1351 If it is capable of playing any variant with an arbitrary board size,\r
1352 it should list "boardsize" as one of the variants.\r
1353 If there is a maximum to the board size, this can be prefixed,\r
1354 e.g. "12x10+0_boardsize".\r
1355 </font>\r
1356 \r
1357 <dt><font color=red>\r
1358 <strong>colors</strong> (boolean, default 1, recommended 0) \r
1359 </font>\r
1360 <dd><font color=red>\r
1361 If colors=1, xboard uses the obsolete "white" and "black"\r
1362 commands in a stylized way that works with most older chess engines\r
1363 that require the commands.  See the "<a href="#13">Idioms</a>" section\r
1364 below for details.  If colors=0, xboard does not use the "white" and\r
1365 "black" commands at all.\r
1366 </font>\r
1367 \r
1368 <dt><font color=red>\r
1369 <strong>ics</strong> (boolean, default 0)\r
1370 </font>\r
1371 <dd><font color=red>\r
1372 If ics=1, xboard will use the protocol's new "ics" command\r
1373 to inform the engine of whether or not it is playing on a chess server;\r
1374 if ics=0, it will not.\r
1375 </font>\r
1376 \r
1377 <dt><font color=red>\r
1378 <strong>name</strong> (boolean, see text below)\r
1379 </font>\r
1380 <dd><font color=red>\r
1381 If name=1, xboard will use the protocol's "name" command\r
1382 to inform the engine of the opponent's name; if name=0, it will not.\r
1383 By default, name=1 if the engine is playing on a chess server; name=0 if not.\r
1384 </font>\r
1385 \r
1386 <dt><font color=red>\r
1387 <strong>pause</strong> (boolean, default 0)\r
1388 </font>\r
1389 <dd><font color=red>\r
1390 If pause=1, xboard may use the protocol's new "pause" command;\r
1391 if pause=0, xboard assumes that the engine does not support this command.\r
1392 </font>\r
1393 \r
1394 <dt><font color=green>\r
1395 <strong>nps</strong> (boolean, default ?)\r
1396 </font>\r
1397 <dd><font color=green>\r
1398 If nps=1, it means the engine supports the nps command.\r
1399 If nps=0, it means the engine does not support it, and WinBoard should refrain from sending it.\r
1400 Default is that WinBoard sends it, in an attempt to try out if the engine understand it.\r
1401 The engine should properly respond with "Error (unkown command): nps" if it does not implement it,\r
1402 (as any protocol version pre-scribes),\r
1403 or WinBoard might assume that the engine did understand the command. \r
1404 In that case the use of different time standards that ensues could lead to time forfeits for the engine.\r
1405 </font>\r
1406 \r
1407 <dt><font color=green>\r
1408 <strong>debug</strong> (boolean, default 0)\r
1409 </font>\r
1410 <dd><font color=green>\r
1411 If debug=1, it means the engine wants to send debug output prefixed by '#',\r
1412 which WinBoard should ignore, except for including it in the winboard.debug file.\r
1413 As this feature is added to protocol 2 ony late,\r
1414 so that not all protocol-2 supporting versions of WinBoard might implement it,\r
1415 it is important that engines check if WinBoard accepts the feature.\r
1416 If the feature is rejected,\r
1417 engines must refrain from sending the debug output,\r
1418 or do so at their own risk.\r
1419 </font>\r
1420 \r
1421 <dt><font color=blue>\r
1422 <strong>memory</strong> (boolean, default 0)\r
1423 </font>\r
1424 <dd><font color=blue>\r
1425 If memory=1, the size of the total amount of memory available for the memory-consuming tables of the engine \r
1426 (e.g. hash, EGTB cache)\r
1427 will be set by the GUI through the "memory" command.\r
1428 </font>\r
1429 \r
1430 <dt><font color=blue>\r
1431 <strong>smp</strong> (boolean, default 0)\r
1432 </font>\r
1433 <dd><font color=blue>\r
1434 If smp=1, the GUI will send the "cores" command to the engine to inform it how many CPU cores it can use.\r
1435 Note that sending smp=1 does not imply the engine can use more than one CPU;\r
1436 just that it wants to receive the "cores" command.\r
1437 </font>\r
1438 \r
1439 <dt><font color=blue>\r
1440 <strong>egt</strong> (string, see text below)\r
1441 </font>\r
1442 <dd><font color=blue>\r
1443 This feature indicates which end-game table formats the engine supports.\r
1444 It should be a comma-separated list of format names.\r
1445 See under the "egtpath" command in <a href="#8">section 8</a> above.\r
1446 If you do not set this feature, xboard will assume the engine does not support end-game tables,\r
1447 and will not send any "egtpath" commands to inform the engine about their whereabouts.\r
1448 </font>\r
1449 \r
1450 <dt><font color=blue>\r
1451 <strong>option</strong> (string, see text below)\r
1452 </font>\r
1453 <dd><font color=blue>\r
1454 This feature is used by the engine to define an option command to appear in a GUI menu,\r
1455 so that the user can change the corresponding setting of the engine through the GUI.\r
1456 The string describes the option by defining a name, type, current value and (sometimes) the acceptable value range.\r
1457 There are six different options types, each requiring a slighly different syntax of the defining string:\r
1458 <br>\r
1459 feature option="NAME -button"\r
1460 <br>\r
1461 feature option="NAME -save"\r
1462 <br>\r
1463 feature option="NAME -check VALUE"\r
1464 <br>\r
1465 feature option="NAME -string VALUE"\r
1466 <br>\r
1467 feature option="NAME -spin VALUE MIN MAX"\r
1468 <br>\r
1469 feature option="NAME -combo CHOICE1 /// CHOICE2 ..."\r
1470 <br>\r
1471 NAME is an arbitrary alphanumeric string which can contain spaces; \r
1472 the oter words in capitals would be replaced by the current (default) setting of the option,\r
1473 the minimum or maximum value of numeric (-spin) options, \r
1474 or arbitrary text labels (for -combo option).\r
1475 In the latter cae, the current value will be preceded by an asterisk.\r
1476 </font>\r
1477 \r
1478 <dt><font color=red>\r
1479 <strong>done</strong> (integer, no default)\r
1480 </font>\r
1481 <dd><font color=red>\r
1482 If you set done=1 during the initial two-second timeout after\r
1483 xboard sends you the "xboard" command, the\r
1484 timeout will end and xboard will not look for any more feature\r
1485 commands before starting normal operation.\r
1486 If you set done=0, the initial timeout is increased to one hour;\r
1487 in this case, you must set done=1 before xboard will enter normal operation.\r
1488 </font>\r
1489 </dl>\r
1490 <p>\r
1491 \r
1492 <dt><strong>Illegal move: MOVE</strong>\r
1493 <dt><strong>Illegal move (REASON): MOVE</strong>\r
1494 <dd>If your engine receives a MOVE command that is recognizably a move\r
1495 but is not legal in the current position, your engine must print an\r
1496 error message in one of the above formats so that xboard can pass the\r
1497 error on to the user and retract the move.  The (REASON) is entirely\r
1498 optional.  Examples:\r
1499 \r
1500 <pre>\r
1501   Illegal move: e2e4\r
1502   Illegal move (in check): Nf3\r
1503   Illegal move (moving into check): e1g1\r
1504 </pre>\r
1505 <p>\r
1506 Generally, xboard will never send an ambiguous move, so it does not \r
1507 matter whether you respond to such a move with an Illegal move message \r
1508 or an Error message.\r
1509 </p>\r
1510 \r
1511 <dt><strong>Error (ERRORTYPE): COMMAND</strong>\r
1512 <dd>If your engine receives a command it does not understand or does\r
1513 not implement, it should print an error message in the above format so\r
1514 that xboard can parse it.  Examples:\r
1515 <pre>\r
1516   Error (ambiguous move): Nf3\r
1517   Error (unknown command): analyze\r
1518   Error (command not legal now): undo\r
1519   Error (too many parameters): level 1 2 3 4 5 6 7\r
1520 </pre>\r
1521 \r
1522 <dt><strong>move MOVE</strong>\r
1523 <dd>Your engine is making the move MOVE.  Do not echo moves from\r
1524 xboard with this command; send only new moves made by the engine.\r
1525 \r
1526 <font color=red>\r
1527 <p>For the actual move text from your chess engine (in place of MOVE\r
1528 above), your move should be either\r
1529 <ul>\r
1530 <li>in coordinate notation (e.g.,\r
1531 e2e4, e7e8q) with castling indicated by the King's two-square move (e.g.,\r
1532 e1g1), or\r
1533 <li>in Standard Algebraic Notation (SAN) as defined in the\r
1534 Portable Game Notation standard (e.g, e4, Nf3, O-O, cxb5, Nxe4, e8=Q),\r
1535 with the extension piece@square (e.g., P@f7) to handle piece placement\r
1536 in bughouse and crazyhouse.\r
1537 </ul>\r
1538 xboard itself also accepts some variants of SAN, but for compatibility\r
1539 with non-xboard interfaces, it is best not to rely on this behavior.\r
1540 </p>\r
1541 \r
1542 <p>Warning: Even though all versions of this protocol specification\r
1543 have indicated that xboard accepts SAN moves, some non-xboard\r
1544 interfaces are known to accept only coordinate notation.  See the\r
1545 Idioms section for more information on the known limitations of some\r
1546 non-xboard interfaces.  It should be safe to send SAN moves if you\r
1547 receive a "protover 2" (or later) command from the interface, but\r
1548 otherwise it is best to stick to coordinate notation for maximum\r
1549 compatibility.  An even more conservative approach would be for your\r
1550 engine to send SAN to the interface only if you have set feature san=1\r
1551 (which causes the interface to send SAN to you) and have received\r
1552 "accepted san" in reply.\r
1553 </p>\r
1554 </font>\r
1555 \r
1556 <dt><strong>RESULT {COMMENT}</strong> <dd>When your engine detects\r
1557 that the game has ended by rule, your engine must output a line of the\r
1558 form "RESULT {comment}" (without the quotes), where RESULT is a PGN\r
1559 result code (1-0, 0-1, or 1/2-1/2), and comment is the reason.  Here\r
1560 "by rule" means that the game is definitely over because of what\r
1561 happened on the board.  In normal chess, this includes checkmate,\r
1562 stalemate, triple repetition, the 50 move rule, or insufficient\r
1563 material; it does not include loss on time or the like.\r
1564 Examples:\r
1565 <pre>\r
1566   0-1 {Black mates}\r
1567   1-0 {White mates}\r
1568   1/2-1/2 {Draw by repetition}\r
1569   1/2-1/2 {Stalemate}\r
1570 </pre>\r
1571 \r
1572 <p>\r
1573 xboard relays the result to the user, the ICS, the other engine in Two\r
1574 Machines mode, and the PGN save file as required.\r
1575 <font color=green>Note that "definitey over" above means that sending this command \r
1576 will be taken by WinBoard as an unconditional refusal of the engine to play on,\r
1577 which might cause you to forfeit if the game was in fact not over.\r
1578 This command should thus not be used to offer draws, accept draws,\r
1579 or make draw-by-rule claims that might not be valid \r
1580 (because it is not your move, and the opponent already moved without you knowing it yet).\r
1581 For offering and claiming draws, "offer draw" should be used.</font>\r
1582 <p>\r
1583 Note to GUI programmers: RESULT commands that the engine sends immediately after its move\r
1584 might be detected by the GUI only after the opponent has moved, because of communication\r
1585 and scheduling delays, no matter how fast the engine sent it.\r
1586 Any judgement of the validity of RESULT claims based on te "current" board position\r
1587 will have to account for this uncertainty.\r
1588 </p>\r
1589 \r
1590 <dt><strong>resign</strong>\r
1591 <dd>If your engine wants to resign, it can send the command "resign".\r
1592 Alternatively, it can use the "RESULT {comment}" command if the string\r
1593 "resign" is included in the comment; for example "0-1 {White\r
1594 resigns}".  xboard relays the resignation to the user, the ICS, the\r
1595 other engine in Two Machines mode, and the PGN save file as required.\r
1596 <p>\r
1597 \r
1598 <dt><strong>offer draw</strong>\r
1599 <dd>If your engine wants to offer a draw by agreement (as opposed to\r
1600 claiming a draw by rule), it can send the command "offer draw".\r
1601 xboard relays the offer to the user, the ICS, the other engine in Two\r
1602 Machines mode, and the PGN save file as required.  In Machine White,\r
1603 Machine Black, or Two Machines mode, the offer is considered valid\r
1604 until your engine has made two more moves.\r
1605 <font color=green>This command must also be used to accept a draw offer.\r
1606 Do not use the 1/2-1/2 command for that, as the offer might be no longer valid,\r
1607 in which case a refusal to play on implied by the RESULT command would make you forfeit the game.\r
1608 "offer draw" should also be used to claim 50-move and 3-fold-repetition draws\r
1609 that will occur <em>after</em> your move, by sending it <em>before</em> making the move.\r
1610 WinBoard will grant draw offers without the opponent having any say in\r
1611 it in situations where draws can be claimed.\r
1612 Only if the draw cannot be claimed, the offer will be passed to your opponent after you make your next move,\r
1613 just before WinBoard relays this move to the opponent.\r
1614 </font>\r
1615 <p>\r
1616 \r
1617 <dt><font color=red><strong>tellopponent MESSAGE</strong></font>\r
1618 <dd><font color=red>\r
1619 This command lets the engine give a message to its opponent,\r
1620 independent of whether the opponent is a user on the local machine or\r
1621 a remote ICS user (Zippy mode).  MESSAGE consists of any characters,\r
1622 including whitespace, to the end of the line.  When the engine is\r
1623 playing against a user on the local machine, xboard pops up an\r
1624 information dialog containing the message.  When the engine is playing\r
1625 against an opponent on the ICS (Zippy mode), xboard sends "say\r
1626 MESSAGE\n" to the ICS.\r
1627 <p>\r
1628 \r
1629 <dt><strong>tellothers MESSAGE</strong> \r
1630 <dd>This command lets the engine give a message to people watching the\r
1631 game other than the engine's opponent.  MESSAGE consists of any\r
1632 characters, including whitespace, to the end of the line.  When the\r
1633 engine is playing against a user on the local machine, this command\r
1634 does nothing.  When the engine is playing against an opponent on the\r
1635 ICS (Zippy mode), xboard sends "whisper MESSAGE\n" to the ICS.\r
1636 <p>\r
1637 \r
1638 <dt><strong>tellall MESSAGE</strong>\r
1639 <dd>This command lets the engine give a message to its opponent and\r
1640 other people watching the game, \r
1641 independent of whether the opponent is a user on the local machine or\r
1642 a remote ICS user (Zippy mode).  MESSAGE consists of any characters,\r
1643 including whitespace, to the end of the line.  When the engine is\r
1644 playing against a user on the local machine, xboard pops up an\r
1645 information dialog containing the message.  When the engine is playing\r
1646 against an opponent on the ICS (Zippy mode), xboard sends "kibitz\r
1647 MESSAGE\n" to the ICS.\r
1648 </font>\r
1649 <p>\r
1650 \r
1651 <dt><strong>telluser MESSAGE</strong>\r
1652 <dd>xboard pops up an information dialog containing the message.\r
1653 MESSAGE consists of any characters, including whitespace, to the end\r
1654 of the line.\r
1655 <p>\r
1656 \r
1657 <dt><strong>tellusererror MESSAGE</strong>\r
1658 <dd>xboard pops up an error dialog containing the message.\r
1659 MESSAGE consists of any characters, including whitespace, to the end\r
1660 of the line.\r
1661 <p>\r
1662 \r
1663 <dt><strong>askuser REPTAG MESSAGE</strong>\r
1664 <dd>Here REPTAG is a string containing no whitespace, and MESSAGE\r
1665 consists of any characters, including whitespace, to the end of the\r
1666 line.  xboard pops up a question dialog that says MESSAGE and\r
1667 has a typein box.  If the user types in "bar", xboard sends "REPTAG\r
1668 bar" to the engine.  The user can cancel the dialog and send nothing.\r
1669 <p>\r
1670 \r
1671 <dt><strong>tellics MESSAGE</strong>\r
1672 <dd>In Zippy mode, xboard sends "MESSAGE\n" to ICS.  MESSAGE consists\r
1673 of any characters, including whitespace, to the end of the line.\r
1674 <p>\r
1675 \r
1676 <dt><font color=red><strong>tellicsnoalias MESSAGE</strong></font>\r
1677 <dd><font color=red>\r
1678 In Zippy mode, xboard sends "xMESSAGE\n" to ICS, where "x" is a\r
1679 character that prevents the ICS from expanding command aliases, if\r
1680 xboard knows of such a character.  (On chessclub.com and chess.net,\r
1681 "/" is used; on freechess.org, "$" is used.)  MESSAGE consists of any\r
1682 characters, including whitespace, to the end of the line.\r
1683 </font>\r
1684 <p>\r
1685 \r
1686 <dt><font color=green><strong># COMMENT</strong></font>\r
1687 <dd><font color=green>\r
1688 The engine can send any string of printable characters, terminated by a newline,\r
1689 for inclusion in the winboard.debug file, provided the line starts with a '#' character.\r
1690 If the engine has set feature debug=1,\r
1691 it is guaranteed that WinBoard (and any future version of it) will completely ignore\r
1692 these lines in any other respect.\r
1693 </font>\r
1694 </dl>\r
1695 <p>\r
1696 \r
1697 <h2><a name="10">10. Thinking Output</a></h2>\r
1698 \r
1699 <p>\r
1700 If the user asks your engine to "show thinking", xboard sends your\r
1701 engine the "post" command.  It sends "nopost" to turn thinking off.\r
1702 In post mode, your engine sends output lines to show the progress of\r
1703 its thinking.  The engine can send as many or few of these lines as it\r
1704 wants to, whenever it wants to.  Typically they would be sent when the\r
1705 PV (principal variation) changes or the depth changes.  The thinking\r
1706 output should be in the following format:\r
1707 </p>\r
1708 \r
1709 <pre>ply score time nodes pv</pre>\r
1710 \r
1711 Where:\r
1712 <table>\r
1713 <tr align="left"><th>ply<td>Integer giving current search depth.\r
1714 <tr align="left"><th>score<td>Integer giving current evaluation in centipawns.\r
1715 <tr align="left"><th>time<td>Current search time in centiseconds (ex:\r
1716 1028 = 10.28 seconds).\r
1717 \r
1718 <tr align="left"><th>nodes<td>Nodes searched.\r
1719 <tr align="left"><th>pv<td>Freeform text giving current "best" line.\r
1720 You can continue the pv onto another line if you start each\r
1721 continuation line with at least four space characters.\r
1722 </table>\r
1723 \r
1724 <p>\r
1725 Example:\r
1726 </p>\r
1727 \r
1728 <pre>  9 156 1084 48000 Nf3 Nc6 Nc3 Nf6</pre>\r
1729 \r
1730 <p>\r
1731 Meaning:\r
1732 </p>\r
1733 \r
1734 9 ply, score=1.56, time = 10.84 seconds, nodes=48000, \r
1735 PV = "Nf3 Nc6 Nc3 Nf6"\r
1736 \r
1737 <p>\r
1738 Longer example from actual Crafty output:\r
1739 </p>\r
1740 <pre>\r
1741   4    109      14   1435  1. e4 d5 2. Qf3 dxe4 3. Qxe4 Nc6\r
1742   4    116      23   2252  1. Nf3 Nc6 2. e4 e6\r
1743   4    116      27   2589  1. Nf3 Nc6 2. e4 e6\r
1744   5    141      44   4539  1. Nf3 Nc6 2. O-O e5 3. e4\r
1745   5    141      54   5568  1. Nf3 Nc6 2. O-O e5 3. e4\r
1746 </pre>\r
1747 \r
1748 <p>\r
1749 You can use the PV to show other things; for instance, while in book,\r
1750 Crafty shows the observed frequency of different reply moves in its\r
1751 book.  In situations like this where your engine is not really\r
1752 searching, start the PV with a '(' character:\r
1753 </p>\r
1754 \r
1755 <pre>\r
1756   0      0       0      0  (e4 64%, d4 24%)\r
1757 </pre>\r
1758 \r
1759 <p>\r
1760 GNU Chess output is very slightly different.  The ply number is\r
1761 followed by an extra nonblank character, and the time is in seconds,\r
1762 not hundredths of seconds.  For compatibility, xboard accepts the\r
1763 extra character and takes it as a flag indicating the different time\r
1764 units.  Example:\r
1765 </p>\r
1766 \r
1767 <pre>\r
1768  2.     14    0       38   d1d2  e8e7 \r
1769  3+     78    0       65   d1d2  e8e7  d2d3 \r
1770  3&     14    0       89   d1d2  e8e7  d2d3 \r
1771  3&     76    0      191   d1e2  e8e7  e2e3 \r
1772  3.     76    0      215   d1e2  e8e7  e2e3 \r
1773  4&     15    0      366   d1e2  e8e7  e2e3  e7e6 \r
1774  4.     15    0      515   d1e2  e8e7  e2e3  e7e6 \r
1775  5+     74    0      702   d1e2  f7f5  e2e3  e8e7  e3f4 \r
1776  5&     71    0     1085   d1e2  e8e7  e2e3  e7e6  e3f4 \r
1777  5.     71    0     1669   d1e2  e8e7  e2e3  e7e6  e3f4 \r
1778  6&     48    0     3035   d1e2  e8e7  e2e3  e7e6  e3e4  f7f5  e4d4 \r
1779  6.     48    0     3720   d1e2  e8e7  e2e3  e7e6  e3e4  f7f5  e4d4 \r
1780  7&     48    0     6381   d1e2  e8e7  e2e3  e7e6  e3e4  f7f5  e4d4 \r
1781  7.     48    0    10056   d1e2  e8e7  e2e3  e7e6  e3e4  f7f5  e4d4 \r
1782  8&     66    1    20536   d1e2  e8e7  e2e3  e7e6  e3d4  g7g5  a2a4  f7f5 \r
1783  8.     66    1    24387   d1e2  e8e7  e2e3  e7e6  e3d4  g7g5  a2a4  f7f5 \r
1784  9&     62    2    38886   d1e2  e8e7  e2e3  e7e6  e3d4  h7h5  a2a4  h5h4 \r
1785                            d4e4 \r
1786  9.     62    4    72578   d1e2  e8e7  e2e3  e7e6  e3d4  h7h5  a2a4  h5h4 \r
1787                            d4e4 \r
1788 10&     34    7   135944   d1e2  e8e7  e2e3  e7e6  e3d4  h7h5  c2c4  h5h4 \r
1789                            d4e4  f7f5  e4f4 \r
1790 10.     34    9   173474   d1e2  e8e7  e2e3  e7e6  e3d4  h7h5  c2c4  h5h4 \r
1791                            d4e4  f7f5  e4f4 \r
1792 </pre>\r
1793 \r
1794 <p>If your engine is pondering (thinking on its opponent's time) in post\r
1795 mode, it can show its thinking then too.  In this case your engine may\r
1796 omit the hint move (the move it is assuming its opponent will make)\r
1797 from the thinking lines <em>if and only if</em> it sends xboard the move in\r
1798 the usual "Hint: xxx" format before sending the first line.\r
1799 </p>\r
1800 \r
1801 <h2><a name="11">11. Time control</a></h2>\r
1802 \r
1803 <p>\r
1804 xboard supports three styles of time control: conventional chess clocks,\r
1805 the ICS-style incremental clock, and an exact number of seconds per move.\r
1806 </p>\r
1807 \r
1808 <p>In conventional clock mode, every time control period is the same.\r
1809 That is, if the time control is 40 moves in 5 minutes, then after each\r
1810 side has made 40 moves, they each get an additional 5 minutes, and so\r
1811 on, ad infinitum.  At some future time it would be nice to support a\r
1812 series of distinct time controls.  This is very low on my personal\r
1813 priority list, but code donations to the xboard project are accepted,\r
1814 so feel free to take a swing at it.  I suggest you talk to me first,\r
1815 though.\r
1816 </p>\r
1817 \r
1818 <p>\r
1819 The command to set a conventional time control looks like this:\r
1820 </p>\r
1821 \r
1822 <pre>\r
1823   level 40 5 0\r
1824   level 40 0:30 0\r
1825 </pre>\r
1826 \r
1827 <p>\r
1828 The 40 means that there are 40 moves per time control.  The 5 means\r
1829 there are 5 minutes in the control.  In the second example, the 0:30\r
1830 means there are 30 seconds.  The final 0 means that we are in\r
1831 conventional clock mode.\r
1832 </p>\r
1833 \r
1834 <p>\r
1835 <font color=green>\r
1836 Note that the time parameter in this command is not a pure numeric argument,\r
1837 but in general is a character string, in order to pass the number of seconds.\r
1838 Engines are encouraged to ignore any unexpected characters at the end of this string,\r
1839 i.e. following the MIN or MIN:SEC specification.\r
1840 Future protocol versions might (under control of an appropriate feature)\r
1841 append such extra characters to this argument,\r
1842 in order to inform the engine in advance of the time control it can expect after the current session completes.\r
1843 E.g. "level 40 25+5 0" could mean that the engine has to play 40 moves in 25 minutes,\r
1844 but should expect to get only 5 minutes for the entire remainder of the game after that,\r
1845 rather than another 25 minutes for the next 40 moves.\r
1846 When the time comes, (i.e. after the 40 moves), \r
1847 it will be informed of the time-control change by receiving a new "level 0 5 0" command,\r
1848 but engines with advanced time management might want to plan for this in advance.\r
1849 </font>\r
1850 </p>\r
1851 \r
1852 <p>\r
1853 The command to set an incremental time control looks like this:\r
1854 </p>\r
1855 \r
1856 <pre>\r
1857   level 0 2 12\r
1858 </pre>\r
1859 \r
1860 <p>\r
1861 Here the 0 means "play the whole game in this time control period",\r
1862 the 2 means "base=2 minutes", and the 12 means "inc=12 seconds".  As\r
1863 in conventional clock mode, the second argument to level can be in\r
1864 minutes and seconds.\r
1865 </p>\r
1866 \r
1867 <p>\r
1868 At the start of the game, each player's clock is set to base minutes.\r
1869 Immediately after a player makes a move, inc seconds are added to his\r
1870 clock.  A player's clock counts down while it is his turn.  Your flag\r
1871 can be called whenever your clock is zero or negative.  (Your clock\r
1872 can go negative and then become positive again because of the\r
1873 increment.)\r
1874 </p>\r
1875 \r
1876 <p><font color=blue>\r
1877 The number of moves given in the level command (when non-zero) should \r
1878 be taken as the number of moves still to do before the specified time\r
1879 will be added to the clock, if the "level" command is received after\r
1880 some moves have already been played.\r
1881 The time given should be interpreted as the time left on its clock\r
1882 (including any time left over from the previous sessions),\r
1883 and not necessarily the time that will be added to the clock\r
1884 after the specified number of moves has been played.\r
1885 This is only relevant in WinBoard 4.3.xx, which might send the engine\r
1886 "level" commands during a game,\r
1887 just before the engine has to start thinking about the first move of \r
1888 a new time-control session.\r
1889 Example: if at the start of the game "level 40 60 0" was given \r
1890 (40 moves per hour),\r
1891 and the engine receives "level 20 22 0" just before move 41,\r
1892 it should understand that it should do the next 20 moves in 22 minutes\r
1893 (pehaps because the secondary session was 20 moves per 15 minutes,\r
1894 and it had 7 minutes left on its clock after the first 40 moves).\r
1895 </font></p>\r
1896 \r
1897 <p>\r
1898 A special rule on some ICS implementations: if you ask for a game with\r
1899 base=0, the clocks really start at 10 seconds instead of 0.  xboard\r
1900 itself does not know about this rule, so it passes the 0 on to the\r
1901 engine instead of changing it to 0:10.\r
1902 </p>\r
1903 \r
1904 <p>\r
1905 ICS also has time odds games.  With time odds, each player has his own\r
1906 (base, inc) pair, but otherwise things work the same as in normal\r
1907 games.  The Zippy xboard accepts time odds games but ignores the fact\r
1908 that the opponent's parameters are different; this is perhaps not\r
1909 quite the right thing to do, but gnuchess doesn't understand time\r
1910 odds.  Time odds games are always unrated.\r
1911 </p>\r
1912 \r
1913 <p>\r
1914 The command to set an exact number of seconds per move looks like this:\r
1915 </p>\r
1916 \r
1917 <pre>\r
1918   st 30\r
1919 </pre>\r
1920 \r
1921 <p>\r
1922 This means that each move must be made in at most 30 seconds.  Time not used\r
1923 on one move does not accumulate for use on later moves.\r
1924 </p>\r
1925 \r
1926 <h2><a name="12">12. Analyze Mode</a></h2>\r
1927 \r
1928 <p>xboard supports analyzing fresh games, edited positions, and games\r
1929 from files.  However, all of these look the same from the chess\r
1930 engine's perspective. Basically, the engine just has to respond to the\r
1931 "analyze" command.  \r
1932 <font color=red>\r
1933 Beginning in protocol version 2,\r
1934 if your engine does not support analyze mode, it should use\r
1935 the feature command to set analyze=0.  \r
1936 </font>\r
1937 The older method of\r
1938 printing the error message "Error (unknown command): analyze" in\r
1939 response to the "analyze" command will also work, however.\r
1940 </p>\r
1941 \r
1942 <p>\r
1943 To enter analyze mode, xboard sends the command sequence "post", "analyze".  \r
1944 Analyze mode in your engine should be\r
1945 similar to force mode, except that your engine thinks about what move\r
1946 it would make next if it were on move.  Your engine should accept the\r
1947 following commands while in analyze mode:\r
1948 </p>\r
1949 \r
1950 <ul>\r
1951 <li>Any legal move, as in force mode\r
1952 <li><strong>undo</strong>&nbsp;&nbsp; Back up one move and analyze previous position.\r
1953 <li><strong>new</strong>&nbsp;&nbsp; Reset position to start of game but stay in analyze mode.\r
1954 <li><font color=red><strong>setboard</strong> if you have set feature setboard=1; otherwise <strong>edit</strong>.  Exiting edit mode returns to analyze mode.\r
1955 </font>\r
1956 <li><strong>exit</strong>&nbsp;&nbsp; Leave analyze mode.\r
1957 <li><strong>.</strong>&nbsp;&nbsp; Send a search status update (optional); see below.\r
1958 <li><font color=red>\r
1959 <strong>bk</strong>&nbsp;&nbsp; Show book moves from this position,\r
1960 if any; see above.</font>\r
1961 <li><font color=red>\r
1962 <strong>hint</strong>&nbsp;&nbsp; Show the predicted move from this\r
1963 position, if any; see above.</font>\r
1964 </ul>\r
1965   \r
1966 <p>\r
1967 If the user selects "Periodic Updates", xboard will send the string\r
1968 ".\n" to the chess engine periodically during analyze mode, unless the\r
1969 last PV received began with a '(' character.\r
1970 </p>\r
1971 \r
1972 <p>\r
1973 The chess engine should respond to ".\n" with a line like this:\r
1974 </p>\r
1975 \r
1976 <pre>\r
1977 stat01: time nodes ply mvleft mvtot <font color=red>mvname</font>\r
1978 </pre>\r
1979 \r
1980 Where:\r
1981 <table>\r
1982 <tr align="left"><th>time<td>Elapsed search time in centiseconds (ie: 567 = 5.67 seconds).\r
1983 <tr align="left"><th>nodes<td>Nodes searched so far.\r
1984 <tr align="left"><th>ply<td>Search depth so far.\r
1985 <tr align="left"><th>mvleft<td>Number of moves left to consider at this depth.\r
1986 <tr align="left"><th>mvtot<td>Total number of moves to consider.\r
1987 <tr align="left"><th><font color=red>mvname</font><td><font color=red>\r
1988 Move currently being considered (SAN or coordinate notation).  Optional;\r
1989 added in protocol version 2.</font>\r
1990 </table>\r
1991 \r
1992 <p>\r
1993 Examples:\r
1994 </p>\r
1995 <pre>\r
1996   stat01: 1234 30000 7 5 30\r
1997   stat01: 1234 30000 7 5 30 Nf3\r
1998 </pre>\r
1999 \r
2000 <p>\r
2001 Meaning:\r
2002 </p>\r
2003 \r
2004 <p>After 12.34 seconds, I've searched 7 ply/30000 nodes, there are a\r
2005   total of 30 legal moves, and I have 5 more moves to search\r
2006   before going to depth 8.  In the second example, of the 30 legal\r
2007   moves, the one I am currently searching is Nf3.</p>\r
2008 \r
2009 <p>\r
2010 Implementation of the "." command is optional. If the engine does not\r
2011 respond to the "." command with a "stat01..." line, xboard will stop\r
2012 sending "."  commands.  If the engine does not implement this command,\r
2013 the analysis window will use a shortened format to display the engine\r
2014 info.\r
2015 </p>\r
2016 \r
2017 <p>\r
2018 To give the user some extra information, the chess engine can output\r
2019 the strings "++\n" and "--\n", to indicate that the current search is\r
2020 failing high or low, respectively.  You don't have to send anything\r
2021 else to say "Okay, I'm not failing high/low anymore."  xboard will\r
2022 figure this out itself.\r
2023 </p>\r
2024 \r
2025 <h2><a name="13">13. Idioms and backward compatibility features</a></h2>\r
2026 \r
2027 <p>\r
2028 Some engines have variant interpretations of the force/go/white/black,\r
2029 time/otim, and hard/easy command sets.  \r
2030 In order to accommodate these older engines, xboard uses these commands\r
2031 only according to the stylized patterns ("idioms") given in this section.\r
2032 The obsolete white and black commands\r
2033 have historically been particularly troublesome, and it is recommended\r
2034 that new engines set the feature colors=0 and/or ignore the commands.\r
2035 </p>\r
2036 \r
2037 <dl>\r
2038 \r
2039 <dt><strong>time N</strong>\r
2040 <dt><strong>otim N</strong>\r
2041 <dt><strong>MOVE</strong>\r
2042 <dd>Sent when the opponent makes a move and the engine is already\r
2043 playing the opposite color.\r
2044 <p>\r
2045 \r
2046 <dt><strong>white</strong>\r
2047 <dt><strong>go</strong>\r
2048 <dd>Sent when the engine is in force mode or playing Black but should\r
2049 switch to playing White.  This sequence is sent only when White is\r
2050 already on move.  \r
2051 <font color=red>\r
2052 If you set the feature colors=0, "white" is not sent.\r
2053 </font>\r
2054 <p>\r
2055 \r
2056 <dt><strong>black</strong>\r
2057 <dt><strong>go</strong>\r
2058 <dd>Sent when the engine is in force mode or playing White but should\r
2059 switch to playing Black.  This sequence is sent only when Black is\r
2060 already on move.  \r
2061 <font color=red>\r
2062 If you set the feature colors=0, "black" is not sent.\r
2063 </font>\r
2064 <p>\r
2065 \r
2066 <dt><strong>white</strong>\r
2067 <dt><strong>time N</strong>\r
2068 <dt><strong>otim N</strong>\r
2069 <dt><strong>black</strong>\r
2070 <dt><strong>go</strong>\r
2071 <dd>Sent when Black is on move, the engine is in force mode or playing\r
2072 White, and the engine's clock needs to be updated before it starts\r
2073 playing.  \r
2074 The initial "white" is a kludge to accommodate GNU Chess\r
2075 4's variant interpretation of these commands.  \r
2076 <font color=red>\r
2077 If you set the feature colors=0, "white" and "black" are not sent.\r
2078 </font>\r
2079 <p>\r
2080 \r
2081 <dt><strong>black</strong>\r
2082 <dt><strong>time N</strong>\r
2083 <dt><strong>otim N</strong>\r
2084 <dt><strong>white</strong>\r
2085 <dt><strong>go</strong>\r
2086 <dd>Sent when White is on move, the engine is in force mode or playing\r
2087 Black, and the engine's clock needs to be updated before it starts\r
2088 playing.  See previous idiom.  \r
2089 The initial "black" is a kludge to accommodate GNU Chess\r
2090 4's variant interpretation of these commands.  \r
2091 <font color=red>\r
2092 If you set the feature colors=0, "black" and "white" are not sent.\r
2093 </font>\r
2094 <p>\r
2095 \r
2096 <dt><strong>hard</strong>\r
2097 <dt><strong>easy</strong>\r
2098 <dd>Sent in sequence to turn off pondering if xboard is not sure\r
2099 whether it is on.  When xboard is sure, it will send "hard" or "easy"\r
2100 alone.  xboard does this because "easy" is a toggle in GNU Chess 4 but\r
2101 "hard" is an absolute on.\r
2102 \r
2103 </dl>\r
2104 \r
2105 <p>\r
2106 To support older engines, certain additional commands from the engine\r
2107 to xboard are also recognized.  (These are commands by themselves, not\r
2108 values to be placed in the comment field of the PGN result code.)\r
2109 These forms are not recommended for new engines; use the PGN result\r
2110 code commands or the resign command instead.\r
2111 </p>\r
2112 \r
2113 <table>\r
2114 <tr align="left"><th>Command              <th>Interpreted as\r
2115 <tr align="left"><td>White resigns        <td>0-1 {White resigns}\r
2116 <tr align="left"><td>Black resigns        <td>1-0 {Black resigns}\r
2117 <tr align="left"><td>White                <td>1-0 {White mates}\r
2118 <tr align="left"><td>Black                <td>0-1 {Black mates}\r
2119 <tr align="left"><td>Draw                 <td>1/2-1/2 {Draw}\r
2120 <tr align="left"><td>computer mates       <td>1-0 {White mates} or 0-1 {Black mates}\r
2121 <tr align="left"><td>opponent mates       <td>1-0 {White mates} or 0-1 {Black mates}\r
2122 <tr align="left"><td>computer resigns     <td>0-1 {White resigns} or 1-0 {Black resigns}\r
2123 <tr align="left"><td>game is a draw       <td>1/2-1/2 {Draw}\r
2124 <tr align="left"><td>checkmate            <td>1-0 {White mates} or 0-1 {Black mates}\r
2125 </table>\r
2126 \r
2127 <p>\r
2128 Commands in the above table are recognized if they begin a line and\r
2129 arbitrary characters follow, so (for example) "White mates" will be\r
2130 recognized as "White", and "game is a draw by the 50 move rule" will\r
2131 be recognized as "game is a draw".  All the commands are\r
2132 case-sensitive.\r
2133 </p>\r
2134 \r
2135 <p>\r
2136 An alternative move syntax is also recognized:\r
2137 </p>\r
2138 \r
2139 <table>\r
2140 <tr align="left"><th>Command              <th>Interpreted as\r
2141 <tr align="left"><td>NUMBER ... MOVE      <td>move MOVE\r
2142 </table>\r
2143 \r
2144 <p>\r
2145 Here NUMBER means any string of decimal digits, optionally ending in a\r
2146 period.  MOVE is any string containing no whitespace.  In this command\r
2147 format, xboard requires the "..." even if your engine is playing\r
2148 White.  A command of the form NUMBER MOVE will be ignored.  This odd\r
2149 treatment of the commands is needed for compatibility with gnuchessx.\r
2150 The original reasons for it are lost in the mists of time, but I\r
2151 suspect it was originally a bug in the earliest versions of xboard,\r
2152 before I started working on it, which someone "fixed" in the wrong\r
2153 way, by creating a special version of gnuchess (gnuchessx) instead of\r
2154 changing xboard.\r
2155 </p>\r
2156 \r
2157 <p>\r
2158 Any line that contains the words "offer" and "draw" is recognized as\r
2159 "offer draw".\r
2160 </p>\r
2161 \r
2162 <p>\r
2163 The "Illegal move" message is recognized even if spelled "illegal\r
2164 move" and even if the colon (":") is omitted.  This accommodates GNU\r
2165 Chess 4, which prints messages like "Illegal move (no matching\r
2166 move)e2e4", and old versions of Crafty, which print just "illegal move".\r
2167 </p>\r
2168 \r
2169 <p>\r
2170 In Zippy mode, for compatibility with older versions of Crafty,\r
2171 xboard passes through to ICS any line that begins "kibitz", "whisper",\r
2172 "tell", or "draw".  Do not use this feature in new code.  Instead, use the\r
2173 commands "tellall", "tellothers", "tellopponent", "tellics" (if needed),\r
2174 "1/2-1/2 {COMMENT}", or "offer draw", as appropriate.\r
2175 </p>\r
2176 \r
2177 <p>\r
2178 <font color=red>\r
2179 If the engine responds to the "sd DEPTH" command with an error message\r
2180 indicating the command is not supported (such as "Illegal move: sd"),\r
2181 xboard sets an internal flag and subsequently uses the command\r
2182 "depth\nDEPTH" instead, for the benefit of GNU Chess 4.  Note the\r
2183 newline in the middle of this command!  New engines should not rely on\r
2184 this feature.\r
2185 </font>\r
2186 </p>\r
2187 \r
2188 <p>\r
2189 <font color=red>\r
2190 If the engine responds to the "st TIME" command with an error message\r
2191 indicating the command is not supported (such as "Illegal move: st"),\r
2192 xboard sets an internal flag and subsequently uses the command "level\r
2193 1 TIME" instead, for the benefit of GNU Chess 4.  Note that this is\r
2194 not a standard use of the level command, as TIME seconds are not added\r
2195 after each player makes 1 move; rather, each move is made in at most\r
2196 TIME seconds.  New engines should not implement or rely on this\r
2197 feature.\r
2198 </font>\r
2199 </p>\r
2200 \r
2201 <font color=red>\r
2202 <p>\r
2203 In support of the -firstHost/-secondHost features, which allow a chess\r
2204 engine to be run on another machine using the rsh protocol, xboard recognizes\r
2205 error messages that are likely to come from rsh as fatal errors.  The following\r
2206 messages are currently recognized:\r
2207 </p>\r
2208 \r
2209 <blockquote>\r
2210 unknown host<br>\r
2211 No remote directory<br>\r
2212 not found<br>\r
2213 No such file<br>\r
2214 can't alloc<br>\r
2215 Permission denied<br>\r
2216 </blockquote>\r
2217 </font>\r
2218 \r
2219 <p>\r
2220 <font color=red>\r
2221 ChessBase/Fritz now implements the xboard/winboard protocol and can use\r
2222 WinBoard-compatible engines in its GUI.  ChessBase's version of the\r
2223 protocol is generally the same as version 1, except that they have\r
2224 added the commands <strong>fritz</strong>, <strong>reset</strong>, and\r
2225 <strong>ponder</strong>, and the edit subcommands\r
2226 <strong>castle</strong> and <strong>ep</strong>.  If you want your\r
2227 engine to work well with the ChessBase/Fritz GUI, you may need to\r
2228 implement these additional commands, and you should also be aware of\r
2229 the peculiar way that ChessBase uses the protocol.  See their <a\r
2230 href="http://www.chessbase.com/Products/engines/winboard/tech.htm"\r
2231 >web page</a> for documentation.\r
2232 </font>\r
2233 </p>\r
2234 \r
2235 <p>\r
2236 <font color=red>\r
2237 ChessMaster 8000 also implements version 1 of the xboard/winboard\r
2238 protocol and can use WinBoard-compatible engines.  The original\r
2239 release of CM8000 also has one additional restriction: only pure\r
2240 coordinate notation (e.g., e2e4) is accepted in the move command.  A\r
2241 patch to correct this should be available from The Learning Company\r
2242 (makers of CM8000) in February 2001.\r
2243 </font>\r
2244 </p>\r
2245 \r
2246 <hr noshade size="2">\r
2247 <address>converted to HTML by <a href="http://www.jakob.at/steffen/">Steffen A. Jakob</a></address>\r
2248 </body>\r
2249 </html>\r