version 1.4w10UCIb22
[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<KibitzMove> (default: false)
384
385 Whether to kibitz when playing a move.
386
387 =item B<KibitzPV> (default: false)
388
389 Whether to kibitz when the PV is changed (new iteration or new best move).
390
391 =item B<KibitzCommand> (default: "tellall")
392
393 xboard command to use for kibitzing, normally "tellall" for kibitzing
394 or "tellothers" for whispering.
395
396
397 =item B<KibitzDelay> (default: 5)
398
399 How many seconds to wait before starting kibitzing.  This has an
400 effect only if "KibitzPV" is selected, move kibitzes are always sent
401 regardless of the delay.
402
403 =item B<UCI> (default: false)
404
405 If true PolyGlot will not understand xboard commands. 
406
407 =item B<Chess960> (default: false)
408
409 Play Chess960 (also called Fischer Random Chess or FRC),
410
411 =item B<MateScore> (default: 10000)
412
413 Mate score reported to GUI when in xboard mode. 
414
415 =item B<Book> (default: false)
416
417 Indicates whether a PolyGlot book should be used.  This has no effect
418 on the engine own book (which can be controlled with the UCI option
419 "OwnBook" in the [Engine] section).  In particular, it is possible to
420 use both a PolyGlot book and an engine book.  In that case, the engine
421 book will be used whenever PolyGlot is out of book.  Remember that
422 PolyGlot is unaware of whether the engine is itself using a book or
423 not.
424
425 =item B<BookFile> (default: book.bin)
426
427 The name of the (binary) book file.  Note that PolyGlot will look for
428 it in the directory it was launched from, not in the engine directory.
429 Of course, full path can be used in which case the current directory
430 does not matter.
431
432 =item B<BookRandom> (default: true)
433
434 Select moves according to their weights in the book. If false the move
435 with the highest weight is selected. 
436
437 =item B<BookLearn> (default: false)
438
439 Record learning information in the opening book. Naturally this requires
440 the opening book to be writable. 
441
442 =item B<UseNice> (default: false)
443
444 Run the engine at nice level 5, or "NiceValue" if it set.  On some
445 operating systems it may be necessary to run the engine at lower
446 priority for it to be responsive to commands from PolyGlot while
447 searching.
448
449 =item B<NiceValue> (default: 5)
450
451 Nice levels go from -20 to 20 with 20 being the lowest priority.
452 On Unix only root can set negative nice levels. On Windows the standard
453 Win32 priority levels are mapped in a sensible way to Unix nice levels.
454
455
456 =item B<Affinity> (default: -1)
457
458 This a bit vector in which each bit represents the processors that a
459 process is allowed to run on. This option works only on Windows. 
460
461
462 =back
463
464 =head2 Work arounds 
465
466 Work arounds are identical to options except that they should be used
467 only when necessary.  Their purpose is to try to hide problems with
468 various software (not just engines).  The default value is always
469 correct for bug-free software.
470
471 IMPORTANT: Any of these work arounds might be removed in future
472 versions of PolyGlot.  You are strongly recommended to contact the
473 author of faulty software and truly fix the problem.
474
475 PolyGlot supports the following work arounds:
476
477 =over 4
478
479 =item B<UCIVersion> (default: 2)
480
481 The default value of 2 corresponds to UCI+.  Use 1 to select plain
482 UCI for engines that have problems with UCI+.
483
484 =item B<CanPonder> (default: false)
485
486 PolyGlot now conforms to the documented UCI behaviour: the engine will
487 be allowed to ponder only if it (the engine) declares the "Ponder" UCI
488 option.  However some engines which can actually ponder do not declare
489 the option.  This work around lets PolyGlot know that they can ponder.
490
491 =item B<SyncStop> (default: false)
492
493 When a ponder miss occurs, Polyglot interrupts the engine and
494 IMMEDIATELY launches a new search.  While there should be no problem
495 with this, some engines seem confused and corrupt their search board.
496 "SyncStop" forces PolyGlot to wait for the (now useless) ponder search
497 to finish before launching the new search.
498
499 =item B<PromoteWorkAround> (default: false)
500
501 Some engines do not specify a promotion piece, e.g. they send "e7e8"
502 instead of the correct "e7e8q".  This work around enables the
503 incorrect form (and of course promotes into a queen).
504
505 =item B<RepeatPV> (default: true)
506
507 When true, PolyGlot repeats the last pv string (which also contains
508 score,depth and time usage) it got from the engine. Some engines
509 however do not send a new pv string just before sending the move and
510 the now old pv string might confuse debugtools that parse the winboard
511 debug files.
512
513
514 =back
515
516
517 =head2 [Engine] section
518
519 This section contains engine UCI options.  PolyGlot does not
520 understand them, but sends the information to the engine at startup
521 (converted to UCI form).  You can add any UCI option that makes sense
522 to the engine (not just the common options about hash-table size and
523 tablebases).
524
525 NOTE: use INI syntax, not UCI.  For example "OwnBook = true" is
526 correct.  It will be replaced by PolyGlot with "setoption name OwnBook
527 value true" at engine startup.
528
529 Standard UCI options are 
530
531     Hash 
532     NalimovPath
533     NalimovCache
534     OwnBook
535
536 Hidden options like "Ponder" or "UCI_xxx" are automatic
537 and should not be put in an INI file.
538
539 The other options are engine-specific.  Check their name using a UCI
540 GUI or launch the engine in a console and type "uci".
541
542 =head1 EXAMPLES
543
544 Compile "games.pgn" into a book "book.bin" retaining all lines of at
545 most 30 plies.
546
547     polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30
548
549 Merge books "w1.bin" and "w2.bin" into a book "w.bin".
550
551     polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin
552
553 Inspect lines for white in "w.bin"
554
555     polyglot dump-book -bin w.bin -color white -out w_white.txt
556
557 Test epd file "test.epd" with a (maximum) search time of 7 minutes per position
558
559     polyglot epd-test -epd test.epd -max-time 420
560
561 The command line for using the UCI engine "fruit" in a GUI which uses the
562 xboard protocol.
563
564     polyglot -ec fruit
565
566 The equivalent config file:
567
568     [PolyGlot]
569     EngineCommand = fruit
570     [Engine]
571
572
573 =head1 EXIT STATUS
574
575 PolyGlot always returns 0 on exit. 
576
577 =head1 AUTHORS
578
579 Main author: Fabien Letouzey<fabien_letouzey(at)hotmail.com>
580
581 Native Windows port:  Huang Chen<webmaster@elephantbase.net> ("Morning Yellow")
582
583 Various enhancements: Fonzy Bleumers<match(at)geenvis.net>
584
585 UCI port: Michel Van den Bergh <michel.vandenbergh(at)uhasselt.be>
586
587 =head1 SEE ALSO
588
589 xboard(6)