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
11 polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en enginename] [-log true/false] [-lf logfile] [-pg <name>=<value>]* [-uci <name>=<value>]*
13 polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform]
15 polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]
17 polyglot info-book [-bin inputfile] [-exact]
19 polyglot dump-book [-bin inputfile] -color color [-out outputfile]
21 polyglot [configfile] epd-test [engineoptions] [-epd inputfile] [-min-depth depth] [-max-depth depth] [-max-time time] [-depth-delta delta]
23 polyglot perft [-fen fen] [-max-depth depth]
27 =head2 PolyGlot as adapter and book engine
29 PolyGlot is a "UCI adapter". It connects a GUI interface (such as
30 XBoard, Winboard, Arena or Chessbase) to a UCI chess engine.
32 By specifying an opening book (in PolyGlot book format) chess engines can
33 transparently use such books.
35 PolyGlot understands the two main GUI protocols: UCI and
36 xboard. Normally the protocol will be auto detected but this can be
37 overridden in the configuration file.
39 In xboard mode PolyGlot fully translates between the xboard and UCI protocols.
40 In addition it tries to solve known problems with other adapters.
41 For instance, it detects and reports draws by fifty-move rule,
42 repetition, etc ... It also supports Chess960.
44 When in UCI mode PolyGlot mostly passes commands from the GUI
45 to the engine and vice versa, except that it will play book moves on
46 behalf of the engine when the occasion arises.
48 The engine options are exported as UCI options in UCI
49 mode and as "feature option=" commands in xboard mode. The latter form
50 an extension of the xboard protocol as defined by H.G. Muller.
52 Options which normally appear in the [PolyGlot] section of the
53 config file (see below) are exported as options with their name prefixed
54 by "Polyglot". This makes it easy to filter them in the GUI.
56 NOTE: Not all options are exported, only those that make sense in the
59 =head2 Book making utilities
61 PolyGlot supports the "PolyGlot opening book format". This is the
62 defacto standard non-proprietary opening book format. It is fully documented
65 http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html
67 Roughly speaking a PolyGlot opening book is a collection of triples
68 (position, move, weight). A "position" is represented by a 64-bit
69 Zobrist hash key. The weight is proportional to the probability the move should
72 Other opening book formats such as ChessBase's .ctg format and Arena's
73 .abk format are undocumented and proprietary. They can only be used
76 PolyGlot can compile a pgn file into a binary PolyGlot book and furthermore
77 it can merge two such binary books into a third one.
79 PolyGlot can also extract some useful information from PolyGlot books. The utility
80 "dump-book" dumps the "lines" in a book for a given color. By definition
81 a line is a sequence of moves (from the starting position) in which
82 the given color makes only book moves and the other color makes
83 arbitrary moves (i.e. not necessarily book moves).
85 Since a PolyGlot book is built up from positions and not lines there
86 may be (and there usually are) many positions in the book that are not
87 on a "line" as defined in the previous paragraph. It is convenient
88 to call such positions "isolated" positions. The utility "info-book"
89 counts such isolated positions.
91 Some of the isolated positions are provably unreachable and they
92 could in principle be deleted from the book. For example if a book
93 contains only the move "e4" in the starting position but also the
94 position after "d4 d5" then this last position is provably unreachable
95 since it requires white to make a non-book move when a book move is
96 available. Such situations arise frequently from the priority rules
99 Unfortunately not all isolated positions are provably unreachable and
100 it is difficult to identify the latter. If invoked with "-exact" the
101 utility info-book will attempt to count the isolated positions which
102 require a player to make a non-book move when a book move is available.
103 Due to the possibility of transpositions this is not a fool proof method.
107 In epd test mode, PolyGlot will search positions in an epd file and
108 record the number of times the right best move was found. The
109 arguments specify when to stop the search in any given position.
113 A perft count is the number of legal move sequence in a given position
114 up to a given depth. PolyGlot can perform such perft counts. It
115 is however much slower than other more dedicated programs.
119 When PolyGlot is invoked as an adapter of in epd-test mode it gets its
120 options from a config file and then from the command line. The
121 default config file is "polyglot.ini" but an alternative one may be
122 optionally included as first argument. The config file format is
125 The following engine options may be specified on the command line.
131 Do not use a config file, even if one was specified on the command line.
135 The argument is a string of the form <name>=<value>. This option will
136 set the Polyglot option <name> to <value>.
140 The argument is a string of the form <name>=<value>. This option will
141 set the engine option <name> to <value>.
145 This is an alias for -pg "EngineCommand=<value>"
149 This is an alias for -pg "EngineDir=<value>"
153 This is an alias for -pg "EngineName=<value>"
155 =item B<-log> (default: false)
157 This is an alias for -pg "Log=<value>"
159 =item B<-lf> (default: "polyglot.log")
161 This is an alias for -pg "LogFile=<value>".
163 =item B<-wb> (default: "true")
165 This is an alias for -pg "OnlyWbOptions=<value>".
171 =head2 polyglot make-book
173 PolyGlot supports the following options
177 =item B<-pgn> (default: "book.pgn")
179 Input file in pgn format.
181 =item B<-bin> (default: "book.bin")
183 Output file in PolyGlot format.
185 =item B<-max-ply> (default: 1024)
187 Specifies the maximum ply-depth of lines included in the book.
189 =item B<-min-game> (default: 3)
191 Specifies the minimum number of games that have to contain this move for it to be included in the book.
193 =item B<-min-score> (default: 0.0)
195 Specifies the minimum score (or weight) this move should have received for
196 it to be included in the book. The score is 2*(wins)+(draws), globally scaled
201 Include only moves for white in the book.
205 Include only moves for black in the book.
209 Set all weights to 1. In other words, all moves will be selected with
217 =head2 polyglot merge-book
219 PolyGlot supports the following options
225 First input file (in PolyGlot book format).
229 Second input file (in PolyGlot book format).
231 =item B<-out> (default: out.bin)
233 Output file (in PolyGlot book format).
237 Input files are not symmetrical, "in1" has priority over "in2". In other
238 words when a position occurs both in "in1" and "in2" only the
239 moves and weights from "in1" will be retained in "out".
244 =head2 polyglot dump-book
246 PolyGlot supports the following options
250 =item B<-bin> (default: book.bin)
252 Input file in PolyGlot book format.
256 The color for whom to generate the lines.
258 =item B<-out> (default: book_<color>.txt)
260 The name of the output file.
267 =head2 polyglot info-book
269 PolyGlot supports the following options
273 =item B<-bin> (default: book.bin)
275 Input file in PolyGlot book format.
279 Attempt to count the provably unreachable positions among the isolated ones.
280 Note that this takes a very long time.
286 =head2 polyglot epd-test
288 (possibly with a config file as first argument) PolyGlot supports
289 besides the generic options described above the following additional
294 =item B<-max-depth> (default: 63)
296 Unconditionally stop the search when this depth has
299 =item B<-max-time> (default: 5.0)
301 Unconditionally stop the seach after this amount of time.
303 =item B<-depth-delta> (default: 3)
305 Stop the search if the solution as been found and the best move has
306 been constant for this many depths, on condition that the mininal
307 depth and minimal time have been reached.
309 =item B<-min-depth> (default: 8)
311 Minimal search depth when the search is stopped using "-depth-delta".
313 =item B<-min-time> (default: 1.0)
315 Minimal search time when the search is stopped using "-depth-delta".
322 =head2 polyglot perft
324 PolyGlot supports the following
329 =item B<-fen> (default: starting position)
331 Fen at which to start searching.
333 =item B<-max-depth> (default: 1)
335 Maximum depth to search.
339 =head1 CONFIG FILE FORMAT
341 There should be a different config file for each engine.
343 The config file is in the traditional INI format.
352 The characters "#" and ";" serve as comment characters.
354 Initial and final white space is stripped from option names and
355 values. If you need to use characters which have a special meaning to
356 PolyGlot (these are ';#[]=\') you should quote them by preceding them
357 with '\'. "Quoting" other characters in this way has no effect. In
358 particular the use of '\' as a path separator in windows should
359 normally not affected.
361 =head2 [PolyGlot] section
363 This section is used by PolyGlot only. The engine is unaware of these
364 options. The list of available options is detailed below.
368 =item B<EngineName> (default: UCI name)
370 This is the name that will appear in the GUI. It is
371 cosmetic only. You can use different names for tweaked versions of
374 =item B<EngineDir> (default: ".")
376 Full path of the directory where the engine is installed. You can use
377 "." (without the quotes) if you know that PolyGlot will be launched in
378 the engine directory or the engine is in the "path" and does not need
381 =item B<EngineCommand>
383 Put here the name of the engine executable file. You can also add
384 command-line arguments. Path searching is used and the current
385 directory will be "EngineDir". On Linux the EngineCommand is passed
386 to wordexp so that shell quoting rules and expansions are applied.
387 On Windows the EngineCommand is simply passed to CreateProcess which
388 does its own shell like processing.
390 =item B<SettingsDir> (default: $HOME/.polyglot on Linux; ".\_PG" on Windows)
392 The directory where ini files are stored for engines that are started with
393 -noini. Such ini files may be created by pushing the "Save" button in the
394 Engine settings dialog in WB/XB 4.4.0 and higher. As a special exception
395 (for WB/XB 4.4.0 compatibility) this directory is also used in case
396 PolyGlot is started with config files named "polyglot_1st.ini" or
399 =item B<Log> (default: false)
401 Whether PolyGlot should log all transactions with the interface and
402 the engine. This should be necessary only to locate problems.
404 =item B<LogFile> (default: polyglot.log)
406 The name of the log file. Note that it is put where PolyGlot was
407 launched from, not into the engine directory.
409 WARNING: Log files are not cleared between sessions, and can become
410 very large. It is safe to remove them though.
412 =item B<Resign> (default: false)
414 Set this to "true" if you want PolyGlot to resign on behalf of the
417 NOTE: Some engines display buggy scores from time to time although the
418 best move is correct. Use this option only if you know what you are
419 doing (e.g. you always check the final position of games).
421 =item B<ResignMoves> (default: 3)
423 Number of consecutive moves with "resign" score (see below) before
424 PolyGlot resigns for the engine. Positions with only one legal move
427 =item B<ResignScore> (default: 600)
429 This is the score in centipawns that will trigger resign "counting".
431 =item B<QueenNeverResigns> (default: true)
433 Suppresses resigning irrespective of the score,
434 as long as the engine still has a Queen (hoping for a perpetual).
436 =item B<HandleDraws> (default: false)
438 When set Polyglot can accept draw offers on behalf of the engine,
439 when the last reported engine score is below Polyglot's contempt.
441 =item B<ContemptScore> (default: 30)
443 This is the score in centipawns that the engine must minimally see
444 in its own disadvantage before Polyglot will accept a draw offer.
446 =item B<ShowPonder> (default: true)
448 Show search information during engine pondering. Turning this off
449 might be better for interactive use in some interfaces.
451 =item B<ShowTbHits> (default: false)
453 Reports extra info on selective depth, search speed (knps) and
454 tablebase hits at the beginning of the PV field in the thinking output
455 of WinBoard protocol, just before the real PV.
457 =item B<ScoreWhite> (default: true)
459 Report score from white's point of view in xboard mode. (Wrecks XBoard...).
461 =item B<KibitzMove> (default: false)
463 Whether to kibitz when playing a move.
465 =item B<KibitzPV> (default: false)
467 Whether to kibitz when the PV is changed (new iteration or new best move).
469 =item B<KibitzCommand> (default: "tellall")
471 xboard command to use for kibitzing, normally "tellall" for kibitzing
472 or "tellothers" for whispering.
474 =item B<KibitzDelay> (default: 5)
476 How many seconds to wait before starting kibitzing. This has an
477 effect only if "KibitzPV" is selected, move kibitzes are always sent
478 regardless of the delay.
480 =item B<KibitzInterval> (default: 0)
482 This is another form of throttling. PolyGlot will usually wait this
483 many seconds before doing the next kibitz.
485 =item B<UCI> (default: false)
487 If true PolyGlot will not understand xboard commands.
489 =item B<MateScore> (default: 10000)
491 Mate score reported to GUI when in xboard mode.
493 =item B<Book> (default: false)
495 Indicates whether a PolyGlot book should be used. This has no effect
496 on the engine own book (which can be controlled with the UCI option
497 "OwnBook" in the [Engine] section). In particular, it is possible to
498 use both a PolyGlot book and an engine book. In that case, the engine
499 book will be used whenever PolyGlot is out of book. Remember that
500 PolyGlot is unaware of whether the engine is itself using a book or
503 =item B<BookFile> (default: book.bin)
505 The name of the (binary) book file. Note that PolyGlot will look for
506 it in the directory it was launched from, not in the engine directory.
507 Of course, full path can be used in which case the current directory
510 =item B<BookRandom> (default: true)
512 Select moves according to their weights in the book. If false the move
513 with the highest weight is selected.
515 =item B<BookLearn> (default: false)
517 Switches on updating of the 'learn fields' of the opening book,
518 which for each move record the number of times the move was played,
519 and the number of half-points scored with it.
520 It also switches on making use of this information already in the book,
521 for altering the move-selection probabilities from those
522 specified by the book weights.
523 (Rarely played moves will be favored,
524 moves with a significant poor performance will be shunned.)
525 This option must be set before the book is specified,
526 or the updating of the learn info will not work!
528 =item B<BookDepth> (default: 256)
530 Stop using the book after this number of moves.
532 =item B<BookTreshold> (default: 5)
534 Do not play moves with a weight (probability) lower than this (in per mil).
536 =item B<UseNice> (default: false)
538 Run the engine at nice level 5, or "NiceValue" if it set. On some
539 operating systems it may be necessary to run the engine at lower
540 priority for it to be responsive to commands from PolyGlot while
543 =item B<NiceValue> (default: 5)
545 Nice levels go from -20 to 20 with 20 being the lowest priority.
546 On Unix only root can set negative nice levels. On Windows the standard
547 Win32 priority levels are mapped in a sensible way to Unix nice levels.
550 =item B<Affinity> (default: -1)
552 This a bit vector in which each bit represents the processors that a
553 process is allowed to run on. This option works only on Windows.
555 =item B<STFudge> (default: 20)
557 PolyGlot will translate "st x" as "go movetime 1000*x-STFudge".
558 The rationale is that in the UCI specification the argument of movetime
559 is defined as the exact search time whereas the argument of the
560 st command is only an upperbound.
562 =item B<OnlyWbOptions> (default: true)
564 If true then PolyGlot restricts the options it sends to those that
565 are potentially useful for WinBoard.
571 Work arounds are identical to options except that they should be used
572 only when necessary. Their purpose is to try to hide problems with
573 various software (not just engines).
575 IMPORTANT: Any of these work arounds might be removed in future
576 versions of PolyGlot. You are strongly recommended to contact the
577 author of faulty software and truly fix the problem.
579 PolyGlot supports the following work arounds:
583 =item B<UCIVersion> (default: 2)
585 The default value of 2 corresponds to UCI+. Use 1 to select plain
586 UCI for engines that have problems with UCI+.
588 =item B<CanPonder> (default: false)
590 PolyGlot now conforms to the documented UCI behaviour: the engine will
591 be allowed to ponder only if it (the engine) declares the "Ponder" UCI
592 option. However some engines which can actually ponder do not declare
593 the option. This work around lets PolyGlot know that they can ponder.
595 =item B<SyncStop> (default: false)
597 When a ponder miss occurs, Polyglot interrupts the engine and
598 IMMEDIATELY launches a new search. While there should be no problem
599 with this, some engines seem confused and corrupt their search board.
600 "SyncStop" forces PolyGlot to wait for the (now useless) ponder search
601 to finish before launching the new search.
603 =item B<PromoteWorkAround> (default: false)
605 Some engines do not specify a promotion piece, e.g. they send "e7e8"
606 instead of the correct "e7e8q". This work around enables the
607 incorrect form (and of course promotes into a queen).
609 =item B<RepeatPV> (default: true)
611 When true, PolyGlot repeats the last pv string (which also contains
612 score,depth and time usage) it got from the engine. Some engines
613 however do not send a new pv string just before sending the move.
614 In that case the output of PolyGlot would be inconsistent.
615 When RepeatPV is false PolyGlot does not repeat the last pv string.
616 Due to the way kibitzing is implemented, KibitzMove is disabled in that case.
621 =head2 [Engine] section
623 This section contains engine UCI options. PolyGlot does not
624 understand them, but sends the information to the engine at startup
625 (converted to UCI form). You can add any UCI option that makes sense
626 to the engine (not just the common options about hash-table size and
629 NOTE: use INI syntax, not UCI. For example "OwnBook = true" is
630 correct. It will be replaced by PolyGlot with "setoption name OwnBook
631 value true" at engine startup.
633 Standard UCI options are
643 Hidden options like "Ponder" or "UCI_xxx" are automatic
644 and should not be put in an INI file.
646 The other options are engine-specific. Check their name using a UCI
647 GUI or launch the engine in a console and type "uci".
651 Running the UCI engine "fruit" under xboard 4.3.15 and later (this invokes PolyGlot internally).
653 xboard -fcp fruit -fUCI
655 An explicit command line for using the UCI engine "fruit" with logging enabled (this works also with older versions of xboard).
657 xboard -fcp "polyglot -noini -log true -ec fruit"
659 The equivalent config file would be:
662 EngineCommand = fruit
666 Compile "games.pgn" into a book "book.bin" retaining all lines of at
669 polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30
671 Merge books "w1.bin" and "w2.bin" into a book "w.bin".
673 polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin
675 Inspect lines for white in "w.bin"
677 polyglot dump-book -bin w.bin -color white -out w_white.txt
679 Test epd file "test.epd" with a (maximum) search time of 7 minutes per position
681 polyglot epd-test -epd test.epd -max-time 420
685 PolyGlot always returns 0 on exit.
689 Main author: Fabien Letouzey<fabien_letouzey(at)hotmail.com>
691 Native Windows port: Huang Chen<webmaster@elephantbase.net> ("Morning Yellow")
693 Various enhancements: Fonzy Bleumers<match(at)geenvis.net>
695 UCI port and implementation of new WB protocol: Michel Van den Bergh
696 <michel.vandenbergh(at)uhasselt.be>