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