Upgrade to Bonanza 6.0
[bonanza.git] / readme.txt
1 ----------------------------------------------------------------------\r
2                         Bonanza 6.0 - Client Source Code\r
3                                             Kunihito Hoki, May 2011\r
4 ----------------------------------------------------------------------\r
5 \r
6 \r
7 1. Introduction\r
8 ----------------\r
9 \r
10 Bonanza is a state-of-the art computer shogi engine which runs on\r
11 Windows and Linux machines, and this directory contains a\r
12 platform-independent source code.\r
13 \r
14 This source code is distributed with a hope that it will be useful in\r
15 addition to the main part of the shogi engine. This program includes\r
16 many useful functions such as manipulating a shogi board, reading and\r
17 writing a CSA record file, speaking of a CSA protocol with a socket\r
18 communication, and controlling time, and etc.. I believe this program\r
19 can be a good starting point if you are interested in making shogi\r
20 programs.\r
21 \r
22 One main feature of this program is that it employs a brute-force\r
23 search method together with bitboard techniques as many chess programs\r
24 do. Another notable feature is a machine learning of shogi evaluation\r
25 functions. The details of the learning algorithm (aka Bonanza method)\r
26 were already presented [1], and this source code provides an example\r
27 of implementation of the learning method.\r
28 \r
29 I admit that some parts of the source code are cryptic, e.g. codes in\r
30 "mate1ply.c". I hope that I will have some time to make a quality\r
31 documentation and comments on the program code, or someone else could\r
32 decrypt my program and provide a documentation.\r
33 \r
34 Any comments or suggestions are welcome [2].\r
35 \r
36 [1] K. Hoki, "Optimal control of minimax search results to learn\r
37     positional evaluation", Game Programming Workshop, Hakone, Japan\r
38     2008.\r
39 \r
40 [2] Contact to "bonanza_query [at] hotmail.com".\r
41 \r
42 \r
43 2. Legal Notices\r
44 -----------------\r
45 \r
46 This program is protected by copyright. Without a specific \r
47 permission, any means of commercial applications are prohibited.\r
48 Furthermore, this program is distributed without any warranty.\r
49 Within these limits, you can use, redistribute, and/or modify it.\r
50 \r
51 \r
52 3. Change Logs\r
53 ---------------\r
54 \r
55 Version 6.0\r
56 \r
57 Search() function is modified to ignore moves which receive negative\r
58 values from Static Exchange Evaluation (SEE) at frontier and\r
59 pre-frontier nodes. Self-play experiments showed that this modification\r
60 makes Bonanza slightly stronger. Similar results were also observed in\r
61 experiments using a shogi program YSS,\r
62 http://www32.ocn.ne.jp/~yss/horizon.txt. Moreover, the branch cut by\r
63 means of SEE at frontier nodes can also be found in a chess program,\r
64 Stockfish.\r
65 \r
66 Now Bonanza does Late Move Reduction (LMR) at root nodes, and recursive\r
67 iterative deepening more often. Self-play experiments showed that these\r
68 modifications make Bonanza slightly stronger.\r
69 \r
70 DFPN searcher is added to the set of Bonanza source codes (dfpn.c,\r
71 dfpn.h, and dfpnhash.c). You can use the searcher by using 'dfpn'\r
72 command with a compile option -DDFPN turned on. To make use of the DFPN\r
73 searcher in ordinary search, use 'dfpn_client' command with a compile\r
74 option -DDFPN_CLIENT turned on. To provide a proper service to the DFPN\r
75 client, you also need to use a server script 'src/server/dfpn_server.pl'\r
76 with one or more DFPN worker(s) connected with 'dfpn connect' command.\r
77 I am thankful to Dr. A. Nagai for his kind and fruitful advice.\r
78 \r
79 Now Bonanza can be a client of parallel searches using cluster computing\r
80 environment with mnj command. 'src/server/parallel_server.pl' is a\r
81 server script of root-node parallelizations, and the server can be a\r
82 client of majority voting cluster computation.\r
83 \r
84 Some techniques which increase computational efficiency of Bonanza are\r
85 reported by E. Ito, http://aleag.cocolog-nifty.com/. In his website,\r
86 two ideas are shown, i.e., (i) speed up of the computation of the static\r
87 evaluation function, and (2) use of SSE instructions of Intel processors\r
88 for bitboard operations. By adopting his ideas to Bonanza, NPS value\r
89 nearly doubled. This is amazing. To use SSE instructions, specify -DSSE2\r
90 or -DSSE4 compiler option. I am thankful to Mr. E. Ito for his kind and\r
91 fruitful advice.\r
92 \r
93 -DINANIWA_SHIFT compilation flag is supplied to enable an Inaniwa-strategy detection\r
94 \r
95 There are many other modifications and bug fixes.\r
96 \r
97 \r
98 Feliz 0.0\r
99 \r
100 - Some results from Y. Sato's experiments with Bonanza inspired me\r
101   to use the history table in LMR in Shogi, as Fruit did in chess. By\r
102   doing so, some improvement in performance of the tree search is\r
103   made.\r
104 \r
105 - From private communications with Yaneurao, it turned out that the\r
106   3-ply-mate detections in 'mate3.c' can search game trees more\r
107   efficiently by using several heuristic pruning techniques. Now\r
108   'mate3.c' adopts some of these techniques.\r
109 \r
110 - E. Ito kindly reported two bugs in the source codes. One is in\r
111   hash_store(), and the other is in ehash_probe() and\r
112   ehash_store(). Now these are fixed.\r
113 \r
114 - The structure of history table is modified from 'square-to' and\r
115   'square-from' method to an exact match method by using the perfect\r
116   hash technique. The hash function of moves in 'phash.c' is generated\r
117   by codes at http://burtleburtle.net/bob/hash/perfect.html.\r
118 \r
119 - A command 'mnj' is added to connect to the cluster-computing server\r
120   in src/cluster/.\r
121 \r
122 - In client_next_game(), the way of dealing with REJECT message from a\r
123   CSA Shogi server is revised. Now Bonanza connects to the server again\r
124   when the game is rejected by an opponent.\r
125 \r
126 \r
127 Version 4.1.3\r
128 - The owner of 'LS3600 Blog Webpage' pointed out that there were two\r
129   serious bugs. Thank you very much! According to his indication,\r
130   is_hand_eq_supe() in 'utility.c' and read_CSA_line() in 'csa.c' are\r
131   revised.\r
132 - In MPV code in 'searchr.c', a test of 'root_abort' flag had been\r
133   forgotten. Now the flag is tested after every call of search().\r
134 - 'lan.txt' is added to 'src/executable/' directory. This is an\r
135   example of an input sequence to connect to CSA Shogi server.\r
136 - 'book.bin' now has smaller moves and positions than previous one does.\r
137   Also, 'book_anti.csa' is added to 'src/executable/' directory. This\r
138   is an example of bad moves which apear in records of human experts.\r
139 - 'Legal Notices' in this document is corrected.\r
140 \r
141 Version 4.1.2\r
142 - In 'Makefile' and 'Makefile.vs', targets which require profile-guided\r
143   optimization are removed. Furthermore, an option, which controls\r
144   optimization, has been reverted from the aggressive flag, -O3, to a\r
145   moderate one, '-O2'. These modifications were necessary for avoiding\r
146   abnormal terminations of the program.\r
147 - In 'ini.c', the attribute of POSIX thread in a global-variable\r
148   'pthread_attr' is set to 'detach-state'. Because threads will never\r
149   join with any other threads in this program, the thread should be\r
150   created in the detached state to free system resources.\r
151 - In 'ini.c', the default size of the transposition table is lifted\r
152   from 12MByte to 48MByte.\r
153 - In 'iterate.c", probing the opening book is avoided when the move\r
154   history of a current game has repetitions.\r
155 - In 'shogi.h', the margins of futility pruning are increased in\r
156   accord with new positional evaluation of the feature vector in\r
157   'fv.bin'.\r
158 - The quality of an opening book, 'winbin/book.bin', has been improved\r
159   at the expense of quantity.\r
160 \r
161 Version 4.1.0 and 4.1.1 (26 Apr 2009)\r
162 - In 'Makefile' and 'Makefile.vs', some options of Intel C compiler\r
163   are modified. Here, agressive optimization '-O3' is substituted for\r
164   the default '-O2', pthreads support '-pthread' is substituted for\r
165   '-lpthread', and an obsolete '-static-libcxx' is removed.\r
166 - In 'Makefile', the conformance of GNU C and Intel C compilers are\r
167   set to GNU extensions of ISO C99 by setting '-std=gnu99' because a\r
168   POSIX function 'strtok_r()' is not in the C99 standard library.\r
169 - In 'Makefile', targets for GNU C with gprof and profile-guided\r
170   optimization of GNU C are removed.\r
171 - In 'shogi.h', inline assemblies and intrinsics are used on x86-64 as\r
172   well as x86. To detect the targets, pre-defined macros '__i386__'\r
173   and '__x86_64__' are examined.\r
174 - In 'evaluate.c', the evaluation function looks up the table\r
175   'stand_pat[ply]' to see if the position have been evaluated since\r
176   the previous move is made by 'make_move_[bw]()' functions. Also, the\r
177   evaluation function probes the hash table 'ehash_tbl[]' to avoid\r
178   re-evaluation of the same position.\r
179 - In 'io.c', an immediate value 0 is substituted for 'fileno(stdin)'\r
180   because the POSIX function 'fileno()' is not part of ANSI C. POSIX\r
181   requires that the file descriptor associated with 'stdin' be 0.\r
182 - In 'iterate.c', a criterion for aging of transposition-table, i.e.,\r
183   increment of a global variable 'trans_table_age', is lifted from 7%\r
184   to 9% of saturation ratio of the table.\r
185 - In 'learn1.c', the macro 'SEARCH_DEPTH' is set to 2. The macro\r
186   specifies the depth threashold of searches for finding all of\r
187   principle variations of positions in a set of games.\r
188 - In 'learn1.c', a step size of increment/decrement of feature vectors\r
189   is fixed to 1 in 'learn_parse2()' function.\r
190 - In 'hash.c', when a node can be pruned by using a hash value based on\r
191   futility pruning, a return value of the node is set to beta.\r
192 - In 'rand.c', some codes of initialization of PRNG variables are\r
193   moved to 'ini_genrand()' from 'ini()' function.\r
194 - In 'sckt.c', a function 'send_crlf()' is removed.\r
195 - In 'search.c', now 'search()' calls 'search_quies()' and returns if\r
196   a search depth reaches a threashold. So that we can call 'search()'\r
197   function anytime, and this makes source codes simple.\r
198 - In 'search.c', the static evaluation value is evaluated and used to\r
199   see if the late-move reduction is applicable or not. The evaluation\r
200   value is also used by the futility pruning.\r
201 - In 'search.c', the futility pruning is not applied if the node is in\r
202   check or the move is a check.\r
203 - In 'search.c', now Bonanza sends the keep-alive command '0x0a' to\r
204   the server in 'detect_signals()'.\r
205 - In 'time.c', 'set_seach_limit_time()' is simplified.\r
206 - In 'time.c', the second argument of 'gettimeofday()' is set to 'NULL'.\r
207 \r
208 Version 4.0.4 (2 Feb 2009)\r
209 - An error of GCC inline assembly for spinlock in "thread.c" is fixed.\r
210 - In Windows OS, Bonanza now opens all streams with file sharing by\r
211   using "_SH_DENYNO" constant in "io.c".\r
212 - GCC built-in functions are substituted for GCC inline assemblies for\r
213   bit-scan operations in "bitop.h". Furthermore, "bitop.h" is removed,\r
214   and some of macros in the header are integrated into "shogi.h".\r
215 \r
216 Version 4.0.3 (Jan 2008)\r
217 \r
218 \r
219 4. Files\r
220 ---------\r
221 \r
222 Here is a list of files you can find in this directory.\r
223 \r
224 C headers\r
225 - param.h     piece values\r
226 - shogi.h     main header\r
227 - bitop.h     bit operations\r
228 - dfpn.h      header of DFPN codes\r
229 \r
230 basic C functions\r
231 - main.c      main function of C program\r
232 - data.c      definition of global variables\r
233 - ini.c       initializations\r
234 - rand.c      pseudo random number generator\r
235 - time.c      time functions\r
236 - bitop.c     bit operations\r
237 - utility.c   misc. functions\r
238 \r
239 I/O\r
240 - proce.c     input procedures\r
241 - csa.c       csa file format I/O\r
242 - io.c        basic I/O\r
243 - sckt.c      Socket communications\r
244 \r
245 bitboard manipulations\r
246 - attack.c    piece attacks\r
247 - genchk.c    move generation (checks)\r
248 - genevasn.c  move generation (evasions)\r
249 - gendrop.c   move generation (drops)\r
250 - gennocap.c  move generation (non-captures)\r
251 - gencap.c    move generation (captures)\r
252 - movgenex.c  move generation (inferior moves)\r
253 - makemove.c  make moves\r
254 - unmake.c    unmake move\r
255 - mate1ply.c  1-ply mate detection\r
256 - debug.c     examine bitboard validity\r
257 \r
258 brute-force search\r
259 - iterate.c   iterative deepning search at root node\r
260 - searchr.c   alpha-beta search at root node\r
261 - search.c    alpha-beta search\r
262 - next.c      obtains next move\r
263 - quiesrch.c  quiescence search\r
264 - evaluate.c  static eveluation function\r
265 - evaldiff.c  easy and fast evaluation function\r
266 - swap.c      static exchange evaluation\r
267 - hash.c      transposition table\r
268 - phash.c     perfect hash function of moves\r
269 - thread.c    thread-level parallelization\r
270 - root.c      root move genelation and shallow min-max search\r
271 - mate3.c     3-ply mate detection\r
272 - ponder.c    pondering\r
273 - book.c      creates and probes opening book\r
274 - problem.c   auto problem solver\r
275 - valid.c     examine move validity\r
276 \r
277 DFPN search\r
278 - dfpn.c      DFPN search\r
279 - dfpnhash.c  Hashing for DFPN search\r
280 \r
281 optimal control of min-max search\r
282 - learn1.c    main functions\r
283 - learn2.c    feture vector manipuration\r
284 \r
285 misc.\r
286 - bonanza.txt which now you are looking at\r
287 - Makefile    makefile for gnu make.exe\r
288 - Makefile.vs makefile for Microsoft nmake.exe\r
289 - bonanza.ico icon file for windows\r
290 - bonanza.rc  resource-definition file for windows\r
291 - lan.txt     example of input sequence to connect CSA Shogi server\r
292 - book_anti.csa example of a set of bad moves which apear in records\r
293               of human exparts. This is used by 'book create' command.\r
294 \r
295 4. How to build Bonanza\r
296 -----------------------\r
297 \r
298 You can build Bonanza by means of GNU Make on Linux or Microsoft NMAKE\r
299 on Windows. Here is some examples:\r
300 \r
301 - GCC on Linux\r
302 > make -f Makefile gcc\r
303 \r
304 - Intel C++ Compiler on Linux\r
305 > make -f Makefile icc\r
306 \r
307 - Microsoft C/C++ Compiler on Windows\r
308 > nmake -f Makefile.vs cl\r
309 \r
310 - Intel C++ Compiler on Windows\r
311 > nmake -f Makefile.vs icl\r
312 \r
313 The C source codes are written by using ANSI C plus a small number of\r
314 new features in ISO C99. Therefore, I think this can be easily built\r
315 in many platforms without much effort.\r
316 \r
317 It may be necessary to define some macros in Makefile or\r
318 Makefile.vs. The macros are:\r
319 \r
320 - NDEBUG (DEBUG)    builds release (debug) version of Bonanza\r
321 \r
322 - MINIMUM           disables some auxiliary functions that are not\r
323                     necessary to play a game, e.g., book composition\r
324                     and optimization of evaluation functions\r
325 \r
326 - TLP               enables thread-level parallel search\r
327 \r
328 - MPV               enables multi-PV search\r
329 \r
330 - CSA_LAN           enables Bonanza to communicate by CSA Shogi TCP/IP\r
331                     protcol\r
332 \r
333 - DEKUNOBOU         enables dekunobou interface (available only for\r
334                     Windows)\r
335 \r
336 - CSASHOGI          builds an engine for CSA Shogi (available only for\r
337                     Windows)\r
338 \r
339 - NO_LOGGING        suppresses dumping log files\r
340 \r
341 - HAVE_SSE2         use SSE2 instructions for speed\r
342 \r
343 - HAVE_SSE4         use SSE2 and SSE4.1 instructions for speed\r
344 \r
345 - MNJ_LAN           enables a client-mode of cluster searches\r
346 \r
347 - INANIWA_SHIFT     enables an Inaniwa strategy detection\r
348 \r
349 - DFPN              build the DFPN worker of mate-problems server\r
350 \r
351 - DFPN_CLIENT       enables the client-mode of mate-problem server\r
352 \r
353 \r
354 Bonanza is an application that does not provide graphical user\r
355 interface. If you could build "bonanza.exe" properly without CSASHOGI\r
356 macro, it shows a prompt "Black 1>" when you execute it at a computer\r
357 console.\r
358 \r
359 Bonanza uses three binary files: a feature vector of static evaluation\r
360 function "fv.bin",  an opening book "book.bin", and a\r
361 position-learning database "hash.bin". You can find these in "winbin/"\r
362 directory. Without the NO_LOGGING option, Bonanza must find "log/"\r
363 directory to dump log files.\r
364 \r
365 \r
366 5. Command List\r
367 ---------------\r
368 \r
369 - beep on\r
370 - beep off\r
371     These commands enable (on) or disable (off) a beep when Bonanza\r
372     makes a move.  The default is on.\r
373 \r
374 - book on\r
375 - book off\r
376     These commands enable (on) or disable (off) to probe the opening\r
377     book, "./book.bin".  The default is on.\r
378 \r
379 - book narrow\r
380 - book wide\r
381     When the command with "narrow" is used, Bonanza selects a book\r
382     move from a small set of opening moves. The default is "wide". The\r
383     narrowing of the opening moves is useful if you want Bonanza\r
384     choose a common opening line.\r
385 \r
386 - book create\r
387     This command creates the opening book file, "./book.bin", by using\r
388     numerous experts' games in a single CSA record file, "./book.csa".\r
389     It also uses another CSA record file, "book_anti.csa", where you\r
390     can register bad moves that may appear in the experts' games at\r
391     the last moves in the record file. Here is the example:\r
392 \r
393     ----------------------------------------\r
394     PI, +, +6978KI, %TORYO\r
395     /\r
396     PI, +, +6978KI, -8384FU, %TORYO\r
397     /\r
398     PI, +, +7776FU, -4132KI, %TORYO\r
399     /\r
400     PI, +, +7776FU, -4132KI, +2726FU, %TORYO\r
401     ----------------------------------------\r
402 \r
403     This command becomes effective when MINIMUM macro is not defined\r
404     in the Makefile.\r
405 \r
406 - connect 'addr' 'port' 'id' 'passwd' ['ngame']\r
407     This command connects Bonanza to a shogi server by using the CSA\r
408     protocol. The first four arguments specify the network address,\r
409     port number, user ID, and password, respectively. The last\r
410     argument limits a number of games that will be played by Bonanza.\r
411     This command becomes effective when CSA_LAN macro is defined in\r
412     the Makefile.\r
413 \r
414 - dfpn go\r
415     Bonanza does DFPN search at a current position.\r
416 \r
417 - dfpn hash 'num'\r
418     This command is used to initialize the transposition table of\r
419     DFPN search and set the size of the table to 2^'num'. This\r
420     command becomes effective when DFPN macro is defined in the\r
421     Makefile.\r
422 \r
423 - dfpn connect 'hostname' 'port#' 'ID'\r
424     This command is used to connect to the server script\r
425     dfpn_server.pl as a worker. This command becomes effective when\r
426     DFPN macro is defined in the Makefile.\r
427 \r
428 - dfpn_client 'hostname' 'port#'\r
429     This command is used to connect to the server script\r
430     dfpn_server.pl as a client. With this, a root and its child\r
431     posittions are examined by the DFPN worker(s). This command\r
432     becomes effective when DFPN_CLIENT macro is defined in the\r
433     Makefile.\r
434 \r
435 - display ['num']\r
436     This command prints the shogi board. If you want to flip the\r
437     board, set 'num' to 2. If not, set it to 1.\r
438 \r
439 - s\r
440     Bonanza makes a prompt reply while thinking as soon as this\r
441     command is used.\r
442 \r
443 - hash 'num'\r
444     This command is used to initialize the transposition table and\r
445     set the size of the table to 2^'num'.\r
446 \r
447 - hash learn create\r
448     This command is used to make a zero-filled position-lerning\r
449     database, "hash.bin". This command becomes effective when MINIMUM\r
450     macro is not defined in the Makefile.\r
451 \r
452 - hash learn on\r
453 - hash learn off\r
454     These commands enable (on) or disable (off) the position learning.\r
455     The default is on.\r
456 \r
457 - learn 'str' 'steps' ['games' ['iterations' ['num1' ['num2']]]]\r
458     This command optimizes a feature vector of the static evaluation\r
459     function by using numorous experts' games in a single CSA record\r
460     file, "./records.csa". If you want to use a zero-filled vector as\r
461     an initial guess of the optimization procedure, set 'str' to\r
462     "ini". If not, set it to "no-ini". The third argument 'games' is a\r
463     number of games to be read from the record file. If the third\r
464     argument is negative or omitted, all games are read from the file.\r
465 \r
466     The learning method iterates a set of procedures, and the number\r
467     of iteration can be limited by the fourth argument. It continues\r
468     as long as the argument is negative. The procedures consist of two\r
469     parts. The first part reads the record file and creates principal\r
470     variations by using 'num1' threads. The default value of 'num1' is\r
471     1. The second part renews the feature vector 'steps' times by using\r
472     'num2' threads in accord with the principal variations. The default\r
473     value of 'steps' and 'num2' is 1. Note that each thread in the\r
474     second procedure uses about 500MByte of the main memory. The two\r
475     arguments 'num1' and 'num2' become effective when TLP macro is\r
476     defined in the Makefile. After the procedures, the optimized\r
477     vector is saved in "./fv.bin". This command become effective when\r
478     MINIMUM macro is not defined in the Makefile.\r
479 \r
480 - limit depth 'num'\r
481     This command is used to specify a depth, 'num', at which Bonanza\r
482     ends the iterative deepening search.\r
483 \r
484 - limit nodes 'num'\r
485     When this command is used, Bonanza stops thinking after searched\r
486     nodes reach to 'num'.\r
487 \r
488 - limit time 'minute' 'second' ['depth']\r
489     This command limits thinking time of Bonanza. It tries to make\r
490     each move by consuming the time 'minute'. When the time is spent\r
491     all, it makes each move in 'second'. The last argument 'depth' can\r
492     be used if you want Bonanza to stop thinking after the iterative\r
493     deepening searches reach sufficient depth.\r
494 \r
495 - limit time extendable\r
496 - limit time strict\r
497     The command, "limit time extendable", allows Bonanza to think\r
498     longer than the time limited by the previous command if it wishes\r
499     to. The default is "strict".\r
500 \r
501 - mnj 'sd' 'seed' 'addr' 'port' 'id' 'factor' 'stable_depth'\r
502     This command connects Bonanza to the majority or parallel server in\r
503     src/server/. The first two integers specify the standard\r
504     deviation and initial seed of pseudo-random numbers which are\r
505     added to the static evaluation function. Experiments suggested\r
506     that an appropriate value for the standard deviation is 15. Note\r
507     that all clients should use different seeds. The following three\r
508     arguments are network address, port number, user ID,\r
509     respectively. You can specify factor as a voting weight. Also\r
510     stable_depth is useful to detect opening positions. Here, when\r
511     Bonanza reaches the specified depth, then this is reported to the\r
512     server to reduce thinking time. This command becomes effective\r
513     when MNJ_LAN macro is defined in the Makefile.\r
514 \r
515 - move ['str']\r
516     Bonanza makes a move of 'str'. If the argument is omitted, Bonanza\r
517     thinks of its next move by itself.\r
518 \r
519 - mpv num 'nroot'\r
520 - mpv width 'threshold'\r
521     These commands control the number of root moves, 'nroot', to\r
522     constitute principal variations. The default number is 1. A root\r
523     move that yields a smaller value than the best value by 'threshold'\r
524     is neglected. The default threshold is about 200. These commands\r
525     become effective when MPV macro is defined in the Makefile.\r
526 \r
527 - new ['str']\r
528     This command initializes the shogi board. The argument 'str'\r
529     controls an initial configuration of the board.  If you want to\r
530     play a no-handicapped game, set 'str' to "PI" and this is the\r
531     default value. In a handicapped game, specify squares and pieces\r
532     to drop, e.g. "new PI82HI22KA" or "new PI19KY".\r
533 \r
534 - peek on\r
535 - peek off\r
536     The command "peek on (off)" enables (disables) peeks at a buffer\r
537     of the standard input file while Bonanza is thinking. The default\r
538     is on. This command is useful when you want to process a set of\r
539     commands as "> ./bonanza.exe < infile".\r
540 \r
541 - ping\r
542     Prompt Bonanza to print "pong".\r
543 \r
544 - ponder on\r
545 - ponder off\r
546     The command "ponder on (off)" enables (disables) thinks on the\r
547     opponent's time. The default is on.\r
548 \r
549 - problem ['num']\r
550     This command is used to solve problems in "./problem.csa". Here\r
551     is an example of the problem file.\r
552 \r
553     -----------------------------\r
554     $ANSWER:+0024FU\r
555     P1-KY-KE-OU-KI *  *  *  * -KY\r
556     P2 *  *  *  *  * -KI *  *  * \r
557     P3 *  * -FU-GI-FU * -KE * -KA\r
558     P4-FU *  * -FU-GI-FU-HI * -FU\r
559     P5 *  *  *  *  *  *  * -FU+KY\r
560     P6+FU+KA+FU+FU+GI+FU+KI *  * \r
561     P7 * +FU *  * +FU *  *  *  * \r
562     P8 * +OU+KI+GI *  * +HI *  * \r
563     P9+KY+KE *  *  *  *  * +KE * \r
564     P+00FU00FU\r
565     P-00FU00FU00FU\r
566     +\r
567     /\r
568     $ANSWER:+0087KY:+0088KY\r
569     P1-OU-KE *  *  *  *  * +GI * \r
570     P2-KY-KI *  *  *  *  *  *  * \r
571     P3-FU-HI * -KI *  * -GI *  * \r
572     P4 *  * -KE *  *  *  *  * -FU\r
573     P5 * +GI * -FU-FU-FU-FU-FU * \r
574     P6+FU+HI-FU *  *  *  *  *  * \r
575     P7 *  *  * +FU *  *  *  * +FU\r
576     P8 *  * +OU+KI+KI *  *  *  * \r
577     P9+KY+KE *  *  *  *  * +KE+KY\r
578     P+00KA00GI00KY00FU00FU\r
579     P-00KA00FU00FU00FU00FU00FU\r
580     +\r
581     -----------------------------\r
582 \r
583     The argument 'num' specifies the number of problems to solve.\r
584 \r
585 - quit\r
586     The quit command and EOF character will exit Bonanza.\r
587 \r
588 - read 'filename' [(t|nil) ['num']]\r
589     This command is used to read a CSA record 'filename' up to 'num'\r
590     moves. Set the second argument to "nil" when you want to ignore\r
591     time information in the record. The default value is "t". Bonanza\r
592     reads all move sequence if the last argument is neglected. If\r
593     'filename' is ".", the command reads an ongoing game from the\r
594     initial position.\r
595 \r
596 - resign\r
597     Use this command when you resign a game.\r
598 \r
599 - resign 'num'\r
600     This command specifies the threshold to resign. 'num' is a value\r
601     of the threshold. The default is around 1000.\r
602 \r
603 - stress on\r
604 - stress off\r
605     When the command "stress on" is used, last-move shown in shogi\r
606     board is stressed. The default is on.\r
607 \r
608 - time remain 'num1' 'num2'\r
609     This command tells Bonanza the remaining time. 'num1' ('num2') is\r
610     the remaining time of black (white) in seconds.\r
611 \r
612 - time response 'num'\r
613     This command specifies a margin to control time. The time margin\r
614     saves Bonanza from time up due to TCP/IP communication to a server\r
615     program, sudden disc access, or imperfection of time control of\r
616     Bonanza. 'num' is the time margin in milli-second. The default\r
617     value is 200.\r
618 \r
619 - tlp 'num'\r
620     This command controls the number of threads to be created when\r
621     Bonana considers a move to make. The command becomes effective\r
622     when TLP macro is defined in the Makefile. 'num' is the number of\r
623     threads. The default value is 1.\r
624 \r
625 - #\r
626     A line beginning with # causes all characters on that line\r
627     to be ignored.\r
628 \r
629 - [move command]\r
630     A move command consists of four digits followed by two\r
631     capital alphabets, e.g. 7776FU. The first two digits\r
632     are a starting square and the last two are a target square. The\r
633     starting square is "OO" if the  move is a dorp, e.g. 0087FU. The\r
634     following two alphabets specify a piece type as the following,\r
635 \r
636       FU - pawn             (Fuhyo)       TO - promoted pawn    (Tokin)\r
637       KY - lance            (Kyousha)     NY - promoted lance   (Narikyo)\r
638       KE - knight           (Keima)       NK - promoted knight  (Narikei)\r
639       GI - silver general   (Ginsho)      NG - promoted silver  (Narigin)\r
640       KI - gold general     (Kinsyo)\r
641       KA - Bishop           (Kakugyo)     UM - Dragon horse     (Ryuma)\r
642       HI - Rook             (Hisha)       RY - Dragon king      (Ryuo)\r
643       OU - King             (Osho)\r
644 \r
645     Here, words in parentheses are romanization of Japanese words.\r