POLYGLOT(6)

πŸ“¦
version 2.0.4+git20210322 Β· 2 versions
  • 2.0.4+git20210322 Β· debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 2.0.4 Β· alpine 3.24
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 POLYGLOT(6) 🌸

okay bestie, sit DOWN, because this is the POLYGLOT(6) manual page and it is so much. it's giving swiss army knife energy, fr fr πŸ’…


✨ NAME ✨

PolyGlot β€” and she does a lot, no cap:

  • a Winboard protocol to UCI protocol adapter πŸ¦‹
  • a book engine for PolyGlot books πŸ“–
  • a collection of utilities for creating and analyzing opening books πŸŽ€
  • a utility for analyzing epd files πŸ”
  • a perft counter πŸ”₯

🫢 SYNOPSIS 🫢

here's the whole vibe, verbatim, don't touch anything:

polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en
enginename] [-log true/false] [-lf logfile] [-pg <name>=<value>]* [-uci
<name>=<value>]*

polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply]
[-min-game games] [-min-score score] [-only-white] [-only-black]
[-uniform]

polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]

polyglot info-book [-bin inputfile] [-exact]

polyglot dump-book [-bin inputfile] -color color [-out outputfile]

polyglot [configfile] epd-test [engineoptions] [-epd inputfile]
[-min-depth depth] [-max-depth depth] [-max-time time] [-depth-delta
delta]

polyglot perft [-fen fen] [-max-depth depth]

πŸ’– DESCRIPTION πŸ’–

πŸ‘‘ PolyGlot as adapter and book engine

so PolyGlot is a "UCI adapter". like, that's her whole thing. she connects a GUI interface (think XBoard, Winboard, Arena or Chessbase) to a UCI chess engine. matchmaker behavior honestly 🌈

and if you specify an opening book (in PolyGlot book format), chess engines can just... transparently use those books. iconic. no extra work, it just happens ✨

PolyGlot understands the two main GUI protocols: UCI and xboard. normally the protocol gets auto detected, but you can override that in the config file if you're feeling spicy.

in xboard mode, PolyGlot fully translates between the xboard and UCI protocols. and not just that β€” she tries to fix known problems other adapters have. for example, she detects and reports draws by fifty-move rule, repetition, etc... she also supports Chess960. queen behavior, honestly πŸ’…

when in UCI mode, PolyGlot mostly just passes commands from the GUI to the engine and vice versa β€” except she'll play book moves on behalf of the engine when the occasion arises. main character moment πŸŽ€

the engine options are exported as UCI options in UCI mode and as "feature option=" commands in xboard mode. that latter form is an extension of the xboard protocol as defined by H.G. Muller.

options that normally live in the [PolyGlot] section of the config file (more on that below πŸ‘‡) get exported as options with their name prefixed by "Polyglot". that makes it super easy to filter them in the GUI, you're welcome.

NOTE: not all options are exported, bestie. only the ones that make sense in the given mode. vibe check passed only for those 🧚

πŸ“š Book making utilities

PolyGlot supports the "PolyGlot opening book format". it's the defacto standard non-proprietary opening book format and it's fully documented right here:

http://hgm.nubati.net/book_format.html

roughly speaking (ngl this is the simplified version), a PolyGlot opening book is a collection of triples: (position, move, weight). a "position" is represented by a 64-bit Zobrist hash key. and the weight is proportional to the probability the move should be played. math girlie behavior πŸ”₯

other opening book formats β€” like ChessBase's .ctg format and Arena's .abk format β€” are undocumented and proprietary. they can only be used by their own GUIs. not our problem πŸ’€

PolyGlot can compile a pgn file into a binary PolyGlot book, and she can also merge two such binary books into a third one. multitasking queen πŸ‘‘

PolyGlot can also extract some genuinely useful info from PolyGlot books:

  • the utility dump-book dumps the "lines" in a book for a given color. by definition a line is a sequence of moves (from the starting position) in which the given color makes only book moves and the other color makes arbitrary moves (i.e. not necessarily book moves).
  • since a PolyGlot book is built up from positions and not lines, there may be (and there usually are) many positions in the book that are not on a "line" as defined in the previous paragraph. it's convenient to call such positions "isolated" positions. the utility info-book counts such isolated positions. πŸ¦‹

