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