version 1.4w10UCIb18
[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 best move has been constant for this many depths,
269 on condition that the mininal depth and minimal time have been reached.
270
271 =item B<-min-depth> (default: 8)
272
273 Minimal search depth when the search is stopped using "-depth-delta".
274
275 =item B<-min-time> (default: 1.0)
276
277 Minimal search time when the search is stopped using "-depth-delta".
278
279
280 =back
281
282 When invoked as
283
284 =head2 polyglot perft
285
286 PolyGlot supports the following
287 options
288
289 =over 4
290
291 =item B<-fen> (default: starting position) 
292
293 Fen at which to start searching.
294
295 =item B<-max-depth> (default: 1) 
296
297 Maximum depth to search.
298
299 =back
300
301 =head1 CONFIG FILE FORMAT
302
303 There should be a different config file for each engine.  
304
305 The config file is in the traditional INI format.  
306
307     [PolyGLot]
308     option = value
309     ...
310     [Engine]
311     option = value
312     ...
313
314 Lines starting with "#" are ignored.
315
316 NOTE: There can be spaces in option names or values.  Do not use
317 quotes. Boolean values are written as "true" or "false". 
318
319 =head2 [PolyGlot] section
320
321 This section is used by PolyGlot only.  The engine is unaware of these
322 options.  The list of available options is detailed below.
323
324 =over 4
325
326 =item B<EngineName> (default: UCI name)
327
328 This is the name that will appear in the GUI.  It is
329 cosmetic only.  You can use different names for tweaked versions of
330 the same engine.
331
332 =item B<EngineDir> (default: ".")
333
334 Full path of the directory where the engine is installed.  You can use
335 "." (without the quotes) if you know that PolyGlot will be launched in
336 the engine directory or the engine is in the "path" and does not need
337 any data file.
338
339 =item B<EngineCommand>
340
341 Put here the name of the engine executable file.  You can also add
342 command-line arguments.  Path searching is used and the current
343 directory will be "EngineDir".
344
345 =item B<Log> (default: false)
346
347 Whether PolyGlot should log all transactions with the interface and
348 the engine.  This should be necessary only to locate problems.
349
350 =item B<LogFile> (default: polyglot.log)
351
352 The name of the log file.  Note that it is put where PolyGlot was
353 launched from, not into the engine directory.
354
355 WARNING: Log files are not cleared between sessions, and can become
356 very large.  It is safe to remove them though.
357
358 =item B<Resign> (default: false)
359
360 Set this to "true" if you want PolyGlot to resign on behalf of the
361 engine.
362
363 NOTE: Some engines display buggy scores from time to time although the
364 best move is correct.  Use this option only if you know what you are
365 doing (e.g. you always check the final position of games).
366
367 =item B<ResignMoves> (default: 3)
368
369 Number of consecutive moves with "resign" score (see below) before
370 PolyGlot resigns for the engine.  Positions with only one legal move
371 are ignored.
372
373 =item B<ResignScore> (default: 600)
374
375 This is the score in centipawns that will trigger resign "counting".
376
377 =item B<ShowPonder> (default: true)
378
379 Show search information during engine pondering.  Turning this off
380 might be better for interactive use in some interfaces.
381
382 =item B<KibitzMove> (default: false)
383
384 Whether to kibitz when playing a move.
385
386 =item B<KibitzPV> (default: false)
387
388 Whether to kibitz when the PV is changed (new iteration or new best move).
389
390 =item B<KibitzCommand> (default: "tellall")
391
392 xboard command to use for kibitzing, normally "tellall" for kibitzing
393 or "tellothers" for whispering.
394
395
396 =item B<KibitzDelay> (default: 5)
397
398 How many seconds to wait before starting kibitzing.  This has an
399 effect only if "KibitzPV" is selected, move kibitzes are always sent
400 regardless of the delay.
401
402 =item B<UCI> (default: false)
403
404 If true PolyGlot will not understand xboard commands. 
405
406 =item B<Chess960> (default: false)
407
408 Play Chess960 (also called Fischer Random Chess or FRC),
409
410 =item B<MateScore> (default: 10000)
411
412 Mate score reported to GUI when in xboard mode. 
413
414 =item B<Book> (default: false)
415
416 Indicates whether a PolyGlot book should be used.  This has no effect
417 on the engine own book (which can be controlled with the UCI option
418 "OwnBook" in the [Engine] section).  In particular, it is possible to
419 use both a PolyGlot book and an engine book.  In that case, the engine
420 book will be used whenever PolyGlot is out of book.  Remember that
421 PolyGlot is unaware of whether the engine is itself using a book or
422 not.
423
424 =item B<BookFile> (default: book.bin)
425
426 The name of the (binary) book file.  Note that PolyGlot will look for
427 it in the directory it was launched from, not in the engine directory.
428 Of course, full path can be used in which case the current directory
429 does not matter.
430
431 =item B<BookRandom> (default: true)
432
433 Select moves according to their weights in the book. If false the move
434 with the highest weight is selected. 
435
436 =item B<BookLearn> (default: false)
437
438 Record learning information in the opening book. Naturally this requires
439 the opening book to be writable. 
440
441 =item B<UseNice> (default: false)
442
443 Run the engine at nice level 5, or "NiceValue" if it set.  On some
444 operating systems it may be necessary to run the engine at lower
445 priority for it to be responsive to commands from PolyGlot while
446 searching.
447
448 =item B<NiceValue> (default: 5)
449
450 Nice levels go from -20 to 20 with 20 being the lowest priority.
451 On Unix only root can set negative nice levels. On Windows the standard
452 Win32 priority levels are mapped in a sensible way to Unix nice levels.
453
454
455 =item B<Affinity> (default: -1)
456
457 This a bit vector in which each bit represents the processors that a
458 process is allowed to run on. This option works only on Windows. 
459
460
461 =back
462
463 =head2 Work arounds 
464
465 Work arounds are identical to options except that they should be used
466 only when necessary.  Their purpose is to try to hide problems with
467 various software (not just engines).  The default value is always
468 correct for bug-free software.
469
470 IMPORTANT: Any of these work arounds might be removed in future
471 versions of PolyGlot.  You are strongly recommended to contact the
472 author of faulty software and truly fix the problem.
473
474 PolyGlot supports the following work arounds:
475
476 =over 4
477
478 =item B<UCIVersion> (default: 2)
479
480 The default value of 2 corresponds to UCI+.  Use 1 to select plain
481 UCI for engines that have problems with UCI+.
482
483 =item B<CanPonder> (default: false)
484
485 PolyGlot now conforms to the documented UCI behaviour: the engine will
486 be allowed to ponder only if it (the engine) declares the "Ponder" UCI
487 option.  However some engines which can actually ponder do not declare
488 the option.  This work around lets PolyGlot know that they can ponder.
489
490 =item B<SyncStop> (default: false)
491
492 When a ponder miss occurs, Polyglot interrupts the engine and
493 IMMEDIATELY launches a new search.  While there should be no problem
494 with this, some engines seem confused and corrupt their search board.
495 "SyncStop" forces PolyGlot to wait for the (now useless) ponder search
496 to finish before launching the new search.
497
498 =item B<PromoteWorkAround> (default: false)
499
500 Some engines do not specify a promotion piece, e.g. they send "e7e8"
501 instead of the correct "e7e8q".  This work around enables the
502 incorrect form (and of course promotes into a queen).
503
504 =item B<RepeatPV> (default: true)
505
506 When true, PolyGlot repeats the last pv string (which also contains
507 score,depth and time usage) it got from the engine. Some engines
508 however do not send a new pv string just before sending the move and
509 the now old pv string might confuse debugtools that parse the winboard
510 debug files.
511
512
513 =back
514
515
516 =head2 [Engine] section
517
518 This section contains engine UCI options.  PolyGlot does not
519 understand them, but sends the information to the engine at startup
520 (converted to UCI form).  You can add any UCI option that makes sense
521 to the engine (not just the common options about hash-table size and
522 tablebases).
523
524 NOTE: use INI syntax, not UCI.  For example "OwnBook = true" is
525 correct.  It will be replaced by PolyGlot with "setoption name OwnBook
526 value true" at engine startup.
527
528 Standard UCI options are 
529
530     Hash 
531     NalimovPath
532     NalimovCache
533     OwnBook
534
535 Hidden options like "Ponder" or "UCI_xxx" are automatic
536 and should not be put in an INI file.
537
538 The other options are engine-specific.  Check their name using a UCI
539 GUI or launch the engine in a console and type "uci".
540
541 =head1 EXAMPLES
542
543 Compile "games.pgn" into a book "book.bin" retaining all lines of at
544 most 30 plies.
545
546     polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30
547
548 Merge books "in1.bin" and "in2.bin" into a book "out.bin".
549
550     polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin
551
552 The command line for using the UCI engine "fruit" in a GUI which uses the
553 xboard protocol.
554
555     polyglot -ec fruit
556
557 The equivalent config file:
558
559     [PolyGlot]
560     EngineCommand = fruit
561     [Engine]
562
563
564 =head1 EXIT STATUS
565
566 PolyGlot always returns 0 on exit. 
567
568 =head1 AUTHORS
569
570 Main author: Fabien Letouzey<fabien_letouzey(at)hotmail.com>
571
572 Native Windows port:  Huang Chen<webmaster@elephantbase.net> ("Morning Yellow")
573
574 Various enhancements: Fonzy Bleumers<match(at)geenvis.net>
575
576 UCI port: Michel Van den Bergh <michel.vandenbergh(at)uhasselt.be>
577
578 =head1 SEE ALSO
579
580 xboard(6)