Initial checking for typhoon chess engine documentation.
[typhoon-doc.git] / typhoon.sgml
1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.0//EN">
2   <book>
3     <bookinfo>
4       <title>Typhoon Chess Engine</title>
5       <author>
6         <firstname>Scott</firstname>
7         <surname>Gasch</surname>
8         <affiliation>
9           <address><email>[email protected]</email></address>
10         </affiliation>
11       </author>
12       <copyright>
13         <year>2002-2006</year>
14         <holder role="mailto:[email protected]">Scott Gasch</holder>
15       </copyright>
16       <pubdate role="rcs">$Date$</pubdate>
17       <releaseinfo>$Id$</releaseinfo>
18       <abstract>
19         <para>
20 This is a user's guide for the <ulink
21 url="http://wannabe.guru.org/scott/hobbies/chess">typhoon chess
22 engine</ulink>.  Its intended audience is the set of people who have
23 downloaded a copy of my chess engine source code available at <ulink
24 url="http://wannabe.guru.org/svn/typhoon/trunk">
25 http://wannabe.guru.org/svn/typhoon/trunk</ulink> or have downloaded a
26 precompiled binary that someone else compiled.  The goal of this
27 manual is to document how to build and use the chess engine.  If you
28 don't care about how to use typhoon are instead looking for a more
29 technical discussion of how to write your own chess engine you might
30 try <ulink url="http://wannabe.guru.org/scott/hobbies/chess">
31 http://wannabe.guru.org/scott/hobbies/chess</ulink> or simply dig 
32 into the <ulink url="http://wannabe.guru.org/svn/typhoon/trunk"> 
33 source code</ulink> itself.
34         </para>
35         <para>
36 This user's guide is available in several formats:
37       <itemizedlist>
38       <listitem><para>One large HTML file: <ulink
39       url="http://wannabe.guru.org/scott/hobbies/chess/typhoon.html">
40       http://wannabe.guru.org/scott/hobbies/chess/typhoon.html</ulink>
41       </para></listitem>
42       <listitem><para>Plain (7 bit ASCII) text: <ulink
43       url="http://wannabe.guru.org/scott/hobbies/chess/typhoon.txt">
44       http://wannabe.guru.org/scott/hobbies/chess/typhoon.txt</ulink>
45       </para></listitem>
46       <listitem><para>Adobe PostScript: <ulink
47       url="http://wannabe.guru.org/scott/hobbies/chess/typhoon.ps">
48       http://wannabe.guru.org/scott/hobbies/chess/typhoon.ps</ulink>
49       </para></listitem>
50       <listitem><para>Adobe Portable Document Format (PDF): <ulink
51       url="http://wannabe.guru.org/scott/hobbies/chess/typhoon.pdf">
52       http://wannabe.guru.org/scott/hobbies/chess/typhoon.pdf</ulink>
53       </para></listitem>
54       <listitem><para>Microsoft Rich Text Format (RTF): <ulink
55       url="http://wannabe.guru.org/scott/hobbies/chess/typhoon.rtf">
56       http://wannabe.guru.org/scott/hobbies/chess/typhoon.rtf</ulink>
57       </para></listitem>
58       </itemizedlist>
59       </abstract>
60     </bookinfo>
61   <chapter>
62     <title>Preliminaries</title>
63     <para>
64 This is a the user's guide for the typhoon chess engine.  It covers
65 how to build, install, configure and use the engine.
66     </para>
67     <para>
68 If you are impatient, have a look at the <link linkend="quickstart">
69 Quick Start Guide</link> section; it
70 will take you through the basics of getting the engine installed and
71 working.  Come back to the rest of the user's guide if you run into
72 difficulties.
73     </para>
74     <para>
75 Readers with more patience may skip the Quick Start and read the rest
76 of the guide in order for a run though of how to get the engine
77 installed and configured.  This will also familiarize you with more
78 advanced topics such as how to build your own opening book from PGN
79 files, how to instruct typhoon to use Eugene Nalimov format endgame
80 tablebases, how to run script files and how to execute commends
81 automatically at engine startup time.
82     </para>
83     <para>
84 Feel free to <ulink url="mailto:[email protected]">email
85 me</ulink> with questions or problems.  Before you do, though, please
86 read this guide and see if your query has been addressed already.
87     </para>
88     <sect1>
89       <title>Introduction</title>
90       <para>
91 Typhoon is a chess playing program that I've been working on for a
92 few years now as a hobby.  It's ugly, unpolished and full of
93 bugs.  While it has its moments of brilliance, it is not yet as strong
94 as some other freely available engines like Yace or Crafty.  If you
95 <link linkend="bugs">find a bug</link>, especially one related to 
96 playing strength, <ulink url="mailto:[email protected]">I'd 
97 like to hear about it.</ulink>
98       </para>
99       <para>
100 When I reach a point in this project where I am happy with the playing
101 strength, usability, stability and portability of the engine I'll
102 release it under the GPL or a similar license.  Until then please
103 consider the source code an alpha-quality prerelease.  Do not
104 redistribute, sell, or modify my chess engine.
105       </para>
106       <para>
107 Typhoon has a modest (and probably outdated) homepage on the Internet
108 at <ulink url="http://wannabe.guru.org/scott/hobbies/chess/">
109 http://wannabe.guru.org/scott/hobbies/chess/</ulink>.  Drop by and
110 have a look.  Typhoon has played in three (3) tournaments to date,
111 <ulink url= "http://www.vrichey.de/cct3/">CCT3</ulink>, <ulink url=
112 "http://www.vrichey.de/cct4/">CCT4</ulink> and <ulink url=
113 "http://www.vrichey.de/cct5/">CCT5</ulink>.  In CCT3 it placed 30th of
114 32.  In CCT4 it placed 15th of 46.  In CCT5 is placed 6th of 45.
115 The engine also plays from time to time on the <ulink
116 url="http://www.chessclub.com">Internet Chess Club</ulink> where it
117 maintains a <ulink
118 url="http://www.chessclub.com/cgi-bin/finger/finger.pl?handle=monsoon">
119 standard rating around 2500 and a blitz rating around 2700</ulink>.
120       </para>
121       <para>
122 Finally, all files in this archive except where otherwise noted are
123 Copyright (C) 2002-2006 by Scott Gasch.  They come with no warranty
124 of any kind.  There are known bugs in the engine.  If you choose to
125 use the chess engine then you do so at your own risk.  Caveat emptor.
126       </para>
127     </sect1>
128     <sect1>
129     <title>Acknowledgments </title>
130       <para>
131 Thanks to all the members of the <ulink
132 url="http://www.talkchess.com"> Computer Chess Club (CCC)</ulink>
133 discussion board especially Bob Hyatt (<application>Cray
134 Blitz</application>, <application>Crafty</application>) and Bruce
135 Moreland (<application>Ferret</application>,
136 <application>Gerbil</application>) for their patience and willingness
137 to explain chess-programming concepts.
138       </para>
139       <para>
140 Thanks to Eugene Nalimov and Ernst Heniz
141 (<application>DarkThought</application>) for their continuing work on
142 high quality endgame tablebases.
143       </para>
144       <para>
145 Thanks to Tim Mann for his continuing work on
146 <application>xboard</application> /
147 <application>WinBoard</application>.  Thanks to Tom Kerrigan
148 (<application>TSCP</application>, <application>Stobor</application>)
149 for publishing <application>TSCP</application> source code which was
150 the first chess engine I read and the reason I became interested in
151 chess programming.  Thanks to Thorsten Greiner for writing and
152 publishing the source to his <application>Amy</application> program
153 and (again) to Bob Hyatt for writing and publishing the source to
154 <application>Crafty</application>.
155       </para>
156       <para>
157 Thanks (again) to Ernst Heinz for publishing his research on
158 computer chess.
159       </para>
160       <para>
161 Thanks to FM Vincent Diepeveen (<application>Diep</application>) for
162 his discussions and expert advice.  Many thanks to Dann Corbit for the
163 initial port of typhoon to the <application>Microsoft Visual
164 C/C++</application> and <application>Intel C++</application>
165 compilers.
166       </para>
167       <para>
168 Thanks to IM Mark Chapman for his help with opening book lines and his
169 patient expert analysis of chess positions.
170       </para>
171       <para>
172 Thanks to Peter McKenzie (<application>LambChop</application>,
173 <application>Warp</application>) for discussing chess programming
174 ideas and sharing his thoughts and advice.
175       </para>
176       <para>
177 Finally many thanks to Steve Timson
178 (<application>Chester</application>) for sharing his good ideas and
179 listening to my lousy ones... without his advice typhoon would surely
180 not be as strong as it is today.
181       </para>
182       <para>
183 The binaries included in the typhoon distribution are based, in part,
184 on code that I did not write.  Such code remains under the copyright 
185 notice of it's author.  I'm grateful to the original authors of the
186 code listed below for sharing it and giving me permission to use it.
187       </para>
188       <itemizedlist>
189       <listitem>
190       <para><filename>mtf.c</filename> (Mersenne Twister random number
191       generator) is Copyright (C) 1997 by Makoto Matsumoto and Takuji
192       Nishimura.  It has been included in typhoon with the authors'
193       permissions. 
194       </para></listitem>
195       <listitem><para>
196       (part of) <filename>system.c</filename>, specifically the case
197       insensitive string comparison and manipulation functions, were
198       taken from the source code for the BSD C runtime library when
199       they were found to be not present on Win32.  This code was
200       released under the BSD license and remains Copyright (C) 1987 by
201       Regents of the University of California.
202       </para></listitem>
203       <listitem><para>
204       <emphasis>Win32 timer code</emphasis> was donated by Dann Corbit
205       during the initial port of typhoon to Win32.  It's used with the
206       author's permission.  Thanks, Dann!
207       </para></listitem>
208       <listitem><para>
209       <filename>egtb.cpp</filename> was written
210       by Eugene Nalimov, released as part of crafty, and reused with
211       the author's permission.
212       </listitem>
213       </itemizedlist>
214     </sect1>
215     <sect1 id="quickstart">
216       <title>Quick Start Guide</title>
217       <para>
218 This is the raw step-by-step guide for getting your copy working on
219 your computer.  If you have questions about any step, stop reading 
220 the Quick Start Guide and move on to the <link linkend="compile">
221 detailed explanation</link> later in this document.  In fact, if 
222 you are not impatient, go ahead and skip the whole Quick Start 
223 Guide; everything covered here is also covered more completely
224 later on.
225       </para>
226       <orderedlist>
227       <listitem>
228       <para>
229 Verify that you are either running some flavor of <application>Windows
230 NT (NT/2000/XP/Server 2003/Vista)</application>, <application>
231 FreeBSD</application>, <application>Linux</application> or <application>
232 OSX</application>.
233       </para>
234       </listitem>
235       <listitem>
236       <para>
237 Verify that you intend to run the chess engine on an x86
238 microprocessor (Intel Pentium, AMD Athlon, Intel-based Mac, etc...) 
239       </para>
240       </listitem>
241       <listitem>
242       <para>
243 If you plan to compile the engine from source code, follow the
244 steps below.  If you have a precompiled binary for your system
245 you can skip these.
246         <orderedlist>
247         <listitem>
248         <para>
249         You will need either <application>gcc, g++</application>, and
250         <application>gmake</application> or the <application>Microsoft 
251         Visual C++</application> compiler.
252         </para>
253         </listitem>
254         <listitem>
255         <para>
256         You will also need a copy of the <application>nasm</application>
257         assembler.
258         </para>
259         </listitem>
260         <listitem>
261         <para>
262         Copy the source code to a directory on your machine (or
263         <link linkend="svn">use Subversion</link> to get a
264         snapshot).
265         </para>
266         </listitem>
267         <listitem>
268         <para>
269         If you're using <application>gcc, g++</application> and
270         <application>gmake</application> have a look at
271         <filename>GNUmakefile</filename> and make sure all 
272         variables look reasonable to you.  Then, from the 
273         commandline type <userinput>make PERF_COUNTERS=1</userinput>.  
274         This will produce a binary image
275         called <filename>typhoon</filename> if all goes well.
276         </para>
277         <para>
278         If you're using <application>MSVC</application>, select 
279         the "Release" configuration and build it.  If all
280         goes well it will produce a binary called <filename>
281         typhoon.exe</filename> in the <filename>Release/</filename>
282         subdirectory.  Note that you may have to edit
283         the project settings to point to where <filename>nasm.exe
284         </filename> can be found on your system.
285         </para>
286         </listitem>
287         <listitem>
288         <para>
289         If you want to build a multithreaded version of the engine
290         with <application>gcc</application>, add
291         <userinput>MP=1</userinput> to your <application>gmake
292         </application> commandline.  If
293         you're interested in building a multithreaded engine with
294         <application>MSVC</application> just build the "MP Release"
295         configuration.
296         </para>
297         </listitem>
298         </orderedlist>
299       </para>
300       </listitem>
301       <listitem>
302       <para>
303       All you need to play chess is the typhoon binary itself and
304       some chessboard GUI program (like Tim Mann's <ulink
305       url="http://www.tim-mann.org/xboard.html"><application>
306       xboard</application> (or <application>winboard</application>)
307       </ulink>).  To run typhoon under <application>xboard</application>
308       just type <userinput>xboard -fcp /path/to/typhoon</userinput>.  
309       Note that typhoon requires version 4.2.3 or higher of
310       <application>xboard</application> (or 
311       <application>WinBoard</application>).  
312       There is also a <link linkend="winboard">section 
313       about using typhoon under <application>xboard</application>
314       or <application>WinBoard</application></link> later in this guide.
315       </para>
316       <para>
317       If you want an opening book you can either download one from
318       <ulink url="http://wannabe.guru.org/scott/hobbies/chess/books">my
319       site</ulink> or build your own from PGN.  If you're interested
320       in the latter, <link linkend="makebook">see the guide section
321       about building a book from scratch</link>.
322       </para>
323       <para>
324       If you're interested in doing anything non-trivial with
325       the engine you'll probably want to read the sections on
326       <link linkend="commandline">commandline arguments</link>, 
327       <link linkend="commands">commands</link>, and 
328       <link linkend="egtb">tablebases</link> later in this document.
329       </para>
330       </listitem>
331       </orderedlist>
332       <para>
333 If you have any problems, please read the rest of this guide before
334 <ulink url="mailto:[email protected]">emailing me</ulink>.
335       </para>
336     </sect1>
337     <sect1>
338       <title>System Requirements</title>
339       <para>
340 Typhoon only runs on x86 microprocessor based systems.  This means
341 that your Intel Pentium or AMD Athlon system will work.  This also
342 means that more recent Apple Macs will run the program.  I have
343 not yet ported the code to any other processor architecture.
344 It's possible that there will be a native AMD64 port of typhoon
345 in the future (namely, when I buy a machine).
346       </para>
347       <para>
348 Typhoon only runs under <application>Windows NT</application>
349 (<application>Windows NT 4.0</application>, <application>Windows 2000
350 </application>, <application>Windows XP</application>, <application>
351 Windows Server 2003</application>, <application>Windows Vista
352 </application>), <application>FreeBSD</application>, 
353 <application>Linux</application> and <application>OSX</application>.
354       </para>
355       <para>
356 Specifically, the engine, when built with Microsoft Visual C/C++, is
357 known not to work with <application>Windows 95</application>,
358 <application>Windows 98</application>, and <application>Windows
359 ME</application>.  Some third parties have reported that the engine
360 does work under <application>Windows 98</application> when built with
361 Cygwin but I have never tried this configuration.  If you're not sure
362 what version of Windows you are using, click "start" then "run" then
363 type <userinput>winver</userinput>.  If the version reported is
364 greater than or equal to 5.0 then your operating system can definitely
365 run typhoon.
366       </para>
367       <para>
368 The codebase may build on other operating systems for Intel-based 
369 processors.  If <application>gcc</application> and <application>
370 nasm</application> are available for your platform of choice, give 
371 it a try and <ulink url="mailto:[email protected]">let me know
372 </ulink> how it goes.
373       </para>
374       <para>
375 If you got a precompiled version of typhoon from some third party then,
376 of course, you need to make sure the version you received was built for
377 your system.
378       </para>
379 <note>
380 <para>
381 I do <emphasis>not</emphasis> currently provide a precompiled version
382 of the code and that running any program someone else built for you
383 is inherently risky.  Make sure you trust the source of such an image
384 and be careful running it.  If you're unsure of the integrity of the
385 source of the precompiled package it's better to build your own.
386 </para>
387 </note>
388       <para>
389 To run the engine your computer should have something reasonable like
390 at least 128Mb or memory and around 10Mb of free hard drive space for an
391 opening book.
392       </para>
393       <para>
394 The engine does not need to be run with administrative privileges but if
395 you do run it with elevated privileges it will do some nice things like
396 try to lock its memory and run with slightly raised priority.
397       </para>
398       <para>
399 While a chess GUI (like <application>xboard</application>, 
400 <application>WinBoard</application>, or
401 <application>Arena</application>) is not technically "required" 
402 in order to typhoon, they make the experience more enjoyable. 
403 The engine itself has no UI to speak of -- it is its only
404 output is text based. Therefore it's strongly recommended that you
405 download and install some GUI frontend to use with typhoon.
406 There is a <link linkend="winboard">section</link> later in this
407 guide that describes where to get <application>WinBoard</application>
408 and how to get the engine working with it.
409       </para>
410     </sect1>
411     <sect1 id="compile">
412     <title>Compilation Guide</title>
413       <para>
414 If you want to compile the chess engine from source code (which may be
415 your only option since at present I do not distribute binary images of
416 the engine) you will probably need to use 
417 <application>gcc/g++</application> with GNU
418 <application>make</application>, <application>gcc/g++</application>
419 with BSD-style <application>make</application> or <application>Microsoft
420 Visual C/C++</application>.
421       </para>
422       <para>
423 I've built typhoon successfully on pretty much every version
424 of <application>gcc</application> from 2.8 onward. I've also used 
425 all of the Microsoft compilers from <application>VC6.0</application>
426 onward. As far as I know any of these should work fine with the
427 caveat that the <filename>typhoon.sln</filename> file currently
428 checked in and available on the source site is for 
429 <application>Microsoft Visual C/C++ 2003</application>.
430       </para>
431 <note>
432 <para>
433 I have never tried using <application>mingw</application> 
434 (<application>gcc</application> for <application>Windows</application>)
435 or Intel's <application>icc</application> (which claims to compile 
436 <application>MSVC</application> projects) so if you try one let me know
437 how it goes. The code is reasonably compiler agnostic so getting it to
438 build on some other random C/C++ compiler should be relatively
439 painless... I hope.  If you have any success porting the codebase
440 to another toolset, please <ulink url="mailto:[email protected]">
441 drop me a line</ulink>.
442 </para>
443 </note>
444       <para>
445 In order to build <filename>x86.asm</filename> you will also need a copy of 
446 the <ulink url="http://nasm.sourceforge.net/wakka.php?wakka=HomePage">
447 Netwide Assembler (<application>nasm</application>)</ulink>.  Some
448 (much hairier) alternatives are to translate the assembly language 
449 to work with some other assembler or to just use the C-language 
450 versions of the routines in <filename>x86.asm</filename>.  Neither 
451 option is recommended.  Make sure that if you are building typhoon
452 on a Mac you have a version of <application>nasm</application> that
453 can produce mach0 format object files (i.e. it supports the 
454 <userinput>-f macho</userinput> commandline flag).
455       </para>
456       <para>
457 Start by copying everything from <ulink
458 url="http://wannabe.guru.org/svn/typhoon/trunk">svn/typhoon/trunk</ulink>
459 into a directory on your machine.  While you can do this manually (or
460 with wget/fetch), a cool alternative is to use <ulink
461 url="http://subversion.tigris.org/"><application>Subversion</application>
462 </ulink> (a version control system) to <link linkend="svn">check out
463 a read-only snapshot of the code</link> from my server.  The reason
464 I do not have a pre-packaged code archive is because the code you can
465 download from the URL above is a current snapshot of the chess engine; 
466 when you use the URL above you are getting the most recent update of
467 the engine available.
468       </para>
469       <para>
470 Have a look at the <filename>README</filename> file to humor me.  
471 Then, what happens next depends largely on what compiler you have
472 chosen to use.
473       </para>
474       <para>
475 If you decided on the <application>gcc/g++/gmake</application>
476 toolset, take a look at the <filename>GNUmakefile</filename>.  
477 You might want to change some variables such as CC, CXX and NASM,
478 and CPU based on the system you plan to build with.  The defaults 
479 are probably reasonable in most cases.
480       </para>
481       <para>
482 If you have a BSD-style <application>make</application>, take a
483 look at <filename>Makefile</filename> instead.
484       </para>
485       <para>
486 In order to build a single threaded release version of the chess
487 engine, type <userinput>make PERF_COUNTERS=1</userinput>.
488 A multithreaded release version is almost the same, just add an
489 <userinput>MP=1</userinput> to the line.  Whereas both <application>
490 Linux</application> and <application>FreeBSD</application> based
491 systems require explicit no build flags, to build for Apple
492 <application>OSX</application> systems you should add an additional
493 <userinput>OSX=1</userinput> to the build commandline.
494       </para>
495       <para>
496 While we're on the subject, here's a list of the preprocessor 
497 symbols that you can use when building typhoon and their effects:
498       <informaltable>
499       <tgroup cols="2">
500         <thead>
501           <row>
502             <entry>Preprocessor symbol</entry>
503             <entry>Effect on image</entry>
504           </row>
505         </thead>
506         <tbody>
507           <row>
508             <entry>DEBUG</entry>
509             <entry>Produces a much slower image that has extra checks
510             enabled.  Symbols are not stripped.  See <link
511             linkend="debug">the section about DEBUG builds</link> for
512             more information.</entry>
513           </row>
514           <row>
515             <entry>TEST</entry>
516             <entry>Bakes some unit testcases into the image, enables
517             the <userinput>test</userinput> command.  Refer to
518             <link linkend="test">the section about TEST builds</link>
519             for more information.</entry>
520           </row>
521           <row>
522             <entry>ASM</entry>
523             <entry>Causes <application>gcc</application> to produce
524             intermediate assembly language (<filename>.s</filename>) 
525             files during the build.</entry>
526           </row>
527           <row>
528             <entry>EVAL_DUMP</entry>
529             <entry>Causes the engine to pay attention to all terms
530             affecting a position's evaluation and be dump them
531             after every eval.  Read <link linkend="evaldump">
532             the section about EVAL_DUMP builds</link> to learn
533             more.</entry>
534           </row>
535           <row>
536             <entry>EVAL_TIME</entry>
537             <entry>Causes the engine to pay attention to how many
538             processor cycles it spends evaluating each position.
539             </entry>
540           </row>
541           <row>
542             <entry>PERF_COUNTERS</entry>
543             <entry>Enables several performance related counters
544             in the engine.</entry>
545           </row>
546           <row>
547             <entry>BOUNDS_CHECKING</entry>
548             <entry>If you have patched your version of <application>
549             gcc</application> to include <userinput>-fbounds-checking
550             </userinput>, this builds an image with baked in
551             bounds checking support.</entry>
552           </row>
553           <row>
554             <entry>MP</entry>
555             <entry>Enables the threadpool and search-splitting code
556             needed to support more than one thread searching at a
557             time.</entry>
558           </row>
559           <row>
560             <entry>DUMP_TREE</entry>
561             <entry>Produces dumps of search trees in XML format.  Tree
562             dump files can be viewed with a web browser or using the
563             <application>typhoonui.exe</application> viewer in the 
564             <application>Subversion</application> repository.
565             </entry>
566           </row>
567           <row>
568             <entry>OSX</entry>
569             <entry>Produces a binary for Intel-based Apple Macs</entry>
570           </row>
571         </tbody>
572       </tgroup>
573       </informaltable>
574       </para>
575       <para>
576 Building with <application>MSVC</application> involves selecting a
577 configuration and compiling.  You probably want to build "Release"
578 or "MP Release".  The only wrinkle is that in the custom build step
579 you will probably have to set the path to
580 <application>nasm</application> on your system.  The resulting image
581 will be either <filename>Release\typhoon.exe</filename> or 
582 <filename>MP Release\typhoon.exe</filename> depending on which 
583 configuration you built.
584       </para>
585       <para>
586 The image you build can run stand-alone as a text-based chess engine
587 with no opening book.  But if you want to run in a more comfortable
588 manner, read on to the next sections which cover the details of setup.
589     </sect1>
590     <sect1 id="svn">
591       <title>Using <application>Subversion</application> to get Typhoon</title>
592       <para>
593 I use the <application>Subversion</application> version control system to 
594 develop typhoon.  If you have <application>svn</application>
595 installed on your system you can use it to check out a read-only
596 snapshot of the source code on your machine, keep up to date with
597 changes I make, access file histories, project branches and change
598 logs.
599       </para>
600       <para>
601 Just use the URL <filename>http://wannabe.guru.org/svn/typhoon</filename>
602 as your repository path.  To get the initial snapshot of the code
603 issue the <userinput>svn checkout</userinput> command from a directory
604 you created to house the typhoon source code:
605       </para>
606 <screen>
607 svn checkout http://wannabe.guru.org/svn/typhoon/trunk
608 </screen>
609       <para>
610 The command <userinput>svn co</userinput> is a shorthand version of 
611 <userinput>svn checkout</userinput>.  Also, if you want more of the
612 typhoon project than just the current code, you can omit the
613 <userinput>/trunk</userinput> from the end of your command.  Warning,
614 this will checkout a bunch of papers, PGN files, opening books,
615 etc; the disk space requirements for the full repository are non 
616 trivial.
617       </para>
618       <para>
619 In order to synchronize your enlistment with the current state of the
620 code on my machine, use the <userinput>svn up</userinput> command.
621 Another useful commands is <userinput>svn log
622 http://wannabe.guru.org/svn/typhoon</userinput> which will give you a
623 high level overview of what changed from revision to revision.  An
624 alternative is <ulink
625 url="http://wannabe.guru.org/cgi-bin/svn.pl?operation=log">http://wannabe.guru.org/cgi-bin/svn.pl?operation=log</ulink>.
626 Using <userinput>svn diff</userinput> allows you to see source code
627 changes at a file level.
628       </para>
629 <screen>
630 svn up
631 </screen>
632 <para>
633 When I am actively developing the engine I make at least one checkin
634 a week (usually more like one a day).  So if you want to track the 
635 bleeding edge, this is the way to do it.
636 </para>
637     </sect1>
638     <sect1 id="install">
639       <title>Installation Guide</title>
640       <para>
641 Once you have a typhoon binary image (either from building it 
642 yourself or from downloading a precompiled binary from some third
643 party) you may want to do some simple setup work.
644       </para>
645       <orderedlist>
646       <listitem>
647       <para>
648 The first thing you may want to do is to install Tim Mann's graphical
649 chessboard.  The UNIX version is called <application>
650 xboard</application> and the Windows version is called <application>
651 WinBoard</application>.  Both can be obtained from the site <ulink
652 url="http://www.tim-mann.org">http://www.tim-mann.org</ulink>.  This program
653 will provide a nice graphical user interface to typhoon which is a
654 text-based engine.  Without it you'll be stuck looking at chessboards
655 on a commandline interface.  There is a <link linkend="winboard">chapter 
656 later in this guide</link> about how to configure the engine to work 
657 under WinBoard.
658       </para>
659       <para>
660 An alternative to <application>xboard</application>/<application>
661 WinBoard</application> is <application>Arena</application>, another 
662 graphical chessboard program which can be downloaded at <ulink
663 url="http://www.playwitharena.com/">http://www.playwitharena.com</ulink>.
664 While I have only done preliminary testing with Arena, typhoon seems to 
665 work just fine as a WB2 engine under <application>Arena
666 1.99beta2</application>.  Since I haven't done much with Arena, if
667 you want to add typhoon as an Arena engine you're on your own.
668       </para>
669       </listitem>
670       <listitem>
671       <para>
672 After you've installed either <application>xboard</application>, 
673 <application>WinBoard</application> or <application>Arena</application>
674 you'll need to copy the typhoon image into some directory on your hard
675 drive.  I usually use <filename>C:\typhoon</filename> but you can put
676 it wherever you like.  I'll be referring to the directory you put 
677 the image in as the "typhoon installation directory" from now on in 
678 this guide.
679       </para>
680       </listitem>
681       <listitem>
682       <para>
683 You now have all you need to play chess.  However, without an opening
684 move library the engine will play the same opening moves every game.
685 If you want an opening move library you have two choices: either
686 download one or build one yourself.  
687       </para>
688       <para>
689 The former choice is easier and I have several opening books available
690 on my server.  You can get them from <ulink
691 url="http://wannabe.guru.org/scott/hobbies/chess/books">
692 http://wannabe.guru.org/scott/hobbies/chess/books</ulink>.  The larger
693 the file, the more opening moves in the library.  If you choose to
694 download an opening library file, just pick one and save it to the
695 typhoon installation directory as <filename>book.bin</filename>.
696       </para>
697       <para>
698 The advantage of building your own opening library is that it's an
699 easy way to tailor the playing style of the engine.  It will only play
700 the opening lines you train it with.  To go this route you will need
701 a PGN file full of games you want the engine to learn opening moves
702 from.  Read <link linkend="makebook">the section about making a
703 custom opening book</link> for detailed instructions.
704       </para>
705       </listitem>
706       <listitem>
707       <para>
708 Just as an opening library is a database of common opening moves for
709 the engine to use, an endgame tablebase is a database of endgame
710 positions that the engine can access during the endgame.  Typhoon
711 knows how to read Eugene Nalimov format EGTB files which are the same 
712 ones that the popular engine Crafty uses.  These files are quite
713 large; all 3-4-5 man files are over 7Gb in size compressed.  A 
714 good resource for learning more aboue EGTB files (including
715 where to get them) is 
716 <ulink url="http://www.aarontay.per.sg/Winboard/egtb.html">
717 http://www.aarontay.per.sg/Winboard/egtb.html</ulink>.
718       </para>
719       <para>
720 If you have EGTB files on your disk you can tell typhoon where they are
721 using the "--egtbpath" commandline argument.  This flag preceeds a 
722 quoted, semi-colon delimited path:
723       </para>
724 <screen>
725 typhoon --egtbpath "C:\egtb\three;C:\egtb\four;C:\egtb\five"
726 </screen>
727       <para>
728 You will know that typhoon found and could use the EGTB files if you
729 see it produce a message like "Found 5-men endgame table bases."
730 during startup.
731 <link linkend="egtb">More information about the use of EGTB
732 files</link> appears later in the guide.
733       </para>
734       </listitem>
735       <listitem>
736       <para>
737 The final thing you'll need to do to run the engine on your computer
738 is set the hash table sizes based on the amount of memory you have
739 in your computer.  If you run the engine stand-alone (i.e. not under
740 a GUI like WinBoard) you can issue the command "dump sizes" to see 
741 how much memory the pawn hash table and main hash table are using.
742 As you can see, the default is for the engine to use just over
743 300Mb of physical memory:
744       </para>
745 <screen>
746 white(1): <userinput>dump sizes</userinput>
747 sizeof(PAWN_HASH_ENTRY). . . . . . . . . 88 bytes
748 sizeof(HASH_ENTRY) . . . . . . . . . . . 16 bytes
749 sizeof(MOVE) . . . . . . . . . . . . . . 4 bytes
750 sizeof(ATTACK_BITV). . . . . . . . . . . 4 bytes
751 sizeof(SQUARE) . . . . . . . . . . . . . 8 bytes
752 sizeof(POSITION) . . . . . . . . . . . . 1428 bytes
753 sizeof(MOVE_STACK) . . . . . . . . . . . 233992 bytes
754 sizeof(PLY_INFO) . . . . . . . . . . . . 424 bytes
755 sizeof(COUNTERS) . . . . . . . . . . . . 236 bytes
756 sizeof(SEARCHER_THREAD_CONTEXT). . . . . 264056 bytes
757 sizeof(GAME_OPTIONS) . . . . . . . . . . 1136 bytes
758 sizeof(MOVE_TIMER) . . . . . . . . . . . 40 bytes
759 sizeof(PIECE_DATA) . . . . . . . . . . . 16 bytes
760 sizeof(VECTOR_DELTA) . . . . . . . . . . 4 bytes
761 sizeof(GAME_PLAYER). . . . . . . . . . . 16 bytes
762 sizeof(GAME_HEADER). . . . . . . . . . . 64 bytes
763 sizeof(GAME_MOVE). . . . . . . . . . . . 60 bytes
764 sizeof(GAME_DATA). . . . . . . . . . . . 72 bytes
765 sizeof(SEE_LIST) . . . . . . . . . . . . 196 bytes
766 sizeof(BOOK_ENTRY) . . . . . . . . . . . 36 bytes
767 -------------------------------------------------
768 Current pawn hash table size . . . . . . 46137344 bytes (~44 Mb)
769 Current main hash table size . . . . . . 268435456 bytes (~256 Mb)
770 </screen>
771       <para>
772 If this amount exceeds the amount of physical memory on your machine
773 the engine will be extremely slow.  It is possible to reduce the
774 memory footprint of the engine by setting the sizes of the main hash
775 table and the pawn hash table.  To do so, use the "--hash" and 
776 "--pawnhash" commandline options.  These flags take an argument which
777 is the number of entries in the table.  This number must be an even 
778 power of two.  For example:
779       </para>
780 <screen>
781 typhoon --hash 16384 --pawnhash 1024
782 </screen>
783       <para>
784 The above command allocates a hash table of 16384 (2^14) entries and
785 a pawn hash table of 1024 (2^10) entries.  Since each main hash entry
786 is 16 bytes in size, the total memory used by 16384 main hash entries
787 is approximately 256kb.  Likewise each pawn hash entry is currently 
788 88 bytes in size making the total memory used by 1024 of them around
789 88kb.
790       </para>
791       <para>
792 If you don't understand any of this, just use the numbers in the 
793 sample above.  Since they are very low the engine will definitely 
794 not use too much memory for your computer.  If you did 
795 understand the paragraph above and care about "optimal performance" then
796 you should set the engine to use as much memory as you can spare.
797 More hash table entries means a higher hash hit percentage and a faster
798 search in most cases.
799       </para>
800       </listitem>
801       </orderedlist>
802     </sect1>
803   </chapter>
804   <chapter id="running">
805     <title>Running Typhoon</title>
806     <para>
807 This chapter covers typhoon's commandline arguments and command
808 parser.  It gives a list of useful commands for interacting with the
809 engine.  Note that if you are running the engine under
810 <application>WinBoard</application> or some other GUI front end then
811 your interface will send the commands to typhoon on your behalf.  This
812 is a much easier way to interact with engine and is recommended for
813 most users.  The following sections assumes you are an advanced user
814 and running typhoon in text mode in order to interact with the program
815 directly.
816     </para>
817     <sect1 id="commandline">
818     <title>Commandline Arguments</title>
819       <para>
820 The following section covers the commandline arguments available when
821 starting the engine and the affect of each on its behavior.
822       <orderedlist>
823       <listitem>
824       <para>
825 The <emphasis>--cpus</emphasis> argument, followed by a number, can
826 be used with multiprocessor builds of typhoon to indicate how many
827 searcher threads should be created.  The number of searcher threads
828 should be set to the number of processors in the system:
829       </para>
830       <screen>
831 typhoon --cpus 2
832       </screen>
833       </listitem>
834       <listitem>
835       <para>
836 The flag <emphasis>--command</emphasis>, followed by a quoted string,
837 can be used to pass an initial command to the engine.  Typhoon will 
838 execute the initial command before processing any user input.  The
839 initial command is often used to specify a script to execute.
840       </para>
841 <screen>
842 typhoon --command "bench"
843 </screen>
844       </listitem>
845       <listitem>
846       <para>
847 The <emphasis>--hash</emphasis> and <emphasis>--pawnhash</emphasis>
848 arguments take a number indicating the size of the main hash table
849 and pawn hash table respectively.  These sizes must be even powers
850 of two or they will be rounded down.  These commands allow you to
851 tailor engine memory usage to the size of physical memory on your
852 system.  See the <link linkend="install">installation guide</link>
853 for a full discussion of how this argument works.
854       </para>
855 <screen>
856 typhoon --hash 16384 --pawnhash 1024
857 </screen>
858       </listitem>
859       <listitem>
860       <para>
861 Use <emphasis>--egtbpath</emphasis> with a quoted string in order to
862 set the path in which the engine should search for Nalimov format
863 EGTB files.  The string can contain more than one directory if the
864 different directories are separated by semi-colons (;).
865       </para>
866 <screen>
867 typhoon --egtbpath "C:\TB\three;C:\TB\four;C:\TB\five"
868 </screen>
869       </listitem>
870       <listitem>
871       <para>
872 Use <emphasis>--batch</emphasis> to indicate that the engine should 
873 never listen to user input from the console.  This flag takes no
874 additional parameters and must be used in conjunction with the 
875 <emphasis>--command</emphasis> flag.  The presence of
876 <emphasis>--batch</emphasis> causes the engine to skip starting
877 an input thread and exit immediately after executing the initial
878 command.
879       </para>
880       <screen>
881 typhoon --command "script C:\ECM.EPD" --batch
882       </screen>
883       </listitem>
884       </orderedlist>
885     </sect1>      
886     <sect1>
887     <title>Entering Moves</title>
888       <para>
889 The most common input you'll probably send to the engine is a chess
890 move.  Typhoon understands moves in two (2) formats: Standard Algebraic
891 Notation (SAN) and the <userinput>d2d4</userinput> format.  When you 
892 enter a move in one of these formats that affects a piece of the side
893 on move, the move will be made and the board redrawn.
894       </para>
895     </sect1>
896     <sect1 id="commands">
897     <title><application>WinBoard</application> Commands</title>
898       <para>
899 Typhoon supports many commands that are part of the
900 <application>WinBoard</application> protocol.  These commands are
901 fully documented in Tim Mann's xboard engine interface document at
902 <ulink url="http://www.tim-mann.org/xboard/engine-intf.html">
903 http://www.tim-mann.org/xboard/engine-intf.html</ulink>.  I will
904 briefly discuss a subset of them here.
905       </para>
906       <itemizedlist>
907       <listitem>
908       <para><emphasis>xboard</emphasis>, <emphasis>random</emphasis>,
909       <emphasis>hint</emphasis>, and <emphasis>variant</emphasis>, and
910       <emphasis>edit</emphasis> are not implemented in typhoon and are
911       basically no-ops.  Typhoon can only play regular chess, no
912       variants are supported.  To edit a position typhoon uses the
913       newer opcode <userinput>setboard</userinput>.
914       </para>
915       <listitem>
916       <para><emphasis>quit</emphasis> is used to exit the chess
917       program.
918       </para>
919       <listitem>
920       <para><emphasis>new</emphasis> is used to start a new game.
921       This sets the computer to play black, resets the maximum search
922       depth, resets the board, and clears all internal data
923       structures.
924       </para>
925       <listitem>
926       <para><emphasis>force</emphasis> puts the engine in "force
927       mode" which means it plays neither side.
928       </para>
929       <listitem>
930       <para><emphasis>white</emphasis> and <emphasis>black</emphasis>
931       are used to tell the engine what color the opponent plays and
932       what side has the move currently.  For example
933       <userinput>white</userinput> means the engine should play black
934       and that it is current white's turn to move.
935       </para>
936       <listitem>
937       <para><emphasis>sd</emphasis> can be used as an alternative to
938       <userinput>set SearchDepthLimit</userinput> to set the maximum
939       depth in ply that the engine should search a position.  The
940       maximum value is 63, the minimum is 1.
941       </para>
942       <listitem>
943       <para><emphasis>st</emphasis> can be used to query or set the
944       clock.  If <userinput>st</userinput> is followed by a parameter
945       the clock is switched into fixed time per move mode and the
946       parameter specifies the number of seconds to search per move.
947       </para>
948       <listitem>
949       <para><emphasis>time</emphasis> can be used in addition to
950       <userinput>set ComputerTimeRemainingSec</userinput> to notify
951       the engine about how much time remains on its clock.  This value
952       affects time per move allocation.
953       </para>
954       <listitem>
955       <para><emphasis>otim</emphasis> can be used in addition to
956       <userinput>set OpponentTimeRemainingSec</userinput> to notify
957       the engine about how much time remains on the opponent's clock.
958       This value affects draw-value calculation.
959       </para>
960       <listitem>
961       <para><emphasis>go</emphasis> tells the engine that it plays the
962       side on move and to begin searching immediately.
963       </para>
964       <listitem>
965       <para><emphasis>?</emphasis> can be used to interrupt the search
966       and instruct the engine to "move now".
967       </para>
968       <listitem>
969       <para><emphasis>result</emphasis> is used to report the end of a
970       game and its result.  It requires an argument to indicate the
971       result and allows an optional comment.  For example:
972       <userinput>result 1-0 {black resigns}</userinput>,
973       <userinput>result 1/2-1/2 {stalemate}</userinput>.  The optional
974       comment, if supplied, becomes the result description in the PGN
975       header of the game.  This command triggers book learning and
976       prints out a PGN record of the game.
977       </para>
978       <listitem>
979       <para><emphasis>undo</emphasis> and <emphasis>remove</emphasis>
980       can be used to take back one half-move or one full-move
981       respectively.
982       </para>
983       <listitem>
984       <para><emphasis>easy</emphasis> and <emphasis>hard</emphasis>
985       instruct the engine to ponder (think on the opponent's time) or
986       not to ponder respectively.
987       </para>
988       <listitem>
989       <para><emphasis>name</emphasis> can be used in addition to
990       <userinput>set OpponentName</userinput> to set the name of the
991       opponent.  This is used to construct PGN headers.
992       </para>
993       <listitem>
994       <para id="rating"><emphasis>rating</emphasis> can be used in
995       addition to <userinput>set ComputerRating</userinput> or
996       <userinput>set OpponentRating</userinput> to set the ELO rating
997       of the computer and its opponent.  This information is used in
998       draw value calculation and PGN header construction.  The
999       <userinput>rating</userinput> command requires two (2)
1000       parameters; the first is the computer's rating and the second is
1001       the opponent's rating.
1002       </para>
1003       <listitem>
1004       <para><emphasis>computer</emphasis> can be used in addition to
1005       <userinput>set OpponentIsComputer true</userinput> to inform the
1006       engine that is it playing against another computer.  This
1007       setting changes draw value calculation and affects some position
1008       evaluation terms.
1009       </para>
1010       <listitem>
1011       <para><emphasis>rated</emphasis> and
1012       <emphasis>unrated</emphasis> can be used to inform the engine
1013       that the game it is playing is rated or unrated.  Typhoon uses
1014       this information in draw value calculation and when deciding
1015       whether to allow a move takeback.  This is not part of the
1016       <application>WinBoard</application> protocol but rather is a 
1017       hack I added to my copy of <application>WinBoard</application>
1018       in order to accommodate move takebacks on Internet Chess
1019       Servers.
1020       </para>
1021       <listitem>
1022       <para><emphasis>level</emphasis> is used setup the chess clock.
1023       This command takes three (3) parameters.  The first is the number of
1024       moves per time period, the second is the computer's starting
1025       clock value and the third is the increment added to the
1026       computer's clock per move.
1027       </para>
1028       <listitem>
1029       <para><emphasis>setboard</emphasis> is used to setup a position
1030       on the chessboard.  It requires an argument which is the
1031       position to setup in FEN format.
1032       </para>
1033       </itemizedlist>      
1034     </sect1>
1035     <sect1>
1036     <title>Miscellaneous Commands</title>
1037       <para>
1038 There are still some other commands that have been hacked in and are
1039 not part of the <application>WinBoard</application> protocol.  These
1040 commands may change at any time and should not be relied upon to
1041 remain constant in future versions.  
1042       </para>
1043       <para>
1044 Note also that these commands are hard to access when the engine is
1045 running under <application> WinBoard</application>.  If you want
1046 to use them you might consider running the engine from the console.
1047       </para>
1048       <itemizedlist>
1049       <listitem>
1050       <para>
1051       <emphasis>board</emphasis> can be used to dump a text-mode
1052       drawing of the current board position as well as the current
1053       FEN.
1054       </para>
1055       </listitem>
1056       <listitem>
1057       <para>
1058       <emphasis>pgn</emphasis> can be used to dump a PGN record of 
1059       the current game.
1060       </para>
1061       </listitem>
1062       <listitem>
1063       <para>
1064       <emphasis>fen</emphasis> can be used to display the current 
1065       board position in FEN format.  With an argument this command
1066       behaves the same way that <userinput>setboard</userinput> does:
1067       it sets the current board position.
1068       </para>
1069       </listitem>
1070       <listitem>
1071       <para>
1072       <emphasis>avoid</emphasis>, <emphasis>solution</emphasis>,
1073       <emphasis>id</emphasis> and <emphasis>script</emphasis> are 
1074       commands normally used to set test positions for the engine.
1075       They are covered in more detail in another section.
1076       </para>
1077       </listitem>
1078       <listitem>
1079       <para>
1080       <emphasis>bench</emphasis> is a command to run an engine speed
1081       benchmark.  It is discussed in detail in another section.
1082       </para>
1083       </listitem>
1084       <listitem>
1085       <para>
1086       <emphasis>book</emphasis> is a command to manage opening books
1087       and is discussed in detail in another section.
1088       </para>
1089       </listitem>
1090       <listitem>
1091       <para>
1092       <emphasis>dump</emphasis> and <emphasis>test</emphasis> are 
1093       commands to show internal engine state and run self diagnostic
1094       checks.  See the source code for details.
1095       </para>
1096       </listitem>
1097       <listitem>
1098       <para>
1099       <emphasis>eval</emphasis> can be used to display a static 
1100       evaluation score of the current board position.  If the engine
1101       is built with EVAL_DUMP defined it will display the terms
1102       that combined to arrive at the eval score.
1103       </para>
1104       </listitem>
1105       <listitem>
1106       <para>
1107       <emphasis>help</emphasis> displays a brief command list.
1108       </para>
1109       </listitem>
1110       <listitem>
1111       <para>
1112       <emphasis>set</emphasis> is used to show or change the state of
1113       engine variables.  It is discussed in detail in another section.
1114       </para>
1115       </listitem>
1116       <listitem>
1117       <para>
1118       <emphasis>version</emphasis> is used to display the version
1119       number and build configuration of the engine.
1120       </para>
1121       </listitem>
1122       </itemizedlist>
1123     </sect1>
1124     <sect1>
1125     <title>Typhoon Variables</title>
1126       <para>
1127 Many aspects of the engine's behavior can be controlled by setting the
1128 values of variables.  Variables in typhoon are names that hold some 
1129 value.  Variables can hold numbers, strings, times, boolean flags,
1130 and so on.  To view the present state of a variable or to change it
1131 you use the <userinput>set</userinput> command.
1132       </para>
1133       <para>
1134 With no arguments, <userinput>set</userinput> displays the present
1135 state of all system variables:
1136       </para>
1137 <screen>
1138 <userinput>set</userinput>
1139 AnnounceOpening              => "TRUE"
1140 BatchMode                    => "FALSE"
1141 BlackPlayer                  => "typhoon"
1142 BlackRating                  => 0
1143 BlackDescription             => "Ver: 1.00 Build Time: 09:08:03 Jul  4 2006"
1144 BlackIsComputer              => "TRUE"
1145 BookFileName                 => "book.bin"
1146 BookProbeFailures            => 0
1147 ComputerTimeRemainingSec     => 600
1148 EGTBPath                     => "C:\egtb\three;C:\egtb\four;C:\egtb\five"
1149 GameDescription              => "(null)"
1150 GameLocation                 => "(null)"
1151 GameIsRated                  => "FALSE"
1152 GameResultComment            => "(null)"
1153 LastEval                     => 0
1154 LogfileName                  => "typhoon.log"
1155 MoveToPonder                 => "(null)"
1156 MovesPerTimePeriod           => 4294967295
1157 OpponentTimeRemainingSec     => 600
1158 PendingInputEvents           => 0
1159 PonderingNow                 => "FALSE"
1160 PostLines                    => "TRUE"
1161 SearchDepthLimit             => 63
1162 SearchTimeLimit              => 0
1163 SearchStartedTime            => 0.000000
1164 SearchSoftTimeLimit          => 0.000000
1165 SearchHardTimeLimit          => 0.000000
1166 SearchNodesBetweenTimeCheck  => 0
1167 ThinkOnOpponentsTime         => "TRUE"
1168 ThinkingNow                  => "FALSE"
1169 TournamentMode               => "FALSE"
1170 VerbosePosting               => "FALSE"
1171 WhitePlayer                  => "(null)"
1172 WhiteRating                  => 0
1173 WhiteDescription             => "(null)"
1174 WhiteIsComputer              => "FALSE"
1175 Xboard                       => "FALSE"
1176 </screen>
1177       <para>
1178 When used with one argument, <userinput>set</userinput> displays the
1179 value of a subset of the engine variables that begin with the user
1180 supplied argument.  For example:
1181       </para>
1182 <screen>
1183 <userinput>set s</userinput>
1184 SearchDepthLimit             => 63
1185 SearchTimeLimit              => 0
1186 SearchStartedTime            => 0.000000
1187 SearchSoftTimeLimit          => 0.000000
1188 SearchHardTimeLimit          => 0.000000
1189 SearchNodesBetweenTimeCheck  => 0
1190 </screen>
1191       <para>
1192 In order to set the value of any variable, use the 
1193 <userinput>set</userinput> command with two arguments: the first to
1194 indicate what variable name is being set and the second to supply a
1195 new value for that variable.  For example:
1196       </para>
1197 <screen>
1198 <userinput>set tourn t</userinput>
1199 </screen>
1200       <para>
1201 Note that some variables are read only and cannot be set manually.
1202 To change such variables I'm afraid you're stuck editing the source
1203 code.
1204       </para>
1205       <para>
1206 When you use the <userinput>set</userinput> command, the letter case
1207 of a variable name is not significant; the names "WhitePlayer" and
1208 "whiteplayer" refer to the same variable in typhoon.  Additionally as
1209 you noticed in the example above, you may abbreviate any variable or
1210 value name when using the set command as long as the abbreviation is
1211 unique.  For example you could use <userinput>set tourn t</userinput>
1212 to achieve the same result as <userinput>set TournamentMode
1213 True</userinput> with less typing.
1214       </para>
1215     </sect1>
1216   <chapter id="book">
1217     <title>Opening Book</title>
1218     <para>
1219 A chess engine's opening book is a library of moves in different
1220 positions that it can access and play in leu of a searching for a
1221 move.  These moves are usually drawn from well known opening lines
1222 played by human masters.  The primary purpose of an opening book is to
1223 impart some level of understanding of opening theory to the engine.  A
1224 secondary goal of an opening book is to vary the deterministic play of
1225 the engine.
1226     </para>
1227     <sect1>
1228     <title>Opening Book Commands</title>
1229       <para>
1230 Commands affecting typhoon's opening book are prefixed with the
1231 <userinput>book</userinput> opcode.  They are:
1232       </para>
1233       <itemizedlist>
1234       <listitem><para>
1235       <emphasis>book name</emphasis>, which sets the opening book
1236       filename.  If you do not use this command the engine defaults
1237       to using <filename>book.bin</filename> as the opening book.  
1238       If you want to use something else or to create a new opening 
1239       book, use this command to override the name of the opening 
1240       book file.
1241       </para>
1242 <screen>
1243 <userinput>book name newbook.bin</userinput>
1244 </screen>
1245       </listitem> 
1246
1247       <listitem><para>
1248       <emphasis>book import</emphasis>, which can be used to import
1249       book learning from an old book into a new one or to merge
1250       opening lines from a PGN file into the current opening book.
1251       Any book editing or learning that takes place in a position is
1252       recorded in typhoon's <filename>book.edt</filename> file.  If
1253       you wish to apply these book changes to another book in the
1254       future, use <userinput>book input</userinput>.  This command
1255       also is how you create or merge new lines into the opening
1256       book.  For more information about creating an opening book, 
1257       <link linkend="makebook">see the appropriate section</link>.
1258       </para>
1259 <screen>
1260 <userinput>book import /home/scott/typhoon/pgn/twic.pgn</userinput>
1261 </screen>
1262       </listitem> 
1263       <listitem><para>
1264       <emphasis>book dump learning</emphasis>, which shows book
1265       learning in the current position.
1266       </para></listitem> 
1267       <listitem><para>
1268       <emphasis>book dump moves</emphasis>, which shows a list of all
1269       moves in the opening book at the current position.
1270       </para></listitem> 
1271       <listitem><para>
1272       <emphasis>book tourn</emphasis>, which displays or toggles
1273       tournament mode.  This is equivalent to the <userinput>set
1274       TournamentMode</userinput> command.
1275       </para></listitem> 
1276       <listitem><para>
1277       <emphasis>book openings</emphasis>, which sets the name of the
1278       book opening lines file for use when announcing opening lines.
1279       </para></listitem> 
1280       </itemizedlist>
1281     </sect1>
1282     <sect1>
1283     <title>Downloading a Pre-built Opening Book</title>
1284       <para>
1285 Creating your own custom opening book has the advantage of allowing
1286 you complete control over what line are included.  But it requires
1287 some time, a machine with a lot of memory, and a good source of PGN
1288 data.
1289       </para>
1290       <para>
1291 If you want to save yourself the trouble of making a custom opening
1292 book you can choose from several pre-built typhoon books which are
1293 available at <ulink url="http://wannabe.guru.org/scott/hobbies/chess/books">
1294 http://wannabe.guru.org/scott/hobbies/chess/books</ulink>.
1295       </para>
1296     </sect1>
1297     <sect1 id="makebook">
1298     <title>Building a Custom Opening Book</title>
1299       <para>
1300 You may want to build a custom opening book with typhoon.  This
1301 section will describe the process for you and give a few tips about
1302 book building.
1303       </para>
1304       <para>
1305 To begin you will need to collect the games you want to include in
1306 your custom book into a single PGN file.  PGN is a standard format for
1307 storing chess games in text files.  Programs like the freely available
1308 <application>scid</application> which can be obtained from <ulink
1309 url="http://scid.sourceforge.net/">http://scid.sourceforge.net/</ulink>
1310 can be very helpful when you are trying to organize and maintain large
1311 collections of chess games.  Commercial programs like <application>
1312 ChessBase</application> do a good job too, of course.
1313       </para>
1314       <para>
1315 Typhoon knows how to read PGN format files and import the moves from
1316 each game in the PGN file into it's opening book.  However at this
1317 time typhoon's PGN reader is a little picky about what it can process.
1318 In general it's pretty good but it will not read games with move lists
1319 that do not have a space between the move number and the move.  It
1320 also can become confused by variations or comments in the PGN
1321 notation.  I suggest you use a chess database to normalize the PGN
1322 file you intend to use for your opening book before sending it through
1323 typhoon.
1324       </para>
1325       <para>
1326 Once you have your PGN file ready you have to decide whether you want
1327 to merge the openings in the PGN file with typhoon's book or create a
1328 new book from scratch.  The engine has an opening book filename that 
1329 you can set via the <userinput>book name</userinput> command.  If this
1330 file exists then the engine will append new openings to it.  If this
1331 file does not exist then the engine will create it.  By default, this
1332 file is called <filename>book.bin</filename>.  Here's how to override
1333 the default:
1334       </para>
1335       <screen>
1336 white(1): <userinput>book name D:\typhoon\regence.bin</userinput>
1337 Opening book name set to "D:\typhoon\regence.bin"
1338       </screen>
1339       <para>
1340 Now that you have set the name of the opening book you can import your
1341 PGN file to create the new opening lines.  To do this type
1342 <userinput>book import
1343 <replaceable>file.pgn</replaceable></userinput>.  
1344 Of course replace
1345 <userinput><replaceable>file.pgn</replaceable></userinput>
1346 with the
1347 name of your PGN file.  Typhoon will read the PGN file one game at a
1348 time and store the moves in the book file in BookName.  If typhoon
1349 encounters a game containing an error or a move it does not understand
1350 it will output a line like "** BAD Game NNNN (line NNNNNN)
1351 saw=XXX... skipped" and discard all moves in that game.
1352 Unfortunately the PGN parser is fairly picky which is why normalizing
1353 your PGN input using a chess database program before building a book
1354 is a good idea.  Here's what to expect:
1355       </para>
1356       <screen>
1357 white(1): <userinput>book import D:\typhoon\pgn\misc\regence.pgn</userinput>
1358 The opening book D:\typhoon\regence.bin does not exists, creating new book
1359 Stage 1: reading and parsing PGN
1360 ** BAD Game 19498 (line 416067) saw="xc2"... skipped.
1361 ** BAD Game 53900 (line 1148893) saw="Rxf8+"... skipped.
1362 ** BAD Game 72836 (line 1560210) saw="O-O"... skipped.
1363 Done reading PGN.
1364 Straining out unpopular positions to compact buffer...
1365 Compacting the opening book... one moment.
1366 Done, compacted 2517462 positions into 135201.
1367 Sorting the book... this may take a while.
1368 Merging book and writing to disk.
1369 Book successfully built...
1370       </screen>
1371 <note>
1372 <para>
1373 Book building can take quite a while, especially on a machine with
1374 limited memory.  I suggest you have at least 1Gb of memory to build
1375 a large opening book.  If you find that building a book takes multiple
1376 hours you can decrease the number of entries in typhoon's "membook" by
1377 adjusting the MemBookSize variable.  Note that the smaller you make
1378 the "membook", though, the more often typhoon will flush unpopular
1379 positions from the opening book.  Everytime this happens you risk
1380 losing good book lines.
1381 </para>
1382 <para>
1383 It is safe to terminate typhoon while it is building an opening book if 
1384 it takes too long.  However there is no way to pick up where it left off
1385 and all work on the opening book will be lost.
1386 </para>
1387 </note>
1388       <para>
1389 When you have finished building an opening book I recommend you exit
1390 typhoon and restart the engine.  This is not strictly required but is
1391 a good idea.  Once you have <userinput>quit</userinput> typhoon you
1392 can check to make sure your new book exists.  To use it, simply use
1393 the <userinput>book name</userinput> command to instruct typhoon to
1394 use an alternate opening book.  An alternative is to rename the file
1395 you downloaded as <filename>book.bin</filename>, the engine's default
1396 opening book name.
1397       </para>
1398       <screen>
1399 white(1): <userinput>quit</userinput>
1400 Freeing dynamic memory allocations...
1401 Closing logfile...
1402 Terminating input thread...
1403
1404 D:\typhoon\Release><userinput>dir ..\regence.bin</userinput>
1405  Volume in drive D is New Volume
1406  Volume Serial Number is 1412-36C8
1407
1408  Directory of D:\typhoon
1409
1410 10/10/2002  04:14 PM         4,867,236 regence.bin
1411                1 File(s)      4,867,236 bytes
1412                0 Dir(s)  58,596,573,184 bytes free
1413       </screen>
1414     </sect1>
1415     <sect1>
1416     <title>Book Learning</title>
1417       <para>
1418 At the end of every game typhoon adjusts its opening book by updating
1419 the win/loss statistics on the line of opening moves it just saw
1420 played.  This leads to a positive/negative reinforcement of different
1421 openings and, hopefully, to superior play over a long period of time.
1422 Typhoon will not adjust the opening book after bullet games, after it
1423 beats a low-rated opponent, or after it is beaten by a high rated
1424 opponent (<link linkend="rating">see the <userinput>rating</userinput>
1425 command</link>).  It will also not adjust the opening book if the
1426 losing side lost by forfeit.
1427       </para>
1428       <para>
1429 When typhoon adjusts the opening book it records the learning in a
1430 file on disk called <filename>bklearn.dat</filename> as well as in
1431 the book file.  This allows you to view the learning information 
1432 periodically and watch which opening lines are receiving what kind 
1433 of reinforcement.
1434       </para>
1435       <para>
1436 Unfortunately typhoon cannot learn new opening moves from game play -- 
1437 it can simply change the weight of moves it already knows in a given
1438 position.  In order to teach typhoon new moves, use the <userinput>
1439 book import</userinput> command to merge a new PGN file with the 
1440 current opening book.
1441       </para>
1442 <screen>
1443 STDIN> result 0-1 {MoonShot checkmated}
1444
1445 [Event "Rated blitz computer chess game"]
1446 [White "MoonShot (computer)"]
1447 [Black "typhoon 0.906 (00:42:58, Oct  8 2002) (computer)"]
1448 [WhiteElo "2795"]
1449 [BlackElo "2731"]
1450 [Result "0-1"]
1451 [Opening: "[B92] Sicilian : Najdorf, Opovcensky Variation"]
1452 [Description: "{MoonShot checkmated}"]
1453
1454 1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6
1455 6. Be2 e5 7. Nb3 Be7 8. O-O O-O 9. Be3 Be6 10. f4 exf4
1456 11. Rxf4 Nc6 12. Nd5 Bxd5 13. exd5 Ne5 14. a4 Nfd7 15. Rb4 b6
1457 16. Qf1 a5 17. Rb5 Bg5 18. Bd4 Rc8 19. c3 Re8 20. Re1 Nc4
1458 21. Bxc4 Rxe1 22. Qxe1 Rxc4 23. Nd2 Rxa4 24. Qd1 Rxd4 25. cxd4 Be3
1459 26. Kh1 Bxd4 27. b4 a4 28. Nf3 Be3 29. Qxa4 Qc8 30. Qa3 Bf2
1460 31. h3 Qc4 32. Qa8 Nf8 33. Qe8 h5 34. g3 Qd3 35. Kg2 Be3
1461 36. Ng1 Qc2 37. Kh1 Qf2 38. Qxe3 Qxe3 39. Kg2 Nd7 40. g4 Qd3
1462 41. Rxb6 Nxb6 42. Nf3 Nxd5 43. Kg3 h4 44. Kf2 Qe3 45. Kf1 Nf4
1463 46. Nxh4 g5 47. b5 gxh4 48. b6 Qe2 49. Kg1 Qg2
1464 {MoonShot checkmated}
1465
1466                |     c5 (+0.00)
1467                |     d6 (+0.00)
1468                |   cxd4 (+0.00)
1469                |    Nf6 (+0.00)
1470                |     a6 (+0.00)
1471                |     e5 (+0.00)
1472                |    Be7 (+0.00)
1473                |    O-O (+0.00)
1474                |    Be6 (+0.00)
1475                |   exf4 (+0.00)
1476                |    Nc6 (+0.00)
1477                |   Bxd5 (+0.00)
1478                |    Ne5 (+0.00)
1479                |   Nfd7 (-0.90)
1480                |     b6 (-0.79)
1481                |     a5 (-0.08)
1482                |    Bg5 (-0.12)
1483                |    Rc8 (+0.32)
1484                |    Re8 (-0.02)
1485                |    Nc4 (+0.14)
1486                |   Rxe1 (+0.67)
1487                |   Rxc4 (+0.22)
1488                |   Rxa4 (+0.72)
1489                |   Rxd4 (+0.63)
1490                |    Be3 (+0.78)
1491                |   Bxd4 (+0.75)
1492                |     a4 (+0.75)
1493                |    Be3 (+0.81)
1494                |    Qc8 (+1.21)
1495                |    Bf2 (+1.33)
1496                |    Qc4 (+2.87)
1497                |    Nf8 (+4.59)
1498                |     h5 (+6.03)
1499                |*    Qd3 (+9.50)
1500                |*   Be3 (+12.06)
1501                |*   Qc2 (+13.36)
1502                |**   Qf2 (+13.78)
1503                |**  Qxe3 (+14.91)
1504                |**   Nd7 (+15.16)
1505                |**   Qd3 (+15.44)
1506                |**  Nxb6 (+16.04)
1507                |**  Nxd5 (+17.53)
1508                |********   h4  (+57.50)
1509                |********   Qe3 (+57.52)
1510                |********   Nf4 (+57.56)
1511                |********    g5 (+57.60)
1512                |********  gxh4 (+57.62)
1513                |********   Qe2 (+57.64)
1514                |********   Qg2 (+57.66)
1515
1516 BookLearn: Revising opening book line...
1517 BookLearn: Changed 26 book positions.
1518 </screen>
1519     </sect1>
1520   </chapter>
1521   <chapter id="egtb">
1522     <title>Endgame Tablebases</title>
1523     <para>
1524 Endgame tablebases are special databases that contain game theoretic
1525 information about different board configurations with very few pieces
1526 left on the board.  When a chess engine finds a position in a
1527 tablebase it will play perfectly by using the tablebase data.  For
1528 example, by accessing a tablebase an engine might instantly determine
1529 that a certain configuration of king vs. king, knight and bishop is a
1530 mate in 38 for the stronger side.  
1531     </para>
1532     <para>
1533 Eugene Nalimov has created a collection of endgame tablebases that
1534 typhoon knows how to access during its search.  At present all 3, 4
1535 and 5 man endgames have a corresponding tablebase and some 6 man
1536 endgames also have a tablebase.  The drawback of tablebases is they
1537 require a large amount of hard disk space to store and are slow to
1538 access.  The benefit of tablebases is that they can drastically
1539 improve engine endgame play in certain positions.
1540     </para>
1541     <para>
1542 This chapter is about tablebases, where to find them, how to generate
1543 them, how to validate them, how to compress them, and how to use them
1544 with typhoon.
1545     </para>
1546     <sect1>
1547     <title>An Overview of Tablebases</title>
1548       <para>
1549 As the previous section explains, tablebases are endgame databases
1550 that contain information the engine can use to play perfectly in some
1551 endgames with a low number of pieces on the board.  There are ten (10)
1552 3-man tablebases, sixty (60) 4-man tablebases, and two-hundred twenty
1553 (220) 5-main tablebases.  At present some 6-man tablebases have been
1554 generated but are not in wide use because of their large disk space
1555 requirements.
1556       </para>
1557       <para>
1558 Typhoon uses Nalimov format tablebases.  These tablebases come two (2)
1559 ways: compressed and uncompressed.  Typhoon can use either type.  The
1560 compressed variety use much less disk space than their uncompressed
1561 equivalents and are only slightly slower to access.  Nalimov
1562 tablebases are compressed with a program called
1563 <filename>datacomp.exe</filename>.  You can distinguish compressed
1564 files from uncompressed ones by looking at the extension: compressed
1565 tablebases end with <filename>.emd</filename>.
1566       </para>
1567       <para>
1568 To store all 3 and 4-man tablebases (compressed) on your hard drive
1569 you will need approximately 31Mb.  If you want to store all 3, 4 and
1570 5-man tablebases (compressed) you'll need more like 7.5Gb of drive
1571 space.  It is estimated that the full set of 6-man tablebases (when
1572 they are available) will consume approximately 1Tb (1024Gb) of drive
1573 space.  And for you psychopaths out there, if you wrote one tablebase
1574 entry on every atom in the universe you could still not store a 32-man
1575 endgame tablebase file.
1576       </para>
1577       <para>
1578 Now that you know how much of your hard drive these things will use
1579 you may (or may not) want to know where to get them.  One option is to
1580 download them from Bob Hyatt's FTP site at <ulink
1581 url="http://ftp.cis.uab.edu/pub/hyatt/TB">http://ftp.cis.uab.edu/pub/hyatt/TB
1582 </ulink>.  Remember we're talking about transferring 7.5Gb of data;
1583 you'll need a nice fast connection to even consider this.  With a 56K
1584 modem this will take 40 hours (at least) -- probably more.
1585       </para>
1586       <para>
1587 An alternative to transferring the tablebases is to generate them on
1588 your own computer.  This way you only have to download the program
1589 that makes the tablebases -- when it runs it will use your computer's
1590 CPU to compute the tablebase data and save it on your hard drive.  The
1591 <filename>tbexe.zip</filename> and <filename>tbgen.zip</filename>
1592 files on the above FTP site contain the program, source code, and a
1593 README file that explains the generation process.  I have never been
1594 though this personally but I have heard that it takes about one week
1595 of processing time on a computer with a reasonably fast processor and
1596 large amount of memory to generate a full set of 3, 4 and 5-man EGTBs.
1597 It should also be noted that the generation program creates
1598 <emphasis>uncompressed</emphasis> tablebase files so you will need
1599 approximately 40Gb of drive space to attempt this.  Once you have
1600 generated the tablebases, though, you can use
1601 <filename>datacomp.exe</filename> to compress them and save some
1602 space.
1603       </para>
1604       <para>
1605 Another choice is to buy these tablebases on CD.  <ulink
1606 url="http://www.chessbase.com">Chessbase</ulink>, <ulink
1607 url="www.gambitsoft.net">Gambitsoft</ulink>, and <ulink
1608 url="http://store.convekta.com/">Convekta</ulink> all sell sets of
1609 Nalimov tablebases on multiple CDs/DVDs.
1610       </para>
1611       <para>
1612 Finally, this section would be incomplete without a link to Aaron
1613 Tay's great frequently asked question (FAQ) list about endgame
1614 tablebases which is online at <ulink
1615 url="http://www.chesskit.com/aarontay/Winboard/egtb.html">
1616 http://www.chesskit.com/aarontay/Winboard/egtb.html</ulink>.  This
1617 helpful page covers different tablebase formats, how to validate your
1618 tablebases, how to generate your tablebases and more.
1619       </para>
1620     </sect1>
1621     <sect1>
1622     <title>Using Nalimov Format Tablebases with Typhoon</title>
1623       <para>
1624 Once you have some Nalimov format tablebase files (compressed or
1625 uncompressed) getting typhoon to use them is pretty easy.  Use the
1626 <userinput>set egtbpath</userinput> command to tell typhoon where on
1627 your hard drive to look for the tablebase files.  If your tablebase
1628 files are in more than one directory, just separate the directories by
1629 semi-colons (;).
1630       </para>
1631 <screen>
1632 <userinput>set egtbpath D:\typhoon\egtb\three;D:\typhoon\egtb\four</userinput>
1633 Rescanning EGTB path...
1634 ...Found 4-men endgame table bases.
1635 </screen>
1636       <para>
1637 When you change the value of the <userinput>EGTBPath</userinput>
1638 variable typhoon automatically rescans the path looking for tablebase
1639 files.  Scanning can take a few seconds.  If everything goes well you
1640 will see a message like "...Found N-men endgame table bases".
1641       </para>
1642       <note>
1643       <para>
1644 It is recommended you use complete sets of endgame tablebase files.
1645 If you try to use 5-man tablebases without some 4-man tablebases or
1646 4-man tablebases without some 3-man tablebases the engine can become
1647 confused and misplay endgames.  It is acceptable to use only some
1648 5-man files if you have all 4-man and 3-man files, though.  Likewise
1649 it is acceptable to use some 6-man files if you have all 3, 4 and
1650 5-man files to support them.
1651       </para>
1652       </note>
1653     </sect1>
1654   </chapter>
1655   <chapter>
1656     <title>Benchmarks</title>
1657     <para>
1658 Benchmarking is the process of measuring the speed of the chess
1659 engine.  This chapter deals with how to run and interpret the 
1660 results of the benchmark.
1661     </para>
1662     <sect1>
1663     <title>The <userinput>bench</userinput> Command</title>
1664       <para>
1665 The command to begin a benchmark is <userinput>bench</userinput>.  Be
1666 aware that the benchmarking process can take a while and be prepared 
1667 to wait.  
1668       </para>
1669       <para>
1670 The <userinput>bench</userinput> command runs the same benchmark
1671 that Bob Hyatt built into the <application>Crafty</application> 
1672 chess engine (at least the copy of <application>Crafty</application> 
1673 that I have, which is a few versions out of date).  It consists of
1674 searching in a series of positions and computing the overall nodes
1675 (positions) per second during the searches.  This is a good overall
1676 speed test for typhoon.
1677       </para>
1678 <screen>
1679 <userinput>bench</userinput>
1680 Beginning Bob Hyatt's crafty benchmark sequence.
1681 This takes a while -- please be patient.
1682
1683 DEPTH LIMIT --> stop searching now
1684 move c3c2
1685 DEPTH LIMIT --> stop searching now
1686 move e5e6
1687 DEPTH LIMIT --> stop searching now
1688 move f4f5
1689 DEPTH LIMIT --> stop searching now
1690 move d7f5
1691 DEPTH LIMIT --> stop searching now
1692 move b7e4
1693 DEPTH LIMIT --> stop searching now
1694 move c8f5
1695
1696 Benchmark results:
1697   122409037 nodes searched
1698   495 sec
1699   247057 overall nps
1700 </screen>
1701     </sect1>
1702     <sect1>
1703     <title>Benchmark Results</title>
1704
1705       <para>
1706 Please see <ulink
1707   url="http://wannabe.guru.org/scott/hobbies/chess/benchmarks.html">http://wannabe.guru.org/scott/hobbies/chess/benchmarks.html</ulink>
1708   for up-to-date benchmark results.  If you benchmark typhoon and your
1709   system is not on the list below please <ulink
1710   url="mailto:[email protected]"> email me</ulink> your results
1711   and I will include them here.  </para>
1712     </sect1>
1713   </chapter>
1714   <chapter>
1715     <title>Test Suites</title>
1716     <para>
1717 One way to measure the strength of a chess engine is to run it
1718 against a test suite -- a collection of positions and solution moves 
1719 (or moves to avoid).  Typhoon supports running test suites and this
1720 chapter deals with how to run a test suite against the engine.  It
1721 also contains a table of test suite results reported by other users.
1722     </para>
1723     <sect1>
1724     <title>Test Suite Commands</title>
1725       <para>
1726 The typhoon commands that support test suites are
1727 <userinput>solution</userinput>, <userinput>avoid</userinput>,
1728 <userinput>id</userinput>, and <userinput>script</userinput>.  The
1729 <userinput>solution</userinput> command sets up a solution move;
1730 typhoon can handle up to three (3) solutions per position.  The
1731 <userinput>avoid</userinput> command sets up a move to avoid; typhoon
1732 can handle up to three (3) avoid moves per position.  The
1733 <userinput>id</userinput> command simply adds a free form text name
1734 for a test position.  And the <userinput>script</userinput> command
1735 reads the contents of a file on disk and treats everything in it as
1736 user input.
1737       </para>
1738       <note>
1739       <para>
1740 You can set up either <userinput>solution</userinput> moves or
1741 <userinput>avoid</userinput> moves but not both in the same position.
1742       </para>
1743       </note>
1744       <para>
1745 Here's an example of how these commands work together.
1746       </para>
1747 <screen>
1748 <userinput>st 5</userinput>
1749 <userinput>script \typhoon\tests\wac.epd</userinput>
1750 SCRIPT> <userinput>setboard 2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 w - -</userinput>
1751 SCRIPT> <userinput>solution Qg6</userinput>
1752 SCRIPT> <userinput>id "WAC.001"</userinput>
1753 SCRIPT> <userinput>go</userinput>
1754
1755  1u   -1.91  00:00:00.08  486          PV= 1. Qe3 Nxe5 [Q] 2. dxe5 [Q] <-2.00>
1756  1u   -1.56  00:00:00.11  556          PV= 1. Ne8 <-2.00>
1757  1.   -1.56  00:00:00.12  576          PV= 1. Ne8 <-2.00>
1758  2.   -1.18  00:00:00.21  1099         PV= 1. Ne8 Qf8 <-2.00>
1759  3+   -0.35  00:00:00.30  3727         Qg6! ++
1760 FORCED MATE --> stop searching now
1761  3.  +MATE1  00:00:00.40  8406         PV= 1. Qg6 fxg6 2. Nxg6+ [+] [MATE]
1762 tellothers depth=3, score=+MATE1, n=8406, nps=20863, PV= 1. Qg6 fxg6 2. Nxg6+ [+] [MATE]
1763 move g3g6
1764 ...
1765 </screen>
1766       <para>
1767 In the above example the user first types <userinput>st 5</userinput>.
1768 This sets the clock to fixed-time-per-move mode and tells the engine
1769 to search exactly five (5) seconds per position.  Next the user types
1770 <userinput>script /typhoon/tests/wac.epd</userinput>.  This begins the
1771 execution of a script file.  From now on typhoon will take commands
1772 from this script file one at a time until the file has been completely
1773 executed.  Commands that typhoon reads from a script have "SCRIPT>"
1774 printed before them.  The script uses <userinput>setboard</userinput>,
1775 <userinput>solution</userinput> and <userinput>id</userinput> to set
1776 up a test position, a solution move, and the position name.  Then the
1777 script sends typhoon the <userinput>go</userinput> command and the
1778 engine starts thinking.  Because the engine has been told to search
1779 exactly five (5) seconds per move, it will stop searching this
1780 position when five (5) seconds are up.  At this time it will count the
1781 position as solved if the move it plays matches any of the solution
1782 move(s) (or does not match any of the avoid move(s)).  It also keeps
1783 track of how long it took to see the correct move.  Once a script has
1784 finished running completely typhoon will print out some final
1785 statistics about the test suite run and begin to watch the keyboard
1786 for commands again.
1787      </para>
1788 <screen>
1789 TEST SCRIPT execution complete.  Final statistics:
1790     correct solutions   : 272
1791     incorrect solutions : 28
1792     total problems      : 300
1793     total nodecount     : 40376223
1794     avg. search speed   : 125601.9 nps
1795     avg. solution time  : 0.4 sec
1796     avg. 1st move beta  : 0.936
1797
1798 Time-to-solution histogram:
1799 00.00s .. 00.20s: ******************************* (73)
1800 00.20s .. 00.40s: ************************************************** (119)
1801 00.40s .. 00.60s: ************** (31)
1802 00.60s .. 00.80s: ******* (15)
1803 00.80s .. 01.00s: *********** (34)
1804    not solved   : **************** (28)
1805 </screen>
1806     </sect1>
1807     <sect1>
1808     <title>Test Suite Results</title>
1809       <para>
1810 Here are some test suite results obtained by typhoon running on my
1811 development machine which is an AMD Athlon XP 1.533Ghz / 512Mb.  In
1812 the table the suite abbreviation "ECM" refers to <ulink
1813 url="http://wannabe.guru.org/scott/hobbies/ECM.EPD">"Encyclopedia of
1814 Chess Middlegames"</ulink> and "WAC" refers to <ulink
1815 url="http://wannabe.guru.org/scott/hobbies/chess/WAC.EPD">"Win At
1816 Chess"</ulink>
1817       </para>
1818       <informaltable>
1819       <tgroup cols="4">
1820         <thead>
1821           <row>
1822             <entry>suite</entry>
1823             <entry>sec/move</entry>
1824             <entry>score</entry>
1825             <entry>date</entry>
1826             <entry>hardware</entry>
1827           </row>
1828         </thead>
1829         <tbody>
1830           <row>
1831             <entry>ECM</entry>
1832             <entry>20</entry>
1833             <entry>674 / 879</entry>
1834             <entry>Dec 22, 2004</entry>
1835             <entry>Dual 1.533ghz Athlon MP</entry>
1836           </row>
1837           <row>
1838             <entry>WAC</entry>
1839             <entry>20</entry>
1840             <entry>296 / 300</entry>
1841             <entry>Jan 11, 2002</entry>
1842             <entry>Dual 1.533ghz Athlon MP</entry>
1843           </row>
1844         </tbody>
1845       </informaltable>
1846     </sect1>
1847   </chapter>
1848   <chapter id="winboard">
1849     <title>Advanced WinBoard Configuration</title>
1850     <para>
1851 This chapter covers how to get typhoon running under
1852 <application>WinBoard</application>, a free, open source graphical
1853 front-end for chess engines.  For more information about
1854 <application>WinBoard</application> or to download it, see <ulink
1855 url="http://www.tim-mann.org/xboard.html">http://www.tim-mann.org/xboard.html
1856 </ulink>.  This chapter is also relevant to
1857 <application>xboard</application>, WinBoard's X11-based version.  More
1858 information about these chess GUI programs is also available in
1859 <ulink url="http://www.aarontay.per.sg/Winboard/Winboard.html">
1860 Aaron Tay's WinBoard FAQ</ulink>.
1861     <para>
1862     <sect1>
1863     <title>Playing Locally</title>
1864       <para>
1865 Probably the most common way you will want to use typhoon with
1866 <application>WinBoard</application> is to play local chess matches
1867 against the program using <application>WinBoard</application> as the
1868 display.  To do this you will need to use
1869 <application>WinBoard's</application> <filename>-fcp</filename> and
1870 <filename>-fd</filename> commandline options like this:
1871       </para>
1872       <screen>
1873 <userinput>winboard -fcp "typhoon" -fd <replaceable>typhoon_directory</replaceable></userinput>
1874       </screen>
1875       <para>
1876 The <filename>-fcp</filename> option sets
1877 <application>WinBoard's</application> <emphasis>first chess
1878 program</emphasis> and the <filename>-fd</filename> sets the
1879 <emphasis>first chess program directory</emphasis>.  You should use
1880 the directory you installed typhoon in after the
1881 <filename>-fd</filename> option.  Once
1882 <application>WinBoard</application> is running, set the "Machine Plays
1883 Black" or "Machine Plays White" menu option.
1884       </para>
1885       <para>
1886 Probably the best way to remember this is to create a little batch
1887 file to start up <application>WinBoard</application> for playing
1888 locally against typhoon.
1889       </para>
1890       <note>
1891       <para>
1892 Typhoon's thinking lines may not be compatible with 
1893 <application>WinBoard</application> and can cause it to crash when you
1894 enable the "Show Thinking" menu option.  I advise you not to do this.
1895       </para>
1896       <para>
1897 Also, typhoon's support for "Analysis Mode" in
1898 <application>WinBoard</application> is incomplete at the time of
1899 writing and may lead to problems.  Please don't enable either of these
1900 WinBoard features for now.  Both shortcomings will be addressed in
1901 future releases of the engine.
1902       </para>
1903       </note>
1904       <para>
1905 If everything is working right typhoon should play instantly in the
1906 early moves of a new game.  If typhoon has to think for more and a
1907 second or two about early moves it may not see the opening book.
1908       </para>
1909       <para>
1910 If you run into trouble getting typhoon to work under
1911 <application>WinBoard</application> I suggest looking at
1912 <filename>typhoon.log</filename>.  This file, which is created by
1913 typhoon every time it is invoked, will contain a record of the
1914 interaction between the engine and <application>WinBoard</application>
1915 and may help to isolate the problem.  You can also enable
1916 <application>WinBoard</application> logging by using the
1917 <filename>-debug</filename> commandline option to
1918 <application>WinBoard</application>.  This will cause the creation of
1919 <filename>winboard.log</filename> which also may help you track down
1920 the problem.
1921       </para>
1922     </sect1>
1923     <sect1>
1924     <title>Engine vs. Engine Matches</title>
1925       <para>
1926 With <application>WinBoard</application> it's possible to play one
1927 chess engine against another.  This section explains how to set this
1928 up and how to run engine vs. engine matches as fairly as possible.
1929       </para>
1930       <para>
1931 To run two engines under <application>WinBoard</application> just use
1932 both the <filename>-fcp</filename> and the <filename>-scp</filename>
1933 commandline options.  <filename>-fcp</filename> sets the
1934 <emphasis>first chess program</emphasis> while
1935 <filename>-scp</filename> sets the <emphasis>second chess
1936 program</emphasis>.  You may want to use the related
1937 <filename>-fd</filename> and <filename>-sd</filename> options too.
1938 Then, once <application>WinBoard</application> is running, set the
1939 "Machine Plays Both" option and watch them fight.
1940       </para>
1941       <para>
1942 It's really not advisable to test engines by playing them under
1943 WinBoard on a single processor machine.  However running on a 
1944 two single-threaded engines on a multi-processor (or multi-core)
1945 machine is a great way to test engines. 
1946       </para>
1947       <para>
1948 If you do choose to run an engine vs. engine match on a single
1949 processor machines you should turn off pondering on both engines so
1950 that they do not constantly compete for system processor resources.
1951 The next step is to make sure that each engine has equal access to the
1952 machine's memory.  When playing engine-engine matches, you should set
1953 the hash table sizes of both engines by hand to roughly half the total
1954 memory on the machine.  Be absolutely sure that combined memory
1955 requirements of the two engines does not exceed the amount of physical
1956 memory on your machine or you will run into swapping which will slow
1957 the engine(s) down severely.
1958       </para>
1959     </sect1>
1960     <sect1>
1961     <title>Playing on an Internet Chess Server</title>
1962       <para>
1963 Internet Chess Servers are machines on the Internet that allow
1964 multiple people/engines to connect and play chess against one
1965 another.  <application>WinBoard</application> knows how to connect to
1966 and communicate with these servers and therefore you can use it to
1967 play typhoon against other people and machines connected to the same
1968 Internet Chess Server.  This is a good way to test two chess engines
1969 because when they play over the Internet, unlike when they both play
1970 on the same machine, they do not have to fight each other for access
1971 to the processor and memory resources of a single computer.
1972       </para>
1973       <note>
1974       <para>
1975 It's unethical and against the rules of most Internet Chess Servers to
1976 use a computer engine to make moves on a human account.  Your human
1977 rating should not be aided by machine and your opponents have the
1978 right to know they are playing against a computer.  Most Internet
1979 Chess Server administrators are pretty good at catching people who
1980 cheat and banning them from playing.  Please don't use typhoon to
1981 cheat on Internet Chess Servers!  Likewise, if you are running typhoon
1982 on a chess server I would be grateful if you would list the program
1983 name and hardware configuration in your account's finger notes.
1984       </para>
1985       </note>
1986       <para>
1987 To connect to an Internet Chess Server with typhoon+WinBoard use the
1988 following commandline options when invoking
1989 <application>WinBoard</application> in addition to the normal
1990 <filename>-fcp</filename> and <filename>-fd</filename> options
1991 described in the last sections: <filename>-zp</filename> (enable chess
1992 engine to ICS code), <filename>-ics</filename> (connect to ICS
1993 server), <filename>-icshost</filename> (ICS server hostname),
1994 <filename>-xpopup</filename> (no popup windows),
1995 <filename>-xautoraise</filename> (no popup windows),
1996 <filename>-xexit</filename> (no popup windows), and
1997 <filename>-reuse</filename> (no need to restart the engine process,
1998 reuse the current one).  You may also want to use
1999 <filename>-icsHelper</filename> (program name to use to connect to the
2000 ICS, something like timestamp.exe or timeseal.exe),
2001 <filename>-zippyPassword</filename> and
2002 <filename>-zippyPassword2</filename> (passwords are for controlling
2003 the chess engine remotely).  For more information about what these
2004 commands do, see the documentation in
2005 <filename>winboard.hlp</filename> and
2006 <filename>README.zippy</filename>, both of which are included with
2007 <application>WinBoard</application>.
2008       </para>
2009       <para>
2010 Here's a sample script based on the one I use to connect typhoon to the
2011 <ulink url="http://www.chessclub.com">Internet Chess Club</ulink>.
2012 This script loops forever restarting the engine and
2013 <application>WinBoard</application> if they lose connection to the ICS
2014 server or terminate for some reason.  You can break out of the script
2015 by pressing ^C.
2016       </para>
2017 <screen>
2018 @echo off
2019 :again
2020 cd /d C:\typhoon
2021 "C:\program files\winboard\winboard.exe" /zp /ics /icshost
2022  chessclub.com /icshelper C:\progra~1\winboard\timestamp.exe /fcp
2023  C:\typhoon\release\typhoon.exe /xzt /xexit /xpopup /xautoraise 
2024  /reuse /debug /zippyPassword xxx /zippyPassword2 yyy
2025 sleep 3
2026 kill -f typhoon.exe
2027 kill -f winboard.exe
2028 sleep 3
2029 goto :again
2030 </screen>
2031       <para>
2032 There are many different Internet Chess Servers on the 'Net.  Some are
2033 free, others cost money to use.  Some are very busy and others are
2034 pretty sparsely used.  There's a list of chess servers on Tim Mann's
2035 website at <ulink url="http://www.tim-mann.org/ics.html">
2036 http://www.tim-mann.org/ics.html</ulink>.
2037       </para>
2038     </sect1>
2039   </chapter>
2040
2041   <chapter id="bugs">
2042     <title>Testing Typhoon</title>
2043     <para>
2044 Typhoon was released in the present, somewhat buggy state mainly 
2045 so that I could benefit from a large pool of testers.  Therefore,
2046 I am very interested in reports about how the engine does.  This
2047 chapter is about how you can help test typhoon.  Thanks for 
2048 helping to make the engine stronger!
2049     </para>
2050     <sect1 id="debug">
2051     <title>A DEBUG build</title>
2052       <para>
2053 With a simple modification to the build instructions presented in 
2054 <link linkend="compile">an earlier section</link> it is possible to
2055 produce a DEBUG build of the chess engine.  A DEBUG build is an
2056 engine that runs much more slowly than normal because it is very
2057 carefully double checking every calculation for errors.  If an
2058 error is found a DEBUG build makes it easier to understand and
2059 fix the problem than a normal build.
2060       </para>
2061       <para>
2062 In order to make your own DEBUG build, just add <userinput>DEBUG=1
2063 </userinput> to the commandline when you build the engine.  The
2064 engine will be called <filename>_typhoon</filename> instead of
2065 the usual <filename>typhoon</filename>.
2066       <para>
2067 I try to run DEBUG builds of the engine for long periods of time
2068 in order to expose bugs.  If you have a spare machine and some time
2069 it would be great if you would be willing to do the same.  If your
2070 DEBUG build crashes, <ulink url="mailto:[email protected]">
2071 send me an email</ulink> with the message and output of the 
2072 <userinput>version</userinput> command.
2073       </para>
2074     <sect1 id="test">
2075     <title>A TEST build</title>
2076       <para>
2077 A TEST build is one that has some extra testcode compiled into it.
2078 TEST builds will also run the testcode once automatically at startup.
2079 I run TEST builds periodically in order to make sure that I have not
2080 broken anything with my changes.  TEST builds are also helpful when
2081 you are trying to port the engine to a new platform; if you get a
2082 TEST build to run cleanly (especially a TEST/DEBUG build) then you
2083 can be pretty sure the port is good.
2084       </para>
2085       <para>
2086 If you want to build your own TEST engine, just add <userinput>TEST=1
2087 </userinput> to the <application>make</application> commandline.
2088       </para>
2089     </sect1>
2090     <sect1 id="evaldump">
2091     <title>An EVAL_DUMP build</title>
2092       <para>
2093 An image built with the <userinput>EVAL_DUMP</userinput> preprocessor
2094 symbol defined will output several debugging messages every time it
2095 runs the evaluation routine (see <filename>eval.c</filename>).  It
2096 will also break down the terms contributing to the eval score when
2097 the user types the <userinput>dump eval</userinput> command.
2098       </para>
2099       <para>
2100 These features are useful if you are curious as to what the engine
2101 thinks of a position.  Of course, it doesn't make sense to run the
2102 evaluator on a position that is not quiet.
2103       </para>
2104       <para>
2105 Since the engine produces output everytime it runs an evaluation and
2106 because the engine typically runs the evaluation routine hundreds of
2107 thousands of times per second, you should not attempt to search with
2108 an engine build using the EVAL_DUMP flag.  It's too verbose.
2109       </para>
2110       <para>
2111 If you find a position where you think the engine's evaluation is
2112 totally wrong, please send it to me.  While I can't promise anything
2113 (some positions are too complicated for static analysis), I will 
2114 definitely take a look.
2115       </para>
2116     <sect1>
2117     <title>Typhoon Crashes</title>
2118       <para>
2119 The engine should hardly ever crash.  If you find a reproducible way
2120 to crash the engine I definitely want to hear about it.  Please 
2121 <ulink url="mailto:[email protected]">send me an email</ulink>
2122 describing how you managed to crash the engine and the output of 
2123 the <userinput>version</userinput> command.  
2124       </para>
2125       <para>
2126 If you have a <filename>typhoon.core</filename> file, send that along
2127 with a copy of your <filename>typhoon</filename> image.  Better yet,
2128 build <link linkend="debug">a DEBUG build</link>, crash it,
2129 and send me the <filename>_typhoon.core</filename>, and <filename>
2130 _typhoon</filename> files.  That makes it easier to figure out what 
2131 went wrong.
2132       </para>
2133     </sect1>
2134     <sect1>
2135     <title>Typhoon Blunders</title>
2136       <para>
2137 While not as severe as outright engine crashes, I am also interested
2138 in positions where the program makes a terrible move.  I'm not a
2139 strong chessplayer so your impressions about the engine's strengths,
2140 weaknesses, trends that indicate errors in judgment, and so on are 
2141 also very welcome.  Please <ulink url="mailto:[email protected]">
2142 email them to me</ulink> along with the output of the 
2143 <userinput>version</userinput> command.
2144       </para>
2145     </sect1>
2146   </chapter>
2147   </book>
2148