some of the isolated positions are provably unreachable and they could in principle be deleted from the book. for example, if a book contains only the move "e4" in the starting position but also the position after "d4 d5", then this last position is provably unreachable, since it requires white to make a non-book move when a book move is available. such situations arise frequently from the priority rules in merging books. it's giving chaos 😭

unfortunately not all isolated positions are provably unreachable and it's difficult to identify the latter. if invoked with "-exact", the utility info-book will attempt to count the isolated positions which require a player to make a non-book move when a book move is available. but because of the possibility of transpositions, this is not a fool proof method. lowkey a warning, highkey still useful πŸ™ˆ


πŸ” Epd test mode

in epd test mode, PolyGlot will search positions in an epd file and record the number of times the right best move was found. the arguments specify when to stop the search in any given position. slay, tracked and logged πŸ’…


πŸ”’ Perft counts

a perft count is the number of legal move sequence in a given position up to a given depth. PolyGlot can perform such perft counts. it is however much slower than other more dedicated programs. just so you know what you're getting into, bestie 🫢


πŸŽ€ OPTIONS πŸŽ€

when PolyGlot is invoked as an adapter or in epd-test mode, she gets her options from a config file and then from the command line. the default config file is "polyglot.ini" but an alternative one may optionally be included as the first argument. the config file format is described below πŸ‘‡

the following engine options may be specified on the command line:

  • -noini β€” do not use a config file, even if one was specified on the command line. bye config file πŸ‘‹
  • -pg β€” the argument is a string of the form <name>=<value>. this option will set the Polyglot option <name> to <value>.
  • -uci β€” the argument is a string of the form <name>=<value>. this option will set the engine option <name> to <value>.
  • -ec β€” this is an alias for -pg "EngineCommand=<value>"
  • -ed β€” this is an alias for -pg "EngineDir=<value>"
  • -en β€” this is an alias for -pg "EngineName=<value>"
  • -log (default: false) β€” this is an alias for -pg "Log=<value>"
  • -lf (default: "polyglot.log") β€” this is an alias for -pg "LogFile=<value>".
  • -wb (default: "true") β€” this is an alias for -pg "OnlyWbOptions=<value>".

when invoked as:


🌸 polyglot make-book

PolyGlot supports the following options:

  • -pgn (default: "book.pgn") β€” input file in pgn format.
  • -bin (default: "book.bin") β€” output file in PolyGlot format.
  • -max-ply (default: 1024) β€” specifies the maximum ply-depth of lines included in the book.
  • -min-game (default: 3) β€” specifies the minimum number of games that have to contain this move for it to be included in the book.
  • -min-score (default: 0.0) β€” specifies the minimum score (or weight) this move should have received for it to be included in the book. the score is 2*(wins)+(draws), globally scaled to fit into 16 bits.
  • -only-white β€” include only moves for white in the book.
  • -only-black β€” include only moves for black in the book.
  • -uniform β€” set all weights to 1. in other words, all moves will be selected with equal probability.

when invoked as:


πŸ’œ polyglot merge-book

PolyGlot supports the following options:

  • -in1 β€” first input file (in PolyGlot book format).
  • -in2 β€” second input file (in PolyGlot book format).
  • -out (default: out.bin) β€” output file (in PolyGlot book format).

when a position occurs in both input books, its moves will be combined. if a move from that position occurs in both books, a single entry for that move will appear in the output book, with a weight that is the sum of the weights from the input books. the learn field will be copied from the first book, though. (that part's important, don't skip it bestie 😀)

when invoked as:


πŸ¦‹ polyglot dump-book

PolyGlot supports the following options:

  • -bin (default: book.bin) β€” input file in PolyGlot book format.
  • -color β€” the color for whom to generate the lines.
  • -out (default: book_<color>.txt) β€” the name of the output file.

when invoked as:


✨ polyglot info-book

PolyGlot supports the following options:

  • -bin (default: book.bin) β€” input file in PolyGlot book format.
  • -exact β€” attempt to count the provably unreachable positions among the isolated ones. note that this takes a very long time. like, go make a snack. πŸ“

when invoked as:


🌈 polyglot epd-test

(possibly with a config file as first argument) PolyGlot supports, besides the generic options described above, the following additional options:

  • -max-depth (default: 63) β€” unconditionally stop the search when this depth has been reached.
  • -max-time (default: 5.0) β€” unconditionally stop the seach after this amount of time.
  • -depth-delta (default: 3) β€” stop the search if the solution as been found and the best move has been constant for this many depths, on condition that the mininal depth and minimal time have been reached.
  • -min-depth (default: 8) β€” minimal search depth when the search is stopped using "-depth-delta".
  • -min-time (default: 1.0) β€” minimal search time when the search is stopped using "-depth-delta".

