]> git.pld-linux.org Git - packages/crafty.git/blame - crafty.doc.ascii
- adapterized (killed trailing spaces/tabs)
[packages/crafty.git] / crafty.doc.ascii
CommitLineData
3fa06793 1
2
3
4
5
6
7
8 Crafty Command Documentation (version 18)
9 -----------------------------------------------
10Crafty is nothing more than a long-time hobby of mine, dat-
11ing back to Blitz and later Cray Blitz. People ask me how I
12keep doing this, and that is the one question that generally
13leaves me at a loss for words.
14
15Perhaps the most common question I'm asked is "is this ver-
16sion of Crafty some dumbed-down version of what you play on
17ICC or what you use at a computer chess event?" The answer
18is a resounding *NO*. The current version is *exactly* what
19is running on ICC under this version number. Note that a
20new version can, on occasion, introduce weaknesses or out-
21right bugs that were not present in previous "gold" ver-
22sions. As a result, you should be careful to back up your
23"favorite" before trying the latest and greatest. If you
24aren't satisfied with the new version, you can then go back
25to what you believe is a better version.
26
27If you are looking for the strongest playing computer chess
28program available, you should likely look to Fritz, Rebel,
29Tiger, and the other commercial entries. There you will
30find strong opponents with polished interfaces that have
31been tested in a systematic and careful way. If you are
32looking for a program that plays good chess, has a reason-
33able set of features for you to use, is available in source
34form, and one where the author welcomes feedback, code or
35suggestions, then you are at the right place. I welcome
36comments and suggestions, and also feedback from ideas you
37try yourself that seem to work.
38
39Crafty is a state-of-the-art computer chess program, and
40uses all of the search algorithms you have probably read
41about, negascout search, killer/history move ordering, SEE
42(Static Exchange Evaluation) quiescence move ordering and
43pruning, hash (transposition/refutation) tables as well as
44evaluation caches, selective extensions, recursive null-move
45search, and a host of other features that have been used and
46are still being used in most computer chess programs. If
47it's not in Crafty, either it is on the "to do" list, or it
48has been tried, found wanting, and discarded.
49
50Chess Knowledge is growing, and suggestions (or even better,
51real code) are welcome. This is the best place to con-
52tribute your ideas, because knowledge can be used to sup-
53plant search and make it play better. The evaluation is
54probably the easiest place to start studying Crafty because
55of the comments and simplicity of using bitmaps, *once* you
56get "into" them.
57
58My purpose for doing this is an exercise in computer chess
59efficiency. I can't begin to count the number of people I
60know that started from scratch to write a chess program.
61
62
63
64
65
66
67
68
69
70
71
72
73
74Even larger is the group that started from scratch, and gave
75up before finishing, because of the basic size of the pro-
76ject.
77
78Crafty offers everyone a very clean starting point, if you
79are fascinated by the bitmap chess board implementation (as
80I am). The search and quiescence code is reasonably
81straightforward, as is the evaluation,
82
83It offers a great starting point, so that if you are inter-
84ested in trying a new search extension, you can be testing
85tomorrow, rather than next year, because you start with a
86fully functional chess engine that is not a "toy" applica-
87tion, but is a functional and "dangerous" chess player. It
88offers a rapid start, although you can certainly replace it
89piece by piece until it is "yours" if you want. It also
90offers a fairly complete set of commands and an interface
91for a GUI as well as support for chess server play, so that
92testing and debugging your new ideas is greatly simplified.
93
94If you'd like more information, please check out the read.me
95document and the crafty.FAQ that are distributed with
96Crafty. These contain recent news and specific instructions
97for commonly asked questions, like "where can I obtain
98tablebase files and how do I use them?"
99 How to play a game.
100 -------------------
101When you execute Crafty, you will immediately be greeted by
102the prompt string "white(1): " and Crafty will wait for com-
103mands. This prompt means it is white on move, and we are at
104move #1 for white. You can first use any of the commands
105from the alphabetic command listing below to tailor the game
106to your liking (time control, hash table size, book random-
107ness, etc.) and then you have two choices. If you want to
108play white, just enter your move, and Crafty will take it
109from there and make a move in response. You will then be
110prompted by "white(2):" and it is your move again. If you
111would prefer to play black, just enter either "move" or "go"
112at the prompt and crafty will move for that side rather than
113accepting a move from you. After it makes its move for
114white, you will then see the prompt "black(1): " indicating
115it is now time for blacks first move. You can enter a move,
116or you can once again enter "move" or "go" and Crafty will
117again move for the current side, change sides, and prompt
118you for what to do next.
119
120If you find yourself continually using a set of commands to
121configure crafty to play as you want, you can put these com-
122mands in a startup file called .craftyrc (Unix) or crafty.rc
123(DOS/Windows). The format for this file is just like you
124would type the commands at the keyboard, with the require-
125ment that the last line of the file must be "exit" on a line
126by itself. Using this, each time you start Crafty, it will
127
128
129
130
131
132
133
134
135
136
137
138
139
140first execute the commands from this file before it prompts
141you for input.
142
143While Crafty is running, you can control what it displays,
144but here's a couple of samples to explain what it is saying
145and why:
146
147 depth time score variation (1)
148 book moves {d4, c3, Nc3, d3, b3, c4, g3, b4, Be2, Bb5}
149 book 0.0s 70% d4
150
151White(3): d4
152 time used: 0.01
153
154This is the normal output for those cases where Crafty is in
155book. The book moves line gives the set of book moves that
156made the first selection cut (see the book selection expla-
157nation given later), followed by the move actually played,
158in this case d4.
159
160If Crafty is out of book, then the output looks somewhat
161different as given below:
162
163 depth time score variation (1)
164 4-> 0.81 2.09 6. dxe4 Bxe4 7. Rad8 Qf2 8. Qb5
165 5 1.37 2.41 6. dxe4 Bxe4 7. Ne5 Qf4 8. Bxe4+
166Qxe4 9. f5
167 5-> 1.88 2.41 6. dxe4 Bxe4 7. Ne5 Qf4 8. Bxe4+
168Qxe4 9. f5
169 6 7.38 -- 6. dxe4
170 6 11.90 1.97 6. dxe4 Bxe4 7. Rab8 Qf2 8. Qc7
171Nc5 9. Qe5
172 6 12.92 ++ 6. Ne5
173 6 13.71 2.23 6. Ne5 Qg2 7. Ng6 h5 8. Nh4 Qg4
174 6-> 15.59 2.23 6. Ne5 Qg2 7. Ng6 h5 8. Nh4 Qg4
175 time: 15.60 cpu:99% mat:1 n:246565 nps:15927
176 ext-> checks:4706 recaps:1336 pawns:0 1rep:301
177 nodes full:45951 quiescence:200614 evals:104657
178 endgame tablebase-> probes done: 0 successful: 0
179
180Let's take this stuff one line at a time. Lines that have
181something like 4-> in the depth column are printed when that
182iteration (depth) is completely finished. The time and
183score columns should be obvious as to their meaning as is
184the PV, the sequence of moves that led to this score. One
185note about the "score" column. As of version 18, Crafty
186displays the score with + values good for white, - values
187good for black, no matter which side it is playing in the
188game. All output now follows this convention, from playing,
189to analysis mode, to annotating your games, to whisper-
190ing/kibitzing on the chess servers, and so forth. This is
191unlike other engines, but once you get used to it, it is
192much less confusing when you remember that negative scores
193
194
195
196
197
198
199
200
201
202
203
204
205
206are good for black and bad for white, and vice-versa.
207
208the line that has -- in the score column means that when we
209started depth 6, dxe4 turned out to be worse than we thought
210(notice score dropped from 2.411 last search to 1.972 for
211this move this search.) To resolve this, Crafty lowers the
212lower search bound (alpha) and re-searches the move to find
213the score. The line with ++ means that this move (Ne5) is
214better than the best move so far, so Crafty raises the upper
215search bound (beta) and re-searches this move to find the
216new score.
217
218the first line of statistics gives the total time taken for
219this search, the cpu percentage which should stay at 98-100%
220unless your machine is heavily loaded or unless Crafty is in
221an endgame that is having lots of contact with endgame
222databases. If this drops below 98%, it means that Crafty is
223not getting full CPU usage and will be playing weaker than
224normal. The mat:1 is simply the true material score, since
225Crafty's positional scores are often larger than a pawn.
226
227 Alphabetic Listing of Commands
228 ------------------------------
229
2301. alarm on|off This command is used to control Crafty's
231"beep" after it makes a move. Turning this off will make
232Crafty "quiet" when it plays, but also makes it easy to miss
233a move if you are using crafty to play in a tournament.
234This is primarily designed to make Crafty tolerable during
235late night matches.
236
2372. analyze This command puts crafty into analyze mode. In
238this mode, Crafty starts computing for whichever side is on
239move, and it continues computing and showing its analysis
240until a move is entered. This move is made, Crafty changes
241sides, and starts thinking and printing analysis all over,
242but for the other side now.
243
244This command is useful to play through a game, because you
245get instant feedback when you try a move. If you want to
246try a different move from the one you just entered, use the
247"back" command to back up one move, or use "back <n>" to
248back up <n> moves. Note that one move is a single move for
249the last player, not a move for both sides. To unmake the
250most recent 2 moves (one for black, one for white) use "back
2512".
252
2533. annotate|annotateh <filename> <colors|name> <moves>
254<margin> <time> This command is used to annotate (make com-
255ments in) a game that has already been played.
256
257The annotate command produces a file with the .can extension
258added to the original name. This file will contain pure
259
260
261
262
263
264
265
266
267
268
269
270
271
272ascii information from the annotation pass. "annotateh"
273produces an HTML file instead (with the .html extension).
274This includes the normal output, plus a nice bitmapped
275graphical board display for every position where crafty had
276'something to say'.
277
278<filename> is the name of the file that has the game moves
279stored in it. This should be a PGN-compatible file,
280although Crafty can read nearly any file with chess moves
281and convert it to pgn using the "read" and "savegame" com-
282mands to perform the conversion.
283
284<colors|name> indicates which side Crafty will annotate.
285The valid choices are w, b, and wb/bw for white only, black
286only, and both, respectively. Crafty will search and pro-
287duce results for the indicated color only, making moves for
288the other side silently as they are read in.
289
290Alternatively, you can specify the player's name (useful if
291you want to annotate several of your own games in one large
292pgn file, for example, and you alternated colors so that you
293can't pick the right one easily). Crafty will then figure
294out which side to annotate for in each game. Note that the
295name is case-sensitive, but that you only have to enter a
296string that is unique in the name field. IE if one name is
297"Anatoly Karpov" and the other is "unknown" then specifying
298Karpov as the name would be sufficient. If the same
299'string' appears in both names, Crafty will complain.
300
301<moves> indicates the moves that should be annotated. If
302this is a single integer, annotation starts at this move
303number (for the color given above) and proceeds for the rest
304of the game. If a range is given, as (20-33), then only
305moves 20-33 inclusive are annotated. To annotate the com-
306plete game, you can use 1-999.
307
308<margin> gives a score "window" that controls whether Crafty
309will produce comments (see below). The larger this number
310this number, the fewer annotations Crafty will produce. A
311negative number will result in an annotation for every move
312selected.
313
314<time> indicates the time limit for each search. Since each
315move selected requires two searches, you can take the number
316of moves, double this number and multiply by <time> to
317determine how long the annotation process will take. This
318time is in seconds.
319
320How it works. Suppose you use the command "annotate game1 w
3211-999 1.000 30" This asks Crafty to read the file "game1",
322and annotate the white moves for the entire game. The mar-
323gin is 1 pawn and the search time limit is 30 seconds. The
324output for the annotate command is found in <filename>.can,
325
326
327
328
329
330
331
332
333
334
335
336
337
338in this case this is game1.can.
339
340Crafty first searches the move actually played in the game
341to determine the score for it. Crafty then searches the
342same position, but tries all legal moves. If the score for
343the best move found in this search is greater than the score
344for the move actually played plus the margin, then a comment
345is added to the output file. This output file is quite
346short, with all the game moves (plus any PGN tags in the
347original, for identification purposes) plus the brief com-
348ments. An annotation looks like this:
349
350{real_value (depth:best_value PV moves)}
351
352real_value is the score for the move actually played. depth
353is the depth Crafty searched to produce the best_value and
354PV for what it thinks is the best sequence of moves for both
355sides. If you set <margin> to 1.000, you are asking Crafty
356to only annotate moves that either lost a pawn or more, or
357moves that failed to win a pawn or more. If you set <mar-
358gin> to .300, you are asking for annotations for any move
359that makes the score drop about 1/3 of a pawn below the
360value for the best move Crafty found.
361
362If you have other moves you would like to see analyzed dur-
363ing this annotate process, at the point where the move can
364be played, insert it into the PGN file as an analysis com-
365ment, surrounded by () or {} characters. Crafty will pro-
366duce analysis for this move as well. If more than one move
367appears inside a single set of delimiters, only the first
368will be analyzed. To force Crafty to analyze more than one
369move, enter them like this: (move1) (move2) as though they
370were two separate comments.
371
3724. ANSI on|off This command is used to control whether or
373not Crafty attempts to display its move in reverse video or
374not. For PC's, Linux, and most Unix boxes, this works fine.
375Should you find yourself playing crafty via a dumb terminal,
376this might hose the terminal and interfere with your ability
377to see or input moves. If moves are not displayed in
378reverse video, it's probably wise to turn this off to avoid
379hanging the terminal you are using.
380
3815. black|white This command simply toggles the side on
382move. if it is white to move, and you enter white, nothing
383happens. If it is white to move and you enter black, then
384it becomes blacks turn to move immediately from the same
385position. Used only infrequently.
386
3876. book (see the book explanation near the end of this doc-
388ument for a full explanation of this command and its many
389options.) Note that there are special commands available
390(*only* on the command line, *not* in the
391
392
393
394
395
396
397
398
399
400
401
402
403
404crafty.rc/.craftyrc files) to direct crafty to specific
405directories for the book files (bookpath=/a/b/c), the table-
406base files (tbpath=/i/j/k) and the log files (log-
407path=/x/y/z). Note that these commands can *only* be used
408on the command line, because they must be executed before
409the engine is initialized. Putting them in the
410crafty.rc/.craftyrc file will produce error messages without
411affecting how the files are opened.
412
413If you need to specify multiple directories (tbpath only)
414you may do so by using "tbpath=path1:path2:path3:etc" or
415else use the more Unix- like
416"tbpath=(path1:path2:path3:etc)" instead. The paths are
417separated by ":" (colon) characters and everything is case-
418sensitive as usual. For dos/windows users, the separator
419can be a semi-color (;) or a comma(,) to avoid the drive
420designation ambiguity.
421
4227. cache=N This command is used to alter the cache size
423used for endgame database probes. N can be a simple inte-
424ger, representing the number of bytes to use or it can be
425specified as nK or nM representing n * 1024 bytes or n *
4261024 * 1024 bytes. This should be in multiples of the
427database "chunk" size, which might vary. Using the nM form
428guarantees that you will have a reasonable number.
429
4308. clock <ctime> <otime> This command is primarily
431intended for use when Crafty is playing in a tournament,
432such as the WMCCC or WCCC events. If the operator is some-
433what slow in entering moves, or forgets to stop the clock
434after making a move for Crafty, the chess clock for the game
435will drift from the values that Crafty maintains internally.
436<ctime> is the time (in minutes or hh:mm format) crafty has
437left until the next time control, and <otime> is the oppo-
438nent's remaining clock time. This command can be used at
439any time, but will only affect the time per move *after*
440crafty makes the current move and starts to think about what
441the opponent might do next.
442
4439. computer This command usually comes from xboard/win-
444board, but can be used at any time to tell Crafty it is
445playing a computer. This will prevent some things from hap-
446pening, such as a draw score that varies, as well as adjust-
447ing the book selection code to be more selective in what it
448plays.
449
45010. display this command is used to display the game
451board. This board is displayed using the ICS style #1 type
452of ASCII display, with white always at the bottom of the
453screen, black at the top. Very unusable to play a game
454with, but good to verify a position after it has been set
455up.
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470This command is also used to display the various
471piece/square tables, by typing "display <piece>" where
472<piece> is replaced by pawn, knight, bishop, rook, queen or
473king. The board is oriented in the same way as the display
474board with a one-to-one correspondence between the squares.
475Perhaps useful for curiosity, but not for anything else.
476These values can not be modified by the user.
477
478The final version of this command is used to control what
479kind of output you will see when crafty runs. Currently the
480following options are available.
481
482 display time: this will make Crafty display the
483 amount of time each side takes after making a move.
484
485 display changes: this will make Crafty display the
486 PV each time it changes during the search, including
487 when a move fails high or becomes a new best move.
488
489 display variation: this will make Crafty display the
490 PV at the end of each iteration, but it will only show
491 the best PV for the entire iteration, not all of the
492 changes.
493
494 display stats: this enables basic search statistics
495 output including time, nodes and so forth.
496
497 display extstats: this enables extended search stats
498 including the hashing statistics, search extension
499 statistics and so forth.
500
501 display movenum: causes all PV output to have move num-
502 bers embedded in them to make the PV possibly easier to
503 read. This causes the PV to look like this: 12. ...
504 Nxe4 13. Bxe4 h6 rather than simply Nxe4 Bxe4 h6. This
505 is very helpful when playing on a server and whispering
506 or kibitzing analysis. It will also be useful when
507 crafty is run from within a database program as the
508 move numbers will sync up with the actual game.
509
510 display moves: will display each root move as it is
511 searched, along with updating the search time at the
512 bottom of the screen, so you can see what move is cur-
513 rently being analyzed.
514
515 display general: will display general information mes-
516 sages whenever Crafty wants to tell you something (ie
517 "clearing hash tables" or other such things like "Mate
518 in n moves."
519
520If you put a "no" in front of any of these options, that
521will disable that particular type of output.
522
523
524
525
526
527
528
529
530
531
532
533
534
535
53611. draw offers Crafty a draw. It generally will look at
537the value returned by the last search, and compare it with
538the value returned by an internal function DrawScore(). If
539the search value is not above this result, then Crafty will
540accept the draw. If the search value is above the theoreti-
541cal value for a draw, Crafty will decline the draw. Note
542that crafty will offer draws based on internal analysis.
543When it offers a draw, you can respond with "draw" although
544the game does not really end until you exit Crafty.
545
54612. drawscore N sets the draw score (or contempt factor) to
547N. If you want crafty to avoid draws, set this number to
548something that is negative. IE -50 says that a repetition
549(draw) is the same as being 1/2 pawn down. Setting it to
550+100 will make it try very hard to draw because that looks
551like it is winning a pawn when it does so. Note that this
552is dangerous (either way) as a -50 in a king and pawn ending
553is very likely dead lost... and a repetition is better.
554
55513. echo <text> This command is normally used inside a
556command file that you are going to use to "feed" crafty some
557positions for analysis or whatever. Since crafty depends on
558the operating system to echo commands as they are typed,
559commands read in from a file are "invisible." This gives
560you the ability to insert commands into such a file so that
561crafty displays a message on the screen to give you an idea
562of where it is in processing the file.
563
56414. edit This command has been "cloned" from GnuChess to
565provide an interface with Xboard. After entering the "edit"
566command, you are in "edit.white" mode, where any
567piece/square combination you enter will add the indicated
568white piece on the given square. Piece/squares are entered
569as "qa3", or "bc4" for example. This puts a white queen on
570a3 and a white bishop on c4. Once all white pieces are
571entered, typing a "c" changes to "edit.black" mode where
572piece/square combinations now place black pieces. Typing a
573"." character exits edit mode. To clear the board ini-
574tially, you use the "#" character.
575
576Here's a sample to set up the original starting position,
577after white has played 1. e4, but no other moves have been
578played.
579
580 edit
581 #
582 ra1 nb1 bc1 qd1 ke1 bf1 ng1 rh1
583 pa2 pb2 pc2 pd2 pe4 pf2 pg2 ph2
584 c
585 ra8 nb8 bc8 qd8 ke8 bf8 ng8 rh8
586 pa7 pb7 pc7 pd7 pe7 pf7 pg7 ph7
587 .
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602Note that input is free form, so piece/squares can be
603entered one per line or all on one line. Ditto for the #,
604c, and . special characters. Note also that there is no way
605to enter castling status here. It is far better to use the
606"setboard" command which uses a FEN-like syntax and allows
607you to set both castling and enpassant status.
608
60915. egtb This command enables the endgame databases.
610Crafty will use the "tbpath" directory (if provided) to
611locate and register all of the databases you have down-
612loaded. It will report the largest class it found, as in "5
613piece tablebase files found" if you downloaded at least one
6145-piece file. If you use this command to enable databases,
615you should also consider using the "cache" command to spec-
616ify the egtb cache size.
617
61816. end|quit These commands are used to terminate crafty.
619Note that you can resume a game later without having to
620replay the moves, by starting Crafty using the "crafty c"
621command. It will immediately read in the moves for the last
622game, although you will have to set the time controls and
623clock time remaining yourself.
624
62517. evaluation option <value> This command is used to mod-
626ify the evaluation scores.
627
628The option "asymmetry" is used to make crafty evaluate king
629safety differently for each side. "evaluation asymmetry 25"
630will increase the king safety scores for the opponent only,
631meaning it will pay less attention to its own king safety
632than to that of its opponent. This will make it play more
633aggressively. "evaluation asymmetry -25" will reduce the
634king safety scores for for the opponent by 25%, making it
635care more about its own king safety than that of its oppo-
636nent. This will make it play more defensively.
637
638The "bscale" option will adjust the scores for blocked
639pawns. The default value is 100. Increasing this will tend
640to make Crafty dislike blocked pawn positions more, which
641will lead to more open positions. Note that this only
642affects moves _after_ the opening book has been followed,
643which means that the position might be blocked before the
644evaluation term has a chance to affect the game.
645
646The "kscale" option will adjust all king safety scores based
647on the 'value' entered. For example, "evaluation kscale 50"
648will reduce all king safety scores to 50% of their normal
649value. "evaluation kscale 133" will increase all king
650safety scores to 133% of their normal values.
651
652The option "tropism" is used to scale king tropism scores.
653This will attract pieces toward kings. A value of 100 means
654no change. other values are treated as a percentage (like
655
656
657
658
659
660
661
662
663
664
665
666
667
668scale) to increase (> 100) or decrease (<100) the king
669tropism scores.
670
671When you use this command, you will see something like this:
672
673modified king-safety values:
674white: 0 4 16 26 39 45 58 77 87 90 93 96 100 103 106 109
675 112 116 119 122 125 128 128 128 128 128 128 128 128 128 128 128
676
677black: 0 5 20 32 48 56 72 96 108 112 116 120 124 128 132 136
678 140 144 148 152 156 160 160 160 160 160 160 160 160 160 160 160
679
680Those values represent the king-safety evaluation as the
681king gets more and more exposed. This is always based on
682the fast that "crafty" will be the side on move when the
683search starts. In the above, it was white's move when this
684was typed, meaning that it appears that crafty will be play-
685ing black. Notice that white's king safety numbers are
686scaled by 20% to make it slightly more cautious about its
687own king. If you type "go" in this position, the scores get
688reversed as Crafty's scores are always left alone (with the
689asymmetry option) and the opponent's scores are scaled down
690as indicated.
691
692You will see similar numbers (but not black and white sets)
693that represent the actual scores produced for king tropism.
694Note that pieces interact to choose which element of this
695vector is used, but in general, the more pieces are close to
696the king, the larger the element from this array.
697
698The "pscale" option is used to scale normal pawn structure
699scoring in the same way as the other scaling options. 100
700is the default. Values less than 100 reduce this term, val-
701ues over 100 inflate it.
702
703The "ppscale" option is used to scale some passed pawn scor-
704ing in the same way as the other scaling options. 100 is
705the default. Values less than 100 reduce this term, values
706over 100 inflate it. This mainly effects outside passed
707pawns/protected passed pawns. The normal pawn scoring com-
708putes the value of a passed pawn. This term is then used to
709scale those terms that modify this value further, such as
710two connected passed pawns on the 6th, or a passed pawn with
711the king supporting it in an endgame.
712
71318. extensions type value
714
715This command is used to control the extension depth for the
716various extensions done in Crafty's search. The extensions
717are set as decimel numbers that represent plies (or frac-
718tions of plies) to extend for each particular reason. Most
719default to 1.0 and .75, but any value can be used. Note
720that value > 1.0 are _very_ dangerous as they can cause the
721
722
723
724
725
726
727
728
729
730
731
732
733
734search to become non-terminating (crafty will stop when it
735runs out of time for the move, but it might not be able to
736get anything useful from such a search).
737
738These extensions are presently limited to a maximum of one
739ply of extensions at any point in the tree. IE no matter
740what you set these values to, they can not exceed one ply at
741present.
742
743incheck This is the amount to extend when the side on move
744makes a move that leaves the opponent in check. Note that
745Crafty extends on the ply where the check is played, not on
746the next ply where the opposite side is in check.
747
748onerep This is the one-reply-to-check extensions, and is
749done at the point where one side is in check and has exactly
750one legal move to escape from the check.
751
752pushpp This is the extension used for certain passed pawn
753pushes in the endgame.
754
755recapture This is the recapture extension, and is applied
756when the current move recaptures an equal-valued piece that
757made a capture at the previous ply. IE BxN, PxB. Note that
758this can only be applied once for every two plies so that
759BxN, BxB, NxB, NxN won't look like three recaptures.
760
761mate This is the mate threat extensions and is applied when
762a null move search returns -MATED, which means that doing
763nothing gets the side on move mated. The opponent must have
764some sort of serious mate threat in such a position.
765
76619. flag on|off This command is used to force crafty to
767end a game where the opponent runs out of time with win-
768board/xboard (on) or to ignore this (off) if desired.
769
77020. force [move] This command is used to force Crafty to
771play a move that is different from the one chosen and played
772by the tree search. If [move] is given, and it is a legal
773move, Crafty will retract its last move and make this move
774instead. It does not change the side on move, but does
775change the position of course. If [move] is not given,
776Crafty will prompt you for a move to make.
777
77821. help This command displays multiple pages of one-line
779help, one command per line. If a line ends with [help],
780then you can use help followed by the specific command to
781get detailed help.
782
78322. history This command displays the history in a verti-
784cal column with one move for white and one per black per
785line. There are other ways to display the current game
786moves and also to save them in files that are explained
787
788
789
790
791
792
793
794
795
796
797
798
799
800later.
801
80223. hash=x and hashp=x These commands are used to adjust
803the size of the hash tables in Crafty. hash modifies the
804size of the transposition/refutation table, while hashp mod-
805ifies the size of the pawn structure/king safety hash table.
806The sizes may be entered as one of the following two types
807of values: nnnK where nnn is an integer indicating how many
808Kbytes Crafty should use for this hash table; nnnM where nnn
809is an integer indicating how many Mbytes Crafty should use.
810
811The transposition/Refutation table is the most critical of
812the two, because it directly affects search efficiency, par-
813ticularly in the endgame. For this reason this should be
814maximized. The most effective size for this hash table is
8153/4 of your available memory. If you don't know how to fig-
816ure this out, but know that you have 16 megs for example,
817they you can say hash=16M and crafty will round that down to
81812M, which is 3/4 of a power of two size. If you study the
819sizes that are possible, you will find 3M, 6M, 12M, 24M,
82048M, and so forth. Anything up to, but not including, the
821next size will be rounded down to the next lower size.
822hashp should be set to approximately 1/2 of what is left.
823For example, the P6 Crafty runs on when playing on ICC often
824uses hash=48M and hashp=8M. The only thing to watch for is
825that if you make this too large, particularly under windows,
826performance will suffer badly because of paging I/O over-
827head. When Crafty is searching in a normal (non-book, non-
828endgame database) position, the disk light should *not* be
829on, indicating lots of I/O.
830
831There is no danger in making this table too large, although
832you have to watch out because if Crafty barely fits in mem-
833ory, doing something else on the machine can cause Crafty to
834be swapped out completely or partially, depending on the
835operating system you are using. If you are going to use the
836machine for anything else while Crafty is running, it is
837better to "pretend" that the machine only has 1/2 of the
838memory it actually does when computing the size of the hash
839tables you want to use.
840
84124. import <filename> [clear] This command is used to
842import any sort of learning data that Crafty supports, which
843currently includes book learning data and position learning
844data. This command reads the appropriate <filename> and
845imports that learned data, just as though Crafty had learned
846it by playing the games. The [clear] option, if specified,
847caused all old learned results to be cleared before the
848import operation, otherwise the imported data is simply
849added to what is already present.
850
85125. input <filename> This command is used to redirect the
852console input I/O stream from the keyboard to a file.
853
854
855
856
857
858
859
860
861
862
863
864
865
866Crafty will then read commands from this file, rather than
867from the keyboard, and execute them just as though they were
868typed in. Such a command file *must* be terminated by an
869"exit" command (no quotes) as the last command in the file.
870This reverts the input stream back to the keyboard, and
871prompts you for another command or move.
872
873This command might be used to configure crafty for a spe-
874cific time control, by putting the appropriate time control
875commands in the file, or to customize the hash table sizes
876as needed.
877
87826. info This command is used to display information about
879Crafty and the current game. Such things as the time con-
880trol, the time left on the clocks and other information is
881shown.
882
88327. learn n controls the learning facilities in crafty.
884Currently this is a 3-bit boolean switch, bit 1 (001) con-
885trols book learning, bit 2 (010) controls position learning,
886and bit 3 (100) controls result learning. learn=0 disables
887all learning, learn=1 enables book learning only, learn=2
888enables position learning only, and learn=4 enables result
889learning. Add the values together to turn on more than one
890type of learning (default=7 to enable everything).
891
89228. level <m> <t> <inc> This command was taken directly
893from GnuChess so that the Xboard/WinBoard interface would
894interface with Crafty. There are other better ways to set
895the time, but this one is well-known. The three parameters
896are <m> (number of moves in the game) <t> initial time on
897the clock. After <m> moves are made, this amount of time is
898added to the clock again. <inc> is the Fischer-Clock incre-
899ment that is added back to each clock after a move is made.
900It may be zero for a non-increment game.
901
902Examples:
903
904level 0 5 0 (ICS 5 0 game)
905level 0 5 3 (ICS 5 3 game)
906level 0 15 30 (ICS 15 30 game)
907
90829. list GM|IM|C|AK|S +name [+name ...] -name [-name ...]
909This command is used to maintain the internal "lists" Crafty
910uses to auto-tune itself when playing on a chess server.
911There are three lists, GM, IM and C. If Crafty's opponent
912is in any of these lists, Crafty adjusts internal controls
913that affect how/when it resigns or offers draws, and how
914randomly it will choose moves from the opening book. For
915example, Crafty resigns much sooner against a GM, because it
916assumes he knows how to win a rook-up ending, regardless of
917how much time is left. By the same token, when playing
918against computers, Crafty will always assume that a draw is
919
920
921
922
923
924
925
926
927
928
929
930
931
9320.000, so that it doesn't wreck its position trying to avoid
933repeating a position.
934
935The AK list will automatically kibitz scores/PV's if the
936opponent is in this list. The S list will turn on special
937scoring for opponents in this list. The only current member
938is "mercilous".
939
940The syntax +name1 +name2 simply adds these players to the
941specified list. To remove a name, use -name1 -name2. You
942can use one command per name to remove or add, or you can
943use one command to add and remove multiple names. Note that
944all names must be entered in lowercase characters, using any
945uppercase characters will break the matching algorithm.
946
94730. log off|on|<n> This command is used to disable log-
948ging. The default is log on, which causes crafty to produce
949a new log.nnn file for each game played. If you are running
950Crafty on a server, you might use log off, which disables
951creating these files as well as the game.nnn files used to
952restart a game after you exit crafty and come back later.
953If you use the form "log n" crafty will simply display the
954last n lines of the log on the screen. If you use "log n
955file" crafty will copy the last n lines of the log to "file"
956which could be your hard drive, or a floppy.
957
958Note that if you run with log off, you will be unable to
959find out what Crafty was thinking about since there is no
960other record of the game. You will always see a game.001
961because as crafty plays a game, this contains all the real
962moves played so far so that you can back up if needed. you
963will also see a log.001 file, but it will be empty.
964
96531. ls <filename> will list all the files that match the
966filename wildcard (the wildcards depend on the system you
967are using, but generally *, ? will work fine. you can also
968supply path information in the filename if you want to list
969the contents of a different directory. Just use the same
970syntax you would if you were using "ls" under unix or "dir"
971under windows.
972
97332. mode tournament|normal This command is primarily used
974to put Crafty into "tournament" mode, which is intended for
975use when Crafty is playing in computer chess events. It
976accomplishes two things: (1) makes all draws return a score
977of 0.000, and (2) makes crafty issue a message after each
978move showing the internal chess clock time, and requesting
979that that operator check and adjust as needed using the
980"clock" command. This primarily makes Crafty comply with
981computer chess rules that say the operator can't do anything
982not specifically requested by the program.
983
98433. name <name> This command is an ICS-play specific
985
986
987
988
989
990
991
992
993
994
995
996
997
998command. Xboard/WinBoard uses this to inform Crafty of the
999opponent's name. Crafty uses the name, and looks it up in
1000its GM/IM/C lists, and if found, adjusts itself accordingly.
1001This is not used by the PGN code and this will not cause the
1002players <name> to show up in the PGN tag section.
1003
100434. new This command wipes everything out and starts a
1005brand new game. It closes the old log-file and game-file,
1006and opens the next sequential numbered file. It also resets
1007the game to the beginning and prepares to start a brand new
1008game. This was added for Xboard, but it turns out that
1009Xboard does not use this, rather it starts Crafty fresh for
1010each new game by first terminating the old copy then start-
1011ing a new one. Not nearly as efficient as using "new" but
1012likely safer it a program can't be sure of resetting every-
1013thing back to the initial state.
1014
101535. noise <n> This command sets the "noise" level in
1016Crafty. Basically, until <n> nodes have been searched,
1017crafty will be silent and not display analysis.
1018
1019This is useful in two ways. First, in end-games, 20+ ply
1020searches are not uncommon, and the search analysis for the
1021first few plies arrives so quickly that it is distracting.
1022Second, when observing games (new interface only) on ICS
1023servers, this can be used to avoid having Crafty generate
1024too many analysis kibitzes. A value of 100000 will basi-
1025cally shut off any output for the first second or so (on a
1026P6/200). Similarly, 1000000 will eliminate any output for
1027about the first 10 seconds. When watching and kibitzing
1028games like the World Championship games on ICC, I generally
1029use 5000000, which is almost one minute of silence so that
1030the first PV it kibitzes is a pretty deep search.
1031
1032noise 0 will cause *all* analysis to be displayed, which on
1033a fast machine causes no problems. On a slower machine, or
1034over a slow phone connection, this might cause a big commu-
1035nication backlog. The default is roughly one second on a
1036P6/200 (100000) but can be modified by this command.
1037
103836. operator <n> Another command intended for use when
1039Crafty is playing in a tournament, operated by a human.
1040This tells crafty to "hide" <n> minutes of time and not use
1041them. This time is basically allocated to the operator to
1042make up for the time it takes to type in moves and/or cor-
1043rect mistakes. At the WMCCC events, the normal value we use
1044is 5. Playing on a server, this is not needed, as it is not
1045needed if you are playing Crafty yourself.
1046
104737. perf This command is primarily used in optimizing
1048Crafty, or to test the speed of the move generator and Make-
1049Move()/UnMakeMove() on different platforms. It produces two
1050results, the moves it can generate per second, and the moves
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064is can generate and make/unmake per second. While this is
1065not a perfect performance indicator, it does give an
1066"approximation" for how fast Crafty might run. In general,
1067the higher the numbers, the better the program will play,
1068although machines are certainly different. It's not uncom-
1069mon to find a machine that searches slower than another, but
1070has a higher "perf" value.
1071
107238. perft <depth> This command is generally used to con-
1073firm that the move generator and bitmap operators are work-
1074ing properly. It simply takes the current position, and
1075generates/makes/unmakes moves and counts them. Many pro-
1076grams use this from a "standard" position to make sure that
1077their move generator does not miss generating odd moves like
1078enpassant/promotions and also to confirm that the
1079make/unmake code correctly updates the board so that the
1080totals remain constant across different machines and pro-
1081grams, since there is no alpha/beta or evaluation things
1082done. if <depth> is greater than 5 or 6, it will take a
1083*long* time, since this is basically a minimax tree traver-
1084sal that will visit *every* node within the <depth> search
1085horizon.
1086
108739. pgn <tag> <value> This command is used to set the
1088usual PGN tags to meaningful values. The recognized tags
1089are Event, Site, Round, Date, White, WhiteElo, Black, Black-
1090Elo, and Result, and the tags *are* case sensitive. The
1091<value> can be any valid input and blanks and special char-
1092acters are allowed. Note that the date is clearly specified
1093in the PGN standard and must be yyyy.mm.dd with no variance.
1094Valid results are 1-0 (white won), 0-1 (black won), 1/2-1/2
1095(drawn) and * (unknown). Some examples:
1096
1097pgn Event 14th World MicroComputer Chess Championship
1098pgn Date 1996.10.8
1099pgn Site Jakarta, Indonesia
1100pgn Round 1
1101pgn White Crafty
1102pgn WhiteElo 2400
1103pgn Black assassin
1104pgn BlackElo 2400
1105pgn Result 1-0
1106
1107Setting these values will result in a proper PGN file when
1108using the savegame command. Note that if you use the "read"
1109command to input a PGN game, these values will be extracted
1110from that game if they are given.
1111
111240. ponder off|on|<move> This command serves two purposes.
1113First, it can be used to disable (off) or enable (on) think-
1114ing on the opponent's time (or pondering as it is called in
1115many programs including Crafty.) Turning it off will weaken
1116Crafty since it will not use any machine time while waiting
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130on the opponent to move. It is sometimes useful, however,
1131when playing Crafty against another computer and the
1132machines are not equal. If crafty is on a faster machine,
1133and you attempt to adjust for this by giving the opponent
1134more time than Crafty, it doesn't work quite as expected,
1135because while the opponent is thinking, so is Crafty, which
1136lets it use the extra opponent time in an unexpected way.
1137In such a case, it's best to stop pondering in both pro-
1138grams.
1139
1140If <move> is given, it directs Crafty to use that <move> to
1141ponder, rather than the one from the previous search. Most
1142commonly this is used to set the right move to ponder after
1143Crafty has been stopped and then restarted, assuming that it
1144is the opponent's turn to move when this happens. Other-
1145wise, it is probably better to not try to influence things,
1146although if you are watching and suddenly wonder "what would
1147Crafty do if the opponent plays move 'X'?", you can answer
1148this by simply typing "ponder X" and then watching the anal-
1149ysis. You should reset the correct ponder move after you do
1150this of course.
1151
115241. reset <n> This command lets you back up in the current
1153game to any move of your choice. reset <n> backs up the
1154game to move <n> with the same side on move. If you want to
1155first change the side to move, use the white/black command,
1156then use the reset command to back up to the right move.
1157Note that you can also go forward as well, just so there are
1158moves in the current game history.
1159
116042. resign <n> This command sets the resign threshold.
1161When running on ICC I typically use "resign 9" which will
1162make crafty resign roughly five moves after the score drops
1163below -9.000. For IM's I change this to 6, and for GM's I
1164often use 3, so that it will resign quicker and not drag a
1165lost game out unnecessarily.
1166
116743. read/reada [<filename>] This command will read input,
1168and extract the chess moves and make them to set up the
1169position at the end of the game. It first resets the chess
1170board to the initial position (read command only) and then
1171extracts the PGN tags (if present) from the front of the
1172input. The rest of the input is parsed for chess moves
1173(comments and similar things are culled automatically) and
1174the moves are made and added to the game history. Once this
1175is done, you can back up, go forward, or play from any point
1176in the game. If you specify a <filename> everything is read
1177from the file, otherwise it is read from the console key-
1178board.
1179
1180The reada command reads moves, but appends them to the cur-
1181rent game history/ position rather than resetting to the
1182initial chess position. This lets you read in a game, then
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196use reada to manually add some more moves to see the result-
1197ing position.
1198
119944. savegame <filename> This command is used to save the
1200current game in a PGN-compliant file with the PGN tags
1201included. Note that the default TAG values might not be
1202what you want if you do not either use the pgn command to
1203set them or else input a valid PGN file with the tags
1204already filled in.
1205
1206Be aware that this command doesn't check the filename for
1207legality since anything goes in UNIX. In DOS, you might
1208produce a bad filename with either too many characters, too
1209many periods, or whatever, so be careful with the name you
1210choose. Note also that this file will be overwritten if it
1211already exists, so be sure to choose a name that is not the
1212name of a file that has something you consider important in
1213it.
1214
121545. savepos <filename> This command writes a single line
1216into <filename> in FEN-like notation. This lets you save a
1217position, and then come back later to re-examine it. You
1218would use the "in <filename>" command to input this file and
1219set the position up.
1220
122146. search <move> This command allows you to specify one
1222particular move for the side on move, and then when you tell
1223Crafty to search this position, this is the only move that
1224will be searched. This is used internally by the annotate
1225command, but can be used to investigate one specific move.
1226If the move is not the best move, a normal search won't show
1227you why it is bad, but this will. It is also quite a bit
1228faster since the other moves in the position are not
1229searched at all.
1230
123147. settc <moves> <ctime> <otime> This command is primar-
1232ily used in tournaments, and is an error-recovery command.
1233If the machine crashes and corrupts the game history file,
1234frequently the operator will have to simply set the position
1235using the setboard command, and then use the settc command
1236to restore the time control values. <moves> is moves until
1237the next time control (from Crafty's perspective, be careful
1238and don't look at the opponent's moves to time control by
1239accident.) <ctime> is minutes left on Crafty's clock,
1240<otime> is minutes left on the opponent's clock.
1241
124248. setboard <FEN input> This command is used to set a
1243chess position up for analysis and is the preferred way to
1244do this, rather than using the gnu EDIT interface. It uses
1245a classic Forsythe-like notation to encode the position and
1246also has provisions for castling status and enpassant cap-
1247ture status.
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262the standard piece codes p,n,b,r,q,k are used to denote the
1263type of piece on a square, upper/lower case are used to
1264indicate the color of the piece (uppercase=white pieces,
1265lowercase=black pieces).
1266
1267the pieces are entered from the classic chess diagram's ori-
1268entation of a8 being the upper-left-hand corner of the
1269board, and this square is entered first, followed by the
1270remainder of the 8th rank left to right. To indicate empty
1271squares, use a number between 1 and 8 to indicate how many
1272adjacent squares are empty. use a / to terminate each rank
1273after all of the pieces for that rank have been entered.
1274Note that you do not have to account for all 8 squares on a
1275given rank, although many test suites do this for clarity.
1276
1277the following input will setup the board position that given
1278below:
1279
1280 k2r/ppp////Q/5PPP/7K/ B
1281
1282this assumes that k represents a white king and -q repre-
1283sents a black queen.
1284
1285 -k * * -r * * * *
1286 -p -p -p * * * * *
1287 * * * * * * * *
1288 * * * * * * * *
1289 * * * * * * * *
1290 q * * * * * * *
1291 * * * * * p p p
1292 * * * * * * * k
1293 *
1294the field after the final "/" should be either b or w to
1295indicate which side is "on move." after this side-to-move
1296field any of the following characters can appear to indicate
1297the following: KQ: white can castle king-side/queen-
1298side/both; kq: same for black; a1-h8: indicates the square
1299occupied by a pawn that can be captured enpassant.
1300
130149. score This command simply gives the positional score
1302for the current position. This score is from whites per-
1303spective, so a + score is good for white, a - score is good
1304for black. Crafty also breaks the score down into major
1305categories (from Evaluate()) to indicate things like pawn
1306structure, piece evaluation, passed pawns, development, and
1307so forth. Note that some of Crafty's evaluation is asymmet-
1308ric, so that if you simply change sides with the white/black
1309command and then enter "score" again, you may get a differ-
1310ent value. This is *not* a bug. :)
1311
131250. sd <n> This command lets you specify a specific search
1313depth limit that Crafty can not exceed. It still pays
1314attention to the clock, however, so often you will use the
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328st <n> command (below) in conjunction with this if the
1329search is going to take an extended amount of time. <n> is
1330the depth (in plies or 1/2 moves) that the search must
1331reach. Note that if Crafty is pondering, it still honors
1332this limit and will stop a ponder search after this depth
1333has been completed as well. This is *not* the way to make
1334Crafty play weaker, although this will be covered in a later
1335section of this document.
1336
133751. show <category> This command forces Crafty to display
1338additional information about certain actions it takes. Cur-
1339rently the only <category> is "book" which will make crafty
1340display information about all the book moves it found in the
1341database. More is given about this information in the BOOK
1342section later in this file.
1343
134452. smpmt=n This command is used to set the number of
1345threads to use on a machine with more than one processor.
1346For optimal performance, "n" should be set to the number of
1347processors you have, although using fewer will reduce the
1348load on your machine. For this command to work, Crafty must
1349have been compiled with SMP defined. When compiled with SMP
1350enabled, mt=0 effectively disables the SMP code completely.
1351
1352This command also has two that are closely related. smpmin
1353and smpmax. Both accept single numerical arguments. smpmin
1354is used to control the minimum tree depth required at a node
1355for it to be eligible for parallel searching. IE smpmin 2
1356says don't split unless at least two more plies are left to
1357search below this node. smpmax sets the maximum for the
1358same idea, is smpmax 10 says don't split if more than 10
1359plies are remaining below this node.
1360
136153. sn <n> This command is similar to the sd command, but
1362instead of setting a specific search depth, it sets a number
1363of nodes to search. Once the search has searched this num-
1364ber of nodes (+ maybe one more second of searching to check
1365the time) the search will exit.
1366
136754. st <n> This command lets you specify a specific search
1368time limit for Crafty. Again, this is not the preferred way
1369to set a time per move, because this limit is absolute and
1370Crafty will never go over this limit, even if it sees that
1371it is losing or getting mated. Setting the time control
1372with the usual "time" or "level" command is *much* better.
1373<time> is given in seconds, although it may also be entered
1374as mm:ss if preferred.
1375
137655. swindle on|off This command gives you control over
1377"swindle mode." When on, and playing a game, Crafty will
1378try to win drawn endings (according to the tablebases) if it
1379has winning chances (like KR vs KB, for example). This will
1380put up very stiff "resistance" to accepting the draw, while
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394with this mode off, it may be very easy to draw a position
1395once the tablebases say "drawn." This mode is automatically
1396turned "off" during analysis or when annotating a game, and
1397is only used when actually playing a game against an oppo-
1398nent. If there are no tablebases then this has no effect on
1399the game at all.
1400
140156. tags This command will simply display the current PGN
1402tags (you can edit them with the various PGN commands).
1403
140457. test <filename> [n] This command will run a suite of
1405positions (the file must be in "Crafty" format as explained
1406below) and produce a summary of how many it got right,
1407wrong, etc. It uses the time per move you set with the
1408(typically) st <n> command. The optional parameter [n] is
1409the "early exit" counter. If Crafty finds, and holds the
1410solution move for n iterations, it will terminate the
1411search. I use this to make a win at chess run take < 15
1412minutes, even though the time per position is set to 1
1413minute, by setting n to 2. After two correct iterations,
1414Crafty goes on to the next problem. For absolutely correct
1415results, this is not advisable as it could obviously change
1416its mind later on, but for performance analysis, this saves
1417a lot of time.
1418
1419The test suite contains the following lines: (this is a
1420sample from my test suite for Win At Chess.)
1421
1422title wac299
1423setboard 1n2rr2/1pk3pp/pNn2p2/2N1p3/8/6P1/PP2PPKP/2RR4 w
1424solution Nca4
1425
1426title wac300
1427setboard b2b1r1k/3R1ppp/4qP2/4p1PQ/4P3/5B2/4N1K1/8 w
1428solution g6
1429
1430end
1431
1432The title command simply displays this message in the log
1433file so you can look at the output and figure out which
1434position it goes with. This is optional, but useful.
1435
1436The setboard command sets the position as explained before.
1437
1438The solution command gives the set of solution moves (one or
1439more moves that are separated by blanks) and/or a set of
1440"anti-solution" moves (moves that must not be played to
1441count the position as correct.) "anti-solution" moves are
1442simply followed by a "?" character, for example:
1443
1444solution Bxa7?
1445
1446The solution command supplies a set of key moves, and then
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460starts the search. If, after the search terminates, one of
1461the key solution moves was chosen (or none of the anti-solu-
1462tion moves were chosen) the position is counted as correct.
1463
1464The final line should be "end" although end-of-file or EOF
1465will also be detected in this case.
1466
146757. time CPU|elapsed|<values> This command controls
1468whether the program uses CPU time or wall-clock time for
1469timing. for tournament play, it is safer to use wall-clock
1470timing, for testing it may be more consistent to use CPU
1471timing if the machine is used for other things concurrently
1472with the tests being run.
1473
1474time is also used to set the basic search timing controls.
1475the general form of the command is as follows:
1476
1477 time nmoves/ntime/[nmoves/ntime]/[increment]
1478
1479nmoves/ntime represents a traditional first time control
1480when nmoves is an integer representing the number of moves
1481and ntime is the total time allowed for these moves. the
1482[optional] nmoves/ntime is a traditional secondary time con-
1483trol. increment is a feature related to ICS play and emu-
1484lates the Fischer clock where <increment> is added to the
1485time left after each move is made.
1486
1487as an alternative, nmoves can be "sd" which represents a
1488sudden death time control of the remainder of the game
1489played in ntime. the optional secondary time control can be
1490a sudden-death time control, as in the following example:
1491
1492 time 60/30/sd/30
1493
1494this sets 60 moves in 30 minutes, then game in 30 additional
1495minutes. an increment can be added if desired.
1496
1497One final example is the following:
1498
1499 time sd/15
1500
1501which is a simple game/15 setting. This command can also be
1502used to perform the same function as the "level" command.
1503For example, to set up a classic ICS 2 12 game, the follow-
1504ing would would work:
1505
1506 time sd/2/12
1507
150859. trace <n> This command is used to make crafty display
1509the tree as it searches a position. Due to the incredible
1510speed at which this program can search, however, this is
1511less than useful since it can swamp any known display driver
1512and make things scroll impossibly fast.
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526Also note that this command usually is disabled, because
1527Crafty is generally compiled with the -DFAST flag, which
1528removes the trace output code from the search to make things
1529slightly faster. You will have to recompile, without the
1530-DFAST, if you want to use this. It's utility is limited,
1531except for debugging, anyway.
1532
153360. usage <n> is simply a way to modify Crafty's time usage
1534to fit your tastes. You can "suggest" a time limit with any
1535of the options discussed previously, but if you use anything
1536other than the "st" command, Crafty will do its best to use
1537time as you suggest, but it also anticipates that it will
1538save some time by pondering, etc., and will therefore be
1539more aggressive at trying to use time. if <n> is a positive
1540integer, it is taken as a percentage and crafty will compute
1541the time limit it thinks is appropriate for the current
1542clock settings, then increase this limit by this percentage
1543(50 would make it take 1.5 times longer than normal.) -50
1544would make it take 1/2 the time it would normally take.
1545
1546Crafty adjusts the usage internally based on time left,
1547opponent's time left, how quickly or slowly the opponent is
1548moving, etc. Further modifying things with this is danger-
1549ous, but possible.
1550
155161. whisper/kibitz <n> These commands are used to control
1552what Crafty will whisper or kibitz on a chess server. The
1553options are (1) only whispers or kibitzes mate announce-
1554ments; (2) adds time, score, depth to the previous option,
1555but no PV or moves. (3) adds the PV. (4) adds book move
1556information to the output. The remaining two options gener-
1557ate a lot of output and should be used with caution. (5)
1558displays the PV after each iteration completes. I use this
1559when using my custom interface to let Crafty observe/comment
1560on games in progress on ICC. Noise can be used to prevent
1561shallow searches from generating output and keeping "noise"
1562down on the games being watched. (6) basically will whis-
1563per/kibitz nearly everything you see on the console from a
1564search, each PV when it changes, fail highs and fail lows,
1565etc. A significant amount of output that should be care-
1566fully weighed before turning it "loose."
1567
156862. xboard This command turns on Xboard/WinBoard compati-
1569bility mode, and makes Crafty behave somewhat like GnuChess.
1570This is designed to be used *only* when Crafty is interfac-
1571ing with Xboard/WinBoard. Crafty will not work with these
1572two GUIs without this option, and really won't work very
1573well with this option if it is not connected to one of them.
1574
157563. There are other commands that are not documented. They
1576are part of the xboard protocol and really should not be
1577used by the normal user. You can find all the commands in
1578option.c should you be interested.
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592 Opening Book Setup and Usage
1593 ----------------------------
1594
1595Crafty uses two pre-compiled opening books, called
1596"book.bin" and "books.bin".
1597
1598The file book.bin is usually build from a large text file
1599containing PGN games, often taken from collections of GM
1600games. Building book.bin is a simple exercise and requires
1601nothing other than the raw input file you are going to use.
1602Generally this will be either medium.zip or the set of four
1603files large[1-4].zip, all of which are stored on the ftp
1604machine ftp.cis.uab.edu/pub/hyatt/.
1605
1606To create the file book.bin, you need a PGN game collection
1607that is a *real* PGN-compliant file. Supposing this file is
1608called "large.pgn" you would use the following command:
1609
1610book create large.pgn <m> [n] [wpct]
1611
1612The only thing you have to supply is <m>, a number indicat-
1613ing how many moves from each game are to be stored in the
1614book.bin database. I typically use 60, which stores the
1615first 60 moves from each game. Increasing this number
1616slightly increases the probability that Crafty will stay in
1617book longer, but it also increases the probability that it
1618will follow a game too far, so that it begins to reach posi-
1619tions where the move actually played might not be the best
1620move, letting it fall into a bad hole. Increasing this also
1621increases the size of the database as well.
1622
1623You can decrease the size of the book, and also reduce the
1624number of ugly moves by specifying <n>, which says that
1625unless a move is played in at least N games, the move is
1626discarded. This will substantially decrease the size of the
1627book.bin file, and also eliminate single game moves that
1628often have significant errors or blunders.
1629
1630You can increase the quality of book lines by specifying
1631<wpct> which is the "winning percentage". This is specified
1632as a percentage of lost games, and is used to discard moves
1633that led to mostly losses. A safe value is 50, which says
1634that if a particular opening move didn't win at least 50% as
1635many games as it lost, the move is culled. A value of 100
1636would mean that moves are culled if they produced more
1637losses than wins, and is really a strict criterion.
1638
1639After creating book.bin, you need to create books.bin. This
1640is a small version of book.bin, which is intended to give
1641you more control over the moves/openings Crafty will play.
1642This is usually built from the file start.pgn on the ftp
1643machine, but you can modify this file to suit your taste
1644easily. To build books.bin, you use the following command:
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658books create start.pgn 60
1659
1660Again, 60 is what I use, but none of my start.pgn lines go
1661anywhere near that many moves. The main point here is that
1662in start.pgn, you can append a "!" to any move you want, and
1663when it is Crafty's turn to move for that color, it will
1664play from the set of moves with "!" if there are any, ignor-
1665ing the rest of the book moves. If you only want it to play
16661. e4 as white, you would just enter the short game:
1667
1668[Crafty only plays 1. e4] 1. e4!
1669
1670and you are finished!. You can enter as many as you want.
1671If on the other hand there is a move you don't want Crafty
1672to play, then follow that move with a "?" and it will never
1673play it. Moves in books.bin that are not flagged with ! or
1674? don't have any influence on Crafty's choice at all.
1675
1676Here's how the files are used. When searching a position,
1677Crafty first enumerates the set of moves it can find in the
1678opening database. It then does the same for the books.bin
1679database, and performs a "merge" operation to combine the ?
1680and ! flags... The purpose of the books.bin file is to give
1681you a small database that you can easily modify, rebuild,
1682and repeat this process over and over. Since it takes a
1683fraction of a second to completely rebuild this file, it is
1684very easy to modify this to control what Crafty will play,
1685without having to rebuild the large database.
1686
1687One important characteristic of the PGN input is the Result
1688tag must be specified in most of the lines, because Crafty
1689counts wins, losses and draws for each book move and uses
1690these counts with some of the book selection options given
1691below.
1692
1693How the flags are used.
1694
1695The ! and ? flags should only appear in the small books.bin
1696file, although there is no reason why they can not appear in
1697the large file as well. For this discussion, it doesn't
1698matter since Crafty takes the moves from both files and
1699"merges" the flags/etc into one entry for each move.
1700
1701Quite simply, if any book legal book move has a ! flag, then
1702Crafty will only play moves from the set of moves which all
1703have the ! flag. If a move has a ? flag, then that move is
1704immediately removed from the set of possible book moves. If
1705the only legal book move has a ? flag, it will not be played
1706as a book move and Crafty will simply pretend that it found
1707no book moves and will execute a normal tree search. Pretty
1708simple.
1709
1710How to control the frequency of opening move selection.
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724A new feature in version 15.15 and beyond allows you to
1725append a PGN comment to any move in a text file used to cre-
1726ate books.bin, of the form {play nn%}. This will force the
1727move it follows to be played that percentage of the time,
1728regardless of the normal book-ordering values based on fre-
1729quency and so forth.
1730
1731Note that {play 0%} will not prevent a move from being
1732played at all, as this will look just like a move with no
1733percent specified. To avoid playing a move, use the ? flag.
1734
1735How does Crafty choose book moves?
1736
1737Crafty's book selection algorithm depends on two user-
1738defined values that can be set at any time during a game:
1739
1740book random <n>
1741
1742book width <w>
1743
1744The selection algorithm first finds the set of legal book
1745moves as above. This set will either be all ! moves, or
1746will have no ! moves in it. This set is then sorted based
1747on the setting of book random. Here's the options:
1748
1749book random 0. This is a special case for book selection.
1750Crafty simply takes the set of book moves, and searches only
1751these moves using a normal alpha/beta search, but with a
1752shorter than usual time limit. It then plays the move that
1753produces the best search value. This has one serious disad-
1754vantage in that there is no randomness to this at all. It
1755will always play the same move in the same position, unless
1756the evaluation is modified, or the time per move is differ-
1757ent enough to let the search find a different move from the
1758book move set.
1759
1760book random 1. This enables a random form of book move
1761selection, but you have a lot of control over how moves are
1762randomly chosen. The moves are ordered, based on 4 parame-
1763ters: frequency of play, win/lose ratio, static evaluation
1764and learned results. Normally these are factored into the
1765value used to sort the moves, based on default settings that
1766you can modify by using the command "bookw option N"
1767"option" should be "freq", "ratio", "eval" and "learn". N
1768should be a number between 0 and 1.
1769
1770Crafty finds the min and max values for each of the 4 param-
1771eters, and then maps this into the range 0-1000 for each
1772parameter. Each parameter is multiplied by the correspond-
1773ing "weight" you have assigned, and this is used as a value
1774to sort the moves from low to high. Note that the first
1775sort value is always the "play percent" to move them to the
1776top of the list. For moves with equal "play percent"
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790values, the normal sort-value is used as the second-level
1791sort variable (if no moves have a play-percent, then this
1792second-level variable is the only one used, of course.)
1793
1794Once Crafty has sorted the moves as given above, it next
1795excludes any book moves which have 0 wins. This culls the
1796odd lines where a player chose a bad line and lost quickly.
1797With zero wins, it will never be chosen, although Crafty
1798will happily follow it from the other side. :) This is not
1799anywhere near perfect, however, because an opening could
1800have 1 win and 19 losses and that still would stay in the
1801list.
1802
1803If a move has a learned value of > 100, this move is ele-
1804vated in priority to that of a ! move, since it appears to
1805win material instantly. If a value is < -100, it is given a
1806? since it appears to be a lemon.
1807
1808After this, the setting for "book width <w>" is used to keep
1809the first <w> moves in the list, after the above culling has
1810been completed. The smaller you make <w> the less random-
1811ness you get, but the chance of Crafty popping out a really
1812bizarre book move gets smaller as well.
1813
1814After sorting, the final step is to fold in any mandatory
1815"play percent" values. What this step does is that it finds
1816all the moves in the "playable move set" just computed,
1817which have no percent-to-play value set. It sums the sort-
1818values for these moves, then adjusts the sort-values for the
1819other moves so that their percentages will be honored.
1820
1821Once this has been done, crafty simply uses the "sort value"
1822for each move to compute a total for all moves. It then
1823generates a random number between 1 and this limit, and
1824chooses the move that this probability distribution matches.
1825This will certainly evolve over time as new ideas are devel-
1826oped.
1827
1828For my play on ICC, I use book random 1, and book width 5
1829normally, although for titled players this is reduced to
1830book width 3. For computers, I reduce this further to 2, to
1831try to play reasonable openings and cull the gambits and
1832things that don't work out.
1833
1834How does book learning work and how can I share learned
1835results?
1836
18371. *all* of crafty's "learned knowledge" is in the book.bin
1838file. It keeps the learned value and learned count right in
1839the book file for speed. You can't modify it, although
1840"show book" will make crafty display all the book stuff
1841before it makes a move.
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
18562. the book.lrn file has two purposes: (a) to serve as a
1857log for your prying eyes, so you can see what it's learned,
1858against whom, and what the score was that got its attention
1859in the first place. The values on the end of each book
1860line, inside the {} characters are as follows:
1861 {value, depth, rating_difference} value is the value of
1862the "key" search that comes from the first 10 moves out of
1863book. it's in centipawns, and + is good - is bad. depth is
1864the depth the search reached at this "key" position, the
1865deeper the search, the more the value is "trusted." rat-
1866ing_difference is crafty's rating - opponent's rating a neg-
1867ative value means pay more attention to the score since the
1868opponent is better than crafty, a positive value means to
1869take the score with a grain of salt, because the opponent
1870was weaker than Crafty.
1871
1872You can delete this file at any time, and it has no effect
1873on learning. As I mentioned, the learning takes place in
1874book.bin... this is mainly for you to peek at if you are
1875interested. However, this is the "portable learning data
1876file" also, and can be given to others to import into their
1877crafty, where it will affect the opening book just like
1878their crafty had played the openings and got the same
1879scores. There are two ways to use such "lrn" files:
1880
18811. "import <filename>" will read <filename> and import the
1882knowledge therein into your book.bin. Since I use the same
1883learning code as is used when playing games, this informa-
1884tion also gets appended to *your* book.lrn file as well, so
1885that your book.lrn always reflects *everything* your program
1886has learned, so long as you don't ever remove this file. It
1887would be a mistake to use this command on your own book.lrn
1888file, because the things would get counted twice, which
1889might or might not be a good thing.
1890
18912. "import <filename> clear" will read <filename) and
1892import the knowledge as above, but first clears *all*
1893learned results from book.bin. you will want to do this if
1894you import my book.lrn, *and*, you have contributed to my
1895book.lrn data by sending me yours. I'll take care of elimi-
1896nating duplicates if you screw up in what you send me, but
1897once you send me something, you run the risk of getting it
1898"back again" later. This is going to be a problem until
1899everyone gets used to sharing something that is rather
1900"vapid" like this "learned info" is...
1901
1902Other than that, we are now "open for business"... when the
1903urge strikes you, email me your .lrn file, I'll keep a large
1904master here and update it on occasion. Probably the best
1905thing to do is to send me your .lrn and at the same
1906*instant* delete yours. This will capture anything learned
1907*after* you send me the file, but you'll get it all right
1908back with the next version of book.lrn that I distribute.
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922after getting this new book.lrn back, here's what you should
1923do:
1924
19251. rename your old book.lrn to something else. I'll call
1926it "book.lrn.old" here.
1927
19282. copy my blearn.dat to your machine, but *do not* put it
1929in the directory with your book.bin and books.bin file
1930because it will get confusing very quickly if you do. put
1931it somewhere else, because you are going to remove it
1932quickly anyway. I'll call it new.lrn for this example.
1933
19343. import new.lrn clear
1935 import book.lrn.old
1936
1937and you are ready to rumble again. The first command clears
1938the learned values, sucks in my new learn file and updates
1939everything. the second command re-learns everything you've
1940learned since you sent me the last book.lrn file. After
1941doing this your book.lrn will have my .lrn stuff, plus your
1942old.lrn stuff, just waiting to be sent to me again...
1943
1944If this is confusing, I can probably add an automatic com-
1945mand to do all of this by renaming book.lrn, etc. Hopefully
1946this is not too error-prone for the time being anyway...
1947
1948What is this new Position Learning I've heard about?
1949
1950Crafty now has a "permanent" hash table that is kept from
1951game to game. A position gets into this "hash file" when
1952Crafty executes a search and the search value is signifi-
1953cantly lower than the last search value.
1954
1955When this happens, Crafty stores the current information for
1956this position in the permanent hash file, which can hold up
1957to 65536 positions. Once it fills up, the positions are
1958replaced on a FIFO basic always keeping the most recent 64K
1959entries.
1960
1961Each time crafty starts a search, the positions/scores from
1962this file are stuffed into the normal transposition table,
1963and used during the search just like any other table entry.
1964Here's how it helps: In a game that was played, the follow-
1965ing moves and scores were found by crafty (playing white):
1966
19671. Ng5 (+.277) h6 2. Nh7 (+.321) Kg8 3. Qh5 (+.133)
1968Qg7 4. Ng5 (-2.122) hxg5
1969
1970So, the knight got trapped at h7, and at move 4 crafty dis-
1971covered that this is gross and "learns" this result/posi-
1972tion.
1973
1974We play the exact same game again: except that two things
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988can happen here. It might be that Ng7 is the *only* square
1989the knight can move to here, which means this whole thing is
1990forced. the first search would find:
1991
19921. Ng5 (-2.122) if the search can reach 8 plies deep, which
1993happens even in 5 second games. It's learned that Ng5 is
1994bad. It stores *this* position in the permanent hash file
1995also, and the next time you try this same trap, it will dis-
1996cover 4-5 moves earlier that if the knight gets to g5 it is
1997in trouble. Each game will diverge from the first game 3-4
1998moves earlier. Simple and effective.
1999
20002. Ng5 might not be forced, and if not, it knows Ng5 loses
2001a piece for a pawn, so it will promptly play something else,
2002which is exactly what is desired.
2003
2004This is implemented with two (count 'em, two) files. One
2005file "position.bin" is a binary file that contains the hash
2006table entries, and it right at one megabyte in size, *max*.
2007(16 bytes per hash entry X 65536 entries = exactly one meg,
2008but I have 8 extra bytes for the FIFO queue implementation
2009and to see how many entries are currently in the file if it
2010is not full.
2011
2012The second file is "position.lrn" and is, you guessed it, a
2013file that can be shared with others, just like book.lrn. It
2014contains all information needed to reconstruct the position,
2015the score, the depth, etc. and also included the pgn tags
2016for who was what color and when the game was played...
2017
2018This data can be imported with the new "import" command (the
2019old book learn <filename> is no longer around) which will
2020import either book.lrn type data or position.lrn type data
2021and can tell them apart without your having to do anything.
2022The <clear> option is still there, should you want to use
2023it, and simply removes the position.lrn and position.bin
2024files before starting the import process for position learn-
2025ing.
2026
2027This can be turned off, if you like, by checking out the
2028"learn" command, which gives you the ability to turn off
2029book learning (as it presently works), position learning,
2030and the next book learning stage which will add to the book
2031in addition to learning which book lines are good and bad.
2032
2033What is this new "result" learning?
2034
2035Result learning works just like normal book learning, except
2036that if Crafty is checkmated or resigns, it will step back
2037through the book line to find the last point where it had
2038more than one move to choose from. It will flag the move it
2039chose as "never play again".
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054This handles the case where the first ten non-book moves
2055produce reasonable scores, but the position is one that
2056Crafty simply can't handle very well. If it loses such a
2057game, it will still vary the next time this opening is
2058played, as otherwise it would possibly repeat the same open-
2059ing, and would certainly repeat the remainder of the game.
2060
2061All three learning modes are turned on by default, although
2062any of them can be disabled with the appropriate command
2063option to "learn".
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
This page took 0.413969 seconds and 4 git commands to generate.