version 1.4b27
[polyglot.git] / polyglot.pod
1 =head1 NAME
2
3 PolyGlot -  Winboard protocol to UCI protocol adapter
4          -  book engine for Polyglot books 
5          -  a collection of utilities for creating and analyzing opening books
6          -  a utility for analyzing epd files
7          -  a perft counter
8
9 =head1 SYNOPSIS
10
11 polyglot [configfile]
12
13 polyglot -ec engine
14
15 polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform]
16
17 polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]
18
19 polyglot info-book [-bin inputfile] [-exact]
20
21 polyglot dumb-book [-bin inputfile] -color color [-out outputfile]
22
23 polyglot [configfile] epd-test [-epd inputfile] [-min-depth depth] [-max-depth depth] [-max-time time] [-depth-delta delta] 
24
25 polyglot perft [-fen fen] [-max-depth depth]
26
27 =head1 DESCRIPTION
28
29 =head2 PolyGlot as adapter and book engine
30
31 PolyGlot is a "UCI adapter".  It connects a GUI interface (such as
32 XBoard, Winboard, Arena or Chessbase) to a UCI chess engine.
33
34 By specifying an opening book (in PolyGlot book format) chess engines can
35 transparently use such books.
36
37 PolyGlot understands the two main GUI protocols: UCI and
38 xboard. Normally the protocol will be auto detected but this can be
39 overridden in the configuration file.
40
41 In xboard mode PolyGlot fully translates between the xboard and UCI protocols.
42 In addition it tries to solve known problems with other adapters.
43 For instance, it detects and reports draws by fifty-move rule,
44 repetition, etc ... It also supports Chess960.
45
46 When in UCI mode PolyGlot mostly passes commands from the GUI
47 to the engine and vice versa, except that it will play book moves on
48 behalf of the engine when the occasion arises.
49
50 The engine options are exported as UCI options in UCI
51 mode and as "feature option=" commands in xboard mode. The latter form
52 an extension of the xboard protocol as defined by H.G. Muller.
53
54 Options which normally appear in the [PolyGlot] section of the
55 config file (see below) are exported as options with their name prefixed
56 by "Polyglot". This makes it easy to filter them in the GUI.
57
58 NOTE: Not all options are exported, only those that make sense in the
59 given mode.
60
61 =head2 Book making utilities
62
63 PolyGlot supports the "PolyGlot opening book format". This is the
64 defacto standard non-proprietary opening book format. It is fully documented
65 here
66
67 http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html
68
69 Roughly speaking a PolyGlot opening book is a collection of triples
70 (position, move, weight). A "position" is represented by a 64-bit
71 Zobrist hash key. The weight is proportional to the probability the move should
72 be played. 
73
74 Other opening book formats such as ChessBase's .ctg format and Arena's
75 .abk format are undocumented and proprietary. They can only be used 
76 by their own GUIs. 
77
78 PolyGlot can compile a pgn file into a binary PolyGlot book and furthermore
79 it can merge two such binary books into a third one.
80
81 PolyGlot can also extract some useful information from PolyGlot books. The utility
82 "dump-book" dumps the "lines" in a book for a given color. By definition
83 a line is a sequence of moves (from the starting position) in which
84 the given color makes only book moves and the other color makes 
85 arbitrary moves (i.e. not necessarily book moves).
86
87 Since a PolyGlot book is built up from positions and not lines there
88 may be (and there usually are) many positions in the book that are not
89 on a "line" as defined in the previous paragraph. It is convenient
90 to call such positions "isolated" positions. The utility "info-book"
91 counts such isolated positions.
92
93 Some of the isolated positions are provably unreachable and they
94 could in principle be deleted from the book. For example if a book
95 contains only the move "e4" in the starting position but also the
96 position after "d4 d5" then this last position is provably unreachable
97 since it requires white to make a non-book move when a book move is
98 available. Such situations arise frequently from the priority rules
99 in merging books.
100
101 Unfortunately not all isolated positions are provably unreachable and
102 it is difficult to identify the latter. If invoked with "-exact" the
103 utility info-book will attempt to count the isolated positions which
104 require a player to make a non-book move when a book move is available.
105 Due to the possibility of transpositions this is not a fool proof method.
106
107 =head2 Epd test mode
108
109 In epd test mode, PolyGlot will search positions in an epd file and
110 record the number of times the right best move was found.  The
111 arguments specify when to stop the search in any given position.
112
113 =head2 Perft counts
114
115 A perft count is the number of legal move sequence in a given position
116 up to a given depth. PolyGlot can perform such perft counts. It
117 is however much slower than other more dedicated programs.
118
119 =head1 OPTIONS
120
121 When invoked without options or with a config file as argument PolyGlot
122 acts as an adapter. The config file format is documented below.  The
123 default config file is "polyglot.ini".
124
125 When invoked as
126
127 =head2 polyglot -ec engine
128
129 PolyGlot simply starts "engine" and acts as an adapter. No config file
130 is used and thus it is expected that all properties will be set by the
131 GUI. 
132
133 When invoked as
134
135 =head2 polyglot make-book
136
137 PolyGlot supports the following options
138
139 =over 4
140
141 =item B<-pgn> (default: "book.pgn")
142
143 Input file in pgn format. 
144
145 =item B<-bin> (default: "book.bin")
146
147 Output file in PolyGlot format. 
148
149 =item B<-max-ply> (default: 1024)
150
151 Specifies the maximum ply-depth of lines included in the book.
152
153 =item B<-min-game> (default: 3)
154
155 Specifies the minimum number of games that have to contain this move for it to be included in the book.
156
157 =item B<-min-score> (default: 0.0)
158
159 Specifies the minimum score (or weight) this move should have received for 
160 it to  be included in the book. The score is 2*(wins)+(draws), globally scaled
161 to fit into 16 bits. 
162
163 =item B<-only-white>
164
165 Include only moves for white in the book.
166
167 =item B<-only-black>
168     
169 Include only moves for black in the book.
170
171 =item B<-uniform>
172     
173 Set all weights to 1. In other words, all moves will be selected with 
174 equal probability. 
175
176 =back
177
178 When invoked
179 as
180
181 =head2 polyglot merge-book
182
183 PolyGlot supports the following options
184
185 =over 4
186
187 =item B<-in1>
188     
189 First input file (in PolyGlot book format).
190
191 =item B<-in2>
192     
193 Second input file (in PolyGlot book format).
194
195 =item B<-out> (default: out.bin)
196     
197 Output file (in PolyGlot book format).
198
199 =back
200
201 Input files are not symmetrical, "in1" has priority over "in2". In other
202 words when a position occurs both in "in1" and "in2" only the
203 moves and weights from "in1" will be retained in "out".
204
205 When invoked
206 as
207
208 =head2 polyglot dump-book
209
210 PolyGlot supports the following options
211
212 =over 4
213
214 =item B<-bin> (default: book.bin)
215
216 Input file in PolyGlot book format.
217
218 =item B<-color> 
219
220 The color for whom to generate the lines.
221
222 =item B<-out> (default: book_<color>.txt)
223
224 The name of the output file.
225
226 =back
227
228 When invoked
229 as
230
231 =head2 polyglot info-book
232
233 PolyGlot supports the following options
234
235 =over 4
236
237 =item B<-bin> (default: book.bin)
238
239 Input file in PolyGlot book format.
240
241 =item B<-exact> 
242
243 Attempt to count the provably unreachable positions among the isolated ones.
244 Note that this takes a very long time. 
245
246 =back
247
248 When invoked as
249
250 =head2 polyglot epd-test
251
252 (possibly with a config file as first argument) PolyGlot supports the following
253 options
254
255 =over 4
256
257 =item B<-max-depth> (default: 63)
258
259 Unconditionally stop the search when this depth has
260 been reached.
261
262 =item B<-max-time> (default: 5.0)
263
264 Unconditionally stop the seach after this amount of time.
265
266 =item B<-depth-delta> (default: 3)
267
268 Stop the search if the solution as been found and the best move has
269 been constant for this many depths, on condition that the mininal
270 depth and minimal time have been reached.
271
272 =item B<-min-depth> (default: 8)
273
274 Minimal search depth when the search is stopped using "-depth-delta".
275
276 =item B<-min-time> (default: 1.0)
277
278 Minimal search time when the search is stopped using "-depth-delta".
279
280
281 =back
282
283 When invoked as
284
285 =head2 polyglot perft
286
287 PolyGlot supports the following
288 options
289
290 =over 4
291
292 =item B<-fen> (default: starting position) 
293
294 Fen at which to start searching.
295
296 =item B<-max-depth> (default: 1) 
297
298 Maximum depth to search.
299
300 =back
301
302 =head1 CONFIG FILE FORMAT
303
304 There should be a different config file for each engine.  
305
306 The config file is in the traditional INI format.  
307
308     [PolyGLot]
309     option = value
310     ...
311     [Engine]
312     option = value
313     ...
314
315 The characters "#" and ";" serve as comment characters. 
316
317 NOTE: There can be spaces in option names or values.  Do not use
318 quotes. Boolean values are written as "true" or "false". 
319
320 =head2 [PolyGlot] section
321
322 This section is used by PolyGlot only.  The engine is unaware of these
323 options.  The list of available options is detailed below.
324
325 =over 4
326
327 =item B<EngineName> (default: UCI name)
328
329 This is the name that will appear in the GUI.  It is
330 cosmetic only.  You can use different names for tweaked versions of
331 the same engine.
332
333 =item B<EngineDir> (default: ".")
334
335 Full path of the directory where the engine is installed.  You can use
336 "." (without the quotes) if you know that PolyGlot will be launched in
337 the engine directory or the engine is in the "path" and does not need
338 any data file.
339
340 =item B<EngineCommand>
341
342 Put here the name of the engine executable file.  You can also add
343 command-line arguments.  Path searching is used and the current
344 directory will be "EngineDir".
345
346 =item B<Log> (default: false)
347
348 Whether PolyGlot should log all transactions with the interface and
349 the engine.  This should be necessary only to locate problems.
350
351 =item B<LogFile> (default: polyglot.log)
352
353 The name of the log file.  Note that it is put where PolyGlot was
354 launched from, not into the engine directory.
355
356 WARNING: Log files are not cleared between sessions, and can become
357 very large.  It is safe to remove them though.
358
359 =item B<Resign> (default: false)
360
361 Set this to "true" if you want PolyGlot to resign on behalf of the
362 engine.
363
364 NOTE: Some engines display buggy scores from time to time although the
365 best move is correct.  Use this option only if you know what you are
366 doing (e.g. you always check the final position of games).
367
368 =item B<ResignMoves> (default: 3)
369
370 Number of consecutive moves with "resign" score (see below) before
371 PolyGlot resigns for the engine.  Positions with only one legal move
372 are ignored.
373
374 =item B<ResignScore> (default: 600)
375
376 This is the score in centipawns that will trigger resign "counting".
377
378 =item B<ShowPonder> (default: true)
379
380 Show search information during engine pondering.  Turning this off
381 might be better for interactive use in some interfaces.
382
383 =item B<ScoreWhite> (default: true)
384
385 Report score from white's point of view in xboard mode.
386
387 =item B<KibitzMove> (default: false)
388
389 Whether to kibitz when playing a move.
390
391 =item B<KibitzPV> (default: false)
392
393 Whether to kibitz when the PV is changed (new iteration or new best move).
394
395 =item B<KibitzCommand> (default: "tellall")
396
397 xboard command to use for kibitzing, normally "tellall" for kibitzing
398 or "tellothers" for whispering.
399
400 =item B<KibitzDelay> (default: 5)
401
402 How many seconds to wait before starting kibitzing.  This has an
403 effect only if "KibitzPV" is selected, move kibitzes are always sent
404 regardless of the delay.
405
406 =item B<KibitzInterval> (default: 0)
407
408 This is another form of throttling. PolyGlot will usually wait this
409 many seconds before doing the next kibitz. 
410
411 =item B<UCI> (default: false)
412
413 If true PolyGlot will not understand xboard commands. 
414
415 =item B<Chess960> (default: false)
416
417 Play Chess960 (also called Fischer Random Chess or FRC),
418
419 =item B<MateScore> (default: 10000)
420
421 Mate score reported to GUI when in xboard mode. 
422
423 =item B<Book> (default: false)
424
425 Indicates whether a PolyGlot book should be used.  This has no effect
426 on the engine own book (which can be controlled with the UCI option
427 "OwnBook" in the [Engine] section).  In particular, it is possible to
428 use both a PolyGlot book and an engine book.  In that case, the engine
429 book will be used whenever PolyGlot is out of book.  Remember that
430 PolyGlot is unaware of whether the engine is itself using a book or
431 not.
432
433 =item B<BookFile> (default: book.bin)
434
435 The name of the (binary) book file.  Note that PolyGlot will look for
436 it in the directory it was launched from, not in the engine directory.
437 Of course, full path can be used in which case the current directory
438 does not matter.
439
440 =item B<BookRandom> (default: true)
441
442 Select moves according to their weights in the book. If false the move
443 with the highest weight is selected. 
444
445 =item B<BookLearn> (default: false)
446
447 Record learning information in the opening book. Naturally this requires
448 the opening book to be writable. 
449
450 =item B<UseNice> (default: false)
451
452 Run the engine at nice level 5, or "NiceValue" if it set.  On some
453 operating systems it may be necessary to run the engine at lower
454 priority for it to be responsive to commands from PolyGlot while
455 searching.
456
457 =item B<NiceValue> (default: 5)
458
459 Nice levels go from -20 to 20 with 20 being the lowest priority.
460 On Unix only root can set negative nice levels. On Windows the standard
461 Win32 priority levels are mapped in a sensible way to Unix nice levels.
462
463
464 =item B<Affinity> (default: -1)
465
466 This a bit vector in which each bit represents the processors that a
467 process is allowed to run on. This option works only on Windows. 
468
469
470 =back
471
472 =head2 Work arounds 
473
474 Work arounds are identical to options except that they should be used
475 only when necessary.  Their purpose is to try to hide problems with
476 various software (not just engines).  The default value is always
477 correct for bug-free software.
478
479 IMPORTANT: Any of these work arounds might be removed in future
480 versions of PolyGlot.  You are strongly recommended to contact the
481 author of faulty software and truly fix the problem.
482
483 PolyGlot supports the following work arounds:
484
485 =over 4
486
487 =item B<UCIVersion> (default: 2)
488
489 The default value of 2 corresponds to UCI+.  Use 1 to select plain
490 UCI for engines that have problems with UCI+.
491
492 =item B<CanPonder> (default: false)
493
494 PolyGlot now conforms to the documented UCI behaviour: the engine will
495 be allowed to ponder only if it (the engine) declares the "Ponder" UCI
496 option.  However some engines which can actually ponder do not declare
497 the option.  This work around lets PolyGlot know that they can ponder.
498
499 =item B<SyncStop> (default: false)
500
501 When a ponder miss occurs, Polyglot interrupts the engine and
502 IMMEDIATELY launches a new search.  While there should be no problem
503 with this, some engines seem confused and corrupt their search board.
504 "SyncStop" forces PolyGlot to wait for the (now useless) ponder search
505 to finish before launching the new search.
506
507 =item B<PromoteWorkAround> (default: false)
508
509 Some engines do not specify a promotion piece, e.g. they send "e7e8"
510 instead of the correct "e7e8q".  This work around enables the
511 incorrect form (and of course promotes into a queen).
512
513 =item B<RepeatPV> (default: true)
514
515 When true, PolyGlot repeats the last pv string (which also contains
516 score,depth and time usage) it got from the engine. Some engines
517 however do not send a new pv string just before sending the move.
518 In that case the output of PolyGlot would be inconsistent. 
519 When RepeatPV is false PolyGlot does not repeat the last pv string.
520 Due to the way kibitzing is implemented, KibitzMove is disabled in that case. 
521
522 =back
523
524
525 =head2 [Engine] section
526
527 This section contains engine UCI options.  PolyGlot does not
528 understand them, but sends the information to the engine at startup
529 (converted to UCI form).  You can add any UCI option that makes sense
530 to the engine (not just the common options about hash-table size and
531 tablebases).
532
533 NOTE: use INI syntax, not UCI.  For example "OwnBook = true" is
534 correct.  It will be replaced by PolyGlot with "setoption name OwnBook
535 value true" at engine startup.
536
537 Standard UCI options are 
538
539     Hash 
540     NalimovPath
541     NalimovCache
542     OwnBook
543
544 Hidden options like "Ponder" or "UCI_xxx" are automatic
545 and should not be put in an INI file.
546
547 The other options are engine-specific.  Check their name using a UCI
548 GUI or launch the engine in a console and type "uci".
549
550 =head1 EXAMPLES
551
552 Compile "games.pgn" into a book "book.bin" retaining all lines of at
553 most 30 plies.
554
555     polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30
556
557 Merge books "w1.bin" and "w2.bin" into a book "w.bin".
558
559     polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin
560
561 Inspect lines for white in "w.bin"
562
563     polyglot dump-book -bin w.bin -color white -out w_white.txt
564
565 Test epd file "test.epd" with a (maximum) search time of 7 minutes per position
566
567     polyglot epd-test -epd test.epd -max-time 420
568
569 The command line for using the UCI engine "fruit" in a GUI which uses the
570 xboard protocol.
571
572     polyglot -ec fruit
573
574 The equivalent config file:
575
576     [PolyGlot]
577     EngineCommand = fruit
578     [Engine]
579
580
581 =head1 EXIT STATUS
582
583 PolyGlot always returns 0 on exit. 
584
585 =head1 AUTHORS
586
587 Main author: Fabien Letouzey<fabien_letouzey(at)hotmail.com>
588
589 Native Windows port:  Huang Chen<webmaster@elephantbase.net> ("Morning Yellow")
590
591 Various enhancements: Fonzy Bleumers<match(at)geenvis.net>
592
593 UCI port: Michel Van den Bergh <michel.vandenbergh(at)uhasselt.be>
594
595 =head1 SEE ALSO
596
597 xboard(6)