dea729347a6e225df37fc0841b906ea1e04bf736
[gnushogi.git] / doc / gnushogi.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c % **  Start of header.
4 @setfilename gnushogi.info
5 @settitle GNU Shogi manual
6 @c % **  End of header.
7
8 @dircategory Games
9 @direntry
10 * gnushogi: (gnushogi).          Japanese chess
11 @end direntry
12
13 @setchapternewpage odd
14
15 @c ==================================
16 @c TeX-specific macros
17 @c ==================================
18
19 @c None yet!
20
21 @c ==================================
22 @c info-specific macros
23 @c ==================================
24
25 @c None yet!
26
27 @c ==================================
28 @c Summary description and copyright.
29 @c ==================================
30
31 @ifinfo
32
33 This file describes how to use GNU shogi, 
34 a program which plays Shogi (Japanese chess).
35
36 Copyright (C) 2013 Yann Dirson and the Free Software Foundation, Inc.
37 Copyright (C) 1999 Michael C. Vanier and the Free Software Foundation, Inc.
38
39 Permission is granted to make and distribute verbatim copies of
40 this manual provided the copyright notice and this permission notice
41 are preserved on all copies.
42
43 @ignore
44 Permission is granted to process this file through TeX and print the
45 results, provided the printed document carries copying permission
46 notice identical to this one except for the removal of this paragraph
47 (this paragraph not being relevant to the printed manual).
48 @end ignore
49
50 Permission is granted to copy and distribute modified versions of this
51 manual under the conditions for verbatim copying, provided that the entire
52 resulting derived work is distributed under the terms of a permission
53 notice identical to this one.
54
55 Permission is granted to copy and distribute translations of this manual
56 into another language, under the above conditions for modified versions,
57 except that this permission notice may be stated in a translation approved
58 by the Free Software Foundation.
59
60 @end ifinfo
61
62 @c =========================================
63 @c End of summary description and copyright.
64 @c =========================================
65
66
67 @c ====================
68 @c Title and copyright.
69 @c ====================
70
71 @titlepage
72 @sp 10
73 @comment The title is printed in a large font.
74 @center @titlefont{GNU Shogi (Japanese chess)}
75 @author   Mike Vanier
76
77 @c  The following two commands start the copyright page.
78 @page
79 @vskip 0pt plus 1filll
80 Copyright @copyright{} 2013-2014 Yann Dirson and the Free Software Foundation
81 Copyright @copyright{} 1999 Michael C. Vanier and the Free Software Foundation
82
83 @end titlepage
84
85 @c ===========================
86 @c End of title and copyright.
87 @c ===========================
88
89
90 @c =========================
91 @c Top node and master menu.
92 @c =========================
93
94 @node    Top, (dir), (dir), (dir)
95 @top     GNU Shogi (Japanese chess)
96
97 @ifnottex
98 @menu
99 * Introduction::         What is GNU shogi?
100 * About shogi::          General information, rules, etc.
101 * gnushogi::             How to play GNU shogi (gnushogi).
102 * References and links:: Where to go for more information.
103 * Acknowledgements::
104 * Bugs::                 Where and how to report bugs.
105 * Index::        
106 @end menu
107 @end ifnottex
108
109 @iftex
110 This document describes GNU shogi, a program which plays Japanese chess
111 (shogi) against a human opponent.
112 @end iftex
113
114 @c ================================
115 @c End of top node and master menu.
116 @c ================================
117
118
119 @c =====
120 @c Body.
121 @c =====
122
123 @node Introduction, About shogi, Top, Top
124 @chapter Introduction
125 @cindex Introduction
126
127 GNU shogi is a program that plays shogi, the Japanese version of chess,
128 against a human (or computer) opponent.  This file describes how to use
129 GNU shogi and also gives background information about the game of shogi.
130
131 In 1994, GNU Shogi 1.2p02, then developed by Matthias Mutz, played in
132 the 5th Computer Shogi Championship, and finished 17th out of 22
133 opponents.
134
135 This file describes GNU Shogi version 1.4.1, but most of it was
136 written for version 1.3.2 by Mike Vanier
137 @email{mvanier@@cs.caltech.edu}, maintainer of GNU shogi at that time.
138
139 GNU Shogi is currently maintained by Yann Dirson
140 @email{ydirson@@free.fr}.
141
142
143 GNU Shogi is actually one program, 'gnushogi', the text-based program
144 which also contains the game-playing engine.  By default it will play
145 Standard Shogi, but can be built to play Mini Shogi (with GNU Shogi
146 1.4.x, you will need to do that explicitely using `./configure
147 --enable-minishogi', but 1.5 will make this more straightforward).
148
149 Most players will just run GNU Shogi through one of the compatible
150 graphical interfaces:
151
152 @enumerate
153 @item
154 @uref{http://repo.or.cz/w/tagua/yd.git, Tagua}, a KDE-based GUI for
155 Chess and Shogi. Developement stopped several years ago, and it is
156 still somewhat maintained at Debian.  Probably the most sophisticated
157 and best-looking free GUI available today.
158
159 @item
160 @uref{https://alioth.debian.org/projects/omaha/, Omaha}, a generic
161 board-game GUI, supporting Shogi and other games, with currently only
162 a Gtk2-based UI.  Still under developement, but already usable for
163 casual games.
164
165 @item
166 @uref{https://github.com/pcapriotti/kaya, Kaya}, a small KDE-based GUI
167 successor to Tagua, but development of this still young program seem
168 to have stalled.
169
170 @item
171 @uref{http://www.gnu.org/software/xboard/, XBoard/Winboard}, a GUI for
172 much more than Shogi, part of the GNU Project.  Patches for GNU Shogi
173 to support it are being integrated into the developement version,
174 1.4.x and earlier versions cannot talk to it.
175
176 @item
177 @uref{http://ftp.gnu.org/gnu/gnushogi/, XShogi}, an X-Window graphical
178 interface to gnushogi, forked off GNU XBoard years ago, and far from
179 today's UI standards. It has barely been maintained recently, while
180 XBoard has grown much and is able to play Shogi, and will be soon
181 retired.
182
183 The GNU Shogi distribution used to contain the 'xshogi' program, In
184 future versions, GNU Shogi will be able to use XBoard as a GUI and
185 XShogi will be retired.  XShogi is still available as a separate
186 source archive on the GNU project FTP server.
187
188 @end enumerate
189
190
191 Disclaimer: I use the personal pronouns ``him'', ``his'' etc. to refer
192 to a shogi player regardless of gender.  That's easier than writing
193 ``his or her'' all over the place.  I don't mean to infer that women
194 don't play shogi; in fact shogi is very popular in Japan among women as
195 well as men.
196
197
198 @node    About shogi, gnushogi, Introduction, Top
199 @chapter About the game of shogi
200      
201
202 @quotation
203 ``Japanese chess cedes nothing in depth or beauty to the European
204 game... it is at least as interesting.''
205
206 --- Alexander Alekhine @*
207 (quoted in David Pritchard, @cite{The Encyclopedia of Chess Variants}) 
208
209 ``... shogi [is] by far the most complex form of chess that has ever
210 achieved widespread popularity.''
211
212 --- R. Wayne Schmittberger, @cite{New Rules for Classic Games}
213 @end quotation
214
215 Shogi is the version of chess played in Japan.  It is strikingly
216 different from standard chess (which I shall refer to henceforth as
217 ``international chess'') and also to all other regional variants,
218 because captured pieces can re-enter play on the side of the capturer.
219 This has several interesting effects on the play of the game:
220
221 @enumerate
222 @item
223 Shogi is much more complex than international chess, at least in
224 terms of the average number of possible moves per turn (estimated at
225 about 35 for chess and at about 80 for shogi).
226
227 @item
228 There are almost no draws (about 1-2% of all games in professional play).
229
230 @item
231 Exchanges complicate the play rather than simplifying it.
232
233 @item
234 There are no ``endgames'' in the standard chess sense; all pieces remain
235 in play throughout the game.  Games typically end in a race to
236 checkmate the other player before being checkmated oneself.
237
238 @item
239 Ownership of a piece is not indicated by the color of the piece;
240 instead, pieces are wedge-shaped and point towards the opponent.  The
241 name of the piece is inscribed in Kanji characters on the front of the
242 piece.
243
244 @item
245 Most importantly: it's more fun than other forms of chess :-)
246
247 @end enumerate
248
249 Shogi is extremely popular in Japan; it has been estimated that 20
250 million Japanese can play shogi, of which perhaps 1 million are active
251 players.  It is even more popular there than the game of go, Japan's
252 other favorite board game.  There are a number of professional players
253 who make a considerable amount of money playing in shogi tournaments,
254 and the game receives extensive newpaper and television coverage.
255 Despite this, the game has yet to become popular outside of Japan.  Part
256 of this is because the Kanji characters on the pieces scare away some
257 people, but mostly it's due, I think, to lack of exposure to the game
258 and to the difficulty of finding opponents.  I hope that GNU shogi will
259 help introduce shogi to a wider audience.
260
261 @ifnottex
262 @menu
263 * The rules of shogi::
264 * Sample game::
265 * Mating problems::
266 * Shogi variants::
267 * Differences between shogi and chess::
268 @end menu
269 @end ifnottex
270
271
272 @c -------------------------------------------------------
273 @c 
274 @c The rules of shogi.
275 @c
276 @c -------------------------------------------------------
277
278 @node    The rules of shogi, Sample game, About shogi, About shogi
279 @section The rules of shogi
280 @cindex  Rules
281
282 Shogi is a two-person abstract strategy board game with full information
283 (i.e. all pieces and moves are visible to both players at all times).
284 It is in the chess family, being descended from the same ancestral game
285 as international chess: the Indian game of Chaturanga.  The two players
286 are referred to as ``Black'' and ``White'', with Black moving first
287 (unlike in international chess, where White moves first), and with
288 movement alternating between the two players.  Note that ``Black'' and
289 ``White'' are just names; the pieces are not colored.  Instead, they are
290 flat, wedge-shaped pieces which point towards the opponent.  The
291 identity of a given piece is indicated by two Japanese Kanji characters
292 on each piece.  In fact, only the top character is needed to identify
293 the piece and thus only the top character is used in shogi diagrams.  I
294 will use alphabetical equivalents in the diagrams here; to see what the
295 Kanji characters look like, start up a graphical interface
296 (@pxref{Introduction}) and compare the starting setup there with the
297 starting setup in this file (@pxref{The opening setup}).
298
299 The object of the game is to capture the opponent's King.  The board is
300 a grid of 9x9 uncolored squares, and pieces are placed on the squares.
301 Each player begins with 20 pieces, described in the next section.
302 Capture is by displacement, as in international chess.
303
304 @ifnottex
305 @menu
306 * The moves of the pieces::
307 * The opening setup::
308 * Promotion of pieces::
309 * Drops::
310 * Winning the game::
311 * Draws::
312 * Handicaps::
313 * Notes for chess players::
314 @end menu
315 @end ifnottex
316
317 @c The moves of the pieces.
318
319 @node       The moves of the pieces, The opening setup, The rules of shogi, The rules of shogi
320 @subsection The moves of the pieces
321 @cindex     Piece moves
322
323 Each player at the beginning of a shogi game has a total of 20 pieces of
324 eight different types.  The moves of the shogi pieces can be divided
325 into three classes: ``stepping'' pieces, that only move one square at a
326 time; ``ranging'' pieces that move any number of unobstructed squares in
327 a line, and ``jumping'' pieces that can jump over obstructing pieces to
328 reach their destination squares.  Most pieces can also promote to
329 different (usually stronger) pieces under certain circumstances (see the
330 next section).  All pieces capture the same way that they move (even
331 pawns).  The piece moves and promotions are as follows; each piece name
332 is followed by the standard piece abbreviation:
333
334 @enumerate
335
336 @item
337 The king (K).  The king can move one square in any horizontal, vertical,
338 or diagonal direction, just like the king in international chess.  The
339 king does not promote.
340
341 @item
342 The rook (R).  The rook can move any number of squares in a horizontal
343 or vertical direction.  The rook is the same as the rook in
344 international chess (except that it can promote).  A rook promotes to a
345 ``dragon king'' or ``dragon'' for short (often just referred to as a
346 ``promoted rook''), which can move as a rook or can move one square in
347 any diagonal direction.
348
349 @item
350 The bishop (B).  The bishop can move any number of squares in a diagonal
351 direction.  The bishop is the same as the bishop in international chess
352 (except that it can promote).  A bishop promotes to a ``dragon horse''
353 or ``horse'' for short (often just referred to as a ``promoted
354 bishop''), which can move as a bishop or can move one square in any
355 horizontal or vertical direction.  Note: the horse should not be
356 confused with a knight (see below), as they are two completely different
357 pieces.
358
359 @item
360 The gold general (G).  A gold general can move one square in any
361 horizontal or vertical direction, or one square in a forward diagonal
362 direction.  Gold generals do not promote.
363
364 @item
365 The silver general (S).  A silver general can move one square in any
366 diagonal direction, or one square straight forward.  A silver general
367 promotes to a gold general.
368
369 @item
370 The knight (N).  A knight can move one square straight forward followed
371 by one square to either forward diagonal, jumping over intervening
372 pieces if any.  In other words, a knight moves like its international
373 chess counterpart, but forward only.  A knight promotes to a gold
374 general.  The knight is the only jumping piece, as in chess.
375
376 @item
377 The lance (L).  A lance can move any number of squares straight forward.
378 A lance promotes to a gold general.
379
380 @item
381 The pawn (P).  A pawn can move one square straight forward.  The pawn
382 captures the same way that it moves, in contrast to international chess.
383 There is also no initial two-space move for pawns and no
384 @emph{en-passant} capture.  A pawn promotes to a gold general; a
385 promoted pawn is usually known as a ``Tokin''.
386
387 @end enumerate
388
389
390 @c The opening setup.
391
392 @node       The opening setup, Promotion of pieces, The moves of the pieces, The rules of shogi
393 @subsection The opening setup
394 @cindex     Opening setup
395
396 The opening setup for shogi is as follows:
397
398 @ifnottex
399 @verbatim
400    9    8    7    6    5    4    3    2    1
401 +--------------------------------------------+
402 | wL | wN | wS | wG | wK | wG | wS | wN | wL |  a
403 +--------------------------------------------+
404 |    | wR |    |    |    |    |    | wB |    |  b
405 +--------------------------------------------+
406 | wP | wP | wP | wP | wP | wP | wP | wP | wP |  c
407 +--------------------------------------------+
408 |    |    |    |    |    |    |    |    |    |  d
409 +--------------------------------------------+
410 |    |    |    |    |    |    |    |    |    |  e
411 +--------------------------------------------+
412 |    |    |    |    |    |    |    |    |    |  f
413 +--------------------------------------------+
414 | bP | bP | bP | bP | bP | bP | bP | bP | bP |  g
415 +--------------------------------------------+
416 |    | bB |    |    |    |    |    | bR |    |  h
417 +--------------------------------------------+
418 | bL | bN | bS | bG | bK | bG | bS | bN | bL |  i
419 +--------------------------------------------+
420 @end verbatim
421 @end ifnottex
422
423 @c The following TeX macros are taken with permission from 
424 @c "TeX for the Beginner" by Wynter Snow.
425
426 @tex
427 \def\startline{\par\nobreak\noindent}
428
429 {\obeylines\obeyspaces%
430 \gdef\beginVerbatim{\bigbreak%
431 \begingroup%
432 \parskip=0pt%
433 \obeylines\obeyspaces%
434 \let^^M=\startline%
435 \tt}}
436 \gdef\endVerbatim{\endgroup\bigbreak}
437 \beginVerbatim
438
439
440    9    8    7    6    5    4    3    2    1
441 +--------------------------------------------+     
442 | wL | wN | wS | wG | wK | wG | wS | wN | wL |  a   
443 +--------------------------------------------+     
444 |    | wR |    |    |    |    |    | wB |    |  b   
445 +--------------------------------------------+     
446 | wP | wP | wP | wP | wP | wP | wP | wP | wP |  c   
447 +--------------------------------------------+     
448 |    |    |    |    |    |    |    |    |    |  d   
449 +--------------------------------------------+     
450 |    |    |    |    |    |    |    |    |    |  e   
451 +--------------------------------------------+     
452 |    |    |    |    |    |    |    |    |    |  f   
453 +--------------------------------------------+     
454 | bP | bP | bP | bP | bP | bP | bP | bP | bP |  g   
455 +--------------------------------------------+     
456 |    | bB |    |    |    |    |    | bR |    |  h   
457 +--------------------------------------------+     
458 | bL | bN | bS | bG | bK | bG | bS | bN | bL |  i   
459 +--------------------------------------------+
460
461 \endVerbatim
462 @end tex
463
464 Here, ``b'' stands for ``black'' and ``w'' stands for ``white'', so
465 that, for instance, ``bL'' means ``black lance''.  The numbers above the
466 files and the letters to the right of the ranks represent the most
467 common notation system used for shogi by westerners (the Japanese also
468 use Arabic numerals for the files but use Japanese numerals for the
469 ranks).  
470
471
472 @c Promotion of pieces.
473
474 @node       Promotion of pieces, Drops, The opening setup, The rules of shogi
475 @subsection Promotion of pieces
476 @cindex     Piece promotion
477
478 In sharp contrast to international chess, where only pawns can promote
479 to higher-ranked pieces, most of the pieces in shogi can promote.  The
480 promoted ranks are discussed in the section on piece moves (@pxref{The
481 moves of the pieces}) but are repeated here for reference:
482
483 @table @asis
484
485 @item Pawn
486 promotes to gold general (called a `tokin' in this case only).
487
488 @item Lance
489 promotes to gold general.
490
491 @item Knight
492 promotes to gold general.
493
494 @item Silver general
495 promotes to gold general.
496
497 @item Gold general
498 does not promote.
499
500 @item Bishop
501 promotes to ``dragon horse'' or just ``horse'' for short.  The horse can
502 move as a bishop or can move one square in any orthogonal direction.
503
504 @item Rook
505 promotes to ``dragon king'' or just ``dragon'' for short.  The dragon
506 can move as a rook or can move one square in any diagonal direction.
507
508 @item King
509 does not promote.
510
511 @end table
512
513 The three ranks furthest away from each player constitute his/her
514 ``promotion zone''.  A player may, but is not required to, promote a
515 piece after making a move in which the piece begins and/or ends in the
516 promotion zone.  Thus you can promote a piece when moving the piece into
517 the promotion zone, out of the promotion zone, or entirely within the
518 promotion zone.  Promotion is mandatory in these cases:
519
520 @enumerate
521
522 @item You must promote a pawn or a lance after moving it to the last rank.
523
524 @item You must promote a knight after moving it to either of the last
525 two ranks.
526
527 @end enumerate
528
529 These forced promotions ensure that a piece cannot be moved to a square
530 from which it would have no further move.
531
532 Pieces ``dropped'' onto the board (@pxref{Drops}) always drop in the
533 unpromoted state, even if they drop into the promotion zone.
534
535
536
537 @c Drops.
538
539 @node       Drops, Winning the game, Promotion of pieces, The rules of shogi
540 @subsection Drops
541 @cindex     Drops
542
543 When a player captures a piece, that piece is not removed from play.
544 Instead, it becomes the property of the capturer and can re-enter play
545 by being placed on (almost) any vacant square during the player's move.
546 This is known as a ``drop'' and counts as a full move (in other words,
547 you can either move a piece on the board or drop a piece onto the board
548 during your move, but not both).  All pieces drop in the unpromoted
549 state.  Pieces may be legally dropped in their promotion zone, but they
550 do not promote on that turn.
551
552 There are several restrictions on drops:
553
554 @enumerate
555
556 @item A pawn may not be dropped onto a file if there is already an
557 unpromoted pawn belonging to the same player on that file.  It is legal
558 to drop a pawn on a file which contains a @emph{promoted} pawn belonging
559 to the same player, however.
560
561 @item A pawn may not be dropped to give immediate checkmate on the
562 move.  A pawn is, however, permitted to be moved on the board to give
563 immediate checkmate.  This is a curious rule, and if anyone knows the
564 reason for it I would appreciate it if they would contact me and explain
565 it to me :-)
566
567 @item A pawn or piece may not be dropped onto a square from which they
568 would have no legal move.  This means that pawns and lances may not be
569 dropped onto the last rank, and the knight may not be dropped onto the
570 last or second-to-last rank.
571
572 @end enumerate
573
574 It is entirely permissible (and often advisable) to drop a piece or pawn
575 between one's King and an attacking ranging piece.  For this reason,
576 the final checkmating move is nearly always an attack on the King from
577 an adjacent square (except for an attack by a Knight).
578
579 Captured pieces are said to be pieces ``in hand''.
580
581 The drop is the primary distinguishing feature of Japanese chess, shared
582 with no other popular chess-type game.  It gives shogi a very aggressive
583 quality, and dramatically increases the number of possible moves once a
584 few pieces have been captured.  Another interesting feature of shogi is
585 that exchanges complicate play rather than simplifying it (as in
586 international chess), because of the drop rule.
587
588
589 @c Winning.
590
591 @node       Winning the game, Draws, Drops, The rules of shogi
592 @subsection Winning the game
593 @cindex     Winning the game
594
595 A game of shogi is won by capturing the opponent's king.  In general,
596 this is done by checkmating the king: attacking the king in such a way
597 that the king cannot be defended no matter what the defending player
598 moves.  Note, though, that there is no rule that requires a player to
599 defend a king which is being attacked.  However, if he does not defend
600 his king, the opponent is entirely free to capture it on the next move,
601 thus winning the game.  As in international chess, in practice most
602 games end by resignation when one player realizes that he cannot escape
603 checkmate. 
604
605
606 @c Draws.
607
608 @node       Draws, Handicaps, Winning the game, The rules of shogi
609 @subsection Draws
610 @cindex     Draws
611
612 There are very few draws in shogi; only about 1-2% of professional games
613 end in a draw.  One reason for this is that material can never be
614 depleted as in chess, because captured pieces are constantly re-entering
615 play as a consequence of the drop rule.  In fact, most of the ways a
616 game can be drawn in chess are not allowed in shogi:
617
618 @itemize @bullet
619
620 @item Draws cannot be offered.
621
622 @item There is no fifty-move rule.
623
624 @item A stalemate counts as a win for the stalemater.  Stated otherwise:
625 if you can't move, you lose.
626
627 @item Perpetual check is illegal (see below).
628
629 @end itemize
630
631 There are only two legal ways in which a draw can occur:
632
633 @enumerate
634
635 @item A position (including the pieces in hand) occurs 4 times with the same
636 player to move (called ``Sennichite'').  However, if this is caused by
637 consecutive checks (direct attacks on the King, threatening to capture
638 it on the next move) by one side, the player giving these checks loses
639 the game.  In other words, perpetual check results in a loss for the
640 attacker who recreates the same position the 4th time.
641
642 @item Both players have moved their King into the the promotion zone (or they
643 cannot be prevented from doing so) and the Kings cannot be checkmated.
644 A King who has entered the promotion zone is known as an ``entering
645 King''; due to the forward orientation of most shogi pieces, it is very
646 hard to mate such a King.  In that case the players may decide to count
647 their pieces as follows: the King does not count, the Rook and Bishop
648 count as 5 points, and all other pieces as one point.  Promotion is
649 disregarded.  If both players have at least 24 points the game is a draw
650 (called ``Jishogi'').  If a player has less, he loses the game.
651
652 Of course, a player can refuse to count pieces when he still has mating
653 chances or chances to gain material which would affect the outcome of
654 the counting.  There is no strict rule about what to do if this is not
655 the case, but nonetheless a player refuses to count up (e.g. because he
656 does not have enough points for a draw).  It has been generally accepted
657 that in such a case the game ends and the pieces are counted after one
658 player has managed to get all his pieces protected in the promotion
659 zone.
660
661 @end enumerate
662
663 @c Handicaps.
664
665 @node       Handicaps, Notes for chess players, Draws, The rules of shogi
666 @subsection Handicaps
667 @cindex     Handicaps
668
669 Unlike international chess, shogi has a well-established handicap system
670 which is used when players of different strengths play against each
671 other.  Handicaps range from small to huge, which makes it possible for
672 weak players to play against even very strong players and have an even
673 chance of winning.
674
675 Shogi players are ranked as follows: the weakest rank is around 15
676 ``kyu'', which represents a beginner.  14 kyu is higher than 15 kyu, 13
677 kyu is higher still, and so on until you get to 1 kyu.  The next highest
678 rank is 1 ``dan'', followed by 2 dan, 3 dan and so forth.  The highest
679 amateur rank is 6 dan; professionals go up to 9 dan.  However,
680 professional ranks are not the same as amateur ranks; a professional 1
681 dan is @emph{much} stronger than an amateur 1 dan.  This system is
682 similar to that used by go players (and also other Japanese sports such
683 as karate).
684
685 A handicap consists of the stronger player playing White and removing
686 one or more pieces from his side of the board at the start of the game.
687 These pieces are permanently removed from play; they are not in hand.
688
689 The following is a list of the accepted handicaps, from weakest to
690 strongest.  The degree of the handicap, represented by the position in
691 the list, represents the difference in rank between the two players for
692 which the handicap is appropriate.  These rules are taken from the books
693 ``Shogi for Beginners'' by John Fairbairn and ``The Art of Shogi'' by
694 Tony Hoskings (@pxref{References and links}) and, I believe, represent
695 current Japanese practice.
696
697 @enumerate
698
699 @item 
700 The stronger player removes his left lance (on 1a).
701
702 @item 
703 The players play a two-game match; in the first game the stronger player
704 removes his left lance (on 1a), while in the second game he removes his
705 bishop.
706
707 @item 
708 The stronger player removes his bishop.
709
710 @item 
711 The stronger player removes his rook.
712
713 @item 
714 The stronger player removes his rook and left lance.
715
716 @item 
717 The players play a two-game match; in the first game the stronger player
718 removes his rook and left lance (on 1a), while in the second game he
719 removes his rook and bishop.
720
721 @item 
722 The stronger player removes his rook and bishop.  This is usually called
723 a ``two-piece'' handicap.
724
725 @item 
726 The stronger player removes his rook, bishop, and both lances.  This is
727 called a ``four-piece'' handicap.
728
729 @item 
730 The stronger player removes his rook, bishop, both lances, and both
731 knights.  This is called a ``six-piece'' handicap.
732
733 @item 
734 The stronger player removes his rook, bishop, both lances, both knights,
735 and both silvers.  This is called an ``eight-piece'' handicap.
736
737 @end enumerate
738
739 Another advantage of playing handicap games is that the handicaps alter
740 the optimal strategy for both players.  For instance, handicaps all have
741 their own opening lines which may bear little or no resemblance to those
742 used in non-handicap shogi.  This means that when learning handicap
743 shogi, you are essentially learning completely new games which use the
744 same equipment!
745
746 The reader may wonder how on earth a player giving an eight-piece
747 handicap, say, could possibly hope to win.  Don't forget, though, that
748 in shogi the opponent's pieces can be captured and then become part of
749 one's own army.  Thus, if the opponent plays badly enough, the number of
750 pieces will soon even out.
751
752
753 @c Notes for chess players.
754
755 @node       Notes for chess players,  , Handicaps, The rules of shogi
756 @subsection Notes for chess players
757
758 Here are a few miscellaneous things that may confuse chess players.
759 Some of these have been mentioned elsewhere, but they bear repeating.
760
761 @enumerate
762 @item There is no queen.
763
764 @item Pawns capture the same way they move.  There is no initial
765 two-space pawn move and no @emph{en-passant} move.
766
767 @item There is no special castling move.  There @emph{are} a large
768 number of possible defensive formations referred to as ``castles''
769 (@pxref{Sample game}) but there is no need for special moves to create
770 them.
771
772 @item A given piece can only promote to @emph{one} other kind of piece.
773
774 @end enumerate
775
776 @c 
777 @c Sample game.
778 @c 
779
780 @node    Sample game, Mating problems, The rules of shogi, About shogi
781 @section Sample game
782 @cindex  Sample game
783
784 @c This will have to be spruced up for the TeX version...
785
786 This game was annotated by Pieter Stouten (@pxref{References and
787 links}).  I have made some minor corrections.  Note that captures are
788 denoted by the ``x'' symbol e.g. Rx3f and drops are denoted by the ``*''
789 symbol e.g. R*3f.  Check is indicated by a ``+'' after the move,
790 e.g. R3f+.  I recommend you use a graphical interface to play along with this
791 game.  In xshogi simply hit the ``Force Moves'' button after starting
792 up, while in gnushogi enter the word ``force'' at the prompt.  This will
793 allow you to enter moves for both sides.
794
795 Note also that the move numbering system used here is the chess-type
796 system where one move means one move by each player.  The Japanese count
797 one move made by each player as two moves.
798
799 ---------------------------------------------------------------------------
800
801 Below you will find (the English translation of) an annotated game which
802 was published in the Dutch Shogi magazine ``81'' and in the Dutch
803 beginners booklet.  It has proven to be a very useful game to explain
804 some basic principles of Shogi.  Also, it is a rather straightforward
805 game compared to professional games where in most cases very diffuse
806 middle game fights take place.
807
808    Pieter Stouten, 14th May 1990.
809
810 ---------------------------------------------------------------------------
811
812 Black: Michael Trent (1-dan).  White: David Murphy (2-dan).
813
814    1. P2f P3d  2. P2e B3c @*
815 [ This move is necessary, as otherwise white can exchange pawns: 3. P2d
816 Px2d 4. Rx2d.  He would thus get a pawn in hand and open up his rook
817 file. ]
818
819    3. P7f P4d @*
820 [ White closes the bishop diagonal again.  He plans to play ranging rook
821 (the rook goes to 5b, 4b, 3 or 2b; a defensive strategy) and in that
822 case he'd better avoid an exchange of bishops.  One of the reasons is
823 that he will have problems developing his pieces without leaving holes
824 for bishop drops. ]
825
826    4. S4h R3b  5. P3f S4b  6. K6h K6b @*
827 [ In general the rook plays an important role in the attacks.  It is
828 wise to move the king away from the area where the initial fights will
829 be and both players act according to the Shogi proverb ``keep the rook
830 and king apart''. ]
831
832    7. K7h K7b  8. P5f P5d  9. G4i-5h G4a-5b @*
833 [ Both players use their second gold general to build their castle. ]
834
835    10. S6h @*
836 [ In itself this move is not bad.  However, it will become clear that
837 black plans a quick attack and in that case it is wiser to omit this
838 move. ]
839
840    10... S5c  11. P1f P1d @*
841 [ The advance of the edge pawns must be timed very well.  The remark at
842 black's tenth move applies here too: this move is good if black wants to
843 play a slow game, because it eliminates a future B1e. ]
844
845    12. P4f K8b  13. N3g S7b @*
846 [ Black develops his knight in order to start an attack over the second,
847 third and fourth files.  White strengthens his king's position and
848 awaits the attack.  He aims at a counterattack as soon as black has
849 broken through into the white camp.  Probably white's breakthrough will
850 take place later, but he has good compensation in the form of a stronger
851 castle.  This theme occurs very often in static rook versus ranging rook
852 games. ]
853
854    14. P4e R4b @*
855 [ Black starts his attack and white puts up a very passive defence.  His
856 rook has a hard task now to penetrate the black position.  Moreover, he
857 blocks his own bishop.  It seems much better to start a counterattack
858 with 14... P3e, later to be followed by B2b, B5a or Bx4d in order to use
859 his rook more actively. ]
860
861    15. Px4d Sx4d  16. P*4e S5c @*
862 [ 16... Sx4e is more active.  A silver general is normally more valuable
863 than a knight, but white gets two pawns in hand and black none, while
864 the knight might come in handy for white too. ]
865
866    17. Bx3c+ Nx3c  18. P2d Px2d @*
867 [ Black threatens to break through and white has to consider taking the
868 pawn on 2d or starting a counterattack with Nx4e.  If he chooses the
869 latter, black can play Px2c+ followed by +P3c.  The disadvantage is the
870 black ``tokin'' (=promoted pawn) that white will get in his camp; the
871 advantage is that it will cost black two more moves to promote his rook.
872 Because white did not trust that the result after engaging in a
873 ``semeai'' (=mutual attack) with 18...Nx4e would give a positive result,
874 he captured the pawn on 2d.  Making the right decision in moments like
875 this often makes the difference between a win and a loss: miss one
876 attacking chance and you will be forced to defend the whole game until
877 the unavoidable defeat; on the other hand, an unsound attack can destroy
878 all ``aji'' (=potential, meaning possibilities, threats) without getting
879 anything in return. ]
880
881    19. Rx2d Nx4e  20. Nx4e Rx4e  21. R2a+ P*4g @*
882 [ Now it becomes clear why black's 10. S6h was not good.  Had this move
883 been omitted, then white would not have had the time to play 13... S7b
884 and after R2a+ the gold on 6a would hang.  Thus black would have kept
885 ``sente'' (=initiative).  Instead of 21... P*4g, B*6d is a very good
886 move, because after 22. P*2h black does not have a pawn in hand anymore
887 and he is being threatened with the annoying 22... N*4f 23. G5g N3h+
888 24. S4g +N4h also.  Black can also counter 21... B*6d with 22. N*3g.
889 White would then reply with 22... R4b 23. B*3c P*4g 24. Bx4b+ Sx4b.  The
890 white rook has played its role and instead of spending moves on saving
891 it white starts to scatter black's defences by successive pawn drops on
892 the fourth file: 25. Gx4g P*4f 26. G5g N*6e 27. G5h P4g+ 28. Gx4g P*4f.
893 This analysis was provided by Kato Hifumi, 9-dan professional (the
894 highest regular grade).  Destroying the coherence of the enemy pieces
895 (their shape) by dropping pawns is one of the most important Shogi
896 techniques.  With the actual move 21... P*4g white missed a good
897 chance. ]
898
899    22. Sx4g P*4f  23. B*3g Px4g+  24. +Rx6a +Px3g @*
900 [ 23. B*3g seems pointless, but a closer look reveals that it is
901 actually quite mean.  On move 24 white cannot capture black's ``Ryu''
902 (=dragon =promoted rook) with his silver: 24... Sx6a 25. N*7d K7b
903 26. G*8b mate.  By attacking the front of the white castle and
904 threatening to mate him there, black has the chance to break down the
905 white defences from the side. ]
906
907    25. +Rx5b S*6b @*
908 [ Here 25... B*4d would be much better, because it is defensive and
909 attacking at the same time.  After e.g. 26. G*4c Bx9i+ 27. Gx5c black
910 threatens 28. +Rx7b Kx7b 29. S*6a K8b 30. S*7a Kx7a 31. G*7b mate.
911 White is one move quicker, however.  He has the following beautiful
912 ``tsume'' (mating sequence where every move is check): 27... N*8f 28. Px8f
913 S*8g 29. Kx8g B*9h 30. K7h Bx8i+ 31. K8g +B8i-8h 32. K9f L*9e mate.
914 This illustrates the sharpness of Shogi: one move can make the
915 difference between winning and losing. ]
916
917    26. P*4f Rx4f @*
918 [ This move eliminates white's last chances.  26... R4b 27. +Rx4b Sx4b
919 28. R*4a seems annoying, but after 28... B*3c 29. S7g B*3b white wins
920 the rook and with his ``tokin'' on 3g there still is some hope. ]
921
922    27. N*6e +P4g @*
923 [ White cannot defend anymore, so he starts a desperate attack.  Black
924 does not lose the right track, however. ]
925
926    28. Nx5c+ +Px5h  29. +Nx6b +Px6h  30. Gx6h N*8f  31. Px8f B*6i  32. Gx6i
927    R4h+  33. N*6h +Rx6h  34. Gx6h S*8g  35. Kx8g N*9e  36. K7h Resigns @*
928 [ White resigns here, because after 36... B*8g 27. K7g his attack has
929 petered out. ]
930
931 @page
932
933
934 @c 
935 @c Mating problems.
936 @c 
937
938 @node    Mating problems, Shogi variants, Sample game, About shogi
939 @section Mating problems
940
941 One good way to improve at shogi is to solve mating problems.  There are
942 several types of these problems, but the most common is called a
943 ``tsume-shogi'' problem, or ``tsume'' problem for short.  In a tsume
944 problem, all pieces that are not on the board are assumed to be in the
945 opponent's hand (except for your King, which is usually not shown).
946 Every move you make must be check until the final checkmate.  Your
947 opponent may play any piece on the board or drop any of his pieces in
948 hand in order to prevent the mate.  In a properly constructed tsume
949 problem, all of your pieces on the board and in hand must be essential
950 to the solution.  One consequence of this is that all of your pieces in
951 hand must be played during the solution.  There should only be one
952 correct solution for the given number of moves.  Tsume problems use
953 Japanese-style move numbering; thus, a problem where you move (and give
954 check), your opponent moves, and you move to give checkmate is called a
955 three-mover.  Here is a really trivial three-mover:
956
957 @ifnottex
958 @verbatim
959    3    2    1
960 ----------------+
961  |    |    |    |  a
962 ----------------+
963  |    |    | wK |  b
964 ----------------+
965  |    |    |    |  c
966 ----------------+
967  | bN |    |    |  d
968 ----------------+
969  |    |    |    |  e
970 ----------------+
971  |    | bN |    |  f
972 ----------------+
973
974 Black in hand: S, G
975 @end verbatim
976 @end ifnottex
977
978
979 @tex
980 \def\startline{\par\nobreak\noindent}
981
982 {\obeylines\obeyspaces%
983 \gdef\beginVerbatim{\bigbreak%
984 \begingroup%
985 \parskip=0pt%
986 \obeylines\obeyspaces%
987 \let^^M=\startline%
988 \tt}}
989 \gdef\endVerbatim{\endgroup\bigbreak}
990 \beginVerbatim
991
992    3    2    1            
993 ----------------+         
994  |    |    |    |  a         
995 ----------------+           
996  |    |    | wK |  b         
997 ----------------+           
998  |    |    |    |  c       
999 ----------------+         
1000  | bN |    |    |  d       
1001 ----------------+         
1002  |    |    |    |  e       
1003 ----------------+         
1004  |    | bN |    |  f       
1005 ----------------+
1006      
1007 Black in hand: 2G
1008
1009 \endVerbatim
1010 @end tex
1011
1012 Here, Black plays G*2b, White plays K1c, and Black plays G*1d mate.
1013 More typical tsume problems range from 5 moves to arbitrarily high
1014 numbers of moves, and they can be quite brain-busting.  Tsume problems
1015 may seem artificial, but in the closing stages of the game where both
1016 players have a lot of pieces in hand, it is often necessary to give
1017 check at every move, or else your opponent will start a counterattack
1018 and will mate you before you mate him.  A tsume problem is a worst-case
1019 scenario for the attacker: you have to mate your opponent even though he
1020 has every piece not on the board in hand, which means you have to
1021 develop sharp attacking skills.  Many more tsume problems can be found
1022 on the internet; I particularly recommend Patrick Davin's ``Shogi
1023 Nexus'' (@pxref{References and links}).
1024
1025 @page
1026
1027 @c 
1028 @c Shogi variants.
1029 @c 
1030
1031 @node    Shogi variants, Differences between shogi and chess, Mating problems, About shogi
1032 @section Shogi variants
1033 @cindex  Shogi variants
1034 @cindex  Variants
1035 @cindex  Tori Shogi
1036 @cindex  Wa Shogi
1037 @cindex  Chu Shogi
1038 @cindex  Dai Shogi
1039 @cindex  Tenjiku Shogi
1040 @cindex  Dai-dai Shogi
1041 @cindex  Maka-dai-dai Shogi
1042 @cindex  Tai Shogi
1043 @cindex  Kyoku Tai Shogi
1044
1045 Several historical variants of shogi exist.  Most of these were invented
1046 before modern shogi (in some cases hundreds of years before), are much
1047 larger than modern shogi and are not played with drops.  Thus, in many
1048 ways they are really more like giant chess games than like modern shogi.
1049 The only one of these games to have survived in Japan is Chu (middle)
1050 shogi, which is still played a little bit.  Thanks to the efforts of
1051 George Hodges and John Fairbairn of the Shogi Association (two British
1052 shogi enthusiasts), these games were resurrected and rules and sets for
1053 them can still be purchased from George Hodges (@pxref{References and
1054 links}).  I hope to eventually extend GNU shogi so that it can play at
1055 least some of these games.  There are also several non-historical
1056 variants of shogi; I don't know much about them but you can find
1057 information about them on the internet (@pxref{References and links}).
1058
1059 The historical variants include:
1060
1061 @enumerate
1062
1063 @item
1064 Tori (bird) shogi, played on a 7x7 board with 32 pieces in all; this is
1065 the only variant that is known to have been played with drops.
1066
1067 @item
1068 Wa shogi, played on an 11x11 board with 54 pieces.  This game can be
1069 played with or without drops but the historical evidence favors the view
1070 that it was played without drops.  However, most people who have tried
1071 it claim it is a much better game with drops, being even more intricate
1072 than standard shogi.
1073
1074 @item
1075 Chu (middle) shogi, played on a 12x12 board with 92 pieces.  This was
1076 (and is) by far the most popular of the variants, and has 21 different
1077 kinds of pieces in the starting line-up alone (along with several others
1078 that appear upon promotion).  Unlike modern shogi, there are a
1079 tremendous number of ranging pieces and the game is definitely not
1080 played with drops.  There is also an amazing piece called the Lion which
1081 has a double king move and can capture two pieces at once!  Chu shogi
1082 has a small but fanatical following, some of whom consider it better
1083 than modern shogi.
1084
1085 @item
1086 Dai (great) shogi, played on a 15x15 board with 130 pieces.  Other than
1087 the larger board, this game is very similar to Chu shogi.
1088
1089 @item
1090 Tenjiku (exotic) shogi, played on a 16x16 board with 176 pieces.  This
1091 game is possibly the most complex tactical game in existence.  There are
1092 many astoundingly powerful pieces, including one (the Fire Demon) that
1093 can capture up to eight opposing pieces in a single move!  Despite the
1094 size of the game, checkmates can occur very suddenly (and often very
1095 early on) if one player makes a wrong move.  Tenjiku also has a small
1096 but fanatical following, one of whom (Colin Adams) has written a book on
1097 the game which is available for download at
1098 @uref{http://wayback.archive.org/web/20120717085827/http://www.colina.demon.co.uk/tenjiku.html}.
1099
1100 @item
1101 Dai-dai (great-great) shogi, played on a 17x17 board with 192 pieces.
1102 The opening setup alone has 64 different kinds of pieces!  This game and
1103 the larger ones that follow sound pretty outlandish, but they have
1104 actually been played; a game of Dai-dai can supposedly be played in
1105 about 12 hours.
1106
1107 @item
1108 Maka-dai-dai (great-great-great) shogi, played on a 19x19 board with 192
1109 pieces.  For those for whom Dai-dai shogi is just too small :-)
1110
1111 @item
1112 Tai (grand) shogi, played on a 25x25 board with 354 pieces!  Until
1113 recently, this was thought to be the biggest chess game ever devised,
1114 but now there is...
1115
1116 @item
1117 Kyoku tai (extremely grand?) shogi, played on a 36x36 board with 402
1118 pieces.  The rules for this have just been unearthed in an old Japanese
1119 book.  Hopefully someone will soon organize a postal Kyoku tai shogi
1120 championship; maybe their distant ancestors could finish it :-)
1121
1122 It is thought that the really huge games (Dai-dai and up) were never
1123 really played to any significant extent (gee, wonder why?) and were
1124 devised merely so that the creators could have the fun of inventing
1125 enormous games, amazing their friends and confounding their enemies.
1126 However, the games up to Tenjiku shogi at least appear to be quite
1127 playable, assuming one has the time.
1128
1129 @end enumerate
1130
1131 Many modern variants have also been devised, usually on small boards,
1132 and often by western people.  Those include:
1133
1134 @enumerate
1135
1136 @item
1137 Mini Shogi, played on a 5x5 board with 12 pieces.  Its rules are
1138 nearly identical to Standard Shogi, and GNU Shogi has some support for
1139 it.
1140
1141 @item
1142 Judkins Shogi, similar to Mini Shogi on a 6x6 board.
1143
1144 @item
1145 Cannon Shogi, played on a 9x9 board, adds pieces inspired by the
1146 Cannon found in Xiang Qi (chinese chess)
1147
1148 @item
1149 Sannin Shogi, a 3-player variant on an hexagonal board, with specific
1150 rules governing alliance between two players
1151
1152 @item
1153 Kyoto Shogi, Micro Shogi, and several others are much more different.
1154
1155 @end enumerate
1156
1157 @c
1158 @c Differences between shogi and chess.
1159 @c
1160
1161 @node    Differences between shogi and chess,  ,  Shogi variants, About shogi
1162 @section Differences between shogi and chess
1163 @cindex  Shogi vs. Chess
1164
1165 Some differences between shogi and international chess have been
1166 mentioned elsewhere in this document; I summarize them here for people
1167 who are interested in game comparisons.  I won't try to deal with the
1168 thorny question of which game is ``better'' although my bias may have
1169 already come through :-) In fact, the drop rule makes the two games so
1170 different in character that arguing over which game is better is like
1171 comparing apples to oranges (you'd be better off comparing chess to Chu
1172 shogi (@pxref{Shogi variants}).  However, I believe that if you are a
1173 chess fan you'll really like shogi as well, and shogi is also popular
1174 with many people who don't particularly like chess.
1175
1176 Here are the significant differences between chess and shogi:
1177
1178 @enumerate
1179
1180 @item
1181 In shogi, captured pieces become the property of the capturer and can
1182 re-enter play by being dropped onto almost any vacant square.  In chess,
1183 captured pieces are out of the game.  Thus, in shogi, piece exchanges
1184 complicate the play significantly while in chess they simplify it.
1185
1186 @item
1187 The shogi board is 9x9; the chess board is 8x8.
1188
1189 @item
1190 Shogi has five pieces with no counterpart in chess: the gold and silver
1191 generals, the lance, the promoted rook and the promoted bishop.  Chess
1192 has one piece with no counterpart in shogi: the queen.  The knight's
1193 move in shogi is much more restrictive than in chess.  Pieces in shogi
1194 generally have a much smaller range of movement than in chess (unless
1195 they are in hand).
1196
1197 @item
1198 In shogi, all pieces except the gold general and the king can promote,
1199 but only to one kind of piece.  Promotion is easier in shogi because the
1200 promotion zone is closer to the starting position of the pieces
1201 (especially pawns).  In chess, only the pawn can promote, but it can
1202 promote to any other piece except the king.
1203
1204 @item
1205 In shogi, pawns capture the same way they move.  There is no initial
1206 two-space pawn move and hence no @emph{en-passant} captures.  In chess,
1207 pawns capture diagonally which means that opposing pawns can block each
1208 other.
1209
1210 @item
1211 In shogi, you only have one rook and one bishop.  Note that the bishop
1212 is not restricted to only one ``color'' square (squares in shogi aren't
1213 colored, but never mind) because promoted bishops can also move one
1214 square orthogonally.
1215
1216 @item
1217 There is no special castling move in shogi.  The term ``castle'' is
1218 used in shogi to denote a defensive formation consisting of (usually)
1219 three generals which protect the king.  There are many such castles
1220 (about 40 or so have names).  @xref{Sample game}.
1221
1222 @item
1223 Draws are much rarer in shogi than in chess.  Perpetual check is not
1224 allowed.  Stalemate is a virtual impossibility, and is a loss for the
1225 stalematee. 
1226
1227 @item
1228 Since pieces are never out of play in shogi, chess-type endgames
1229 involving only a few pieces do not occur.
1230
1231 @item
1232 Shogi games are generally longer than chess games (about 60-70 moves is
1233 typical).
1234
1235 @item
1236 Shogi has a well-developed handicap system which is in general use;
1237 chess does not.
1238
1239 @end enumerate
1240
1241 The effects of all these differences on play include (in my opinion):
1242
1243 @enumerate
1244
1245 @item
1246 Piece/pawn structures in chess are more rigid than in shogi.  Pawns
1247 block each other and pawns, once advanced, cannot ever retreat.  In
1248 shogi, you can repair the hole caused by a pawn advance by exchanging
1249 the pawn and dropping it back where you want it.  Thus shogi is more
1250 fluid than chess and less ``structural''.
1251
1252 @item
1253 Counterattack is MUCH more common in shogi than in chess.  Games
1254 typically end in mutual mating attacks, where each player is trying to
1255 checkmate the other player before being checkmated himself.  This makes
1256 tempo incredibly important and also makes sacrificial play quite common.
1257
1258 @item
1259 Attacks involving only ranging pieces are more a feature of chess than
1260 of shogi.  A shogi attack typically uses a ranging piece or pieces to
1261 support an attack by short-range pieces (especially generals).  It is
1262 very rare to mate a king with a non-adjacent ranging piece in shogi
1263 since the player whose king is threatened can almost always interpose by
1264 dropping a piece.
1265
1266 @end enumerate
1267
1268
1269 @c --------------------
1270 @c gnushogi.
1271 @c --------------------
1272
1273 @node    gnushogi, References and links, About shogi, Top
1274 @chapter gnushogi
1275 @cindex  gnushogi
1276
1277 This section describes how to run the ``gnushogi'' program.
1278
1279 SYNOPSIS
1280      
1281 gnushogi [ [[-]a] [-b bookfile] [-B binbookfile] [-C] [-h langfile] 
1282 [-L langfile] [-r length] [-R] [-s pathname] [-l pathname] [-S binbooksize]
1283 [-t] [-c size] [-T size] [-v] [-x] [-X] arg1 arg2 ]
1284
1285 DESCRIPTION
1286
1287 GNU shogi (gnushogi) plays a game of japanese chess (shogi) against the
1288 user or it plays against itself.
1289
1290 At startup gnushogi reads the binbook file if it is present.  It then
1291 looks for a book file.  If it is present it adds its contents to the
1292 binbook data.  If the binbook file is writable a new combined binbook
1293 file is written.
1294
1295 Gnushogi is a modified version of the gnuchess program.  It has a simple
1296 alphanumeric board display, or it can be used with the xshogi program
1297 under X windows.  The program gets its opening moves from the file
1298 gnushogi.bbk which is located in a directory specified in the Makefile.
1299 To invoke the program type:
1300
1301 @table @samp
1302
1303 @item  gnushogi -C
1304 simple curses based version
1305
1306 @item  gnushogi -X (or just gnushogi)
1307 xshogi compatible version
1308
1309 @item gnushogi -R
1310 raw test display version
1311 @end table
1312
1313 TIME CONTROLS
1314
1315 If one argument is given, it is the search time per move in
1316 [minutes:]seconds.  So gnushogi 30 will generate one move every 30
1317 seconds, while gnushogi 5:00 will generate one move every 5 minutes.
1318
1319 If two or more arguments are given, they will be used to set tournament
1320 time controls with the first argument of each pair being the number of
1321 moves and the second being the total clock time in minutes[:seconds].
1322 Thus, entering gnushogi 60 5 will set the clocks for 5 minutes (300
1323 seconds) for the first 60 moves, and gnushogi 30 3:30 will allow 3
1324 minutes and 30 seconds for 30 moves.
1325
1326 gnushogi 30 5 1 :30 will allow 5 minutes for the first 30 moves and 30
1327 seconds for each move after that.  Up to 4 pairs of controls may be
1328 specified.
1329
1330 If no argument is given the program will prompt the user for level of
1331 play.
1332
1333 @page
1334
1335 BOOK
1336
1337 The book gnushogi.tbk consists of a sequence of openings.  An opening
1338 begins with a line starting with a # (the rest of the line is a comment).
1339 Following this is a series of moves in algebraic notation alternating
1340 between black and white separated by whitespace.  A move may have a ?
1341 after it indicating this move should never be made in this position.  Moves
1342 are stored as position:move so transpositions between openings can take
1343 place.
1344
1345 HASHFILE
1346
1347 The hashfile if created should be on the order of 4 megabytes; you can
1348 create such a hashfile by typing ``gnushogi -c 22'' (see below).  This
1349 file contains positions and moves learned from previous games.  If a
1350 hashfile is used the computer makes use of the experience it gained in
1351 past games.  Tests run so far show that it plays no worse with the
1352 hashfile than without, but it is not clear yet whether it provides a
1353 real advantage.
1354
1355 LEGAL MOVES
1356
1357 Note: Piece letters are determined by the language file.  What is
1358 specified here is the default (English).
1359
1360 Once gnushogi is invoked, the program will display the board and prompt
1361 the user for a move.  To enter a move, use the notation 7g7f where the
1362 first letter-number pair indicates the origin square and the second
1363 letter-number pair indicates the destination square.  An alternative is
1364 to use the notation P7f where the first letter indicates the piece type
1365 (P,L,N,S,G,B,R,K).  To promote append a + the type of the new piece to
1366 the move, as in 2d2c+ or P2c+. Note that you must use capital letters
1367 for the pieces by default.
1368
1369 COMMAND-LINE OPTIONS
1370
1371 @table @samp
1372
1373 @item -a
1374 Do not search on opponent's time.
1375
1376 @item a
1377 Do search on opponent's time.
1378
1379 @item -b @var{bookfile}
1380 Use bookfile for opening book.
1381
1382 @item -B @var{binbookfile}
1383 Use binbookfile for binary opening book.
1384
1385 @item -c @var{size}          
1386 Create a new HASHFILE.  File size is 2^size entries of approximately 65+?
1387 bytes.
1388
1389 @item -C
1390 Use curses-based display mode.
1391
1392 @item -h   
1393 Do not use hashfile.
1394
1395 @item h    
1396 Do use hashfile.
1397
1398 @item -l @var{pathname}
1399 Pathname of the loadfile used with get or xget.
1400
1401 @item -L @var{lang}
1402 Use language lang from the file gnushogi.lang.  If -L is not specified
1403 it uses the first language in the file.
1404
1405 @item  -P @var{plylevels}
1406 Number of plys to include in the binbookfile.  For generating a
1407 binbookfile.
1408
1409 @item  -r @var{length}
1410 Rehash @emph{length} times in searching entries for position in
1411 transposition table.
1412
1413 @item  -R  
1414 Use raw text display mode.  This can be used for dumb terminals or for
1415 systems that don't have curses.
1416
1417 @item  -s @var{pathname}
1418 Pathname of the save file to use with the save command.
1419
1420 @item  -S @var{size}
1421 Size of binbookfile for memory based books.  For creating a binbookfile.
1422
1423 @item  -t   
1424 Show statistics for HASHFILE.
1425
1426 @item  -T @var{size}
1427 Set the transposition table size to 2^size entries.
1428
1429 @item  -v   
1430 Show version and patchlevel.
1431
1432 @item  -x @var{value}
1433 Use value as the evaluation window xwndw.
1434
1435 @item  -X   
1436 Use xshogi display mode (the default).
1437
1438 @end table
1439
1440
1441 COMMANDS
1442
1443 In addition to legal moves, the following commands can be entered at the
1444 gnushogi prompt.  Note: command names are determined by the language
1445 file and may vary with the implementation.  The default language is
1446 English.
1447
1448 @table @samp
1449
1450 @item alg
1451 allow algebraic input (not implemented).
1452
1453 @item Awindow 
1454 change Alpha window (default score + 90).
1455
1456 @item Bwindow 
1457 change Beta window (default score - 90).
1458
1459 @item beep 
1460 toggles beeping after each move (default: on).
1461
1462 @item bd 
1463 updates the current board position on the display.
1464
1465 @item book 
1466 turns off use of the opening library.
1467
1468 @item both 
1469 causes the computer to play both sides of a shogi game.
1470
1471 @item black 
1472 causes the computer to play as White, if the computer was to move
1473 first.
1474
1475 @item bsave 
1476 saves a game to disk as a book textfile.  The program will prompt the
1477 user for a file name.
1478
1479 @item gamein 
1480 toggles game mode time control.  Assumes the time specified for time
1481 control is the time for a complete game.  Input with the level command
1482 should be the game time and the expected number of moves in a game.  go
1483 command must be given.
1484
1485 @item coords 
1486 show coordinates on the display (visual only).
1487
1488 @item contempt 
1489 allows the value of @emph{contempt} to be modified.
1490
1491 @item debug 
1492 asks for a piece as color piece, as wb or bn, and shows its calculated
1493 value on each square.
1494
1495 @item debuglevel 
1496 sets level of debugging output if compiled with debug options.
1497
1498 @item depth 
1499 allows the user to change the search depth of the program.  The maximum
1500 depth is 29 ply.  Normally the depth is set to 29 and the computer
1501 terminates its search based on elapsed time rather than depth.  If depth
1502 is set to (say) 4 ply, the program will search until all moves have been
1503 examined to a depth of 4 ply (with extensions up to 11 additional ply
1504 for sequences of checks and captures).  If you set a maximum time per
1505 move and also use the depth command, the search will stop at the
1506 specified time or the specified depth, whichever comes first.
1507
1508 @item easy 
1509 toggles easy mode (thinking on opponents time) on and off. The default
1510 is easy mode ON.  If easy mode is disabled, the keyboard is polled for
1511 input every so often and when input is seen the search is terminated. It
1512 may also be terminated with a sigint.
1513
1514 @item edit 
1515 allows the user to set up a board position.
1516 @itemize @minus
1517
1518 @item #    
1519 clear the board.
1520
1521 @item c
1522 toggle piece color.
1523
1524 @item .
1525 command will exit setup mode.
1526
1527 @item p3b
1528 place a pawn on 3b
1529
1530 @item p3b+
1531 place a promoted pawn on 3b
1532
1533 @item p*
1534 place a pawn in hand (among the captured pieces)
1535
1536 @end itemize
1537
1538 Pieces are entered by typing a letter (p,l,n,s,g,b,r,k)  for
1539 the piece followed by the coordinate.  Here, letter case is ignored.
1540
1541 The usual warning about the language file applies.
1542
1543 @item exit 
1544 exits gnushogi.
1545
1546 @item first 
1547 tells the computer to move first.  Computer begins searching for a move.
1548 (same as ``go'').
1549
1550 @item force 
1551 allows the user to enter moves for both sides.  To get the program to
1552 play after a sequence of moves has been entered use the ``black'' or
1553 ``white'' commands.
1554
1555 @item get 
1556 retrieves a game from disk.  The program will prompt the user for a file
1557 name.
1558
1559 @item go 
1560 tells the computer to move first.  Computer begins searching for a move.
1561 (same as ``first'').
1562
1563 @item hash 
1564 use/don't use hashfile.
1565
1566 @item hashdepth 
1567 allows the user to change the minimum depth for using the hashfile and
1568 the number of moves from the beginning of the game to use it.
1569
1570 @item help 
1571 displays a short description of the commands and the current status of
1572 options.
1573
1574 @item hint 
1575 causes the program to supply the user with its predicted move.
1576
1577 @item level 
1578 allows the user to set time controls such as 60 moves in 5 minutes etc.
1579 In tournament mode, the program will vary the time it takes for each
1580 move depending on the situation.  If easy mode is disabled (using the
1581 ``easy'' command), the program will often respond with its move
1582 immediately, saving time on its clock for use later on.
1583
1584 @item list 
1585 writes the game moves and some statistics on search depth, nodes, and
1586 time to the file ``shogi.lst''.
1587
1588 @item material 
1589 toggle material flag - draws on no pawns and both sides < rook.
1590
1591 @item new 
1592 starts a new game.
1593
1594 @item p 
1595 evaluates the board and shows the point score for each piece.  The total
1596 score for a position is the sum of these individual piece scores.
1597
1598 @item post 
1599 causes the program to display the principal variation and the score
1600 during the search.  A score of 100 is equivalent to a 1 pawn advantage
1601 for the computer.
1602
1603 @item quit 
1604 exits the game.
1605
1606 @item random 
1607 causes the program to randomize its move selection slightly.
1608
1609 @item rcptr 
1610 set recapture mode.
1611
1612 @item remove 
1613 backout the last level for both sides.  Equal to 2 undo's.
1614
1615 @item reverse 
1616 causes the board display to be reversed.  That is, the Black's pieces will
1617 now appear at the top of the board.
1618
1619 @item rv 
1620 reverse board display.
1621
1622 @item save 
1623 saves a game to disk.  The program will prompt the user for a file name.
1624
1625 @item switch 
1626 causes the program to switch places with the opponent and begin
1627 searching.
1628
1629 @item test 
1630 performs some speed tests for MoveList and CaptureList generation, and
1631 ScorePosition position scoring for the current board.
1632
1633 @item time 
1634 set computer's time remaining, intended for synchronizing clocks among
1635 multiple players.
1636
1637 @item tsume 
1638 toggle tsume mode. In tsume mode, not all possible moves will be
1639 generated. If a king is in check, only moves that get the king out of
1640 check are generated.  If the king is not in check, only moves that give
1641 check to the opponent's king are generated.
1642
1643 @item undo 
1644 undoes the last move whether it was the computer's or the human's.  You
1645 may also type ``remove''.  This is equivalent to two ``undo'''s
1646 (e.g. retract one move for each side).
1647
1648 @item white 
1649 causes the computer to play as Black; if the computer is to move
1650 first the go command must be given.
1651
1652 @item xget 
1653 read an xshogi position file.
1654
1655 @item xsave 
1656 save as an xshogi position file.
1657
1658 @item xwndw 
1659 change X window. The window around alpha/beta used to determine whether
1660 the position should be scored or just estimated.  Note: this has
1661 @emph{nothing} to do with xshogi or X windows; the terms are completely
1662 separate.
1663
1664 @end table
1665
1666
1667 @c ---------------------
1668 @c References and links.
1669 @c ---------------------
1670
1671 @node    References and links, Acknowledgements, gnushogi, Top
1672 @chapter References and links
1673 @cindex  References
1674 @cindex  Books
1675 @cindex  Mailing lists
1676 @cindex  Web sites
1677
1678
1679 There are very few English-language books for people learning shogi.
1680 The two I recommend are:
1681
1682 @enumerate
1683
1684 @item
1685 @cite{Shogi for Beginners, 2nd. Edition}, by John Fairbairn.  This is a
1686 superb beginner's book in every way, covering all phases of the game.
1687 It was out of print for a long time, but has now been reprinted and is
1688 available either from Kiseido (@uref{http://www.labnet.or.jp/~kiseido})
1689 or from George Hodges (see below).
1690
1691 @item
1692 @cite{The Art of Shogi}, by Tony Hoskings.  This is one step up from the
1693 Fairbairn book.  It covers a lot of ground, and is especially noteworthy
1694 for its detailed treatment of opening lines.  You can order this book
1695 from Amazon.com's UK branch (@uref{http://www.amazon.co.uk}).
1696
1697 @end enumerate
1698
1699 Another book you may find is @cite{Shogi: Japan's Game of Strategy} by
1700 Trevor Leggett.  This book is very elementary and is somewhat outdated,
1701 having been published first in 1966.  However, it does feature a paper
1702 shogi board and punch-out pieces, so if you want a really cheap shogi
1703 set you might pick this book up.  It is still in print.
1704
1705 Two books that are no longer in print but are definitely worth getting
1706 if you find them are @cite{Guide to Shogi Openings} and @cite{Better
1707 Moves for Better Shogi}, both by Aono Teriuchi.  They are published in a
1708 bilingual edition (English/Japanese) and are the only books on shogi in
1709 English written by a Japanese professional shogi player.  John Fairbairn
1710 did the translation from Japanese to English.
1711
1712 Shogi sets are available from:
1713
1714 @quotation
1715 George F. Hodges @*
1716 P.O. Box 77 @*
1717 Bromley, Kent @*
1718 United Kingdom BR1 2WT
1719 @end quotation
1720
1721 George also sells equipment for all the historical shogi variants
1722 (@pxref{Shogi variants}) (except for Kyoku tai shogi) and also sells
1723 back issues of the magazine ``Shogi'' which he published for 70 issues
1724 in the late 70's to late 80's.  This magazine is STRONGLY recommended;
1725 it contains more information about shogi in English than you will ever
1726 find anywhere else.
1727
1728 Here are some useful URLs:
1729
1730 @table @asis
1731
1732 @item Pieter Stouten's shogi page: @uref{http://www.shogi.net}
1733 This is the main shogi-related site on the internet, with links to
1734 almost all the other sites.
1735
1736 @item Roger Hare's shogi page: @uref{http://www.ed.ac.uk/~rjhare/shogi}
1737 This has lots of information, including full rules to most of the shogi
1738 variants.
1739
1740 @item Patrick Davin's Shogi Nexus: @uref{http://www.vega.or.jp/~patrick/shogi/}
1741 There's lots of cool stuff on this site; my favorite is the extensive
1742 collection of Tsume-shogi (mating) problems, both for beginners and
1743 more advanced players.
1744
1745 @item Steve Evans' shogi page: @uref{http://www.netspace.net.au/~trout/index.html} 
1746 Steve has written a program that plays almost all of the shogi variants,
1747 unfortunately it only runs on Windows :-(
1748
1749 @item Hans Bodlaender's chess variant pages: @uref{http://www.cs.ruu.nl/~hansb/d.chessvar}
1750 This page has an almost unimaginable variety of rules for different
1751 chess variants, including many shogi variants (historical and non-historical).
1752
1753 @item Wikipedia's shogi variant pages: @uref{http://en.wikipedia.org/wiki/Category:Shogi_variants}
1754 Those pages contain a large number of variant rules, both ancient and
1755 modern.
1756
1757 @end table
1758
1759 @c -----------------
1760 @c Acknowledgements.
1761 @c -----------------
1762
1763 @node    Acknowledgements, Bugs, References and links, Top
1764 @chapter Acknowledgements
1765 @cindex  Acknowledgements
1766
1767 I would like to thank the following people:
1768
1769 @itemize @bullet
1770
1771 @item
1772 Matthias Mutz, who originally developed GNU shogi as a spin-off of GNU
1773 chess and who very kindly let me take over the maintenance of this very
1774 interesting project.
1775
1776 @item
1777 Richard Stallman and the Free Software Foundation, for creating an
1778 organization where anyone can contribute software for the common good of
1779 all, for making GNU/Linux possible, and especially for writing emacs and
1780 gcc, without which my working life would be intolerable.
1781
1782 @item
1783 Georges Hodges, for starting the Shogi Association in England, without
1784 which I would probably never have heard of shogi, for supplying shogi
1785 equipment, for publishing the excellent magazine ``Shogi'' (now sadly
1786 defunct), for personally answering all my silly questions by mail, and
1787 for being the ambassador of shogi to the West.
1788
1789 @item
1790 Pieter Stouten, for having the most comprehensive shogi site on the
1791 World Wide Web (@uref{http://www.shogi.net}), and for
1792 maintaining the shogi-l mailing list.  Go to Pieter's web site for more
1793 information on subscribing to the list.  Also thanks to everyone who
1794 contributes and has contributed to that list.
1795
1796 @item
1797 Matt Casters, for testing GNU shogi.  Matt and I will be working
1798 together on improving the solution engine in future versions of this
1799 program.
1800
1801 @end itemize
1802
1803 @c -----
1804 @c Bugs.
1805 @c -----
1806
1807 @node    Bugs, Index, Acknowledgements, Top
1808 @chapter Bugs
1809
1810 The motto of GNU shogi is ``100% bug-free or you don't pay!'' :-) In
1811 the extremely unlikely case (*ahem*) that you do find a bug, please
1812 report it to the bug tracker at
1813 @uref{https://savannah.gnu.org/projects/gnushogi/}.  Also, feel free
1814 to post comments, complaints, out-and-out raves, suggestions and such
1815 to one of the mailing lists at
1816 @uref{https://savannah.gnu.org/mail/?group=gnushogi}.
1817
1818
1819 @c ============
1820 @c End of body.
1821 @c ============
1822
1823
1824
1825 @c ====
1826 @c End.
1827 @c ====
1828
1829 @node    Index,  , Bugs, Top
1830 @chapter Index
1831
1832 @printindex cp
1833
1834 @contents
1835
1836 @bye
1837
1838