when invoked as:


πŸ”₯ polyglot perft

PolyGlot supports the following options:

  • -fen (default: starting position) β€” fen at which to start searching.
  • -max-depth (default: 1) β€” maximum depth to search.

πŸ“– CONFIG FILE FORMAT πŸ“–

there should be a different config file for each engine. one engine, one config, that's the rule πŸŽ€

the config file is in the traditional INI format.

[PolyGLot]
option = value
...
[Engine]
option = value
...

the characters "#" and ";" serve as comment characters.

initial and final white space is stripped from option names and values. if you need to use characters which have a special meaning to PolyGlot (these are ';#[]=\') you should quote them by preceding them with '\'. "quoting" other characters in this way has no effect. in particular, the use of '\' as a path separator in windows should normally not affected. πŸ’…


πŸ’– [PolyGlot] section

this section is used by PolyGlot only. the engine is unaware of these options. the list of available options is detailed below.

  • EngineName (default: UCI name) β€” this is the name that will appear in the GUI. it is cosmetic only. you can use different names for tweaked versions of the same engine. cute, right? πŸŽ€
  • EngineDir (default: ".") β€” full path of the directory where the engine is installed. you can use "." (without the quotes) if you know that PolyGlot will be launched in the engine directory, or the engine is in the "path" and does not need any data file.
  • EngineCommand β€” put the name of the engine executable file right here, bestie 🫢 you can also add command-line arguments to it. Path searching is used, and the current directory will be EngineDir. On Linux the EngineCommand gets passed to wordexp, so shell quoting rules and expansions are applied. On Windows the EngineCommand is simply passed to CreateProcess, which does its own shell-like processing.
  • Save
  • SettingsFile (default: polyglot.ini) β€” this option redefines the name of PolyGlot's config file, so that a future use of the interactive "Polyglot Save" option can save settings you changed interactively (i.e. through the GUI interface) to a different file than the one the settings were originally read from. little glow-up for your config file ✨
  • SettingsDir (default: $HOME/.polyglot on Linux; ".\_PG" on Windows) β€” the directory where ini files are stored for engines that are started with -noini. Such ini files may be created by pushing the "Polyglot Save" button in the Engine settings dialog in WB/XB 4.4.0 and higher. As a special exception (for WB/XB 4.4.0 compatibility) this directory is also used in case PolyGlot is started with config files named "polyglot_1st.ini" or "polyglot_2nd.ini".
  • Log (default: false) β€” whether PolyGlot should log all transactions with the interface and the engine. This should be necessary only to locate problems. detective mode, but only when you need it πŸ”
  • LogFile (default: polyglot.log) β€” the name of the log file. Note that it is put where PolyGlot was launched from, not into the engine directory.
    • ⚠️ WARNING: Log files are not cleared between sessions, and can become very large. It is safe to remove them though.
  • Resign (default: false) β€” set this to "true" if you want PolyGlot to resign on behalf of the engine. letting PolyGlot take the L for you, iconic πŸ’…
    • πŸ“Œ NOTE: Some engines display buggy scores from time to time although the best move is correct. Use this option only if you know what you are doing (e.g. you always check the final position of games).
  • ResignMoves (default: 3) β€” number of consecutive moves with "resign" score (see below) before PolyGlot resigns for the engine. Positions with only one legal move are ignored.
  • ResignScore (default: 600) β€” this is the score in centipawns that will trigger resign "counting".
  • QueenNeverResigns (default: true) β€” suppresses resigning irrespective of the score, as long as the engine still has a Queen (hoping for a perpetual). the queen stays booked and busy, periodt πŸ‘‘
  • Handledraws (default: false) β€” when set, Polyglot can accept draw offers on behalf of the engine, when the last reported engine score is below Polyglot's contempt.
  • ContemptScore (default: 30) β€” this is the score in centipawns that the engine must minimally see in its own disadvantage before Polyglot will accept a draw offer.
  • ShowPonder (default: true) β€” show search information during engine pondering. Turning this off might be better for interactive use in some interfaces.
  • ShowTbHits (default: false) β€” reports extra info on selective depth, search speed (knps) and tablebase hits at the beginning of the PV field in the thinking output of WinBoard protocol, just before the real PV.
  • ScoreWhite (default: true) β€” report score from white's point of view in xboard mode. (Wrecks XBoard...). yeah it literally says that, not me being dramatic 😭
  • KibitzMove (default: false) β€” whether to kibitz when playing a move.
  • KibitzPV (default: false) β€” whether to kibitz when the PV is changed (new iteration or new best move).
  • KibitzCommand (default: "tellall") β€” xboard command to use for kibitzing, normally "tellall" for kibitzing or "tellothers" for whispering. telling everyone vs telling some everyone 🫒
  • KibitzDelay (default: 5) β€” how many seconds to wait before starting kibitzing. This has an effect only if "KibitzPV" is selected, move kibitzes are always sent regardless of the delay.
  • KibitzInterval (default: 0) β€” this is another form of throttling. PolyGlot will usually wait this many seconds before doing the next kibitz.
  • UCI (default: false) β€” if true PolyGlot will not understand xboard commands.
  • MateScore (default: 0) β€” mate score reported to GUI when in xboard mode. When set to 0 it uses the new CECP convention of reporting 100000 + N for mate in N moves, and -(100000 + N) for mated in N.
  • Book (default: false) β€” indicates whether a PolyGlot book should be used. This has no effect on the engine own book (which can be controlled with the UCI option "OwnBook" in the [Engine] section). In particular, it is possible to use both a PolyGlot book and an engine book. In that case, the engine book will be used whenever PolyGlot is out of book. Remember that PolyGlot is unaware of whether the engine is itself using a book or not. two books, zero beef, they just coexist πŸ“š
  • BookFile (default: book.bin) β€” the name of the (binary) book file. Note that PolyGlot will look for it in the directory it was launched from, not in the engine directory. Of course, a full path can be used, in which case the current directory does not matter.
  • BookRandom (default: true) β€” select moves according to their weights in the book. If false the move with the highest weight is selected.
  • BookLearn (default: false) β€” switches on updating of the 'learn fields' of the opening book, which for each move record the number of times the move was played, and the number of half-points scored with it. It also switches on making use of this information already in the book, for altering the move-selection probabilities from those specified by the book weights. (Rarely played moves will be favored, moves with a significant poor performance will be shunned.) This option must be set before the book is specified, or the updating of the learn info will not work! fr fr, order matters πŸ’€
  • BookDepth (default: 256) β€” stop using the book after this number of moves.
  • BookTreshold (default: 5) β€” do not play moves with a weight (probability) lower than this (in per mil). (yes, it's spelled BookTreshold, no we are not fixing it, it's canon πŸŽ€)
  • UseNice (default: false) β€” run the engine at nice level 5, or "NiceValue" if it is set. On some operating systems it may be necessary to run the engine at lower priority for it to be responsive to commands from PolyGlot while searching.
  • NiceValue (default: 5) β€” nice levels go from -20 to 20 with 20 being the lowest priority. On Unix only root can set negative nice levels. On Windows the standard Win32 priority levels are mapped in a sensible way to Unix nice levels.
  • Affinity (default: -1) β€” this is a bit vector in which each bit represents the processors that a process is allowed to run on. This option works only on Windows.
  • STFudge (default: 20) β€” PolyGlot will translate "st x" as "go movetime 1000*x-STFudge". The rationale is that in the UCI specification the argument of movetime is defined as the exact search time whereas the argument of the st command is only an upperbound.
  • OnlyWbOptions (default: true) β€” if true then PolyGlot restricts the options it sends to those that are potentially useful for WinBoard.

πŸ”§ Work arounds

Work arounds are identical to options except that they should be used only when necessary. Their purpose is to try to hide problems with various software (not just engines). band-aids for other people's bugs 🩹

IMPORTANT: Any of these work arounds might be removed in future versions of PolyGlot. You are strongly recommended to contact the author of faulty software and truly fix the problem. please go yell at the actual bug, not at PolyGlot πŸ™

PolyGlot supports the following work arounds:

  • UCIVersion (default: 2) β€” the default value of 2 corresponds to UCI+. Use 1 to select plain UCI for engines that have problems with UCI+.
  • CanPonder (default: false) β€” PolyGlot now conforms to the documented UCI behaviour: the engine will be allowed to ponder only if it (the engine) declares the "Ponder" UCI option. However some engines which can actually ponder do not declare the option. This work around lets PolyGlot know that they can ponder.
  • SyncStop (default: false) β€” when a ponder miss occurs, Polyglot interrupts the engine and IMMEDIATELY launches a new search. While there should be no problem with this, some engines seem confused and corrupt their search board. "SyncStop" forces PolyGlot to wait for the (now useless) ponder search to finish before launching the new search. patience is a virtue, apparently πŸ’†
  • PromoteWorkAround (default: false) β€” some engines do not specify a promotion piece, e.g. they send "e7e8" instead of the correct "e7e8q". This work around enables the incorrect form (and of course promotes into a queen). she's getting that crown either way πŸ‘‘
  • RepeatPV (default: true) β€” when true, PolyGlot repeats the last pv string (which also contains score, depth and time usage) it got from the engine. Some engines however do not send a new pv string just before sending the move. In that case the output of PolyGlot would be inconsistent. When RepeatPV is false PolyGlot does not repeat the last pv string. Due to the way kibitzing is implemented, KibitzMove is disabled in that case.

πŸŽ›οΈ [Engine] section

This section contains engine UCI options. PolyGlot does not understand them, but sends the information to the engine at startup (converted to UCI form). You can add any UCI option that makes sense to the engine (not just the common options about hash-table size and tablebases). PolyGlot is literally just the messenger 🫑

NOTE: use INI syntax, not UCI. For example "OwnBook = true" is correct. It will be replaced by PolyGlot with "setoption name OwnBook value true" at engine startup.

Standard UCI options are

  • Hash
  • NalimovPath
  • NalimovCache
  • GaviotaPath
  • GaviotaCache
  • SyzygyPath
  • OwnBook

Hidden options like "Ponder" or "UCI_xxx" are automatic and should not be put in an INI file. leave those alone bestie, they handle themselves πŸ™ˆ

The other options are engine-specific. Check their name using a UCI GUI or launch the engine in a console and type "uci".

✨ EXAMPLES ✨

Okay bestie, this is the part where it all clicks. Real commands, real vibes, let's GO πŸ’…


πŸ“ Running fruit under xboard 4.3.15 and later

This one is chef's kiss because xboard does the PolyGlot wrangling for you internally:

xboard -fcp fruit -fUCI

🌸 An explicit command line, with logging ON

Same engine (fruit, an UCI engine), but you spell the whole thing out, and logging is turned on. Bonus: this also works with older versions of xboard, no cap.

xboard -fcp "polyglot -noini -log true -ec fruit"

And the equivalent config file (yes, the same setup, just written as config) would be:

[PolyGlot]
EngineCommand = fruit
Log = true
[Engine]

πŸŽ€ Compiling a book from a PGN

Compile games.pgn into a book book.bin, keeping all lines that are at most 30 plies long:

polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30

πŸ¦‹ Merging two books into one

Merge books w1.bin and w2.bin into a book called w.bin:

polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin

πŸ’œ Peeking inside a book

Inspect the lines for white in w.bin:

polyglot dump-book -bin w.bin -color white -out w_white.txt

πŸ”₯ Testing an EPD file

Test test.epd with a (maximum) search time of 7 minutes per position:

polyglot epd-test -epd test.epd -max-time 420

(Seven minutes = 420 seconds, in case the math wasn't mathing at first glance. It's giving "trust the process" ⭐)


πŸ’€ EXIT STATUS

PolyGlot always returns 0 on exit.

That's it. That's the whole section. No dramatic failures, no exit-code lore, it just walks out of the party with a zero and a smile. Iconic behaviour, honestly πŸ™ˆ


πŸ‘‘ AUTHORS

  • Main author: Fabien Letouzey<fabien_letouzey(at)hotmail.com>
  • Native Windows port: Huang Chen<webmaster@elephantbase.net> ("Morning Yellow")
  • Various enhancements: Fonzy Bleumers<match(at)geenvis.net>
  • UCI port and implementation of new WB protocol: Michel Van den Bergh <michel.vandenbergh(at)uhasselt.be>

Shoutout to the whole squad 🫢 these are the people who made PolyGlot exist and keep it cute.


🌈 SEE ALSO


That's a wrap on POLYGLOT(6) bestie β€” page date 2021-03-21, and yes, the footer says POLYGLOT(6) because that's its whole name-tag energy ✨ Go forth, run your engines, and remember: -noini when you want to be ✨mysterious✨ about your config. Mwah πŸ’‹