From 8ae7e7d1b257ef36d8a9fd1cd88807954ef10764 Mon Sep 17 00:00:00 2001 From: Luis Felipe Strano Moraes Date: Tue, 13 Mar 2012 13:24:41 -0300 Subject: [PATCH] Updating to version 1.3, release made by Mike Vanier (mvanier@bbb.caltech.edu). --- CONTRIB | 26 + COPYING | 339 ++ ChangeLog | 59 + INSTALL | 77 + INSTALL.generic | 176 + Makefile.in | 108 + NEWS | 31 + README | 23 + README-1.2p03 | 19 - TRANS.TBL | 17 + config.h.in | 87 + configure | 3304 ++++++++++++ configure.in | 198 + doc/BOOKFILES | 56 +- doc/CHANGES | 50 - doc/CONTRIB | 4 - doc/COPYING | 339 -- doc/GENERAL | 56 - doc/INSTALL | 27 - doc/Makefile | 47 + doc/PORTING | 28 +- doc/README-FIRST | 17 - doc/TRANS.TBL | 41 + doc/gnushogi.1 | 432 -- doc/gnushogi.6 | 442 ++ doc/gnushogi.info | 55 + doc/gnushogi.info-1 | 1082 ++++ doc/gnushogi.info-2 | 1262 +++++ doc/gnushogi.ps | 4297 ++++++++++++++++ doc/gnushogi.texinfo | 2715 ++++++++++ doc/gnushogi_1.html | 61 + doc/gnushogi_10.html | 80 + doc/gnushogi_11.html | 126 + doc/gnushogi_12.html | 40 + doc/gnushogi_13.html | 210 + doc/gnushogi_14.html | 72 + doc/gnushogi_15.html | 129 + doc/gnushogi_16.html | 145 + doc/gnushogi_17.html | 534 ++ doc/gnushogi_18.html | 543 ++ doc/gnushogi_19.html | 121 + doc/gnushogi_2.html | 461 ++ doc/gnushogi_20.html | 64 + doc/gnushogi_21.html | 26 + doc/gnushogi_22.html | 142 + doc/gnushogi_3.html | 98 + doc/gnushogi_4.html | 46 + doc/gnushogi_5.html | 97 + doc/gnushogi_6.html | 57 + doc/gnushogi_7.html | 94 + doc/gnushogi_8.html | 79 + doc/gnushogi_9.html | 32 + doc/gnushogi_stoc.html | 37 + doc/gnushogi_toc.html | 50 + doc/listserv.ref | 18 +- doc/make_fig1 | 55 + doc/make_fig2 | 53 + doc/shogi.rules | 64 +- doc/texinfo.tex | 5868 ++++++++++++++++++++++ doc/tutorial1.gam | 22 +- doc/xshogi.6 | 616 +++ gnushogi/Makefile.in | 284 ++ gnushogi/TRANS.TBL | 30 + gnushogi/attacks.c | 254 + gnushogi/book.c | 1067 ++++ gnushogi/book.h | 64 + gnushogi/commondsp.c | 2181 ++++++++ gnushogi/cursesdsp.c | 1166 +++++ gnushogi/cursesdsp.h | 87 + gnushogi/debug.h | 70 + gnushogi/dspwrappers.c | 566 +++ gnushogi/dspwrappers.h | 70 + gnushogi/eval.c | 2730 ++++++++++ gnushogi/eval.h | 71 + gnushogi/genmove.c | 1654 ++++++ gnushogi/globals.c | 181 + gnushogi/gnushogi.h | 1081 ++++ gnushogi/init.c | 1347 +++++ gnushogi/main.c | 468 ++ gnushogi/makepattern.c | 297 ++ gnushogi/opts.h | 214 + gnushogi/pat2inc.c | 146 + gnushogi/pattern.c | 902 ++++ gnushogi/pattern.h | 115 + gnushogi/pattern.inc | 166 + gnushogi/rawdsp.c | 970 ++++ gnushogi/rawdsp.h | 79 + gnushogi/search.c | 1592 ++++++ gnushogi/sizetest.c | 299 ++ gnushogi/sysdeps.c | 346 ++ gnushogi/tcontrl.c | 349 ++ gnushogi/util.c | 575 +++ install-sh | 250 + misc/TRANS.TBL | 3 + misc/gnushogi.lng | 468 +- src/.LVS_ENV | 1 - src/Makefile | 456 -- src/ataks.c | 342 -- src/book.c | 931 ---- src/book.h | 60 - src/dspcom.c | 2147 -------- src/eval.c | 3128 ------------ src/eval.h | 59 - src/genmove.c | 1478 ------ src/globals.c | 176 - src/gnushogi.h | 1155 ----- src/init.c | 1146 ----- src/main.c | 372 -- src/nondsp.c | 831 ---- src/pat2inc.c | 129 - src/pattern.c | 1002 ---- src/pattern.h | 120 - src/pattern.inc | 166 - src/search.c | 1787 ------- src/sizetest.c | 293 -- src/tcontrl.c | 302 -- src/util.c | 605 --- src/uxdsp.c | 1050 ---- src/version.h | 10 - version.h | 41 + xshogi/BUGS | 7 + xshogi/Makefile.in | 149 + xshogi/NEWS | 117 + xshogi/README | 43 + xshogi/README.xboard | 96 + xshogi/REMOTEHOSTS | 15 + xshogi/TRANS.TBL | 15 + xshogi/bitmaps.h | 260 + xshogi/eastern_bitmaps/TRANS.TBL | 118 + xshogi/eastern_bitmaps/bigblank.xbm | 12 + xshogi/eastern_bitmaps/bigblankR.xbm | 12 + xshogi/eastern_bitmaps/biglight.xbm | 16 + xshogi/eastern_bitmaps/bigsolid.xbm | 12 + xshogi/eastern_bitmaps/bigsolidR.xbm | 12 + xshogi/eastern_bitmaps/bigsolidR_l.xbm | 38 + xshogi/eastern_bitmaps/bigsolidR_m.xbm | 26 + xshogi/eastern_bitmaps/bigsolid_l.xbm | 38 + xshogi/eastern_bitmaps/bigsolid_m.xbm | 26 + xshogi/eastern_bitmaps/bishop.xbm | 12 + xshogi/eastern_bitmaps/bishopP.top.xbm | 14 + xshogi/eastern_bitmaps/bishopP.xbm | 12 + xshogi/eastern_bitmaps/bishopPR.top.xbm | 16 + xshogi/eastern_bitmaps/bishopPR.xbm | 12 + xshogi/eastern_bitmaps/bishopPR_l.top.xbm | 46 + xshogi/eastern_bitmaps/bishopPR_l.xbm | 38 + xshogi/eastern_bitmaps/bishopPR_m.top.xbm | 32 + xshogi/eastern_bitmaps/bishopPR_m.xbm | 26 + xshogi/eastern_bitmaps/bishopP_l.top.xbm | 46 + xshogi/eastern_bitmaps/bishopP_l.xbm | 38 + xshogi/eastern_bitmaps/bishopP_m.top.xbm | 32 + xshogi/eastern_bitmaps/bishopP_m.xbm | 26 + xshogi/eastern_bitmaps/bishopR.xbm | 12 + xshogi/eastern_bitmaps/bishopR_l.xbm | 38 + xshogi/eastern_bitmaps/bishopR_m.xbm | 26 + xshogi/eastern_bitmaps/bishop_l.xbm | 38 + xshogi/eastern_bitmaps/bishop_m.xbm | 26 + xshogi/eastern_bitmaps/gold.xbm | 12 + xshogi/eastern_bitmaps/goldR.xbm | 12 + xshogi/eastern_bitmaps/goldR_l.xbm | 38 + xshogi/eastern_bitmaps/goldR_m.xbm | 26 + xshogi/eastern_bitmaps/gold_l.xbm | 38 + xshogi/eastern_bitmaps/gold_m.xbm | 26 + xshogi/eastern_bitmaps/icon.xbm | 14 + xshogi/eastern_bitmaps/king.xbm | 12 + xshogi/eastern_bitmaps/kingR.xbm | 12 + xshogi/eastern_bitmaps/kingR_l.xbm | 38 + xshogi/eastern_bitmaps/kingR_m.xbm | 26 + xshogi/eastern_bitmaps/king_l.xbm | 38 + xshogi/eastern_bitmaps/king_m.xbm | 26 + xshogi/eastern_bitmaps/knight.xbm | 12 + xshogi/eastern_bitmaps/knightP.xbm | 12 + xshogi/eastern_bitmaps/knightPR.xbm | 12 + xshogi/eastern_bitmaps/knightPR_l.xbm | 38 + xshogi/eastern_bitmaps/knightPR_m.xbm | 26 + xshogi/eastern_bitmaps/knightP_l.xbm | 38 + xshogi/eastern_bitmaps/knightP_m.xbm | 26 + xshogi/eastern_bitmaps/knightR.xbm | 12 + xshogi/eastern_bitmaps/knightR_l.xbm | 38 + xshogi/eastern_bitmaps/knightR_m.xbm | 26 + xshogi/eastern_bitmaps/knight_l.xbm | 38 + xshogi/eastern_bitmaps/knight_m.xbm | 26 + xshogi/eastern_bitmaps/lance.xbm | 12 + xshogi/eastern_bitmaps/lanceP.xbm | 12 + xshogi/eastern_bitmaps/lancePR.xbm | 12 + xshogi/eastern_bitmaps/lancePR_l.xbm | 38 + xshogi/eastern_bitmaps/lancePR_m.xbm | 26 + xshogi/eastern_bitmaps/lanceP_l.xbm | 38 + xshogi/eastern_bitmaps/lanceP_m.xbm | 26 + xshogi/eastern_bitmaps/lanceR.xbm | 12 + xshogi/eastern_bitmaps/lanceR_l.xbm | 38 + xshogi/eastern_bitmaps/lanceR_m.xbm | 26 + xshogi/eastern_bitmaps/lance_l.xbm | 38 + xshogi/eastern_bitmaps/lance_m.xbm | 26 + xshogi/eastern_bitmaps/none.xbm | 12 + xshogi/eastern_bitmaps/none_l.xbm | 38 + xshogi/eastern_bitmaps/none_m.xbm | 26 + xshogi/eastern_bitmaps/pawn.xbm | 12 + xshogi/eastern_bitmaps/pawnP.xbm | 12 + xshogi/eastern_bitmaps/pawnPR.xbm | 12 + xshogi/eastern_bitmaps/pawnPR_l.xbm | 38 + xshogi/eastern_bitmaps/pawnPR_m.xbm | 26 + xshogi/eastern_bitmaps/pawnP_l.xbm | 38 + xshogi/eastern_bitmaps/pawnP_m.xbm | 26 + xshogi/eastern_bitmaps/pawnR.xbm | 12 + xshogi/eastern_bitmaps/pawnR_l.xbm | 38 + xshogi/eastern_bitmaps/pawnR_m.xbm | 26 + xshogi/eastern_bitmaps/pawn_l.xbm | 38 + xshogi/eastern_bitmaps/pawn_m.xbm | 26 + xshogi/eastern_bitmaps/rook.xbm | 12 + xshogi/eastern_bitmaps/rookP.top.xbm | 14 + xshogi/eastern_bitmaps/rookP.xbm | 12 + xshogi/eastern_bitmaps/rookPR.top.xbm | 16 + xshogi/eastern_bitmaps/rookPR.xbm | 12 + xshogi/eastern_bitmaps/rookPR_l.top.xbm | 46 + xshogi/eastern_bitmaps/rookPR_l.xbm | 38 + xshogi/eastern_bitmaps/rookPR_m.top.xbm | 32 + xshogi/eastern_bitmaps/rookPR_m.xbm | 26 + xshogi/eastern_bitmaps/rookP_l.top.xbm | 46 + xshogi/eastern_bitmaps/rookP_l.xbm | 38 + xshogi/eastern_bitmaps/rookP_m.top.xbm | 32 + xshogi/eastern_bitmaps/rookP_m.xbm | 26 + xshogi/eastern_bitmaps/rookR.xbm | 12 + xshogi/eastern_bitmaps/rookR_l.xbm | 38 + xshogi/eastern_bitmaps/rookR_m.xbm | 26 + xshogi/eastern_bitmaps/rook_l.xbm | 38 + xshogi/eastern_bitmaps/rook_m.xbm | 26 + xshogi/eastern_bitmaps/silver.xbm | 12 + xshogi/eastern_bitmaps/silverP.xbm | 12 + xshogi/eastern_bitmaps/silverPR.xbm | 12 + xshogi/eastern_bitmaps/silverPR_l.xbm | 38 + xshogi/eastern_bitmaps/silverPR_m.xbm | 26 + xshogi/eastern_bitmaps/silverP_l.xbm | 38 + xshogi/eastern_bitmaps/silverP_m.xbm | 26 + xshogi/eastern_bitmaps/silverR.xbm | 12 + xshogi/eastern_bitmaps/silverR_l.xbm | 38 + xshogi/eastern_bitmaps/silverR_m.xbm | 26 + xshogi/eastern_bitmaps/silver_l.xbm | 38 + xshogi/eastern_bitmaps/silver_m.xbm | 26 + xshogi/eastern_bitmaps/smallblank.xbm | 12 + xshogi/eastern_bitmaps/smallblankR.xbm | 12 + xshogi/eastern_bitmaps/smalllight.xbm | 16 + xshogi/eastern_bitmaps/smallsolid.xbm | 12 + xshogi/eastern_bitmaps/smallsolidR.xbm | 12 + xshogi/eastern_bitmaps/smallsolidR_l.xbm | 38 + xshogi/eastern_bitmaps/smallsolidR_m.xbm | 26 + xshogi/eastern_bitmaps/smallsolid_l.xbm | 38 + xshogi/eastern_bitmaps/smallsolid_m.xbm | 26 + xshogi/parser.y | 212 + xshogi/scanner.l | 102 + xshogi/sysdeps.h | 94 + xshogi/western_bitmaps/TRANS.TBL | 29 + xshogi/western_bitmaps/bishopPRW.xbm | 14 + xshogi/western_bitmaps/bishopPW.xbm | 14 + xshogi/western_bitmaps/bishopRW.xbm | 14 + xshogi/western_bitmaps/bishopW.xbm | 14 + xshogi/western_bitmaps/goldRW.xbm | 14 + xshogi/western_bitmaps/goldW.xbm | 14 + xshogi/western_bitmaps/kingRW.xbm | 14 + xshogi/western_bitmaps/kingW.xbm | 14 + xshogi/western_bitmaps/knightPRW.xbm | 14 + xshogi/western_bitmaps/knightPW.xbm | 14 + xshogi/western_bitmaps/knightRW.xbm | 14 + xshogi/western_bitmaps/knightW.xbm | 14 + xshogi/western_bitmaps/lancePRW.xbm | 14 + xshogi/western_bitmaps/lancePW.xbm | 14 + xshogi/western_bitmaps/lanceRW.xbm | 14 + xshogi/western_bitmaps/lanceW.xbm | 14 + xshogi/western_bitmaps/noneW.xbm | 12 + xshogi/western_bitmaps/pawnPRW.xbm | 14 + xshogi/western_bitmaps/pawnPW.xbm | 14 + xshogi/western_bitmaps/pawnRW.xbm | 14 + xshogi/western_bitmaps/pawnW.xbm | 14 + xshogi/western_bitmaps/rookPRW.xbm | 14 + xshogi/western_bitmaps/rookPW.xbm | 14 + xshogi/western_bitmaps/rookRW.xbm | 14 + xshogi/western_bitmaps/rookW.xbm | 14 + xshogi/western_bitmaps/silverPRW.xbm | 14 + xshogi/western_bitmaps/silverPW.xbm | 14 + xshogi/western_bitmaps/silverRW.xbm | 14 + xshogi/western_bitmaps/silverW.xbm | 14 + xshogi/xshogi.c | 7745 +++++++++++++++++++++++++++++ xshogi/xshogi.h | 182 + xshogi/xshogifn.h | 195 + 283 files changed, 57132 insertions(+), 19008 deletions(-) create mode 100644 CONTRIB create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 INSTALL.generic create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 README delete mode 100644 README-1.2p03 create mode 100644 TRANS.TBL create mode 100644 config.h.in create mode 100755 configure create mode 100644 configure.in delete mode 100644 doc/CHANGES delete mode 100644 doc/CONTRIB delete mode 100644 doc/COPYING delete mode 100644 doc/GENERAL delete mode 100644 doc/INSTALL create mode 100644 doc/Makefile delete mode 100644 doc/README-FIRST create mode 100644 doc/TRANS.TBL delete mode 100644 doc/gnushogi.1 create mode 100644 doc/gnushogi.6 create mode 100644 doc/gnushogi.info create mode 100644 doc/gnushogi.info-1 create mode 100644 doc/gnushogi.info-2 create mode 100644 doc/gnushogi.ps create mode 100644 doc/gnushogi.texinfo create mode 100644 doc/gnushogi_1.html create mode 100644 doc/gnushogi_10.html create mode 100644 doc/gnushogi_11.html create mode 100644 doc/gnushogi_12.html create mode 100644 doc/gnushogi_13.html create mode 100644 doc/gnushogi_14.html create mode 100644 doc/gnushogi_15.html create mode 100644 doc/gnushogi_16.html create mode 100644 doc/gnushogi_17.html create mode 100644 doc/gnushogi_18.html create mode 100644 doc/gnushogi_19.html create mode 100644 doc/gnushogi_2.html create mode 100644 doc/gnushogi_20.html create mode 100644 doc/gnushogi_21.html create mode 100644 doc/gnushogi_22.html create mode 100644 doc/gnushogi_3.html create mode 100644 doc/gnushogi_4.html create mode 100644 doc/gnushogi_5.html create mode 100644 doc/gnushogi_6.html create mode 100644 doc/gnushogi_7.html create mode 100644 doc/gnushogi_8.html create mode 100644 doc/gnushogi_9.html create mode 100644 doc/gnushogi_stoc.html create mode 100644 doc/gnushogi_toc.html create mode 100755 doc/make_fig1 create mode 100755 doc/make_fig2 create mode 100644 doc/texinfo.tex create mode 100644 doc/xshogi.6 create mode 100644 gnushogi/Makefile.in create mode 100644 gnushogi/TRANS.TBL create mode 100644 gnushogi/attacks.c create mode 100644 gnushogi/book.c create mode 100644 gnushogi/book.h create mode 100644 gnushogi/commondsp.c create mode 100644 gnushogi/cursesdsp.c create mode 100644 gnushogi/cursesdsp.h create mode 100644 gnushogi/debug.h create mode 100644 gnushogi/dspwrappers.c create mode 100644 gnushogi/dspwrappers.h create mode 100644 gnushogi/eval.c create mode 100644 gnushogi/eval.h create mode 100644 gnushogi/genmove.c create mode 100644 gnushogi/globals.c create mode 100644 gnushogi/gnushogi.h create mode 100644 gnushogi/init.c create mode 100644 gnushogi/main.c create mode 100644 gnushogi/makepattern.c create mode 100644 gnushogi/opts.h create mode 100644 gnushogi/pat2inc.c create mode 100644 gnushogi/pattern.c create mode 100644 gnushogi/pattern.h create mode 100644 gnushogi/pattern.inc create mode 100644 gnushogi/rawdsp.c create mode 100644 gnushogi/rawdsp.h create mode 100644 gnushogi/search.c create mode 100644 gnushogi/sizetest.c create mode 100644 gnushogi/sysdeps.c create mode 100644 gnushogi/tcontrl.c create mode 100644 gnushogi/util.c create mode 100755 install-sh create mode 100644 misc/TRANS.TBL delete mode 100644 src/.LVS_ENV delete mode 100644 src/Makefile delete mode 100644 src/ataks.c delete mode 100644 src/book.c delete mode 100644 src/book.h delete mode 100644 src/dspcom.c delete mode 100644 src/eval.c delete mode 100644 src/eval.h delete mode 100644 src/genmove.c delete mode 100644 src/globals.c delete mode 100644 src/gnushogi.h delete mode 100644 src/init.c delete mode 100644 src/main.c delete mode 100644 src/nondsp.c delete mode 100644 src/pat2inc.c delete mode 100644 src/pattern.c delete mode 100644 src/pattern.h delete mode 100644 src/pattern.inc delete mode 100644 src/search.c delete mode 100644 src/sizetest.c delete mode 100644 src/tcontrl.c delete mode 100644 src/util.c delete mode 100644 src/uxdsp.c delete mode 100644 src/version.h create mode 100644 version.h create mode 100644 xshogi/BUGS create mode 100644 xshogi/Makefile.in create mode 100644 xshogi/NEWS create mode 100644 xshogi/README create mode 100644 xshogi/README.xboard create mode 100644 xshogi/REMOTEHOSTS create mode 100644 xshogi/TRANS.TBL create mode 100644 xshogi/bitmaps.h create mode 100644 xshogi/eastern_bitmaps/TRANS.TBL create mode 100644 xshogi/eastern_bitmaps/bigblank.xbm create mode 100644 xshogi/eastern_bitmaps/bigblankR.xbm create mode 100644 xshogi/eastern_bitmaps/biglight.xbm create mode 100644 xshogi/eastern_bitmaps/bigsolid.xbm create mode 100644 xshogi/eastern_bitmaps/bigsolidR.xbm create mode 100644 xshogi/eastern_bitmaps/bigsolidR_l.xbm create mode 100644 xshogi/eastern_bitmaps/bigsolidR_m.xbm create mode 100644 xshogi/eastern_bitmaps/bigsolid_l.xbm create mode 100644 xshogi/eastern_bitmaps/bigsolid_m.xbm create mode 100644 xshogi/eastern_bitmaps/bishop.xbm create mode 100644 xshogi/eastern_bitmaps/bishopP.top.xbm create mode 100644 xshogi/eastern_bitmaps/bishopP.xbm create mode 100644 xshogi/eastern_bitmaps/bishopPR.top.xbm create mode 100644 xshogi/eastern_bitmaps/bishopPR.xbm create mode 100644 xshogi/eastern_bitmaps/bishopPR_l.top.xbm create mode 100644 xshogi/eastern_bitmaps/bishopPR_l.xbm create mode 100644 xshogi/eastern_bitmaps/bishopPR_m.top.xbm create mode 100644 xshogi/eastern_bitmaps/bishopPR_m.xbm create mode 100644 xshogi/eastern_bitmaps/bishopP_l.top.xbm create mode 100644 xshogi/eastern_bitmaps/bishopP_l.xbm create mode 100644 xshogi/eastern_bitmaps/bishopP_m.top.xbm create mode 100644 xshogi/eastern_bitmaps/bishopP_m.xbm create mode 100644 xshogi/eastern_bitmaps/bishopR.xbm create mode 100644 xshogi/eastern_bitmaps/bishopR_l.xbm create mode 100644 xshogi/eastern_bitmaps/bishopR_m.xbm create mode 100644 xshogi/eastern_bitmaps/bishop_l.xbm create mode 100644 xshogi/eastern_bitmaps/bishop_m.xbm create mode 100644 xshogi/eastern_bitmaps/gold.xbm create mode 100644 xshogi/eastern_bitmaps/goldR.xbm create mode 100644 xshogi/eastern_bitmaps/goldR_l.xbm create mode 100644 xshogi/eastern_bitmaps/goldR_m.xbm create mode 100644 xshogi/eastern_bitmaps/gold_l.xbm create mode 100644 xshogi/eastern_bitmaps/gold_m.xbm create mode 100644 xshogi/eastern_bitmaps/icon.xbm create mode 100644 xshogi/eastern_bitmaps/king.xbm create mode 100644 xshogi/eastern_bitmaps/kingR.xbm create mode 100644 xshogi/eastern_bitmaps/kingR_l.xbm create mode 100644 xshogi/eastern_bitmaps/kingR_m.xbm create mode 100644 xshogi/eastern_bitmaps/king_l.xbm create mode 100644 xshogi/eastern_bitmaps/king_m.xbm create mode 100644 xshogi/eastern_bitmaps/knight.xbm create mode 100644 xshogi/eastern_bitmaps/knightP.xbm create mode 100644 xshogi/eastern_bitmaps/knightPR.xbm create mode 100644 xshogi/eastern_bitmaps/knightPR_l.xbm create mode 100644 xshogi/eastern_bitmaps/knightPR_m.xbm create mode 100644 xshogi/eastern_bitmaps/knightP_l.xbm create mode 100644 xshogi/eastern_bitmaps/knightP_m.xbm create mode 100644 xshogi/eastern_bitmaps/knightR.xbm create mode 100644 xshogi/eastern_bitmaps/knightR_l.xbm create mode 100644 xshogi/eastern_bitmaps/knightR_m.xbm create mode 100644 xshogi/eastern_bitmaps/knight_l.xbm create mode 100644 xshogi/eastern_bitmaps/knight_m.xbm create mode 100644 xshogi/eastern_bitmaps/lance.xbm create mode 100644 xshogi/eastern_bitmaps/lanceP.xbm create mode 100644 xshogi/eastern_bitmaps/lancePR.xbm create mode 100644 xshogi/eastern_bitmaps/lancePR_l.xbm create mode 100644 xshogi/eastern_bitmaps/lancePR_m.xbm create mode 100644 xshogi/eastern_bitmaps/lanceP_l.xbm create mode 100644 xshogi/eastern_bitmaps/lanceP_m.xbm create mode 100644 xshogi/eastern_bitmaps/lanceR.xbm create mode 100644 xshogi/eastern_bitmaps/lanceR_l.xbm create mode 100644 xshogi/eastern_bitmaps/lanceR_m.xbm create mode 100644 xshogi/eastern_bitmaps/lance_l.xbm create mode 100644 xshogi/eastern_bitmaps/lance_m.xbm create mode 100644 xshogi/eastern_bitmaps/none.xbm create mode 100644 xshogi/eastern_bitmaps/none_l.xbm create mode 100644 xshogi/eastern_bitmaps/none_m.xbm create mode 100644 xshogi/eastern_bitmaps/pawn.xbm create mode 100644 xshogi/eastern_bitmaps/pawnP.xbm create mode 100644 xshogi/eastern_bitmaps/pawnPR.xbm create mode 100644 xshogi/eastern_bitmaps/pawnPR_l.xbm create mode 100644 xshogi/eastern_bitmaps/pawnPR_m.xbm create mode 100644 xshogi/eastern_bitmaps/pawnP_l.xbm create mode 100644 xshogi/eastern_bitmaps/pawnP_m.xbm create mode 100644 xshogi/eastern_bitmaps/pawnR.xbm create mode 100644 xshogi/eastern_bitmaps/pawnR_l.xbm create mode 100644 xshogi/eastern_bitmaps/pawnR_m.xbm create mode 100644 xshogi/eastern_bitmaps/pawn_l.xbm create mode 100644 xshogi/eastern_bitmaps/pawn_m.xbm create mode 100644 xshogi/eastern_bitmaps/rook.xbm create mode 100644 xshogi/eastern_bitmaps/rookP.top.xbm create mode 100644 xshogi/eastern_bitmaps/rookP.xbm create mode 100644 xshogi/eastern_bitmaps/rookPR.top.xbm create mode 100644 xshogi/eastern_bitmaps/rookPR.xbm create mode 100644 xshogi/eastern_bitmaps/rookPR_l.top.xbm create mode 100644 xshogi/eastern_bitmaps/rookPR_l.xbm create mode 100644 xshogi/eastern_bitmaps/rookPR_m.top.xbm create mode 100644 xshogi/eastern_bitmaps/rookPR_m.xbm create mode 100644 xshogi/eastern_bitmaps/rookP_l.top.xbm create mode 100644 xshogi/eastern_bitmaps/rookP_l.xbm create mode 100644 xshogi/eastern_bitmaps/rookP_m.top.xbm create mode 100644 xshogi/eastern_bitmaps/rookP_m.xbm create mode 100644 xshogi/eastern_bitmaps/rookR.xbm create mode 100644 xshogi/eastern_bitmaps/rookR_l.xbm create mode 100644 xshogi/eastern_bitmaps/rookR_m.xbm create mode 100644 xshogi/eastern_bitmaps/rook_l.xbm create mode 100644 xshogi/eastern_bitmaps/rook_m.xbm create mode 100644 xshogi/eastern_bitmaps/silver.xbm create mode 100644 xshogi/eastern_bitmaps/silverP.xbm create mode 100644 xshogi/eastern_bitmaps/silverPR.xbm create mode 100644 xshogi/eastern_bitmaps/silverPR_l.xbm create mode 100644 xshogi/eastern_bitmaps/silverPR_m.xbm create mode 100644 xshogi/eastern_bitmaps/silverP_l.xbm create mode 100644 xshogi/eastern_bitmaps/silverP_m.xbm create mode 100644 xshogi/eastern_bitmaps/silverR.xbm create mode 100644 xshogi/eastern_bitmaps/silverR_l.xbm create mode 100644 xshogi/eastern_bitmaps/silverR_m.xbm create mode 100644 xshogi/eastern_bitmaps/silver_l.xbm create mode 100644 xshogi/eastern_bitmaps/silver_m.xbm create mode 100644 xshogi/eastern_bitmaps/smallblank.xbm create mode 100644 xshogi/eastern_bitmaps/smallblankR.xbm create mode 100644 xshogi/eastern_bitmaps/smalllight.xbm create mode 100644 xshogi/eastern_bitmaps/smallsolid.xbm create mode 100644 xshogi/eastern_bitmaps/smallsolidR.xbm create mode 100644 xshogi/eastern_bitmaps/smallsolidR_l.xbm create mode 100644 xshogi/eastern_bitmaps/smallsolidR_m.xbm create mode 100644 xshogi/eastern_bitmaps/smallsolid_l.xbm create mode 100644 xshogi/eastern_bitmaps/smallsolid_m.xbm create mode 100644 xshogi/parser.y create mode 100644 xshogi/scanner.l create mode 100644 xshogi/sysdeps.h create mode 100644 xshogi/western_bitmaps/TRANS.TBL create mode 100644 xshogi/western_bitmaps/bishopPRW.xbm create mode 100644 xshogi/western_bitmaps/bishopPW.xbm create mode 100644 xshogi/western_bitmaps/bishopRW.xbm create mode 100644 xshogi/western_bitmaps/bishopW.xbm create mode 100644 xshogi/western_bitmaps/goldRW.xbm create mode 100644 xshogi/western_bitmaps/goldW.xbm create mode 100644 xshogi/western_bitmaps/kingRW.xbm create mode 100644 xshogi/western_bitmaps/kingW.xbm create mode 100644 xshogi/western_bitmaps/knightPRW.xbm create mode 100644 xshogi/western_bitmaps/knightPW.xbm create mode 100644 xshogi/western_bitmaps/knightRW.xbm create mode 100644 xshogi/western_bitmaps/knightW.xbm create mode 100644 xshogi/western_bitmaps/lancePRW.xbm create mode 100644 xshogi/western_bitmaps/lancePW.xbm create mode 100644 xshogi/western_bitmaps/lanceRW.xbm create mode 100644 xshogi/western_bitmaps/lanceW.xbm create mode 100644 xshogi/western_bitmaps/noneW.xbm create mode 100644 xshogi/western_bitmaps/pawnPRW.xbm create mode 100644 xshogi/western_bitmaps/pawnPW.xbm create mode 100644 xshogi/western_bitmaps/pawnRW.xbm create mode 100644 xshogi/western_bitmaps/pawnW.xbm create mode 100644 xshogi/western_bitmaps/rookPRW.xbm create mode 100644 xshogi/western_bitmaps/rookPW.xbm create mode 100644 xshogi/western_bitmaps/rookRW.xbm create mode 100644 xshogi/western_bitmaps/rookW.xbm create mode 100644 xshogi/western_bitmaps/silverPRW.xbm create mode 100644 xshogi/western_bitmaps/silverPW.xbm create mode 100644 xshogi/western_bitmaps/silverRW.xbm create mode 100644 xshogi/western_bitmaps/silverW.xbm create mode 100644 xshogi/xshogi.c create mode 100644 xshogi/xshogi.h create mode 100644 xshogi/xshogifn.h diff --git a/CONTRIB b/CONTRIB new file mode 100644 index 0000000..38fd1a5 --- /dev/null +++ b/CONTRIB @@ -0,0 +1,26 @@ +Contributions from users +------------------------ + +Sep 12, 1994 + Hiroshi Tsuda: some openings added to gnushogi.tbk + +09/07/1993 + Cameron Gregory has added the shogi rules to the xshogi manual pages. + +05/04/1993 + Ken'ichi Nakayama has created alternative bitmaps for + promoted rook and promoted bishop. He claims that these + icons are more readable for japanese people. The bitmaps + are introduced using the --with-top-part-bitmaps option. + +04/02/1993 + Paul Reines has created a set of pieces with more chess-like + graphics, so that it may easier to learn how to play shogi. + These pieces can be chosen instead of the japanese pieces + by using the -DWESTERN_BITMAPS options in the Makefile. + The postscript file western_moves.ps shows the possible moves + using these icons. + [NOTE: this postscript file has since been removed. The western + bitmaps are now always available.] + + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..e77696a --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..a9f4c5c --- /dev/null +++ b/ChangeLog @@ -0,0 +1,59 @@ +ChangeLog will start with GNU Shogi 1.0 patchlevel 11 (04/07/1993) + +version 1.3 + 06/1999 + gnushogi is now only one executable. + Merged xshogi into the gnushogi source tree. + Renamed several files. + Cleaned up the source code and Makefile. + Added a configure script. + Added texinfo documentation. + +version 1.2 patchlevel 2 -> version 1.2 patchlevel 3 + ../05/1995 + correct connection to xshogi + correct creation of binary book file + better support of unsigned characters + +version 1.1 patchlevel 2 -> version 1.2 patchlevel 1 +version 1.2 patchlevel 1 -> version 1.2 patchlevel 2 + 13/09/1994 + change 'reachedGameCnt' from small_short to short in "pattern.h" + change "dspcom.c" for Illegal move support of xshogi + 24/09/1994 + change "genmove.c" in order to allow "stupid" non-promotion moves + change "dspcom.c" in order to protocol "stupid" moves + +version 1.1 patchlevel 2 -> version 1.2 patchlevel 1 + ../09/1994 + several changes to evaluation functions and move generation; + language file and pattern file are made internal + +version 1.1 patchlevel 1 -> version 1.1 patchlevel 2 + 10/06/1993 + correcting bug: MakeMove no longer destroys the node->flags + 07/11/1993 + changes according to GnuChess 4.0pl62; + introducing "IsCheckmate" in order to forbid checkmates + by dropping a pawn (illegal move); + correcting bug: UnmakeMove no longer destroys the node->flags + (especially the "exact" flag) + 05/11/1993 + enabling draw by repetition detection + 04/29/1993 + correcting "save game" and "get game"; + introducing a "tsume" mode, which allows gnushogi especially + search for forced checkmates + +version 1.0 patchlevel 11 -> version 1.1 patchlevel 1 + 04/22/1993 + deep search cut in genmoves.c + 04/20/1993 + enable pattern related scoring in opening stage + 04/15/1993 + tuning "eval.c" + 04/14/1993 + correction for the "abs" function in "init.c" + 04/10/1993 + switches SAVE_PTYPE_DISTDATA and SAVE_DISTDATA for optional + space reductions. diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..0d0d2c6 --- /dev/null +++ b/INSTALL @@ -0,0 +1,77 @@ +Installation procedure for GNU Shogi +==================================== + +If you've never installed a software package using a configure script before, +please read (or skim) the file "INSTALL.generic" which gives general +information on using configure scripts. This file contains information +specific to GNU shogi. + +The basic procedure: +------------------- + +1. Type 'configure --prefix='. If you + don't specify a prefix, it will be set to /usr/local. There are a few GNU + shogi-specific options you can use for this command; see below. + +2. Type 'make' to create gnushogi, the binary book file gnushogi.bbk, and + xshogi (the graphical interface to gnushogi). + +3. Type 'make install' to copy the binary book file to the library + destination directory and to copy the gnushogi executable to the + binary destination directory. + +4. OPTIONAL: + Type 'make clean' to remove object files and binaries from destination + source directory. + + +Configuration options specific to GNU shogi: +------------------------------------------- + +These only affect xshogi. + + --with-top-part-bitmaps Use top part of Kanji bitmaps only. + + --with-first-shogi-program=PROGNAME + Use PROGNAME as the first shogi program (default: gnushogi) + + --with-second-shogi-program=PROGNAME + Use PROGNAME as the second shogi program (default: gnushogi) + + --with-first-host=HOSTNAME + Use HOSTNAME as the machine on which the first shogi program + runs (default: localhost) + + --with-second-host=HOSTNAME + Use HOSTNAME as the machine on which the second shogi program + runs (default: localhost) + + --with-xshogi + Compile the xshogi graphical interface to GNU shogi (default: yes) + +If you don't want to compile xshogi, do +'configure --without-xshogi' + + +Other options: +------------- + +In the gnushogi directory, the file 'opts.h' includes a number of options that +can be set to configure the evaluator, to set the debugging level, etc. These +options will probably only be of interest to people who are hacking the source +code, with one exception: if you want to have your games automatically saved +on exit, #define LIST_ON_EXIT in this file. + + +Platforms GNU shogi is known to compile on: +------------------------------------------ + +Red Hat Linux 5.2 +Sun Solaris 2.6 + +Information about attempted or successful ports to other platforms would be +appreciated. If you submit such a report, please specify what you had to do +to get GNU shogi to compile and run successfully. + +-- Mike Vanier (mvanier@bbb.caltech.edu) + diff --git a/INSTALL.generic b/INSTALL.generic new file mode 100644 index 0000000..3b50ea9 --- /dev/null +++ b/INSTALL.generic @@ -0,0 +1,176 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes a while. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..cab7a06 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,108 @@ +# +# Makefile for GNU Shogi and xshogi +# +# Copyright (c) 1993, 1994 Matthias Mutz +# Copyright (c) 1998, 1999 Michael Vanier and the Free Software Foundation +# +# GNU Shogi is based on GNU Chess +# Copyright (c) 1992 Free Software Foundation +# +# This file is part of GNU Shogi. +# +# GNU Shogi is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# GNU Shogi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Shogi; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# + +GNUSHOGIDIR = ./gnushogi +XSHOGIDIR = ./xshogi + +# +# Default targets. +# + +all : gnushogi_compile pat2inc gnushogi.bbk @XSHOGI@ + + +# +# Primary targets. +# + +gnushogi_compile: + -cd $(GNUSHOGIDIR); $(MAKE) gnushogi + +pat2inc: + -cd $(GNUSHOGIDIR); $(MAKE) pat2inc + +sizetest: + -cd $(GNUSHOGIDIR); $(MAKE) sizetest + +xshogi_compile: + -cd $(XSHOGIDIR); $(MAKE) + +gnushogi.bbk: + -cd $(GNUSHOGIDIR); $(MAKE) gnushogi.bbk + + +# +# Installation. +# + +install: gnushogi_install @XSHOGIINSTALL@ + +gnushogi_install: + -cd $(GNUSHOGIDIR); $(MAKE) install + +xshogi_install: $(XSHOGIDIR)/xshogi + -cd $(XSHOGIDIR); $(MAKE) install + + + +# +# Cleanup. +# + +clean: gnushogi_clean @XSHOGICLEAN@ + +gnushogi_clean: + cd $(GNUSHOGIDIR); $(MAKE) clean + +xshogi_clean: + cd $(XSHOGIDIR); $(MAKE) clean + + +# +# Return to a pristine pre-configuration state. +# + +DISTCLEANFILES = \ + config.cache config.log config.status config.h \ + Makefile $(GNUSHOGIDIR)/Makefile $(XSHOGIDIR)/Makefile + +distclean: clean + for file in $(DISTCLEANFILES); do \ + if [ -f $$file ]; then rm $$file; fi; \ + done + + +# +# Extra cleanup, for the maintainer only :-) +# + +MAINTAINERCLEANFILES = configure config.h.in doc/gnushogi.info + +maintainerclean: distclean + for file in $(MAINTAINERCLEANFILES); do \ + if [ -f $$file ]; then rm $$file; fi; \ + done + diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..523be5f --- /dev/null +++ b/NEWS @@ -0,0 +1,31 @@ +GNU shogi news +-------------- + +This file will start with GNU Shogi 1.3 (07/01/1999). + +Changes in version 1.3 (07/1999): + +* xshogi has been merged into the gnushogi source tree and build process. + +* gnushogi is now only one executable, instead of three (one each for the raw + text interface, the xshogi interface, and the curses interface). The three + interfaces are still there; you select between them using a command-line + option: "gnushogi -C" for the curses interface, "gnushogi -R" for the raw + text interface, and "gnushogi -X" or just "gnushogi" for the xshogi + interface. Making the xshogi interface the default makes it easier for + xshogi to invoke gnushogi (translation: I couldn't be bothered figuring out + why this was the case, so I just left it that way). + +* The gnushogi and xshogi source code has been thoroughly cleaned up and + ANSIfied. Several files have been renamed. Makefiles have also been + cleaned up considerably, but you don't need to care about this, because... + +* Building GNU shogi and xshogi now uses a configure script generated by + autoconf. This should increase portability and make compilation much + easier. + +* There is now fairly extensive documentation in texinfo form, which has been + used to generate info, postscript, and html versions of the documentation. + The man page is included in the texinfo file. The (separate) man pages have + been updated to deal with the new command-line options for gnushogi. + diff --git a/README b/README new file mode 100644 index 0000000..b33a360 --- /dev/null +++ b/README @@ -0,0 +1,23 @@ +GNU Shogi, release 1.3 +---------------------- + +This is release 1.3 of GNU shogi, a program which plays shogi (Japanese +chess), as well as xshogi, the graphical interface to GNU shogi. GNU shogi +and xshogi were originally written by Matthias Mutz (mutz@fmi.uni-passau.de), +but are now maintained by me, Mike Vanier (mvanier@bbb.caltech.edu). GNU +shogi was in turn based on GNU Chess 4.0, i.e. the first version of GNU Shogi +was obtained by "simply" modifying the chess-specific parts of GNU Chess 4.0. +We would like to thank the authors of GNU Chess 4.0 for making the sources of +that program available. I would also like to thank Matthias for allowing me +to take over the maintenance of this project. + +See the file NEWS for the new features of this release. + +For the installation procedure read the file "INSTALL". For more information +on shogi please look at the files in the doc directory or read the info file. + +Please email bugs, comments, suggestions, and wish lists regarding GNU shogi +to me. And enjoy the program :-) + +Mike Vanier (mvanier@bbb.caltech.edu) + diff --git a/README-1.2p03 b/README-1.2p03 deleted file mode 100644 index c71e9b5..0000000 --- a/README-1.2p03 +++ /dev/null @@ -1,19 +0,0 @@ -Hello, - -this is GNU Shogi 1.2 patchlevel 3. There are only minor -changes of the patchlevel 2 version. Some bugs have been -removed. - -For installation procedure read doc/INSTALL. - -You cannot use the binary book file from previous versions, -you have to rebuild it. - -You may email discovered bugs or comments to me. - -Have fun, - - Matthias Mutz. - -email: mutz@fmi.uni-passau.de - diff --git a/TRANS.TBL b/TRANS.TBL new file mode 100644 index 0000000..534e01c --- /dev/null +++ b/TRANS.TBL @@ -0,0 +1,17 @@ +F CHANGELO.;1 ChangeLog +F CONFIGUR.;1 configure +F CONFIGUR.IN;1 configure.in +F CONFIG_H.IN;1 config.h.in +F CONTRIB.;1 CONTRIB +F COPYING.;1 COPYING +D DOC doc +D GNUSHOGI gnushogi +F INSTALL.;1 INSTALL +F INSTALL.GEN;1 INSTALL.generic +F INSTALL-.;1 install-sh +F MAKEFILE.IN;1 Makefile.in +D MISC misc +F NEWS.;1 NEWS +F README.;1 README +F VERSION.H;1 version.h +D XSHOGI xshogi diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..76cafb5 --- /dev/null +++ b/config.h.in @@ -0,0 +1,87 @@ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define as the return type of signal handlers (int or void). */ +#undef RETSIGTYPE + +/* Define if the setvbuf function takes the buffering type as its second + argument and the buffer pointer as the third, as on System V + before release 3. */ +#undef SETVBUF_REVERSED + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define if your declares struct tm. */ +#undef TM_IN_SYS_TIME + +/* Define if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* The number of bytes in a long. */ +#undef SIZEOF_LONG + +/* Define if you have the bcopy function. */ +#undef HAVE_BCOPY + +/* Define if you have the gethostname function. */ +#undef HAVE_GETHOSTNAME + +/* Define if you have the gettimeofday function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define if you have the memcpy function. */ +#undef HAVE_MEMCPY + +/* Define if you have the setlinebuf function. */ +#undef HAVE_SETLINEBUF + +/* Define if you have the setvbuf function. */ +#undef HAVE_SETVBUF + +/* Define if you have the strstr function. */ +#undef HAVE_STRSTR + +/* Define if you have the strtol function. */ +#undef HAVE_STRTOL + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FILE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FILIO_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the curses library (-lcurses). */ +#undef HAVE_LIBCURSES + +/* Define if you have the m library (-lm). */ +#undef HAVE_LIBM + +/* Define if you have the termcap library (-ltermcap). */ +#undef HAVE_LIBTERMCAP diff --git a/configure b/configure new file mode 100755 index 0000000..cb94989 --- /dev/null +++ b/configure @@ -0,0 +1,3304 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --with-x use the X Window System" +ac_help="$ac_help + --with-top-part-bitmaps Use top part of Kanji bitmaps only." +ac_help="$ac_help + --with-first-shogi-program=PROGNAME + Use PROGNAME as the first shogi program (default: gnushogi)" +ac_help="$ac_help + --with-second-shogi-program=PROGNAME + Use PROGNAME as the second shogi program (default: gnushogi)" +ac_help="$ac_help + --with-first-host=HOSTNAME + Use HOSTNAME as the machine on which the first shogi program + runs (default: localhost)" +ac_help="$ac_help + --with-second-host=HOSTNAME + Use HOSTNAME as the machine on which the second shogi program + runs (default: localhost)" +ac_help="$ac_help + --with-xshogi + Compile the xshogi graphical interface to GNU shogi (default: yes)" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=gnushogi/gnushogi.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + + + +# +# Check for C compiler. +# + +echo +echo $ac_n "checking for C compiler""... $ac_c" 1>&6 +echo "configure:555: checking for C compiler" >&5 +echo + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:561: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:591: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:642: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:674: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 685 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:716: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:721: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:749: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + + + +# +# Check for parser generators. +# + +echo +echo $ac_n "checking for yacc/bison, lex/flex, and install""... $ac_c" 1>&6 +echo "configure:788: checking for yacc/bison, lex/flex, and install" >&5 +echo + +for ac_prog in 'bison -y' byacc +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:796: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_YACC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +YACC="$ac_cv_prog_YACC" +if test -n "$YACC"; then + echo "$ac_t""$YACC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +# Extract the first word of "flex", so it can be a program name with args. +set dummy flex; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:829: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LEX="flex" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_LEX" && ac_cv_prog_LEX="lex" +fi +fi +LEX="$ac_cv_prog_LEX" +if test -n "$LEX"; then + echo "$ac_t""$LEX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$LEXLIB" +then + case "$LEX" in + flex*) ac_lib=fl ;; + *) ac_lib=l ;; + esac + echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 +echo "configure:863: checking for yywrap in -l$ac_lib" >&5 +ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l$ac_lib $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LEXLIB="-l$ac_lib" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:935: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + + +# +# Check for X windows. +# + +echo +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:995: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1016: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1033: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1050: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +# If we find X, set shell vars x_includes and x_libraries to the +# paths, otherwise set no_x=yes. +# Uses ac_ vars as temps to allow command line to override cache and checks. +# --without-x overrides everything else, but does not touch the cache. +echo $ac_n "checking for X""... $ac_c" 1>&6 +echo "configure:1079: checking for X" >&5 + +# Check whether --with-x or --without-x was given. +if test "${with_x+set}" = set; then + withval="$with_x" + : +fi + +# $have_x is `yes', `no', `disabled', or empty when we do not yet know. +if test "x$with_x" = xno; then + # The user explicitly disabled X. + have_x=disabled +else + if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then + # Both variables are already set. + have_x=yes + else +if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # One or both of the vars are not set, and there is no cached value. +ac_x_includes=NO ac_x_libraries=NO +rm -fr conftestdir +if mkdir conftestdir; then + cd conftestdir + # Make sure to not put "make" in the Imakefile rules, since we grep it out. + cat > Imakefile <<'EOF' +acfindx: + @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' +EOF + if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + for ac_extension in a so sl; do + if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && + test -f $ac_im_libdir/libX11.$ac_extension; then + ac_im_usrlibdir=$ac_im_libdir; break + fi + done + # Screen out bogus values from the imake configuration. They are + # bogus both because they are the default anyway, and because + # using them would break gcc on systems where it needs fixed includes. + case "$ac_im_incroot" in + /usr/include) ;; + *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; + esac + case "$ac_im_usrlibdir" in + /usr/lib | /lib) ;; + *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; + esac + fi + cd .. + rm -fr conftestdir +fi + +if test "$ac_x_includes" = NO; then + # Guess where to find include files, by looking for this one X11 .h file. + test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h + + # First, try using that file with no special directory specified. +cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1146: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + # We can compile using X headers with no special include directory. +ac_x_includes= +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + # Look for the header file in a standard set of common directories. +# Check X11 before X11Rn because it is often a symlink to the current release. + for ac_dir in \ + /usr/X11/include \ + /usr/X11R6/include \ + /usr/X11R5/include \ + /usr/X11R4/include \ + \ + /usr/include/X11 \ + /usr/include/X11R6 \ + /usr/include/X11R5 \ + /usr/include/X11R4 \ + \ + /usr/local/X11/include \ + /usr/local/X11R6/include \ + /usr/local/X11R5/include \ + /usr/local/X11R4/include \ + \ + /usr/local/include/X11 \ + /usr/local/include/X11R6 \ + /usr/local/include/X11R5 \ + /usr/local/include/X11R4 \ + \ + /usr/X386/include \ + /usr/x386/include \ + /usr/XFree86/include/X11 \ + \ + /usr/include \ + /usr/local/include \ + /usr/unsupported/include \ + /usr/athena/include \ + /usr/local/x11r5/include \ + /usr/lpp/Xamples/include \ + \ + /usr/openwin/include \ + /usr/openwin/share/include \ + ; \ + do + if test -r "$ac_dir/$x_direct_test_include"; then + ac_x_includes=$ac_dir + break + fi + done +fi +rm -f conftest* +fi # $ac_x_includes = NO + +if test "$ac_x_libraries" = NO; then + # Check for the libraries. + + test -z "$x_direct_test_library" && x_direct_test_library=Xt + test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc + + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS="$LIBS" + LIBS="-l$x_direct_test_library $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + LIBS="$ac_save_LIBS" +# We can link X programs with no special library path. +ac_x_libraries= +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + LIBS="$ac_save_LIBS" +# First see if replacing the include by lib works. +# Check X11 before X11Rn because it is often a symlink to the current release. +for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ + /usr/X11/lib \ + /usr/X11R6/lib \ + /usr/X11R5/lib \ + /usr/X11R4/lib \ + \ + /usr/lib/X11 \ + /usr/lib/X11R6 \ + /usr/lib/X11R5 \ + /usr/lib/X11R4 \ + \ + /usr/local/X11/lib \ + /usr/local/X11R6/lib \ + /usr/local/X11R5/lib \ + /usr/local/X11R4/lib \ + \ + /usr/local/lib/X11 \ + /usr/local/lib/X11R6 \ + /usr/local/lib/X11R5 \ + /usr/local/lib/X11R4 \ + \ + /usr/X386/lib \ + /usr/x386/lib \ + /usr/XFree86/lib/X11 \ + \ + /usr/lib \ + /usr/local/lib \ + /usr/unsupported/lib \ + /usr/athena/lib \ + /usr/local/x11r5/lib \ + /usr/lpp/Xamples/lib \ + /lib/usr/lib/X11 \ + \ + /usr/openwin/lib \ + /usr/openwin/share/lib \ + ; \ +do + for ac_extension in a so sl; do + if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi +rm -f conftest* +fi # $ac_x_libraries = NO + +if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then + # Didn't find X anywhere. Cache the known absence of X. + ac_cv_have_x="have_x=no" +else + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" +fi +fi + fi + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + echo "$ac_t""$have_x" 1>&6 + no_x=yes +else + # If each of the values was on the command line, it overrides each guess. + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + # Update the cache value to reflect the command line values. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$x_includes ac_x_libraries=$x_libraries" + echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 +fi + +if test "$no_x" = yes; then + # Not all programs may use this symbol, but it does not hurt to define it. + cat >> confdefs.h <<\EOF +#define X_DISPLAY_MISSING 1 +EOF + + X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= +else + if test -n "$x_includes"; then + X_CFLAGS="$X_CFLAGS -I$x_includes" + fi + + # It would also be nice to do this for all -L options, not just this one. + if test -n "$x_libraries"; then + X_LIBS="$X_LIBS -L$x_libraries" + # For Solaris; some versions of Sun CC require a space after -R and + # others require no space. Words are not sufficient . . . . + case "`(uname -sr) 2>/dev/null`" in + "SunOS 5"*) + echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 +echo "configure:1328: checking whether -R must be followed by a space" >&5 + ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_R_nospace=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_R_nospace=no +fi +rm -f conftest* + if test $ac_R_nospace = yes; then + echo "$ac_t""no" 1>&6 + X_LIBS="$X_LIBS -R$x_libraries" + else + LIBS="$ac_xsave_LIBS -R $x_libraries" + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_R_space=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_R_space=no +fi +rm -f conftest* + if test $ac_R_space = yes; then + echo "$ac_t""yes" 1>&6 + X_LIBS="$X_LIBS -R $x_libraries" + else + echo "$ac_t""neither works" 1>&6 + fi + fi + LIBS="$ac_xsave_LIBS" + esac + fi + + # Check for system-dependent libraries X programs must link with. + # Do this before checking for the system-independent R6 libraries + # (-lICE), since we may need -lsocket or whatever for X linking. + + if test "$ISC" = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" + else + # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And karl@cs.umb.edu says + # the Alpha needs dnet_stub (dnet does not exist). + echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 +echo "configure:1393: checking for dnet_ntoa in -ldnet" >&5 +ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldnet $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_lib_dnet_dnet_ntoa = no; then + echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 +echo "configure:1434: checking for dnet_ntoa in -ldnet_stub" >&5 +ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldnet_stub $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) + # needs -lnsl. + # The nsl library prevents programs from opening the X display + # on Irix 5.2, according to dickey@clark.net. + echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 +echo "configure:1482: checking for gethostbyname" >&5 +if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) +choke me +#else +gethostbyname(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_gethostbyname=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_gethostbyname=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_gethostbyname = no; then + echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 +echo "configure:1531: checking for gethostbyname in -lnsl" >&5 +ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lnsl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # lieder@skyler.mavd.honeywell.com says without -lsocket, + # socket/setsockopt and other routines are undefined under SCO ODT + # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary + # on later versions), says simon@lia.di.epfl.ch: it contains + # gethostby* variants that don't use the nameserver (or something). + # -lsocket must be given before -lnsl if both are needed. + # We assume that if connect needs -lnsl, so does gethostbyname. + echo $ac_n "checking for connect""... $ac_c" 1>&6 +echo "configure:1580: checking for connect" >&5 +if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char connect(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_connect) || defined (__stub___connect) +choke me +#else +connect(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_connect=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_connect=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_connect = no; then + echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 +echo "configure:1629: checking for connect in -lsocket" >&5 +ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsocket $X_EXTRA_LIBS $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. + echo $ac_n "checking for remove""... $ac_c" 1>&6 +echo "configure:1672: checking for remove" >&5 +if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char remove(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_remove) || defined (__stub___remove) +choke me +#else +remove(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_remove=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_remove=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_remove = no; then + echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 +echo "configure:1721: checking for remove in -lposix" >&5 +ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lposix $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. + echo $ac_n "checking for shmat""... $ac_c" 1>&6 +echo "configure:1764: checking for shmat" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shmat(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shmat) || defined (__stub___shmat) +choke me +#else +shmat(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1792: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shmat=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shmat=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_shmat = no; then + echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 +echo "configure:1813: checking for shmat in -lipc" >&5 +ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lipc $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" +else + echo "$ac_t""no" 1>&6 +fi + + fi + fi + + # Check for libraries that X11R6 Xt/Xaw programs need. + ac_save_LDFLAGS="$LDFLAGS" + test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" + # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to + # check for ICE first), but we must link in the order -lSM -lICE or + # we get undefined symbols. So assume we have SM if we have ICE. + # These have to be linked with before -lX11, unlike the other + # libraries we check for below, so use a different variable. + # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. + echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 +echo "configure:1865: checking for IceConnectionNumber in -lICE" >&5 +ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lICE $X_EXTRA_LIBS $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" +else + echo "$ac_t""no" 1>&6 +fi + + LDFLAGS="$ac_save_LDFLAGS" + +fi + + + +# +# Check for other libraries. +# + +echo $ac_n "checking for clrtoeol in -lcurses""... $ac_c" 1>&6 +echo "configure:1915: checking for clrtoeol in -lcurses" >&5 +ac_lib_var=`echo curses'_'clrtoeol | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lcurses $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo curses | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + +echo $ac_n "checking for pow in -lm""... $ac_c" 1>&6 +echo "configure:1962: checking for pow in -lm" >&5 +ac_lib_var=`echo m'_'pow | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lm $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + +echo $ac_n "checking for tgoto in -ltermcap""... $ac_c" 1>&6 +echo "configure:2009: checking for tgoto in -ltermcap" >&5 +ac_lib_var=`echo termcap'_'tgoto | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltermcap $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo termcap | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + + + +# +# C compiler warnings. +# + +if [ $ac_cv_prog_gcc = yes ] +then +WARNINGS="-Wall -Wno-implicit-int" +CEXTRAFLAGS="-fsigned-char -funroll-loops \$(HASH)" +else +# Who knows what warnings your compiler uses? +WARNINGS= +CEXTRAFLAGS="\$(HASH)" +fi + + + + + +# +# Check for header files. +# + +echo +echo $ac_n "checking for header files""... $ac_c" 1>&6 +echo "configure:2081: checking for header files" >&5 +echo + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:2085: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2098: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:2165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 +echo "configure:2189: checking for sys/wait.h that is POSIX.1 compatible" >&5 +if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifndef WEXITSTATUS +#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +#define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif +int main() { +int s; +wait (&s); +s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; +; return 0; } +EOF +if { (eval echo configure:2210: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_sys_wait_h=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_sys_wait_h=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&6 +if test $ac_cv_header_sys_wait_h = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_SYS_WAIT_H 1 +EOF + +fi + +for ac_hdr in fcntl.h sys/file.h sys/ioctl.h sys/time.h unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:2234: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2244: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in time.h sys/time.h sys/filio.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:2274: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2284: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 +echo "configure:2311: checking whether time.h and sys/time.h may both be included" >&5 +if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +int main() { +struct tm *tp; +; return 0; } +EOF +if { (eval echo configure:2325: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_time=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_time=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_time" 1>&6 +if test $ac_cv_header_time = yes; then + cat >> confdefs.h <<\EOF +#define TIME_WITH_SYS_TIME 1 +EOF + +fi + + + +# +# Check for typedefs, structures, and compiler characteristics. +# + +echo +echo $ac_n "checking for typedefs""... $ac_c" 1>&6 +echo "configure:2353: checking for typedefs" >&5 +echo + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:2357: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:2411: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:2432: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + +echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 +echo "configure:2465: checking whether time.h and sys/time.h may both be included" >&5 +if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +int main() { +struct tm *tp; +; return 0; } +EOF +if { (eval echo configure:2479: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_time=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_time=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_time" 1>&6 +if test $ac_cv_header_time = yes; then + cat >> confdefs.h <<\EOF +#define TIME_WITH_SYS_TIME 1 +EOF + +fi + +echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 +echo "configure:2500: checking whether struct tm is in sys/time.h or time.h" >&5 +if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +int main() { +struct tm *tp; tp->tm_sec; +; return 0; } +EOF +if { (eval echo configure:2513: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_struct_tm=time.h +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_struct_tm=sys/time.h +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_struct_tm" 1>&6 +if test $ac_cv_struct_tm = sys/time.h; then + cat >> confdefs.h <<\EOF +#define TM_IN_SYS_TIME 1 +EOF + +fi + + +echo +echo $ac_n "checking for compiler characteristics""... $ac_c" 1>&6 +echo "configure:2536: checking for compiler characteristics" >&5 +echo + +echo $ac_n "checking size of long""... $ac_c" 1>&6 +echo "configure:2540: checking size of long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long)); + exit(0); +} +EOF +if { (eval echo configure:2559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_long" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2586: checking for library functions" >&5 +echo + +echo $ac_n "checking whether setvbuf arguments are reversed""... $ac_c" 1>&6 +echo "configure:2590: checking whether setvbuf arguments are reversed" >&5 +if eval "test \"`echo '$''{'ac_cv_func_setvbuf_reversed'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +/* If setvbuf has the reversed format, exit 0. */ +main () { + /* This call has the arguments reversed. + A reversed system may check and see that the address of main + is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ + if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0) + exit(1); + putc('\r', stdout); + exit(0); /* Non-reversed systems segv here. */ +} +EOF +if { (eval echo configure:2612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_func_setvbuf_reversed=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_setvbuf_reversed=no +fi +rm -fr conftest* +fi + +rm -f core core.* *.core +fi + +echo "$ac_t""$ac_cv_func_setvbuf_reversed" 1>&6 +if test $ac_cv_func_setvbuf_reversed = yes; then + cat >> confdefs.h <<\EOF +#define SETVBUF_REVERSED 1 +EOF + +fi + +echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 +echo "configure:2636: checking return type of signal handlers" >&5 +if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int main() { +int i; +; return 0; } +EOF +if { (eval echo configure:2658: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_type_signal=void +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_type_signal=int +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_type_signal" 1>&6 +cat >> confdefs.h <&6 +echo "configure:2679: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in memcpy bcopy +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2734: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2762: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in setlinebuf setvbuf +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2789: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + + +# +# Set various user-definable options. +# +# Valid OPT settings: +# --with-top-part-bitmaps +# +# Other settings: +# --with-first-shogi-program=PROGNAME +# --with-second-shogi-program=PROGNAME +# --with-first-host=HOSTNAME +# --with-second-host=HOSTNAME +# + +OPT= +FIRST_SHOGI_PROGRAM=gnushogi +SECOND_SHOGI_PROGRAM=gnushogi +FIRST_HOST=localhost +SECOND_HOST=localhost + +# Check whether --with-top-part-bitmaps or --without-top-part-bitmaps was given. +if test "${with_top_part_bitmaps+set}" = set; then + withval="$with_top_part_bitmaps" + OPT=-DTOP_PART_BITMAPS +fi + + +# Check whether --with-first-shogi-program or --without-first-shogi-program was given. +if test "${with_first_shogi_program+set}" = set; then + withval="$with_first_shogi_program" + FIRST_SHOGI_PROGRAM=$withval +fi + + +# Check whether --with-second-shogi-program or --without-second-shogi-program was given. +if test "${with_second_shogi_program+set}" = set; then + withval="$with_second_shogi_program" + SECOND_SHOGI_PROGRAM=$withval +fi + + +# Check whether --with-first-host or --without-first-host was given. +if test "${with_first_host+set}" = set; then + withval="$with_first_host" + FIRST_HOST=$withval +fi + + +# Check whether --with-second-host or --without-second-host was given. +if test "${with_second_host+set}" = set; then + withval="$with_second_host" + SECOND_HOST=$withval +fi + + +# Check whether --with-xshogi or --without-xshogi was given. +if test "${with_xshogi+set}" = set; then + withval="$with_xshogi" + with_xshogi=$withval +else + with_xshogi=yes +fi + + + + + + + + +if [ $with_xshogi = yes ] +then +XSHOGI=xshogi_compile +XSHOGIINSTALL=xshogi_install +XSHOGICLEAN=xshogi_clean +else +XSHOGI= +XSHOGIINSTALL= +XSHOGICLEAN= +fi + + + + + + +echo +echo outputting files... + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile gnushogi/Makefile xshogi/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@YACC@%$YACC%g +s%@LEX@%$LEX%g +s%@LEXLIB@%$LEXLIB%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@CPP@%$CPP%g +s%@X_CFLAGS@%$X_CFLAGS%g +s%@X_PRE_LIBS@%$X_PRE_LIBS%g +s%@X_LIBS@%$X_LIBS%g +s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g +s%@WARNINGS@%$WARNINGS%g +s%@CEXTRAFLAGS@%$CEXTRAFLAGS%g +s%@OPT@%$OPT%g +s%@FIRST_SHOGI_PROGRAM@%$FIRST_SHOGI_PROGRAM%g +s%@SECOND_SHOGI_PROGRAM@%$SECOND_SHOGI_PROGRAM%g +s%@FIRST_HOST@%$FIRST_HOST%g +s%@SECOND_HOST@%$SECOND_HOST%g +s%@XSHOGI@%$XSHOGI%g +s%@XSHOGIINSTALL@%$XSHOGIINSTALL%g +s%@XSHOGICLEAN@%$XSHOGICLEAN%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..f6e0580 --- /dev/null +++ b/configure.in @@ -0,0 +1,198 @@ +# ------------------------------------------------------------ +# GNU shogi and xshogi configuration script. +# ------------------------------------------------------------ + +dnl Process this file with autoconf to produce a configure script. + +AC_INIT(gnushogi/gnushogi.h) +AC_CONFIG_HEADER(config.h) + + +# +# Check for C compiler. +# + +echo +AC_MSG_CHECKING(for C compiler) +echo + +AC_PROG_CC + + +# +# Check for parser generators. +# + +echo +AC_MSG_CHECKING([for yacc/bison, lex/flex, and install]) +echo + +AC_PROG_YACC +AC_PROG_LEX +AC_PROG_INSTALL + + +# +# Check for X windows. +# + +echo +AC_PATH_XTRA + + +# +# Check for other libraries. +# + +AC_CHECK_LIB(curses, clrtoeol) +AC_CHECK_LIB(m, pow) +dnl Replace `main' with a function in -ltermcap: +AC_CHECK_LIB(termcap, tgoto) + + +# +# C compiler warnings. +# + +if [[ $ac_cv_prog_gcc = yes ]] +then +WARNINGS="-Wall -Wno-implicit-int" +CEXTRAFLAGS="-fsigned-char -funroll-loops \$(HASH)" +else +# Who knows what warnings your compiler uses? +WARNINGS= +CEXTRAFLAGS="\$(HASH)" +fi + +AC_SUBST(WARNINGS) +AC_SUBST(CEXTRAFLAGS) + + +# +# Check for header files. +# + +echo +AC_MSG_CHECKING(for header files) +echo + +AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_CHECK_HEADERS(fcntl.h sys/file.h sys/ioctl.h sys/time.h unistd.h) +AC_CHECK_HEADERS(time.h sys/time.h sys/filio.h) +AC_HEADER_TIME + + +# +# Check for typedefs, structures, and compiler characteristics. +# + +echo +AC_MSG_CHECKING(for typedefs) +echo + +AC_C_CONST +AC_TYPE_SIZE_T +AC_HEADER_TIME +AC_STRUCT_TM + +echo +AC_MSG_CHECKING(for compiler characteristics) +echo + +AC_CHECK_SIZEOF(long) + + +# +# Check for library functions. +# + +echo +AC_MSG_CHECKING(for library functions) +echo + +AC_FUNC_SETVBUF_REVERSED +AC_TYPE_SIGNAL +AC_CHECK_FUNCS(gethostname gettimeofday strstr strtol) +AC_CHECK_FUNCS(memcpy bcopy) +AC_CHECK_FUNCS(setlinebuf setvbuf) + + +# +# Set various user-definable options. +# +# Valid OPT settings: +# --with-top-part-bitmaps +# +# Other settings: +# --with-first-shogi-program=PROGNAME +# --with-second-shogi-program=PROGNAME +# --with-first-host=HOSTNAME +# --with-second-host=HOSTNAME +# + +OPT= +FIRST_SHOGI_PROGRAM=gnushogi +SECOND_SHOGI_PROGRAM=gnushogi +FIRST_HOST=localhost +SECOND_HOST=localhost + +AC_ARG_WITH(top-part-bitmaps, +[ --with-top-part-bitmaps Use top part of Kanji bitmaps only.], +OPT=-DTOP_PART_BITMAPS) + +AC_ARG_WITH(first-shogi-program, +[ --with-first-shogi-program=PROGNAME + Use PROGNAME as the first shogi program (default: gnushogi)], +FIRST_SHOGI_PROGRAM=$withval) + +AC_ARG_WITH(second-shogi-program, +[ --with-second-shogi-program=PROGNAME + Use PROGNAME as the second shogi program (default: gnushogi)], +SECOND_SHOGI_PROGRAM=$withval) + +AC_ARG_WITH(first-host, +[ --with-first-host=HOSTNAME + Use HOSTNAME as the machine on which the first shogi program + runs (default: localhost)], +FIRST_HOST=$withval) + +AC_ARG_WITH(second-host, +[ --with-second-host=HOSTNAME + Use HOSTNAME as the machine on which the second shogi program + runs (default: localhost)], +SECOND_HOST=$withval) + +AC_ARG_WITH(xshogi, +[ --with-xshogi + Compile the xshogi graphical interface to GNU shogi (default: yes)], +with_xshogi=$withval, +with_xshogi=yes) + +AC_SUBST(OPT) +AC_SUBST(FIRST_SHOGI_PROGRAM) +AC_SUBST(SECOND_SHOGI_PROGRAM) +AC_SUBST(FIRST_HOST) +AC_SUBST(SECOND_HOST) + +if [[ $with_xshogi = yes ]] +then +XSHOGI=xshogi_compile +XSHOGIINSTALL=xshogi_install +XSHOGICLEAN=xshogi_clean +else +XSHOGI= +XSHOGIINSTALL= +XSHOGICLEAN= +fi + +AC_SUBST(XSHOGI) +AC_SUBST(XSHOGIINSTALL) +AC_SUBST(XSHOGICLEAN) + + +echo +echo outputting files... + +AC_OUTPUT(Makefile gnushogi/Makefile xshogi/Makefile) + diff --git a/doc/BOOKFILES b/doc/BOOKFILES index 1571cd4..2079335 100644 --- a/doc/BOOKFILES +++ b/doc/BOOKFILES @@ -1,49 +1,51 @@ Binary book files ----------------- -In GNU Shogi the book file is a binary file. -The binary book file is "gnushogi.bbk". -It is intended that text book files will only be -used to generate the binary file (see remarks about syntax below). +In GNU Shogi the book file is a binary file. The binary book file is +called "gnushogi.bbk". It is intended that book files in text form +(hereafter referred to as "text book files") will only be used to generate +the binary file (see remarks about the text book file syntax below). -The Makefile will generate a "gnushogi.bbk" in the "src" directory -from the text book file "gnushogi.tbk" in the "misc" directory -if "make gnushogi.bbk" is entered (the "gnushogir" executable -must be available in the "src" directory or it is created). +The Makefile will generate a file called "gnushogi.bbk" in the "src" +directory from the text book file "gnushogi.tbk" in the "misc" directory if +"make gnushogi.bbk" is entered (the "gnushogir" executable must be +available in the "src" directory or it will be created). "make install" also copies the "gnushogi.bbk" to the installation directory for libraries. + Adding new opening lines ------------------------ -You can add entries to the binary file by providing a text book -file "gnushogi.tbk" in the installation directory. -After starting gnushogi, the new entries will be added. It is -recommended to remove the text book file after adding the entries to -the binary book file (or gnushogi will always check for new entries). +You can add entries to the binary file by providing a text book file +"gnushogi.tbk" in the installation directory. After starting gnushogi, the +new entries will be added. It is recommended to remove the text book file +after adding the entries to the binary book file (or gnushogi will always +check for new entries). You can also use the "bsave" command while running gnushogi. The current moves will be appended to the named file in a text book file style. + Syntax of text book files ------------------------- -Text book files are used to generate the binary book file. You must follow a -special text book file syntax while adding an opening line. The book file -parser (program that interpretes the text book moves) is abble to accept -several common Shogi notations. -It also allows to include comments. +Text book files are used to generate the binary book file. You must follow +a special text book file syntax while adding an opening line. The book file +parser (program that interpretes the text book moves) is able to accept +several common Shogi notations. It also allows the writer to include +comments. -All characters in a line following a '#' character are comments. -The moves of an opening line is always between two lines with a '#' as its first -character. So, you must not use 1st-column-'#'-comments to give comments to an -opening line. "in-opening" comments are included in brackets ('[' ... ']'). -After each ply, you can add a comment in parantheses ('(' ... ')'). -This is normally used in Shogi notations to indicate the amount of time used by -the player to enter that move. +All characters in a line following a '#' character are comments. The moves +of an opening line are always between two lines with a '#' as its first +character. Therefore, you must not use 1st-column-'#'-comments to give +comments to an opening line. "In-opening" comments are included in brackets +('[' ... ']'). After each ply, you can add a comment in parantheses ('(' +... ')'). This is normally used in Shogi notations to indicate the amount +of time used by the player to enter that move. -There are several possibilites to describe a move. Examples are +There are several possibilites for describing a move. Examples are 7g7f P7f P7g-7f P-7f 3c3d +B3cx3d +Bx3d +B3d @@ -57,7 +59,7 @@ may be important in order to avoid ambiguities. For example # - # Double Fortess + # Double Fortress P7f P8d [ this is an "in-opening" comment ] S6h P8e(1) diff --git a/doc/CHANGES b/doc/CHANGES deleted file mode 100644 index 5e59a0c..0000000 --- a/doc/CHANGES +++ /dev/null @@ -1,50 +0,0 @@ -ChangeLog will start with GNU Shogi 1.0 patchlevel 11 (04/07/1993) - -version 1.2 patchlevel 2 -> version 1.2 patchlevel 3 - ../05/1995 - correct connection to xshogi - correct creation of binary book file - better support of unsigned characters - -version 1.1 patchlevel 2 -> version 1.2 patchlevel 1 -version 1.2 patchlevel 1 -> version 1.2 patchlevel 2 - 13/09/1994 - change 'reachedGameCnt' from small_short to short in "pattern.h" - change "dspcom.c" for Illegal move support of xshogi - 24/09/1994 - change "genmove.c" in order to allow "stupid" non-promotion moves - change "dspcom.c" in order to protocol "stupid" moves - -version 1.1 patchlevel 2 -> version 1.2 patchlevel 1 - ../09/1994 - several changes to evaluation functions and move generation; - language file and pattern file are made internal - -version 1.1 patchlevel 1 -> version 1.1 patchlevel 2 - 10/06/1993 - correcting bug: MakeMove no longer destroys the node->flags - 07/11/1993 - changes according to GnuChess 4.0pl62; - introducing "IsCheckmate" in order to forbid checkmates - by dropping a pawn (illegal move); - correcting bug: UnmakeMove no longer destroys the node->flags - (especially the "exact" flag) - 05/11/1993 - enabling draw by repetition detection - 04/29/1993 - correcting "save game" and "get game"; - introducing a "tsume" mode, which allows gnushogi especially - search for forced checkmates - -version 1.0 patchlevel 11 -> version 1.1 patchlevel 1 - 04/22/1993 - deep search cut in genmoves.c - 04/20/1993 - enable pattern related scoring in opening stage - 04/15/1993 - tuning "eval.c" - 04/14/1993 - correction for the "abs" function in "init.c" - 04/10/1993 - switches SAVE_PTYPE_DISTDATA and SAVE_DISTDATA for optional - space reductions. diff --git a/doc/CONTRIB b/doc/CONTRIB deleted file mode 100644 index b802b91..0000000 --- a/doc/CONTRIB +++ /dev/null @@ -1,4 +0,0 @@ - -Sep 12, 1994 - Hiroshi Tsuda: some openings added to gnushogi.tbk - diff --git a/doc/COPYING b/doc/COPYING deleted file mode 100644 index e77696a..0000000 --- a/doc/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/doc/GENERAL b/doc/GENERAL deleted file mode 100644 index d9df93b..0000000 --- a/doc/GENERAL +++ /dev/null @@ -1,56 +0,0 @@ - GNU Shogi - -Copyright (C) 1993 Matthias Mutz - (Copying permission notice at the end.) - -GNU Shogi is your program (as long as you follow the copyright and -licensing rules listed in the file COPYING). Your contribution -inspire current and future software developers. - -This document -------------- -This document is not meant to be a an introduction to computer shogi. - -Current Distribution --------------------- -The most recent distribution of GNU Shogi contains the following -main-level files and directories: - - Filename Purpose - ------------------------------------------------------ -doc: - -GENERAL ---------- general gnushogi documentation --------- -COPYING - -ChangeLog ----------- specific gnushogi documentation ---------- -CHANGES -BOOKFILES -INSTALL -PROBLEMS -TOTO -README-FIRST - -gnushogi.1 ---------- man pages ----------- - -misc: -*.book - opening book - -src: -Makefile - unix makefile - -ataks.c - sources for the shogi playing program -ataks.h -book.c -dspcom.c -eval.c -genmoves.c -init.c -main.c -gnushogi.h -search.c -util.c -version.h - -nondsp.c - ASCII interface for acsii terminal/ chesstool/ xboard -uxdsp.c - curses based user interface diff --git a/doc/INSTALL b/doc/INSTALL deleted file mode 100644 index 637132d..0000000 --- a/doc/INSTALL +++ /dev/null @@ -1,27 +0,0 @@ -Installation procedure for GNU Shogi ------------------------------------- - -1. edit src/Makefile. For setting the paths, normally only - HOME or LIBDIR and BINDIR need to be changed. Setting CC - and CFLAGS sets C compiler and compiler options. - -2. type 'make gnushogir' to create plain dumb-terminal shogi. - -3. type 'make gnushogi.bbk' to create the binary book file. - -4. OPTIONAL: - type 'make gnushogi' to create cursed based shogi - -5. OPTIONAL: - type 'make gnushogix' to create xshogi based shogi. You may - use GNU XShogi as an X Windows based graphical interface to - GNU Shogi. GNU XShogi also supports the Internet Shogi - Server (ISS). - -6. type 'make install' to copy the binary book file to the libraries - destination directory and to copy the gnushogi* executables to - the binaries destination directory. - -7. OPTIONAL: - type 'make clean' to remove objects from destination source - directory. diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..2281134 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,47 @@ +DISTCLEANFILES = *.info* *.ps *.html + +CLEANFILES = *.log *.dvi *.aux *.dlog \ + *.cp *.cps *.fn *.ky *.pg *.toc *.tp *.vr + + +info: + makeinfo gnushogi.texinfo + +tex: + texi2dvi gnushogi.texinfo + +# I do some egregious hacks to get around limitations of +# texi2html. + +html: + texi2html -split_node gnushogi.texinfo + ./make_fig1 < gnushogi_6.html > tmp.html + mv tmp.html gnushogi_6.html + ./make_fig2 < gnushogi_14.html > tmp.html + mv tmp.html gnushogi_14.html + +view: + xdvi gnushogi.dvi + +ps: + dvips -t letter gnushogi.dvi -o gnushogi.ps + +ps2: + dvi2ps gnushogi.dvi > gnushogi.ps + +spell: + tr '[A-Z]' '[a-z]' < gnushogi.texinfo | tr -cd '[A-Za-z0-9_ \012]' | \ + tr -s '[ ]' '\012' | sort | uniq -c | sort -nr | spell + +clean: + @for file in $(CLEANFILES); \ + do if [ -f $$file ]; then rm $$file; fi; \ + done + +distclean: clean + @for file in $(DISTCLEANFILES); \ + do if [ -f $$file ]; then rm $$file; fi; \ + done + + + diff --git a/doc/PORTING b/doc/PORTING index b647989..f28913d 100644 --- a/doc/PORTING +++ b/doc/PORTING @@ -1,15 +1,23 @@ +Porting GNU shogi +----------------- -This is a note how to port gnushogi to machines with scarce memory: -gnushogi minimal requirements are: - - approximately 200 kByte memory for the executable program. - - at least 300 kByte for data structures. -You dont want to port gnushogi to a machine with less memory than that. +NOTE: this file may be seriously outdated. I haven't had time to go over +it yet. Let me know if there are problems. -gnushogi is optmized for speed and that means that memory has been used +-- Mike (mvanier@bbb.caltech.edu) + + +This describes how to port GNU shogi to machines with scarce memory. +GNU shogi's minimal requirements are: + - approximately 200 kBytes memory for the executable program. + - at least 300 kBytes for data structures. +You don't want to port GNU shogi to a machine with less memory than that. + +GNU shogi is optimized for speed and that means that memory has been used when there has been a tradeoff between memory usage and speed. If you intend -to run gnushogi on a machine with less than 4 Mbyte memory the size of some +to run GNU shogi on a machine with less than 4 Mbyte memory the size of some data structures have to be reduced. Here is a list of the largest data -structures in gnushogi, their sizes and a small comment on what can +structures in GNU shogi, their sizes and a small comment on what can be done to reduce their size: ttable: 1.5 MByte (#define vttblsz ) @@ -31,8 +39,8 @@ You can remove the static evaluation cache by omitting the compiler option CACHE. You can remove the history table by omitting the compiler option HISTORY (NOT recommended). -If this isn`nt enough, reconsider if you really want to do this port. -There is`nt really that much to gain by changing the other +If this isn't enough, reconsider if you really want to do this port. +There isn't really that much to gain by changing the other data structures. There are some switches in order to enable space reduction: diff --git a/doc/README-FIRST b/doc/README-FIRST deleted file mode 100644 index 969351c..0000000 --- a/doc/README-FIRST +++ /dev/null @@ -1,17 +0,0 @@ -GNU Shogi is the japanese version of chess. You can find the -rules of Shogi in "shogi.rules". This file and many other -shogi related stuff can be obtained from the SHOGI-L listserver (see -"listserv.ref"). - -GNU Shogi is based on GNU Chess 4.0, i.e. the first -version of GNU Shogi has been obtained by "simply" modifying -the chess-specific parts of GNU Chess 4.0. - -There are now major changes compared to GNU Chess. - -I would like to thank all people who have made the -sources of GNU Chess 4.0 available. - - Matthias Mutz. - (mutz@fmi.uni-passau.de) - diff --git a/doc/TRANS.TBL b/doc/TRANS.TBL new file mode 100644 index 0000000..2c57a0b --- /dev/null +++ b/doc/TRANS.TBL @@ -0,0 +1,41 @@ +F BOOKFILE.;1 BOOKFILES +F GNUSHOGI.000;1 gnushogi_22.html +F GNUSHOGI.001;1 gnushogi_21.html +F GNUSHOGI.002;1 gnushogi_20.html +F GNUSHOGI.003;1 gnushogi_19.html +F GNUSHOGI.004;1 gnushogi_18.html +F GNUSHOGI.005;1 gnushogi_17.html +F GNUSHOGI.006;1 gnushogi_16.html +F GNUSHOGI.007;1 gnushogi_15.html +F GNUSHOGI.008;1 gnushogi_14.html +F GNUSHOGI.009;1 gnushogi_13.html +F GNUSHOGI.00A;1 gnushogi_12.html +F GNUSHOGI.00B;1 gnushogi_11.html +F GNUSHOGI.00C;1 gnushogi_10.html +F GNUSHOGI.00D;1 gnushogi_9.html +F GNUSHOGI.00E;1 gnushogi_8.html +F GNUSHOGI.00F;1 gnushogi_7.html +F GNUSHOGI.00G;1 gnushogi_6.html +F GNUSHOGI.00H;1 gnushogi_5.html +F GNUSHOGI.00I;1 gnushogi_4.html +F GNUSHOGI.00J;1 gnushogi_3.html +F GNUSHOGI.00K;1 gnushogi_2.html +F GNUSHOGI.00L;1 gnushogi_1.html +F GNUSHOGI.00M;1 gnushogi_stoc.html +F GNUSHOGI.00N;1 gnushogi.info-2 +F GNUSHOGI.00O;1 gnushogi.info-1 +F GNUSHOGI.6;1 gnushogi.6 +F GNUSHOGI.HTM;1 gnushogi_toc.html +F GNUSHOGI.INF;1 gnushogi.info +F GNUSHOGI.PS;1 gnushogi.ps +F GNUSHOGI.TEX;1 gnushogi.texinfo +F LISTSERV.REF;1 listserv.ref +F MAKEFILE.;1 Makefile +F MAKE_FIG.;1 make_fig1 +F MAKE_FIG.000;1 make_fig2 +F PORTING.;1 PORTING +F SHOGI.RUL;1 shogi.rules +F TEXINFO.TEX;1 texinfo.tex +F TUTORIAL.000;1 tutorial2.gam +F TUTORIAL.GAM;1 tutorial1.gam +F XSHOGI.6;1 xshogi.6 diff --git a/doc/gnushogi.1 b/doc/gnushogi.1 deleted file mode 100644 index 0aa5821..0000000 --- a/doc/gnushogi.1 +++ /dev/null @@ -1,432 +0,0 @@ -.TH gnushogi 6 -.SH NAME -gnushogi \- Shogi -.SH SYNOPSIS -.B gnushogi -[ -.B [[-]a] -.B [-b bookfile] -.B [-B binbookfile] -.B [-h langfile] -.B [-L langfile] -.B [-r length] -.B [-s pathname] [-l pathname] -.B [-S binbooksize] -.B [-t] [-c size] -.B [-T size] -.B [-v] -.B [-x] -.B arg1 arg2 -] -.SH DESCRIPTION -.I Gnushogi -plays a game of japanese chess (shogi) against the user or it plays against itself. -.PP -At startup -.I Gnushogi -reads the -.I binbook -file if it is present. It then looks for a -.I book -file. If it is present it adds its contents to the -.I binbook -data. If the -.I binbook -file is writable a new combined -.I binbook -file is written. - -.PP -.I Gnushogi -is an updated version of the gnuchess program. -It has a simple alpha-numeric board display, -or it can be compiled for use with the -.B chesstool -program on a SUN workstation or with the -.B xshogi -program under X-windows. -The program gets its opening moves from the file -.B gnushogi.book -which is located in a directory specified in the makefile. -To invoke the program type: -.TP -.B gnushogi -- simple curses based version -.TP -.B gnuchessx -- xshogi compatible version -.SH TIME CONTROLS -.PP -If one argument is given, it is the search time per move in -[minutes:]seconds. -So -.B gnushogi 30 -will generate one move every 30 seconds, while -.B gnushogi 5:00 -will generate one move every 5 minutes. - -If two or more arguments are given, they will be used to set tournament -time controls with the first argument of each pair being the number of moves and the second -being the total clock time in minutes[:seconds]. Thus, entering -.B gnushogi 60 5 -will set -the clocks for 5 minutes (300 seconds) for the first 60 moves, -and -.B gnushogi 30 3:30 -will allow 3 minutes and 30 seconds for 30 moves. - -.B gnushogi 30 5 1 :30 -will allow 5 minutes for the first 30 moves and 30 seconds for each move after that. -Up to 4 pairs of controls may be specified. - -If no argument is given the program will prompt the user for level of play. - -For use with -.B xshogi -, see the documentation on this programs. -.SH BOOK -.PP -The book -.I gnushogi.book -consists of a sequence of openings. -An opening begins with a line starting with a -.B ! -, the rest of the line is comments. -Following this is a series of moves in algebraic notation alternating black -and white separated by white space. A move may have a -.B ? -after it indicating this move should never be made in this position. -Moves are stored as position:move so transpositions between openings -can take place. -.SH HASHFILE -.PP -The hashfile if created should be on the order of 4 megabytes or -.B gnushogi -c 22. -This file contains positions and moves learned from previous games. -If a hashfile is used the computer makes use of the experience it -gained in past games. Tests run so far show that it plays no worse -with the hashfile than without, but it is not clear yet whether -it provides a real advantage. -.SH LEGAL MOVES -.PP -.B Note: -Piece letters are determined by the language file. -What is specified here is the default English. -.PP -Once -.I gnushogi -is invoked, the program will display the board and prompt the user -for a move. To enter a move, use the notation -.B 7g7f -where the first letter-number pair indicates the origination square -and the second letter-number pair indicates the destination square. -An alternative is to use the notation -.B p7f -where the first letter indicates the piece type (p,l,n,s,g,b,r,k). -To promote append a + the type of the new piece to the move, as in -.B 2d2c+ -or -.B P2c+. -.SH "FUNCTION LETTERS" -.TP -.B -L lang -Use language -.I lang from the file -.B gnushogi.lang. -If -L is not specified it uses the first language in the file. -.TP -.B -a -Do not search on opponents time. -.TP -.B a -Do search on opponents time. -.TP -.B -b bookfile -Use bookfile for opening book. -.TP -.B -B binbookfile -Use binbookfile for binary opening book. -.TP -.B -S size -Size of binbookfile for memory based books. For creating a binbookfile. -.TP -.B -P plylevels -Number of plys to include in the binbookfile. For generating a binbookfile. -.TP -.B -c size -Create a new HASHFILE. File size is 2^size entries of approximately 65+? bytes. -.TP -.B -h -Do not use hashfile. -.TP -.B h -Do use hashfile. -.TP -.B -l pathname -Pathname of the loadfile use with the -.BR get -or -.BR xget. -.TP -.B -r length -Rehash length times in searching entries for position in transposition table. -.TP -.B -s pathname -Pathname of the save file to use with the -.BR save -command. -.TP -.B -t -Show statistics for HASHFILE -.TP -.B -T size -Set the transposition table size to 2^size entries. -.TP -.B -v -Show version and patchlevel. -.TP -.B -x value -Use -.BR value -as the evaluation window -.BR xwndw. -.SH COMMANDS -.PP -In addition to legal moves, the following commands are available as responses. -.B Note: -command names are determined by the -.I language -file and may vary with the implementation. This is default English. -.PP -.B alg --- allow algrbraic input (not implemented) -.PP -.B Awindow --- change Alpha window (default score + 90) -.PP -.B Bwindow --- change Beta window (default score - 90) -.PP -.B beep --- causes the program to beep after each move. -.PP -.B bd --- updates the current board position on the display. -.PP -.B book --- turns off use of the opening library. -.PP -.B both --- causes the computer to play both sides of a shogi game. -.PP -.B black --- causes the computer to take the white pieces, if the computer is to move first the -.PP -.B bsave --- saves a game to disk as a book textfile. -The program will prompt the user for a file name. -.PP -.B gamein --- toggles game mode time control. Assumes the time specified for time control -is the time for a complete game. Input with the level command should be the game time -and the expected number of moves in a game. -.B go -command must be given. -.PP -.B coords --- show coordinates on the display (visual only) -.PP -.B contempt --- allows the value of -.I contempt -to be modified. -.PP -.B debug --- asks for a piece as color piece, as wb or bn, and shows its calculated value on -each square. -.PP -.B debuglevel --- sets level of debugging output if compiled with debug options. -.PP -.B depth --- allows the user to change the -search depth of the program. The maximum depth is 29 ply. -Normally the depth is set to 29 and the computer terminates -its search based on elapsed time rather than depth. -If depth is set to (say) 4 ply, -the program will search until all moves -have been examined to a depth of 4 ply (with extensions up -to 11 additional ply for sequences of checks and captures). -If you set a maximum time per move and also use the depth command, -the search will stop at the specified time or the specified depth, whichever -comes first. -.PP -.B easy --- toggles easy mode (thinking on opponents time) -on and off. The default is easy mode ON. If easy mode is disabled, -the keyboard is polled for input every so often and when input is -seen the search is terminated. It may also be terminated with a -.I sigint. -.PP -.B edit --- allows the user to set up a board position. - -.B # -- command will clear the board. - -.B c -- toggle piece color. - -.B . -- command will exit setup mode. - -.B p3b -- place a pawn on 3b - -.B p3b+ -- place a promoted pawn on 3b - -.B p* -- place a pawn to the captured pieces - -Pieces are entered by typing a letter (p,l,n,s,g,b,r,k) for -the piece followed by the coordinate. - -The usual warning about the -.I language file -applies. -.PP -.B exit --- exits gnushogi. -.PP -.B first --- tells the computer to move first. Computer begins searching for a move. -(same as "go"). -.PP -.B force --- allows the user to enter moves for both -sides. To get the program to play after a sequence of moves -has been entered use the 'black' or 'white' commands. -.PP -.B get --- retrieves a game from disk. The program will -prompt the user for a file name. -.PP -.B hash --- use/don't use hashfile. -.PP -.B hashdepth --- allows the user to change the minimum depth for using the hashfile and the number of moves from the -begining of the game to use it. -.PP -.B help --- displays a short description of the commands and the current status of options. -.PP -.B go --- tells the computer to move first. Computer begins searching for a move. -(same as "first"). -.PP -.B hint --- causes the program to supply the user with its predicted move. -.PP -.B level --- allows the user to set time controls such as -60 moves in 5 minutes etc. In tournament mode, the program will -vary the time it takes for each -move depending on the situation. If easy mode is disabled (using -the 'easy' command), the program -will often respond with its move immediately, saving time on -its clock for use later on. -.PP -.B list --- writes the game moves and some statistics -on search depth, nodes, and time to the file 'chess.lst'. -.PP -.B material --- toggle material flag - draws on no pawns and both sides < rook -.PP -.B new --- starts a new game. -.PP -.B p --- evaluates the board and shows the point score for each piece. The total score for -a position is the sum of these individual piece scores. -.PP -.B post --- causes the program to display the principle -variation and the score during the search. A score of -100 is equivalent to a 1 pawn advantage for the computer. -.PP -.B quit --- exits the game. -.PP -.B random --- causes the program to randomize its move -selection slightly. -.PP -.B rcptr --- set recapture mode. -.PP -.B remove --- backout the last level for both sides. Equal to 2 -.I undo's. -.PP -.B reverse --- causes the board display to be reversed. That -is, the black pieces will now appear at the top of the board. -.PP -.B rv --- reverse board display. -.PP -.B save --- saves a game to disk. The program will prompt -the user for a file name. -.PP -.B switch --- causes the program to switch places with -the opponent and begin searching. -.PP -.B test --- performs some speed tests for MoveList and CaptureList generation, and ScorePosition position scoring -for the current board. -.PP -.B time --- set computers time remaining, intended for synchronizing clocks among multiple players. -.PP -.B tsume --- toggle tsume mode. In tsume mode, not all possible moves will be -generated. If a king is in check, only moves that makes the king not being -in check are generated. If the king is not in check, only moves that give -check to the opponents king are generated. -.PP -.B undo --- undoes the last move whether it was the computer's -or the human's. You may also type "remove". This is equivalent -to two "undo's" (e.g. retract one move for each side). -.PP -.B white --- causes the computer to take the black pieces, if the computer is to move first the -iB go -command must be given. -.PP -.B xget --- read an -.Ixshogi -position file. -.PP -.B xsave --- save as an -.Ixshogi -position file. -.PP -.B xwndw --- change X window. The window around alpha/beta used to determine whether the position -should be scored or just estimated. -.SH BUGS -.PP -.fi -.SH SEE ALSO -.nf -xshogi(6) -.fi - diff --git a/doc/gnushogi.6 b/doc/gnushogi.6 new file mode 100644 index 0000000..f7d1502 --- /dev/null +++ b/doc/gnushogi.6 @@ -0,0 +1,442 @@ +.TH gnushogi 6 +.SH NAME +gnushogi \- GNU Shogi (Japanese Chess), version 1.3 +.SH SYNOPSIS +.B gnushogi +[ +.B [[-]a] +.B [-b bookfile] +.B [-B binbookfile] +.B [-C] +.B [-h langfile] +.B [-L langfile] +.B [-r length] +.B [-R] +.B [-s pathname] [-l pathname] +.B [-S binbooksize] +.B [-t] [-c size] +.B [-T size] +.B [-v] +.B [-x] +.B [-X] +.B arg1 arg2 +] +.SH DESCRIPTION +.I Gnushogi +plays a game of japanese chess (shogi) against the user or it plays against +itself. +.PP +At startup +.I Gnushogi +reads the +.I binbook +file if it is present. It then looks for a +.I book +file. If it is present it adds its contents to the +.I binbook +data. If the +.I binbook +file is writable a new combined +.I binbook +file is written. + +.PP +.I Gnushogi +is a modified version of the gnuchess program. It has a simple +alphanumeric board display, or it can be compiled for use with the +.B xshogi +program under X windows. The program gets its opening moves from the file +.B gnushogi.bbk +which is located in a directory specified in the Makefile. To invoke the +program type: +.TP +.B gnushogi -C +- simple curses based version +.TP +.B gnushogi -X (or just gnushogi) +- xshogi compatible version +.TP +.B gnushogi -R +- raw test display version +.SH TIME CONTROLS +.PP +If one argument is given, it is the search time per move in +[minutes:]seconds. +So +.B gnushogi 30 +will generate one move every 30 seconds, while +.B gnushogi 5:00 +will generate one move every 5 minutes. + +If two or more arguments are given, they will be used to set tournament +time controls with the first argument of each pair being the number of +moves and the second being the total clock time in minutes[:seconds]. +Thus, entering +.B gnushogi 60 5 +will set +the clocks for 5 minutes (300 seconds) for the first 60 moves, +and +.B gnushogi 30 3:30 +will allow 3 minutes and 30 seconds for 30 moves. + +.B gnushogi 30 5 1 :30 +will allow 5 minutes for the first 30 moves and 30 seconds for each move +after that. Up to 4 pairs of controls may be specified. + +If no argument is given the program will prompt the user for level of play. + +For use with +.B xshogi +see the documentation on that program. +.SH BOOK +.PP +The book +.I gnushogi.tbk +consists of a sequence of openings. An opening begins with a line starting +with a +.B # +, the rest of the line is a comment. Following this is a series of moves +in algebraic notation alternating black and white separated by white +space. A move may have a +.B ? +after it indicating this move should never be made in this position. +Moves are stored as position:move so transpositions between openings +can take place. +.SH HASHFILE +.PP +The hashfile if created should be on the order of 4 megabytes or +.B gnushogi -c 22. +This file contains positions and moves learned from previous games. If a +hashfile is used the computer makes use of the experience it gained in past +games. Tests run so far show that it plays no worse with the hashfile than +without, but it is not clear yet whether it provides a real advantage. +.SH LEGAL MOVES +.PP +.B Note: +Piece letters are determined by the language file. +What is specified here is the default (English). +.PP +Once +.I gnushogi +is invoked, the program will display the board and prompt the user +for a move. To enter a move, use the notation +.B 7g7f +where the first letter-number pair indicates the origin square +and the second letter-number pair indicates the destination square. +An alternative is to use the notation +.B P7f +where the first letter indicates the piece type (P,L,N,S,G,B,R,K). +To promote append a + the type of the new piece to the move, as in +.B 2d2c+ +or +.B P2c+. +Note that you must use capital letters for the pieces by default. +.SH "COMMAND-LINE OPTIONS" +.TP +.B -a +Do not search on opponent's time. +.TP +.B a +Do search on opponent's time. +.TP +.B -b bookfile +Use bookfile for opening book. +.TP +.B -B binbookfile +Use binbookfile for binary opening book. +.TP +.B -c size +Create a new HASHFILE. File size is 2^size entries of approximately 65+? bytes. +.TP +.B -C +Use curses-based display mode. +.TP +.B -h +Do not use hashfile. +.TP +.B h +Do use hashfile. +.TP +.B -l pathname +Pathname of the loadfile use with +.BR get +or +.BR xget. +.TP +.B -L lang +Use language +.I lang from the file +.B gnushogi.lang. +If -L is not specified it uses the first language in the file. +.TP +.B -P plylevels +Number of plys to include in the binbookfile. For generating a binbookfile. +.TP +.B -r length +Rehash length times in searching entries for position in transposition table. +.TP +.B -R +Use raw text display mode. This can be used for dumb terminals or for +systems that don't have curses. +.TP +.B -s pathname +Pathname of the save file to use with the +.BR save +command. +.TP +.B -S size +Size of binbookfile for memory based books. For creating a binbookfile. +.TP +.B -t +Show statistics for HASHFILE +.TP +.B -T size +Set the transposition table size to 2^size entries. +.TP +.B -v +Show version and patchlevel. +.TP +.B -x value +Use +.BR value +as the evaluation window +.BR xwndw. +.TP +.B -X +Use xshogi display mode (the default). +.SH "COMMANDS" +.PP +In addition to legal moves, the following commands are available as responses. +.B Note: +command names are determined by the +.I language +file and may vary with the implementation. The default language is English. +.PP +.B alg +-- allow algebraic input (not implemented) +.PP +.B Awindow +-- change Alpha window (default score + 90) +.PP +.B Bwindow +-- change Beta window (default score - 90) +.PP +.B beep +-- toggles beeping after each move (default: on). +.PP +.B bd +-- updates the current board position on the display. +.PP +.B book +-- turns off use of the opening library. +.PP +.B both +-- causes the computer to play both sides of a shogi game. +.PP +.B black +-- causes the computer to take the white pieces, if the computer is to move +first. +.PP +.B bsave +-- saves a game to disk as a book textfile. +The program will prompt the user for a file name. +.PP +.B gamein +-- toggles game mode time control. Assumes the time specified for time control +is the time for a complete game. Input with the level command should be the +game time and the expected number of moves in a game. +.B go +command must be given. +.PP +.B coords +-- show coordinates on the display (visual only) +.PP +.B contempt +-- allows the value of +.I contempt +to be modified. +.PP +.B debug +-- asks for a piece as color piece, as wb or bn, and shows its calculated value on +each square. +.PP +.B debuglevel +-- sets level of debugging output if compiled with debug options. +.PP +.B depth +-- allows the user to change the search depth of the program. The maximum +depth is 29 ply. Normally the depth is set to 29 and the computer +terminates its search based on elapsed time rather than depth. If depth is +set to (say) 4 ply, the program will search until all moves have been +examined to a depth of 4 ply (with extensions up to 11 additional ply for +sequences of checks and captures). If you set a maximum time per move and +also use the depth command, the search will stop at the specified time or +the specified depth, whichever comes first. +.PP +.B easy +-- toggles easy mode (thinking on opponents time) on and off. The default +is easy mode ON. If easy mode is disabled, the keyboard is polled for +input every so often and when input is seen the search is terminated. It +may also be terminated with a +.I sigint. +.PP +.B edit +-- allows the user to set up a board position. + +.B # +- command will clear the board. + +.B c +- toggle piece color. + +.B . +- command will exit setup mode. + +.B p3b +- place a pawn on 3b + +.B p3b+ +- place a promoted pawn on 3b + +.B p* +- place a pawn to the captured pieces + +Pieces are entered by typing a letter (p,l,n,s,g,b,r,k) for +the piece followed by the coordinate. + +The usual warning about the +.I language file +applies. +.PP +.B exit +-- exits gnushogi. +.PP +.B first +-- tells the computer to move first. Computer begins searching for a move. +(same as "go"). +.PP +.B force +-- allows the user to enter moves for both +sides. To get the program to play after a sequence of moves +has been entered use the 'black' or 'white' commands. +.PP +.B get +-- retrieves a game from disk. The program will +prompt the user for a file name. +.PP +.B hash +-- use/don't use hashfile. +.PP +.B hashdepth +-- allows the user to change the minimum depth for using the hashfile and +the number of moves from the beginning of the game to use it. +.PP +.B help +-- displays a short description of the commands and the current status of options. +.PP +.B go +-- tells the computer to move first. Computer begins searching for a move. +(same as "first"). +.PP +.B hint +-- causes the program to supply the user with its predicted move. +.PP +.B level +-- allows the user to set time controls such as 60 moves in 5 minutes etc. +In tournament mode, the program will vary the time it takes for each move +depending on the situation. If easy mode is disabled (using the 'easy' +command), the program will often respond with its move immediately, saving +time on its clock for use later on. +.PP +.B list +-- writes the game moves and some statistics on search depth, nodes, and +time to the file 'shogi.lst'. +.PP +.B material +-- toggle material flag - draws on no pawns and both sides < rook +.PP +.B new +-- starts a new game. +.PP +.B p +-- evaluates the board and shows the point score for each piece. The total score for +a position is the sum of these individual piece scores. +.PP +.B post +-- causes the program to display the principal variation and the score +during the search. A score of 100 is equivalent to a 1 pawn advantage for +the computer. +.PP +.B quit +-- exits the game. +.PP +.B random +-- causes the program to randomize its move selection slightly. +.PP +.B rcptr +-- set recapture mode. +.PP +.B remove +-- backout the last level for both sides. Equal to 2 +.I undo's. +.PP +.B reverse +-- causes the board display to be reversed. That +is, the black pieces will now appear at the top of the board. +.PP +.B rv +-- reverse board display. +.PP +.B save +-- saves a game to disk. The program will prompt the user for a file name. +.PP +.B switch +-- causes the program to switch places with the opponent and begin +searching. +.PP +.B test +-- performs some speed tests for MoveList and CaptureList generation, and +ScorePosition position scoring for the current board. +.PP +.B time +-- set computer's time remaining, intended for synchronizing clocks among +multiple players. +.PP +.B tsume +-- toggle tsume mode. In tsume mode, not all possible moves will be +generated. If a king is in check, only moves that get the king out of check +are generated. If the king is not in check, only moves that give check to +the opponent's king are generated. +.PP +.B undo +-- undoes the last move whether it was the computer's +or the human's. You may also type "remove". This is equivalent +to two "undo"'s (e.g. retract one move for each side). +.PP +.B white +-- causes the computer to take the black pieces, if the computer is to move +first the +.B go +command must be given. +.PP +.B xget +-- read an +.I xshogi +position file. +.PP +.B xsave +-- save as an +.I xshogi +position file. +.PP +.B xwndw +-- change X window. The window around alpha/beta used to determine whether +the position should be scored or just estimated. +.SH BUGS +.PP +.fi +.SH SEE ALSO +.nf +xshogi(6) +.fi + diff --git a/doc/gnushogi.info b/doc/gnushogi.info new file mode 100644 index 0000000..1798d34 --- /dev/null +++ b/doc/gnushogi.info @@ -0,0 +1,55 @@ +This is gnushogi.info, produced by Makeinfo version 3.12h from +gnushogi.texinfo. + + This file describes how to use GNU shogi, a program which plays +Shogi (Japanese chess). + + Copyright (C) 1999 Michael C. Vanier and the Free Software +Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Free Software Foundation. + + +Indirect: +gnushogi.info-1: 928 +gnushogi.info-2: 49347 + +Tag Table: +(Indirect) +Node: Top928 +Node: Introduction1486 +Node: License2566 +Node: About shogi21727 +Node: The rules of shogi24322 +Node: The moves of the pieces25984 +Node: The opening setup29150 +Node: Promotion of pieces30682 +Node: Drops32525 +Node: Winning the game34777 +Node: Draws35491 +Node: Handicaps37896 +Node: Notes for chess players41323 +Node: Sample game42042 +Node: Mating problems49347 +Node: Shogi variants51596 +Node: Differences between shogi and chess55956 +Node: gnushogi60365 +Node: xshogi71847 +Node: References and links88414 +Node: Acknowledgements91580 +Node: Bugs93108 +Node: Index93592 + +End Tag Table diff --git a/doc/gnushogi.info-1 b/doc/gnushogi.info-1 new file mode 100644 index 0000000..c2af8de --- /dev/null +++ b/doc/gnushogi.info-1 @@ -0,0 +1,1082 @@ +This is gnushogi.info, produced by Makeinfo version 3.12h from +gnushogi.texinfo. + + This file describes how to use GNU shogi, a program which plays +Shogi (Japanese chess). + + Copyright (C) 1999 Michael C. Vanier and the Free Software +Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Free Software Foundation. + + +File: gnushogi.info, Node: Top, Next: (dir), Prev: (dir), Up: (dir) + +GNU Shogi (Japanese chess) +************************** + +* Menu: + +* Introduction:: What is GNU shogi? +* License:: The GNU General Public License. +* About shogi:: General information, rules, etc. +* gnushogi:: How to play GNU shogi (gnushogi). +* xshogi:: The X interface to GNU shogi. +* References and links:: Where to go for more information. +* Acknowledgements:: +* Bugs:: Where and how to report bugs. +* Index:: + + +File: gnushogi.info, Node: Introduction, Next: License, Prev: Top, Up: Top + +Introduction +************ + + GNU shogi is a program that plays shogi, the Japanese version of +chess, against a human (or computer) opponent. This file describes how +to use GNU shogi and also gives background information about the game +of shogi. + + This file describes GNU shogi version 1.3. It was written by me, +Mike Vanier, the current maintainer of GNU shogi. My email address is +. + + GNU shogi is actually two programs: + + +`gnushogi' + is the text-based program which also contains the game-playing + engine. + +`xshogi' + is the X-windows graphical interface to gnushogi. + + + Since xshogi invokes gnushogi, most players will just type "xshogi" +and start playing. + + Disclaimer: I use the personal pronouns "him", "his" etc. to refer +to a shogi player regardless of gender. That's easier than writing +"his or her" all over the place. I don't mean to infer that women +don't play shogi; in fact shogi is very popular in Japan among women as +well as men. + + +File: gnushogi.info, Node: License, Next: About shogi, Prev: Introduction, Up: Top + +GNU GENERAL PUBLIC LICENSE +************************** + + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +Preamble +======== + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it in +new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, +and (2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains a + notice placed by the copyright holder saying it may be distributed + under the terms of this General Public License. The "Program", + below, refers to any such program or work, and a "work based on + the Program" means either the Program or any derivative work under + copyright law: that is to say, a work containing the Program or a + portion of it, either verbatim or with modifications and/or + translated into another language. (Hereinafter, translation is + included without limitation in the term "modification".) Each + licensee is addressed as "you". + + Activities other than copying, distribution and modification are + not covered by this License; they are outside its scope. The act + of running the Program is not restricted, and the output from the + Program is covered only if its contents constitute a work based on + the Program (independent of having been made by running the + Program). Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the + notices that refer to this License and to the absence of any + warranty; and give any other recipients of the Program a copy of + this License along with the Program. + + You may charge a fee for the physical act of transferring a copy, + and you may at your option offer warranty protection in exchange + for a fee. + + 2. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a. You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b. You must cause any work that you distribute or publish, that + in whole or in part contains or is derived from the Program + or any part thereof, to be licensed as a whole at no charge + to all third parties under the terms of this License. + + c. If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display + an announcement including an appropriate copyright notice and + a notice that there is no warranty (or else, saying that you + provide a warranty) and that users may redistribute the + program under these conditions, and telling the user how to + view a copy of this License. (Exception: if the Program + itself is interactive but does not normally print such an + announcement, your work based on the Program is not required + to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the + Program, and can be reasonably considered independent and separate + works in themselves, then this License, and its terms, do not + apply to those sections when you distribute them as separate + works. But when you distribute the same sections as part of a + whole which is a work based on the Program, the distribution of + the whole must be on the terms of this License, whose permissions + for other licensees extend to the entire whole, and thus to each + and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or + contest your rights to work written entirely by you; rather, the + intent is to exercise the right to control the distribution of + derivative or collective works based on the Program. + + In addition, mere aggregation of another work not based on the + Program with the Program (or with a work based on the Program) on + a volume of a storage or distribution medium does not bring the + other work under the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms + of Sections 1 and 2 above provided that you also do one of the + following: + + a. Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Sections 1 and 2 above on a medium customarily used for + software interchange; or, + + b. Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a + medium customarily used for software interchange; or, + + c. Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with + such an offer, in accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete + source code means all the source code for all modules it contains, + plus any associated interface definition files, plus the scripts + used to control compilation and installation of the executable. + However, as a special exception, the source code distributed need + not include anything that is normally distributed (in either + source or binary form) with the major components (compiler, + kernel, and so on) of the operating system on which the executable + runs, unless that component itself accompanies the executable. + + If distribution of executable or object code is made by offering + access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify + or distribute the Program or its derivative works. These actions + are prohibited by law if you do not accept this License. + Therefore, by modifying or distributing the Program (or any work + based on the Program), you indicate your acceptance of this + License to do so, and all its terms and conditions for copying, + distributing or modifying the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program + subject to these terms and conditions. You may not impose any + further restrictions on the recipients' exercise of the rights + granted herein. You are not responsible for enforcing compliance + by third parties to this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent + issues), conditions are imposed on you (whether by court order, + agreement or otherwise) that contradict the conditions of this + License, they do not excuse you from the conditions of this + License. If you cannot distribute so as to satisfy simultaneously + your obligations under this License and any other pertinent + obligations, then as a consequence you may not distribute the + Program at all. For example, if a patent license would not permit + royalty-free redistribution of the Program by all those who + receive copies directly or indirectly through you, then the only + way you could satisfy both it and this License would be to refrain + entirely from distribution of the Program. + + If any portion of this section is held invalid or unenforceable + under any particular circumstance, the balance of the section is + intended to apply and the section as a whole is intended to apply + in other circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of + any such claims; this section has the sole purpose of protecting + the integrity of the free software distribution system, which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system; it is up to the author/donor to decide if he or she is + willing to distribute software through any other system and a + licensee cannot impose that choice. + + This section is intended to make thoroughly clear what is believed + to be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, + the original copyright holder who places the Program under this + License may add an explicit geographical distribution limitation + excluding those countries, so that distribution is permitted only + in or among countries not thus excluded. In such case, this + License incorporates the limitation as if written in the body of + this License. + + 9. The Free Software Foundation may publish revised and/or new + versions of the General Public License from time to time. Such + new versions will be similar in spirit to the present version, but + may differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the + Program specifies a version number of this License which applies + to it and "any later version", you have the option of following + the terms and conditions either of that version or of any later + version published by the Free Software Foundation. If the Program + does not specify a version number of this License, you may choose + any version ever published by the Free Software Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the + author to ask for permission. For software which is copyrighted + by the Free Software Foundation, write to the Free Software + Foundation; we sometimes make exceptions for this. Our decision + will be guided by the two goals of preserving the free status of + all derivatives of our free software and of promoting the sharing + and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE + LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT + HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT + WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE + QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY + SERVICING, REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY + MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE + LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, + INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR + INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF + DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU + OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY + OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs +============================================= + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. + Copyright (C) 19YY NAME OF AUTHOR + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Also add information on how to contact you by electronic and paper +mail. + + If the program is interactive, make it output a short notice like +this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details + type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + + The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + + You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the program, +if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + SIGNATURE OF TY COON, 1 April 1989 + Ty Coon, President of Vice + + This General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use the +GNU Library General Public License instead of this License. + + +File: gnushogi.info, Node: About shogi, Next: gnushogi, Prev: License, Up: Top + +About the game of shogi +*********************** + + "Japanese chess cedes nothing in depth or beauty to the European + game... it is at least as interesting." + + -- Alexander Alekhine + (quoted in David Pritchard, `The Encyclopedia of Chess Variants') + + + "... shogi [is] by far the most complex form of chess that has ever + achieved widespread popularity." + + -- R. Wayne Schmittberger, `New Rules for Classic Games' + + + Shogi is the version of chess played in Japan. It is strikingly +different from standard chess (which I shall refer to henceforth as +"international chess") and also to all other regional variants, because +captured pieces can re-enter play on the side of the capturer. This +has several interesting effects on the play of the game: + + + 1. Shogi is much more complex than international chess, at least in + terms of the average number of possible moves per turn (estimated + at about 35 for chess and at about 80 for shogi). + + 2. There are almost no draws (about 1-2% of all games in professional + play). + + 3. Exchanges complicate the play rather than simplifying it. + + 4. There are no "endgames" in the standard chess sense; all pieces + remain in play throughout the game. Games typically end in a race + to checkmate the other player before being checkmated oneself. + + 5. Ownership of a piece is not indicated by the color of the piece; + instead, pieces are wedge-shaped and point towards the opponent. + The name of the piece is inscribed in Kanji characters on the + front of the piece. + + 6. Most importantly: it's more fun than other forms of chess :-) + + + + Shogi is extremely popular in Japan; it has been estimated that 20 +million Japanese can play shogi, of which perhaps 1 million are active +players. It is even more popular there than the game of go, Japan's +other favorite board game. There are a number of professional players +who make a considerable amount of money playing in shogi tournaments, +and the game receives extensive newpaper and television coverage. +Despite this, the game has yet to become popular outside of Japan. Part +of this is because the Kanji characters on the pieces scare away some +people, but mostly it's due, I think, to lack of exposure to the game +and to the difficulty of finding opponents. I hope that GNU shogi will +help introduce shogi to a wider audience. + +* Menu: + +* The rules of shogi:: +* Sample game:: +* Mating problems:: +* Shogi variants:: +* Differences between shogi and chess:: + + +File: gnushogi.info, Node: The rules of shogi, Next: Sample game, Prev: About shogi, Up: About shogi + +The rules of shogi +================== + + Shogi is a two-person abstract strategy board game with full +information (i.e. all pieces and moves are visible to both players at +all times). It is in the chess family, being descended from the same +ancestral game as international chess: the Indian game of Chaturanga. +The two players are referred to as "Black" and "White", with Black +moving first (unlike in international chess, where White moves first), +and with movement alternating between the two players. Note that +"Black" and "White" are just names; the pieces are not colored. +Instead, they are flat, wedge-shaped pieces which point towards the +opponent. The identity of a given piece is indicated by two Japanese +Kanji characters on each piece. In fact, only the top character is +needed to identify the piece and thus only the top character is used in +shogi diagrams. I will use alphabetical equivalents in the diagrams +here; to see what the Kanji characters look like, start up xshogi +(*note xshogi::.) and compare the starting setup there with the +starting setup in this file (*note The opening setup::.). + + The object of the game is to capture the opponent's King. The board +is a grid of 9x9 uncolored squares, and pieces are placed on the +squares. Each player begins with 20 pieces, described in the next +section. Capture is by displacement, as in international chess. + +* Menu: + +* The moves of the pieces:: +* The opening setup:: +* Promotion of pieces:: +* Drops:: +* Winning the game:: +* Draws:: +* Handicaps:: +* Notes for chess players:: + + +File: gnushogi.info, Node: The moves of the pieces, Next: The opening setup, Prev: The rules of shogi, Up: The rules of shogi + +The moves of the pieces +----------------------- + + Each player at the beginning of a shogi game has a total of 20 +pieces of eight different types. The moves of the shogi pieces can be +divided into three classes: "stepping" pieces, that only move one +square at a time; "ranging" pieces that move any number of unobstructed +squares in a line, and "jumping" pieces that can jump over obstructing +pieces to reach their destination squares. Most pieces can also +promote to different (usually stronger) pieces under certain +circumstances (see the next section). All pieces capture the same way +that they move (even pawns). The piece moves and promotions are as +follows; each piece name is followed by the standard piece abbreviation: + + 1. The king (K). The king can move one square in any horizontal, + vertical, or diagonal direction, just like the king in + international chess. The king does not promote. + + 2. The rook (R). The rook can move any number of squares in a + horizontal or vertical direction. The rook is the same as the + rook in international chess (except that it can promote). A rook + promotes to a "dragon king" or "dragon" for short (often just + referred to as a "promoted rook"), which can move as a rook or can + move one square in any diagonal direction. + + 3. The bishop (B). The bishop can move any number of squares in a + diagonal direction. The bishop is the same as the bishop in + international chess (except that it can promote). A bishop + promotes to a "dragon horse" or "horse" for short (often just + referred to as a "promoted bishop"), which can move as a bishop or + can move one square in any horizontal or vertical direction. + Note: the horse should not be confused with a knight (see below), + as they are two completely different pieces. + + 4. The gold general (G). A gold general can move one square in any + horizontal or vertical direction, or one square in a forward + diagonal direction. Gold generals do not promote. + + 5. The silver general (S). A silver general can move one square in + any diagonal direction, or one square straight forward. A silver + general promotes to a gold general. + + 6. The knight (N). A knight can move one square straight forward + followed by one square to either forward diagonal, jumping over + intervening pieces if any. In other words, a knight moves like + its international chess counterpart, but forward only. A knight + promotes to a gold general. The knight is the only jumping piece, + as in chess. + + 7. The lance (L). A lance can move any number of squares straight + forward. A lance promotes to a gold general. + + 8. The pawn (P). A pawn can move one square straight forward. The + pawn captures the same way that it moves, in contrast to + international chess. There is also no initial two-space move for + pawns and no _en-passant_ capture. A pawn promotes to a gold + general; a promoted pawn is usually known as a "Tokin". + + + +File: gnushogi.info, Node: The opening setup, Next: Promotion of pieces, Prev: The moves of the pieces, Up: The rules of shogi + +The opening setup +----------------- + + The opening setup for shogi is as follows: + + 9 8 7 6 5 4 3 2 1 ++--------------------------------------------+ +| wL | wN | wS | wG | wK | wG | wS | wN | wL | a ++--------------------------------------------+ +| | wR | | | | | | wB | | b ++--------------------------------------------+ +| wP | wP | wP | wP | wP | wP | wP | wP | wP | c ++--------------------------------------------+ +| | | | | | | | | | d ++--------------------------------------------+ +| | | | | | | | | | e ++--------------------------------------------+ +| | | | | | | | | | f ++--------------------------------------------+ +| bP | bP | bP | bP | bP | bP | bP | bP | bP | g ++--------------------------------------------+ +| | bB | | | | | | bR | | h ++--------------------------------------------+ +| bL | bN | bS | bG | bK | bG | bS | bN | bL | i ++--------------------------------------------+ + + + Here, "b" stands for "black" and "w" stands for "white", so that, +for instance, "bL" means "black lance". The numbers above the files +and the letters to the right of the ranks represent the most common +notation system used for shogi by westerners (the Japanese also use +Arabic numerals for the files but use Japanese numerals for the ranks). + + +File: gnushogi.info, Node: Promotion of pieces, Next: Drops, Prev: The opening setup, Up: The rules of shogi + +Promotion of pieces +------------------- + + In sharp contrast to international chess, where only pawns can +promote to higher-ranked pieces, most of the pieces in shogi can +promote. The promoted ranks are discussed in the section on piece +moves (*note The moves of the pieces::.) but are repeated here for +reference: + +Pawn + promotes to gold general (called a `tokin' in this case only). + +Lance + promotes to gold general. + +Knight + promotes to gold general. + +Silver general + promotes to gold general. + +Gold general + does not promote. + +Bishop + promotes to "dragon horse" or just "horse" for short. The horse + can move as a bishop or can move one square in any orthogonal + direction. + +Rook + promotes to "dragon king" or just "dragon" for short. The dragon + can move as a rook or can move one square in any diagonal + direction. + +King + does not promote. + + + The three ranks furthest away from each player constitute his/her +"promotion zone". A player may, but is not required to, promote a +piece after making a move in which the piece begins and/or ends in the +promotion zone. Thus you can promote a piece when moving the piece into +the promotion zone, out of the promotion zone, or entirely within the +promotion zone. Promotion is mandatory in these cases: + + + 1. You must promote a pawn or a lance after moving it to the last + rank. + + 2. You must promote a knight after moving it to either of the last + two ranks. + + + + These forced promotions ensure that a piece cannot be moved to a +square from which it would have no further move. + + Pieces "dropped" onto the board (*note Drops::.) always drop in the +unpromoted state, even if they drop into the promotion zone. + + +File: gnushogi.info, Node: Drops, Next: Winning the game, Prev: Promotion of pieces, Up: The rules of shogi + +Drops +----- + + When a player captures a piece, that piece is not removed from play. +Instead, it becomes the property of the capturer and can re-enter play +by being placed on (almost) any vacant square during the player's move. +This is known as a "drop" and counts as a full move (in other words, +you can either move a piece on the board or drop a piece onto the board +during your move, but not both). All pieces drop in the unpromoted +state. Pieces may be legally dropped in their promotion zone, but they +do not promote on that turn. + + There are several restrictions on drops: + + 1. A pawn may not be dropped onto a file if there is already an + unpromoted pawn belonging to the same player on that file. It is + legal to drop a pawn on a file which contains a _promoted_ pawn + belonging to the same player, however. + + 2. A pawn may not be dropped to give immediate checkmate on the move. + A pawn is, however, permitted to be moved on the board to give + immediate checkmate. This is a curious rule, and if anyone knows + the reason for it I would appreciate it if they would contact me + and explain it to me :-) + + 3. A pawn or piece may not be dropped onto a square from which they + would have no legal move. This means that pawns and lances may + not be dropped onto the last rank, and the knight may not be + dropped onto the last or second-to-last rank. + + + It is entirely permissible (and often advisable) to drop a piece or +pawn between one's King and an attacking ranging piece. For this +reason, the final checkmating move is nearly always an attack on the +King from an adjacent square (except for an attack by a Knight). + + Captured pieces are said to be pieces "in hand". + + The drop is the primary distinguishing feature of Japanese chess, +shared with no other popular chess-type game. It gives shogi a very +aggressive quality, and dramatically increases the number of possible +moves once a few pieces have been captured. Another interesting +feature of shogi is that exchanges complicate play rather than +simplifying it (as in international chess), because of the drop rule. + + +File: gnushogi.info, Node: Winning the game, Next: Draws, Prev: Drops, Up: The rules of shogi + +Winning the game +---------------- + + A game of shogi is won by capturing the opponent's king. In general, +this is done by checkmating the king: attacking the king in such a way +that the king cannot be defended no matter what the defending player +moves. Note, though, that there is no rule that requires a player to +defend a king which is being attacked. However, if he does not defend +his king, the opponent is entirely free to capture it on the next move, +thus winning the game. As in international chess, in practice most +games end by resignation when one player realizes that he cannot escape +checkmate. + + +File: gnushogi.info, Node: Draws, Next: Handicaps, Prev: Winning the game, Up: The rules of shogi + +Draws +----- + + There are very few draws in shogi; only about 1-2% of professional +games end in a draw. One reason for this is that material can never be +depleted as in chess, because captured pieces are constantly re-entering +play as a consequence of the drop rule. In fact, most of the ways a +game can be drawn in chess are not allowed in shogi: + + + * Draws cannot be offered. + + * There is no fifty-move rule. + + * A stalemate counts as a win for the stalemater. Stated otherwise: + if you can't move, you lose. + + * Perpetual check is illegal (see below). + + + + There are only two legal ways in which a draw can occur: + + + 1. A position (including the pieces in hand) occurs 4 times with the + same player to move (called "Sennichite"). However, if this is + caused by consecutive checks (direct attacks on the King, + threatening to capture it on the next move) by one side, the + player giving these checks loses the game. In other words, + perpetual check results in a loss for the attacker who recreates + the same position the 4th time. + + 2. Both players have moved their King into the the promotion zone (or + they cannot be prevented from doing so) and the Kings cannot be + checkmated. A King who has entered the promotion zone is known as + an "entering King"; due to the forward orientation of most shogi + pieces, it is very hard to mate such a King. In that case the + players may decide to count their pieces as follows: the King does + not count, the Rook and Bishop count as 5 points, and all other + pieces as one point. Promotion is disregarded. If both players + have at least 24 points the game is a draw (called "Jishogi"). If + a player has less, he loses the game. + + Of course, a player can refuse to count pieces when he still has + mating chances or chances to gain material which would affect the + outcome of the counting. There is no strict rule about what to do + if this is not the case, but nonetheless a player refuses to count + up (e.g. because he does not have enough points for a draw). It + has been generally accepted that in such a case the game ends and + the pieces are counted after one player has managed to get all his + pieces protected in the promotion zone. + + + + +File: gnushogi.info, Node: Handicaps, Next: Notes for chess players, Prev: Draws, Up: The rules of shogi + +Handicaps +--------- + + Unlike international chess, shogi has a well-established handicap +system which is used when players of different strengths play against +each other. Handicaps range from small to huge, which makes it +possible for weak players to play against even very strong players and +have an even chance of winning. + + Shogi players are ranked as follows: the weakest rank is around 15 +"kyu", which represents a beginner. 14 kyu is higher than 15 kyu, 13 +kyu is higher still, and so on until you get to 1 kyu. The next highest +rank is 1 "dan", followed by 2 dan, 3 dan and so forth. The highest +amateur rank is 6 dan; professionals go up to 9 dan. However, +professional ranks are not the same as amateur ranks; a professional 1 +dan is _much_ stronger than an amateur 1 dan. This system is similar +to that used by go players (and also other Japanese sports such as +karate). + + A handicap consists of the stronger player playing White and removing +one or more pieces from his side of the board at the start of the game. +These pieces are permanently removed from play; they are not in hand. + + The following is a list of the accepted handicaps, from weakest to +strongest. The degree of the handicap, represented by the position in +the list, represents the difference in rank between the two players for +which the handicap is appropriate. These rules are taken from the books +"Shogi for Beginners" by John Fairbairn and "The Art of Shogi" by Tony +Hoskings (*note References and links::.) and, I believe, represent +current Japanese practice. + + + 1. The stronger player removes his left lance (on 1a). + + 2. The players play a two-game match; in the first game the stronger + player removes his left lance (on 1a), while in the second game he + removes his bishop. + + 3. The stronger player removes his bishop. + + 4. The stronger player removes his rook. + + 5. The stronger player removes his rook and left lance. + + 6. The players play a two-game match; in the first game the stronger + player removes his rook and left lance (on 1a), while in the + second game he removes his rook and bishop. + + 7. The stronger player removes his rook and bishop. This is usually + called a "two-piece" handicap. + + 8. The stronger player removes his rook, bishop, and both lances. + This is called a "four-piece" handicap. + + 9. The stronger player removes his rook, bishop, both lances, and both + knights. This is called a "six-piece" handicap. + + 10. The stronger player removes his rook, bishop, both lances, both + knights, and both silvers. This is called an "eight-piece" + handicap. + + + + Another advantage of playing handicap games is that the handicaps +alter the optimal strategy for both players. For instance, handicaps +all have their own opening lines which may bear little or no +resemblance to those used in non-handicap shogi. This means that when +learning handicap shogi, you are essentially learning completely new +games which use the same equipment! + + The reader may wonder how on earth a player giving an eight-piece +handicap, say, could possibly hope to win. Don't forget, though, that +in shogi the opponent's pieces can be captured and then become part of +one's own army. Thus, if the opponent plays badly enough, the number of +pieces will soon even out. + + +File: gnushogi.info, Node: Notes for chess players, Prev: Handicaps, Up: The rules of shogi + +Notes for chess players +----------------------- + + Here are a few miscellaneous things that may confuse chess players. +Some of these have been mentioned elsewhere, but they bear repeating. + + + 1. There is no queen. + + 2. Pawns capture the same way they move. There is no initial + two-space pawn move and no _en-passant_ move. + + 3. There is no special castling move. There _are_ a large number of + possible defensive formations referred to as "castles" (*note + Sample game::.) but there is no need for special moves to create + them. + + 4. A given piece can only promote to _one_ other kind of piece. + + + + +File: gnushogi.info, Node: Sample game, Next: Mating problems, Prev: The rules of shogi, Up: About shogi + +Sample game +=========== + + This game was annotated by Pieter Stouten (*note References and +links::.). I have made some minor corrections. Note that captures are +denoted by the "x" symbol e.g. Rx3f and drops are denoted by the "*" +symbol e.g. R*3f. Check is indicated by a "+" after the move, e.g. +R3f+. I recommend you use gnushogi/xshogi to play along with this +game. In xshogi simply hit the "Force Moves" button after starting up, +while in gnushogi enter the word "force" at the prompt. This will +allow you to enter moves for both sides. + + Note also that the move numbering system used here is the chess-type +system where one move means one move by each player. The Japanese count +one move made by each player as two moves. + +-------------------------------------------------------------------------- + + Below you will find (the English translation of) an annotated game +which was published in the Dutch Shogi magazine "81" and in the Dutch +beginners booklet. It has proven to be a very useful game to explain +some basic principles of Shogi. Also, it is a rather straightforward +game compared to professional games where in most cases very diffuse +middle game fights take place. + + Pieter Stouten, 14th May 1990. + +-------------------------------------------------------------------------- + + Black: Michael Trent (1-dan). White: David Murphy (2-dan). + + 1. P2f P3d 2. P2e B3c +[ This move is necessary, as otherwise white can exchange pawns: 3. P2d +Px2d 4. Rx2d. He would thus get a pawn in hand and open up his rook +file. ] + + 3. P7f P4d +[ White closes the bishop diagonal again. He plans to play ranging rook +(the rook goes to 5b, 4b, 3 or 2b; a defensive strategy) and in that +case he'd better avoid an exchange of bishops. One of the reasons is +that he will have problems developing his pieces without leaving holes +for bishop drops. ] + + 4. S4h R3b 5. P3f S4b 6. K6h K6b +[ In general the rook plays an important role in the attacks. It is +wise to move the king away from the area where the initial fights will +be and both players act according to the Shogi proverb "keep the rook +and king apart". ] + + 7. K7h K7b 8. P5f P5d 9. G4i-5h G4a-5b +[ Both players use their second gold general to build their castle. ] + + 10. S6h +[ In itself this move is not bad. However, it will become clear that +black plans a quick attack and in that case it is wiser to omit this +move. ] + + 10... S5c 11. P1f P1d +[ The advance of the edge pawns must be timed very well. The remark at +black's tenth move applies here too: this move is good if black wants to +play a slow game, because it eliminates a future B1e. ] + + 12. P4f K8b 13. N3g S7b +[ Black develops his knight in order to start an attack over the second, +third and fourth files. White strengthens his king's position and +awaits the attack. He aims at a counterattack as soon as black has +broken through into the white camp. Probably white's breakthrough will +take place later, but he has good compensation in the form of a stronger +castle. This theme occurs very often in static rook versus ranging rook +games. ] + + 14. P4e R4b +[ Black starts his attack and white puts up a very passive defence. His +rook has a hard task now to penetrate the black position. Moreover, he +blocks his own bishop. It seems much better to start a counterattack +with 14... P3e, later to be followed by B2b, B5a or Bx4d in order to use +his rook more actively. ] + + 15. Px4d Sx4d 16. P*4e S5c +[ 16... Sx4e is more active. A silver general is normally more valuable +than a knight, but white gets two pawns in hand and black none, while +the knight might come in handy for white too. ] + + 17. Bx3c+ Nx3c 18. P2d Px2d +[ Black threatens to break through and white has to consider taking the +pawn on 2d or starting a counterattack with Nx4e. If he chooses the +latter, black can play Px2c+ followed by +P3c. The disadvantage is the +black "tokin" (=promoted pawn) that white will get in his camp; the +advantage is that it will cost black two more moves to promote his rook. +Because white did not trust that the result after engaging in a +"semeai" (=mutual attack) with 18...Nx4e would give a positive result, +he captured the pawn on 2d. Making the right decision in moments like +this often makes the difference between a win and a loss: miss one +attacking chance and you will be forced to defend the whole game until +the unavoidable defeat; on the other hand, an unsound attack can destroy +all "aji" (=potential, meaning possibilities, threats) without getting +anything in return. ] + + 19. Rx2d Nx4e 20. Nx4e Rx4e 21. R2a+ P*4g +[ Now it becomes clear why black's 10. S6h was not good. Had this move +been omitted, then white would not have had the time to play 13... S7b +and after R2a+ the gold on 6a would hang. Thus black would have kept +"sente" (=initiative). Instead of 21... P*4g, B*6d is a very good +move, because after 22. P*2h black does not have a pawn in hand anymore +and he is being threatened with the annoying 22... N*4f 23. G5g N3h+ +24. S4g +N4h also. Black can also counter 21... B*6d with 22. N*3g. +White would then reply with 22... R4b 23. B*3c P*4g 24. Bx4b+ Sx4b. The +white rook has played its role and instead of spending moves on saving +it white starts to scatter black's defences by successive pawn drops on +the fourth file: 25. Gx4g P*4f 26. G5g N*6e 27. G5h P4g+ 28. Gx4g P*4f. +This analysis was provided by Kato Hifumi, 9-dan professional (the +highest regular grade). Destroying the coherence of the enemy pieces +(their shape) by dropping pawns is one of the most important Shogi +techniques. With the actual move 21... P*4g white missed a good +chance. ] + + 22. Sx4g P*4f 23. B*3g Px4g+ 24. +Rx6a +Px3g +[ 23. B*3g seems pointless, but a closer look reveals that it is +actually quite mean. On move 24 white cannot capture black's "Ryu" +(=dragon =promoted rook) with his silver: 24... Sx6a 25. N*7d K7b 26. +G*8b mate. By attacking the front of the white castle and threatening +to mate him there, black has the chance to break down the white +defences from the side. ] + + 25. +Rx5b S*6b +[ Here 25... B*4d would be much better, because it is defensive and +attacking at the same time. After e.g. 26. G*4c Bx9i+ 27. Gx5c black +threatens 28. +Rx7b Kx7b 29. S*6a K8b 30. S*7a Kx7a 31. G*7b mate. +White is one move quicker, however. He has the following beautiful +"tsume" (mating sequence where every move is check): 27... N*8f 28. Px8f +S*8g 29. Kx8g B*9h 30. K7h Bx8i+ 31. K8g +B8i-8h 32. K9f L*9e mate. +This illustrates the sharpness of Shogi: one move can make the +difference between winning and losing. ] + + 26. P*4f Rx4f +[ This move eliminates white's last chances. 26... R4b 27. +Rx4b Sx4b +28. R*4a seems annoying, but after 28... B*3c 29. S7g B*3b white wins +the rook and with his "tokin" on 3g there still is some hope. ] + + 27. N*6e +P4g +[ White cannot defend anymore, so he starts a desperate attack. Black +does not lose the right track, however. ] + + 28. Nx5c+ +Px5h 29. +Nx6b +Px6h 30. Gx6h N*8f 31. Px8f B*6i 32. +Gx6i R4h+ 33. N*6h +Rx6h 34. Gx6h S*8g 35. Kx8g N*9e 36. K7h +Resigns +[ White resigns here, because after 36... B*8g 27. K7g his attack has +petered out. ] + diff --git a/doc/gnushogi.info-2 b/doc/gnushogi.info-2 new file mode 100644 index 0000000..af2563b --- /dev/null +++ b/doc/gnushogi.info-2 @@ -0,0 +1,1262 @@ +This is gnushogi.info, produced by Makeinfo version 3.12h from +gnushogi.texinfo. + + This file describes how to use GNU shogi, a program which plays +Shogi (Japanese chess). + + Copyright (C) 1999 Michael C. Vanier and the Free Software +Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Free Software Foundation. + + +File: gnushogi.info, Node: Mating problems, Next: Shogi variants, Prev: Sample game, Up: About shogi + +Mating problems +=============== + + One good way to improve at shogi is to solve mating problems. There +are several types of these problems, but the most common is called a +"tsume-shogi" problem, or "tsume" problem for short. In a tsume +problem, all pieces that are not on the board are assumed to be in the +opponent's hand (except for your King, which is usually not shown). +Every move you make must be check until the final checkmate. Your +opponent may play any piece on the board or drop any of his pieces in +hand in order to prevent the mate. In a properly constructed tsume +problem, all of your pieces on the board and in hand must be essential +to the solution. One consequence of this is that all of your pieces in +hand must be played during the solution. There should only be one +correct solution for the given number of moves. Tsume problems use +Japanese-style move numbering; thus, a problem where you move (and give +check), your opponent moves, and you move to give checkmate is called a +three-mover. Here is a really trivial three-mover: + + + 3 2 1 +---------------+ +| | | | a +---------------+ +| | | wK | b +---------------+ +| | | | c +---------------+ +| bN | | | d +---------------+ +| | | | e +---------------+ +| | bN | | f +---------------+ + +Black in hand: S, G + + + Here, Black plays G*2b, White plays K1c, and Black plays S*1d mate. +More typical tsume problems range from 5 moves to arbitrarily high +numbers of moves, and they can be quite brain-busting. Tsume problems +may seem artificial, but in the closing stages of the game where both +players have a lot of pieces in hand, it is often necessary to give +check at every move, or else your opponent will start a counterattack +and will mate you before you mate him. A tsume problem is a worst-case +scenario for the attacker: you have to mate your opponent even though he +has every piece not on the board in hand, which means you have to +develop sharp attacking skills. Many more tsume problems can be found +on the internet; I particularly recommend Patrick Davin's "Shogi Nexus" +(*note References and links::.). + + +File: gnushogi.info, Node: Shogi variants, Next: Differences between shogi and chess, Prev: Mating problems, Up: About shogi + +Shogi variants +============== + + Several historical variants of shogi exist. Most of these were +invented before modern shogi (in some cases hundreds of years before), +are much larger than modern shogi and are not played with drops. Thus, +in many ways they are really more like giant chess games than like +modern shogi. The only one of these games to have survived in Japan is +Chu (middle) shogi, which is still played a little bit. Thanks to the +efforts of George Hodges and John Fairbairn of the Shogi Association +(two British shogi enthusiasts), these games were resurrected and rules +and sets for them can still be purchased from George Hodges (*note +References and links::.). I hope to eventually extend GNU shogi so +that it can play at least some of these games. There are also several +non-historical variants of shogi; I don't know much about them but you +can find information about them on the internet (*note References and +links::.). + + The historical variants include: + + + 1. Tori (bird) shogi, played on a 7x7 board with 32 pieces in all; + this is the only variant that is known to have been played with + drops. + + 2. Wa shogi, played on an 11x11 board with 54 pieces. This game can + be played with or without drops but the historical evidence favors + the view that it was played without drops. However, most people + who have tried it claim it is a much better game with drops, being + even more intricate than standard shogi. + + 3. Chu (middle) shogi, played on a 12x12 board with 92 pieces. This + was (and is) by far the most popular of the variants, and has 21 + different kinds of pieces in the starting line-up alone (along + with several others that appear upon promotion). Unlike modern + shogi, there are a tremendous number of ranging pieces and the + game is definitely not played with drops. There is also an + amazing piece called the Lion which has a double king move and can + capture two pieces at once! Chu shogi has a small but fanatical + following, some of whom consider it better than modern shogi. + + 4. Dai (great) shogi, played on a 15x15 board with 130 pieces. Other + than the larger board, this game is very similar to Chu shogi. + + 5. Tenjiku (exotic) shogi, played on a 16x16 board with 176 pieces. + This game is possibly the most complex tactical game in existence. + There are many astoundingly powerful pieces, including one (the + Fire Demon) that can capture up to eight opposing pieces in a + single move! Despite the size of the game, checkmates can occur + very suddenly (and often very early on) if one player makes a + wrong move. Tenjiku also has a small but fanatical following, one + of whom (Colin Adams) has written a book on the game which is + available for download at + `http://www.colina.demon.co.uk/tenjiku.html'. + + 6. Dai-dai (great-great) shogi, played on a 17x17 board with 192 + pieces. The opening setup alone has 64 different kinds of pieces! + This game and the larger ones that follow sound pretty + outlandish, but they have actually been played; a game of Dai-dai + can supposedly be played in about 12 hours. + + 7. Maka-dai-dai (great-great-great) shogi, played on a 19x19 board + with 192 pieces. For those for whom Dai-dai shogi is just too + small :-) + + 8. Tai (grand) shogi, played on a 25x25 board with 377 pieces! Until + recently, this was thought to be the biggest chess game ever + devised, but now there is... + + 9. Kyoku tai (extremely grand?) shogi, played on a 36x36 board with + 402 pieces. The rules for this have just been unearthed in an old + Japanese book. Hopefully someone will soon organize a postal + Kyoku tai shogi championship; maybe their distant ancestors could + finish it :-) + + It is thought that the really huge games (Dai-dai and up) were + never really played to any significant extent (gee, wonder why?) + and were devised merely so that the creators could have the fun of + inventing enormous games, amazing their friends and confounding + their enemies. However, the games up to Tenjiku shogi at least + appear to be quite playable, assuming one has the time. + + + + +File: gnushogi.info, Node: Differences between shogi and chess, Prev: Shogi variants, Up: About shogi + +Differences between shogi and chess +=================================== + + Some differences between shogi and international chess have been +mentioned elsewhere in this document; I summarize them here for people +who are interested in game comparisons. I won't try to deal with the +thorny question of which game is "better" although my bias may have +already come through :-) In fact, the drop rule makes the two games so +different in character that arguing over which game is better is like +comparing apples to oranges (you'd be better off comparing chess to Chu +shogi (*note Shogi variants::.). However, I believe that if you are a +chess fan you'll really like shogi as well, and shogi is also popular +with many people who don't particularly like chess. + + Here are the significant differences between chess and shogi: + + + 1. In shogi, captured pieces become the property of the capturer and + can re-enter play by being dropped onto almost any vacant square. + In chess, captured pieces are out of the game. Thus, in shogi, + piece exchanges complicate the play significantly while in chess + they simplify it. + + 2. The shogi board is 9x9; the chess board is 8x8. + + 3. Shogi has five pieces with no counterpart in chess: the gold and + silver generals, the lance, the promoted rook and the promoted + bishop. Chess has one piece with no counterpart in shogi: the + queen. The knight's move in shogi is much more restrictive than + in chess. Pieces in shogi generally have a much smaller range of + movement than in chess (unless they are in hand). + + 4. In shogi, all pieces except the gold general and the king can + promote, but only to one kind of piece. Promotion is easier in + shogi because the promotion zone is closer to the starting + position of the pieces (especially pawns). In chess, only the + pawn can promote, but it can promote to any other piece except the + king. + + 5. In shogi, pawns capture the same way they move. There is no + initial two-space pawn move and hence no _en-passant_ captures. + In chess, pawns capture diagonally which means that opposing pawns + can block each other. + + 6. In shogi, you only have one rook and one bishop. Note that the + bishop is not restricted to only one "color" square (squares in + shogi aren't colored, but never mind) because promoted bishops can + also move one square orthogonally. + + 7. There is no special castling move in shogi. The term "castle" is + used in shogi to denote a defensive formation consisting of + (usually) three generals which protect the king. There are many + such castles (about 40 or so have names). *Note Sample game::. + + 8. Draws are much rarer in shogi than in chess. Perpetual check is + not allowed. Stalemate is a virtual impossibility, and is a loss + for the stalematee. + + 9. Since pieces are never out of play in shogi, chess-type endgames + involving only a few pieces do not occur. + + 10. Shogi games are generally longer than chess games (about 60-70 + moves is typical). + + 11. Shogi has a well-developed handicap system which is in general use; + chess does not. + + + + The effects of all these differences on play include (in my opinion): + + + 1. Piece/pawn structures in chess are more rigid than in shogi. Pawns + block each other and pawns, once advanced, cannot ever retreat. In + shogi, you can repair the hole caused by a pawn advance by + exchanging the pawn and dropping it back where you want it. Thus + shogi is more fluid than chess and less "structural". + + 2. Counterattack is MUCH more common in shogi than in chess. Games + typically end in mutual mating attacks, where each player is + trying to checkmate the other player before being checkmated + himself. This makes tempo incredibly important and also makes + sacrificial play quite common. + + 3. Attacks involving only ranging pieces are more a feature of chess + than of shogi. A shogi attack typically uses a ranging piece or + pieces to support an attack by short-range pieces (especially + generals). It is very rare to mate a king with a non-adjacent + ranging piece in shogi since the player whose king is threatened + can almost always interpose by dropping a piece. + + + + +File: gnushogi.info, Node: gnushogi, Next: xshogi, Prev: About shogi, Up: Top + +gnushogi +******** + + This section describes how to run the "gnushogi" program. + + + SYNOPSIS + + + gnushogi [ [[-]a] [-b bookfile] [-B binbookfile] [-C] [-h langfile] +[-L langfile] [-r length] [-R] [-s pathname] [-l pathname] [-S +binbooksize] [-t] [-c size] [-T size] [-v] [-x] [-X] arg1 arg2 ] + + + DESCRIPTION + + + GNU shogi (gnushogi) plays a game of japanese chess (shogi) against +the user or it plays against itself. + + At startup gnushogi reads the binbook file if it is present. It then +looks for a book file. If it is present it adds its contents to the +binbook data. If the binbook file is writable a new combined binbook +file is written. + + Gnushogi is a modified version of the gnuchess program. It has a +simple alphanumeric board display, or it can be used with the xshogi +program under X windows. The program gets its opening moves from the +file gnushogi.bbk which is located in a directory specified in the +Makefile. To invoke the program type: + + +`gnushogi -C' + simple curses based version + +`gnushogi -X (or just gnushogi)' + xshogi compatible version + +`gnushogi -R' + raw test display version + + + TIME CONTROLS + + + If one argument is given, it is the search time per move in +[minutes:]seconds. So gnushogi 30 will generate one move every 30 +seconds, while gnushogi 5:00 will generate one move every 5 minutes. + + If two or more arguments are given, they will be used to set +tournament time controls with the first argument of each pair being the +number of moves and the second being the total clock time in +minutes[:seconds]. Thus, entering gnushogi 60 5 will set the clocks +for 5 minutes (300 seconds) for the first 60 moves, and gnushogi 30 +3:30 will allow 3 minutes and 30 seconds for 30 moves. + + gnushogi 30 5 1 :30 will allow 5 minutes for the first 30 moves and +30 seconds for each move after that. Up to 4 pairs of controls may be +specified. + + If no argument is given the program will prompt the user for level of +play. + + For use with xshogi see the documentation on that program. *Note +xshogi::. + + + BOOK + + + The book gnushogi.tbk consists of a sequence of openings. An opening +begins with a line starting with a # (the rest of the line is a +comment). Following this is a series of moves in algebraic notation +alternating black and white separated by white space. A move may have a +? after it indicating this move should never be made in this position. +Moves are stored as position:move so transpositions between openings can +take place. + + + HASHFILE + + + The hashfile if created should be on the order of 4 megabytes; you +can create such a hashfile by typing "gnushogi -c 22" (see below). This +file contains positions and moves learned from previous games. If a +hashfile is used the computer makes use of the experience it gained in +past games. Tests run so far show that it plays no worse with the +hashfile than without, but it is not clear yet whether it provides a +real advantage. + + + LEGAL MOVES + + + Note: Piece letters are determined by the language file. What is +specified here is the default (English). + + Once gnushogi is invoked, the program will display the board and +prompt the user for a move. To enter a move, use the notation 7g7f +where the first letter-number pair indicates the origin square and the +second letter-number pair indicates the destination square. An +alternative is to use the notation P7f where the first letter indicates +the piece type (P,L,N,S,G,B,R,K). To promote append a + the type of +the new piece to the move, as in 2d2c+ or P2c+. Note that you must use +capital letters for the pieces by default. + + + COMMAND-LINE OPTIONS + + +`-a' + Do not search on opponent's time. + +`a' + Do search on opponent's time. + +`-b BOOKFILE' + Use bookfile for opening book. + +`-B BINBOOKFILE' + Use binbookfile for binary opening book. + +`-c SIZE' + Create a new HASHFILE. File size is 2^size entries of + approximately 65+? bytes. + +`-C' + Use curses-based display mode. + +`-h' + Do not use hashfile. + +`h' + Do use hashfile. + +`-l PATHNAME' + Pathname of the loadfile used with get or xget. + +`-L LANG' + Use language lang from the file gnushogi.lang. If -L is not + specified it uses the first language in the file. + +`-P PLYLEVELS' + Number of plys to include in the binbookfile. For generating a + binbookfile. + +`-r LENGTH' + Rehash _length_ times in searching entries for position in + transposition table. + +`-R' + Use raw text display mode. This can be used for dumb terminals or + for systems that don't have curses. + +`-s PATHNAME' + Pathname of the save file to use with the save command. + +`-S SIZE' + Size of binbookfile for memory based books. For creating a + binbookfile. + +`-t' + Show statistics for HASHFILE. + +`-T SIZE' + Set the transposition table size to 2^size entries. + +`-v' + Show version and patchlevel. + +`-x VALUE' + Use value as the evaluation window xwndw. + +`-X' + Use xshogi display mode (the default). + + + COMMANDS + + + In addition to legal moves, the following commands can be entered at +the gnushogi prompt. Note: command names are determined by the language +file and may vary with the implementation. The default language is +English. + +`alg' + allow algebraic input (not implemented). + +`Awindow' + change Alpha window (default score + 90). + +`Bwindow' + change Beta window (default score - 90). + +`beep' + toggles beeping after each move (default: on). + +`bd' + updates the current board position on the display. + +`book' + turns off use of the opening library. + +`both' + causes the computer to play both sides of a shogi game. + +`black' + causes the computer to take the white pieces, if the computer is + to move first. + +`bsave' + saves a game to disk as a book textfile. The program will prompt + the user for a file name. + +`gamein' + toggles game mode time control. Assumes the time specified for + time control is the time for a complete game. Input with the + level command should be the game time and the expected number of + moves in a game. go command must be given. + +`coords' + show coordinates on the display (visual only). + +`contempt' + allows the value of _contempt_ to be modified. + +`debug' + asks for a piece as color piece, as wb or bn, and shows its + calculated value on each square. + +`debuglevel' + sets level of debugging output if compiled with debug options. + +`depth' + allows the user to change the search depth of the program. The + maximum depth is 29 ply. Normally the depth is set to 29 and the + computer terminates its search based on elapsed time rather than + depth. If depth is set to (say) 4 ply, the program will search + until all moves have been examined to a depth of 4 ply (with + extensions up to 11 additional ply for sequences of checks and + captures). If you set a maximum time per move and also use the + depth command, the search will stop at the specified time or the + specified depth, whichever comes first. + +`easy' + toggles easy mode (thinking on opponents time) on and off. The + default is easy mode ON. If easy mode is disabled, the keyboard + is polled for input every so often and when input is seen the + search is terminated. It may also be terminated with a sigint. + +`edit' + allows the user to set up a board position. + - # clear the board. + + - c toggle piece color. + + - . command will exit setup mode. + + - p3b place a pawn on 3b + + - p3b+ place a promoted pawn on 3b + + - p* place a pawn in hand (among the captured pieces) + + + Pieces are entered by typing a letter (p,l,n,s,g,b,r,k) for the + piece followed by the coordinate. Here, letter case is ignored. + + The usual warning about the language file applies. + +`exit' + exits gnushogi. + +`first' + tells the computer to move first. Computer begins searching for a + move. (same as "go"). + +`force' + allows the user to enter moves for both sides. To get the program + to play after a sequence of moves has been entered use the "black" + or "white" commands. + +`get' + retrieves a game from disk. The program will prompt the user for + a file name. + +`go' + tells the computer to move first. Computer begins searching for a + move. (same as "first"). + +`hash' + use/don't use hashfile. + +`hashdepth' + allows the user to change the minimum depth for using the hashfile + and the number of moves from the beginning of the game to use it. + +`help' + displays a short description of the commands and the current + status of options. + +`hint' + causes the program to supply the user with its predicted move. + +`level' + allows the user to set time controls such as 60 moves in 5 minutes + etc. In tournament mode, the program will vary the time it takes + for each move depending on the situation. If easy mode is + disabled (using the "easy" command), the program will often + respond with its move immediately, saving time on its clock for + use later on. + +`list' + writes the game moves and some statistics on search depth, nodes, + and time to the file "shogi.lst". + +`material' + toggle material flag - draws on no pawns and both sides < rook. + +`new' + starts a new game. + +`p' + evaluates the board and shows the point score for each piece. The + total score for a position is the sum of these individual piece + scores. + +`post' + causes the program to display the principal variation and the score + during the search. A score of 100 is equivalent to a 1 pawn + advantage for the computer. + +`quit' + exits the game. + +`random' + causes the program to randomize its move selection slightly. + +`rcptr' + set recapture mode. + +`remove' + backout the last level for both sides. Equal to 2 undo's. + +`reverse' + causes the board display to be reversed. That is, the black + pieces will now appear at the top of the board. + +`rv' + reverse board display. + +`save' + saves a game to disk. The program will prompt the user for a file + name. + +`switch' + causes the program to switch places with the opponent and begin + searching. + +`test' + performs some speed tests for MoveList and CaptureList generation, + and ScorePosition position scoring for the current board. + +`time' + set computer's time remaining, intended for synchronizing clocks + among multiple players. + +`tsume' + toggle tsume mode. In tsume mode, not all possible moves will be + generated. If a king is in check, only moves that get the king out + of check are generated. If the king is not in check, only moves + that give check to the opponent's king are generated. + +`undo' + undoes the last move whether it was the computer's or the human's. + You may also type "remove". This is equivalent to two "undo"'s + (e.g. retract one move for each side). + +`white' + causes the computer to take the black pieces, if the computer is + to move first the go command must be given. + +`xget' + read an xshogi position file. + +`xsave' + save as an xshogi position file. + +`xwndw' + change X window. The window around alpha/beta used to determine + whether the position should be scored or just estimated. Note: + this has _nothing_ to do with xshogi or X windows; the terms are + completely separate. + + + +File: gnushogi.info, Node: xshogi, Next: References and links, Prev: gnushogi, Up: Top + +xshogi +****** + + This section describes how to run the "xshogi" program. + + + SYNOPSIS + + + xshogi [ options ] + + + DESCRIPTION + + + xshogi provides an X11/Xt/Athena Widgets user interface for gnushogi. +With xshogi you can play gnushogi, set up arbitrary positions, force +variations, or watch xshogi manage a game between two shogi programs. +Furthermore, it can be used as an interface between two players on +different displays. + + xshogi can also be used as a shogi board to play out games. It will +read through a game file or allow a player to play through a variation +manually (force mode). This is useful for keeping track of email postal +games or browsing games off the net. + + After starting xshogi, you can make moves by pressing mouse button 1 +while the cursor is over a square with your piece on it and dragging the +mouse to another square. If the move is illegal, gnushogi will not +allow it. xshogi will then retract the move. + + + COMMAND-LINE OPTIONS + + + The following command line options also correspond to X resources +that you can set in your .Xdefaults file. + + +`[standard Xt options]' + xshogi accepts standard Xt options like -display, -geometry, and + -iconic. + +`-tc or -timeControl minutes[:seconds]' + Amount of time for a set of moves determined by movesPerSession. + If this number of moves is played within the time control period, + xshogi resets the time clocks. Default: 5 minutes. + +`-mps or -movesPerSession moves' + Number of moves in a time control period. Default: 40 moves. + +`-st or -searchTime minutes[:seconds]' + Tell gnushogi to spend at most the given amount of time searching + for each of its moves. Without this option, gnushogi chooses its + search time based on the number of moves and amount of time + remaining until the next time control. Setting this option also + sets -clockMode to False. + +`-sd or -searchDepth number' + Tell gnushogi to look ahead at most the given number of moves when + searching for a move to make. Without this option, gnushogi + chooses its search depth based on the number of moves and amount + of time remaining until the next time control. Setting this + option also sets -clockMode to False. + +`-clock or -clockMode (True | False)' + Determines whether or not to use the clock. If clockMode is + False, the clock does not run, but the side that is to play next + is still highlighted. + +`-td or -timeDelay seconds' + Time delay between moves during "Load Game". This doesn't have to + be a round number. Try -td 0.4. Default: 1 second. + +`-nsp or -noShogiProgram (True | False)' + If this option is True, xshogi acts as a passive shogi board; it + does not try to start a shogi program, not even to check whether + moves made in Force mode are legal. It also sets -clockMode to + False. Default: False. + +`-fsp or -firstShogiProgram program' + Name of first shogi program. In matches between two machines, this + program plays white. Default: "gnushogi". + +`-ssp or -secondShogiProgram program' + Name of second shogi program, if needed. In matches between two + machines, this program plays black; otherwise it is not started. + Default: "gnushogi". + +`-fh or -firstHost host' + Name of host the first shogi program plays on. Default: + "localhost". + +`-sh or -secondHost host' + Name of host the second shogi program plays on. Default: + "localhost". + +`-rsh or -remoteShell shell_name' + Some systems do not use rsh as the remote shell. This option + allows a user to name the remote shell command. This should be + done in the resource file. + +`-mm or -matchMode (False | Init | Position | Opening)' + Automatically run a game between firstShogiProgram and + secondShogiProgram. If matchMode is set to Init, xshogi will + start the game with the initial shogi position. If matchMode is + set to Position, xshogi will start the game with the position + specified by the loadPositionFile resource. If matchMode is set + to Opening, xshogi will play out the opening moves specified by + the -loadGameFile resource. If the -saveGameFile resource is set, + a move record for the match will be saved in the specified file. + Default: "False". + +`-lgf or -loadGameFile file' + Name of file to read a game record from. Game files are found in + the directory named by the SHOGIDIR environment variable. If this + variable is not set, the current directory is used unless the file + name starts with a /. + +`-lpf or -loadPositionFile file' + Name of file to read a game position from. Position files are + found in the directory named by the SHOGIDIR environment variable. + If this variable is not set, the current directory is used unless + the file name starts with a /. + +`-sgf or -saveGameFile file' + Name of file to save a game record to. Game files are saved in the + directory named by the SHOGIDIR environment variable. If this + variable is not set, the current directory is used unless the file + name starts with a /. + +`-spf or -savePositionFile file' + Name of file to save a game position to. Position files are saved + in the directory named by the SHOGIDIR environment variable. If + this variable is not set, the current directory is used unless the + file name starts with a /. + +`-coords or -showCoords (True | False)' + If this option is True, xshogi displays algebraic coordinates + along the board's left and bottom edges. The default is False. + The coordFont resource specifies what font to use. + +`-mono or -monoMode (True | False)' + Determines whether xshogi displays its pieces and squares with two + colors or four. You shouldn't have to specify monochrome. xshogi + will determine if this is necessary. + +`-wpc or -blackPieceColor color' + Color specification for black pieces suitable for + XParseColor(3X11). Default: #FFFFCC. These colors look good on a + DEC workstation. If you need different colors, try using the + xcolors application. Source for xcolors can be found in the X11 + contrib directory. + +`-bpc or -whitePieceColor color' + Same for white pieces. Default: #202020. + +`-lsc or -lightSquareColor color' + Same for light squares. Default: #C8C365. + +`-dsc or -darkSquareColor color' + Same for dark squares. Default: #77A26D. + +`-wps or -westernPieceSet (True | False)' + Choose the Western style piece set. + +`-npb or -normalPawnBitmap file' + +`-nnb or -normalKnightBitmap file' + +`-nbb or -normalBishopBitmap file' + +`-nrb or -normalRookBitmap file' + +`-nkb or -normalKingBitmap file' + Names of the bitmap files for the bitmap piece icons. + +`-rpb or -reversePawnBitmap file' + +`-rnb or -reverseKnightBitmap file' + +`-rbb or -reverseBishopBitmap file' + +`-rrb or -reverseRookBitmap file' + +`-rkb or -reverseKingBitmap file' + Names of the bitmap files for the outline piece icons. + +`-debug or -debugMode (True | False)' + Turns on debugging printout. + + + OTHER X RESOURCES + + +`initString' + The actual string that is sent to initialize the shogi program can + be set from .Xdefaults. It can't be set from the command line + because of syntax problems. The default value is + "new\nbeep\nrandom\neasy\n". The "new" and "beep" commands are + required. You can remove the "random" command if you like; + including it causes gnushogi to randomize its move selection + slightly so that it doesn't play the same moves in every game. + Even without "random", gnushogi randomizes its choice of moves + from its opening book. You can also remove "easy" if you like; + including it toggles easy mode off, causing gnushogi to think on + your time. That is, if "easy" is included in the initString, GNU + Shogi thinks on your time; if not, it does not. (Yes, this does + seem backwards, doesn't it.) You can also try adding other + commands to the initString; see the gnushogi documentation (*note + gnushogi::.) for details. + +`blackString and whiteString' + These resources control what is sent when the Machine Black and + Machine White buttons are selected. This is mostly for + compatibility with obsolete versions of gnushogi. + + Alternate bitmaps for piece icons can be specified either by + choosing one of the built-in sets or with the file name resources + described above. There are three built-in sets of piece bitmaps + available, large (the default), medium, or small. It is easiest + to select the set you prefer in the .Xdefaults file: + + XShogi*boardSize: Medium + + The font used for button labels and comments can be changed in the + .Xdefaults file. You may want to choose a smaller font if you are + using the small pieces: + + XShogi*font: helvetica_oblique12 + + The font used for coordinates (when the showCoords option is True) + can be set similarly: + + XShogi*coordFont: helvetica_10 + + If you are using a grayscale monitor, try setting the colors to: + + XShogi*blackPieceColor: gray100 + XShogi*whitePieceColor: gray0 + XShogi*lightSquareColor: gray60 + XShogi*darkSquareColor: gray40 + + + COMMAND BUTTONS AND KEYS + + +`Quit' + Quits xshogi. Q or q is a keyboard equivalent. + +`Reset' + Resets xshogi to the beginning of a shogi game. It also deselects + any game or position files. + +`Flip View' + inverts the view of the shogi board. + +`Hint' + displays a move hint from gnushogi. + +`Load Game' + plays a game from a record file. If no file is specified a popup + dialog asks for a filename. Game files are found in the directory + named by the SHOGIDIR environment variable. If this variable is + not declared then the current directory is used unless the file + name starts with a /. G or g is a keyboard equivalent. The game + file parser will accept almost any file that contains moves in + algebraic notation. If the first line begins with `#', it is + assumed to be a title and is displayed. Text enclosed in + parentheses or square brackets is assumed to be commentary and is + displayed in a pop-up window. Any other text in the file is + ignored. + +`Load Position' + sets up a position from a position file. If no file is specified a + popup dialog asks for a filename. Position files are found in the + directory named by the SHOGIDIR environment variable. If this + variable is not declared then the current directory is used unless + the file name starts with a /. Position files must be in the + format that the Save Position command writes. + +`Save Game' + saves a game to a record file. If no file is specified a popup + dialog asks for a filename. If the filename exists, the user is + asked whether the current game record is be appended to this file + or if the file should be replaced. Game files are saved in the + directory named by the SHOGIDIR environment variable. If this + variable is not declared then the current directory is used unless + the file name starts with a /. Game files are human-readable, and + can also be read back by the Load Game command. Furthermore, they + are accepted as gnushogi text bookfiles. + +`Save Position' + saves a position to a position file. If no file is specified a + popup dialog asks for a filename. Position files are saved in the + directory named by the SHOGIDIR environment variable. If this + variable is not declared then the current directory is used unless + the file name starts with a /. Position files are human-readable, + and can also be read back by the Load Position command. + +`Machine White' + forces gnushogi to play white. + +`Machine Black' + forces gnushogi to play black. + +`Force Moves' + forces a series of moves. That is, gnushogi stops playing and + xshogi allows you to make moves for both white and black. + +`Two Machines' + plays a game between two computer programs. + +`Forward' + moves forward through a series of remembered moves. F or f is a + keyboard equivalent. + +`Backward' + moves backward through a series of remembered moves. As a side + effect, puts xshogi into Force Moves mode. B or b is a keyboard + equivalent. + +`Pause' + pauses the clocks or (in Load Game mode) pauses the game being + loaded. Press Pause again to continue. P or p is a keyboard + equivalent. + +`Edit Position' + lets you set up an arbitrary board position. Use mouse button 1 + to drag pieces to new squares, or to delete a piece by dragging it + off the board or dragging an empty square on top of it. To drop a + new piece on a square, press mouse button 2 or 3 over the square. + This brings up a menu of black pieces (button 2) or white pieces + (button 3). Additional menu choices let you empty the square or + clear the board. You can set the side to play next by clicking on + the Black or White indicator at the top of the screen. + +`Challenge' + allows to make a two display game between two human players. + Enter the display you want to connect to. If you are allowed to + connect, a new board is displayed at the remote display. + Challenge mode can only be stopped by pressing "quit". + +`Select Level' + allows to reset the clocks for both players. Enter the number of + moves and the number of minutes in which the moves should be done. + +`Move NOW' + force computer to stop thinking and to make the current best move. + +`Iconify I, i, C or c' + iconifies xshogi. + + + LIMITATIONS + + + If you press the Pause button during GNU Shogi's turn, xshogi +will stop the clocks, but gnushogi will still make a move. + + After a mate or draw when playing against gnushogi, if you back up +with the Backward button, the clocks are reset (because gnushogi +has exited and must be restarted). + + The game parser recognizes only algebraic notation. + + + AUTHORS + + + Original authors of XBoard: Chris Sears and Dan Sears. + + Enhancements for XBoard (Version 2.0): Tim Mann. + + Conversion to XShogi (Version 1.1): Matthias Mutz. + + Current maintainer: Mike Vanier. + + + COPYRIGHT INFORMATION + + + XShogi borrows its piece bitmaps from CRANES Shogi. + + Copyright 1991 by Digital Equipment Corporation, Maynard, +Massachusetts. Enhancements Copyright 1992 Free Software Foundation, +Inc. Enhancements Copyright 1993 Matthias Mutz. Further enhancements +copyright 1999 by Michael Vanier and the Free Software Foundation, Inc. + + The following terms apply to Digital Equipment Corporation's +copyright interest in XBoard: + + All Rights Reserved + + Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + + DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + The following terms apply to the enhanced version of XShogi +distributed by the Free Software Foundation: + + This file is part of XSHOGI. + + XSHOGI is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY. No author or distributor accepts responsibility to anyone +for the consequences of using it or for whether it serves any particular +purpose or works at all, unless he says so in writing. Refer to the +XSHOGI General Public License for full details. + + Everyone is granted permission to copy, modify and redistribute +XSHOGI, but only under the conditions described in the XSHOGI General +Public License. A copy of this license is supposed to have been given +to you along with XSHOGI so you can know your rights and +responsibilities. It should be in a file named COPYING. Among other +things, the copyright notice and this notice must be preserved on all +copies. + + +File: gnushogi.info, Node: References and links, Next: Acknowledgements, Prev: xshogi, Up: Top + +References and links +******************** + + There are very few English-language books for people learning shogi. +The two I recommend are: + + + 1. `Shogi for Beginners, 2nd. Edition', by John Fairbairn. This is a + superb beginner's book in every way, covering all phases of the + game. It was out of print for a long time, but has now been + reprinted and is available either from Kiseido + (`http://www.labnet.or.jp/~kiseido') or from George Hodges (see + below). + + 2. `The Art of Shogi', by Tony Hoskings. This is one step up from the + Fairbairn book. It covers a lot of ground, and is especially + noteworthy for its detailed treatment of opening lines. You can + order this book from Amazon.com's UK branch + (`http://www.amazon.co.uk'). + + + + Another book you may find is `Shogi: Japan's Game of Strategy' by +Trevor Leggett. This book is very elementary and is somewhat outdated, +having been published first in 1966. However, it does feature a paper +shogi board and punch-out pieces, so if you want a really cheap shogi +set you might pick this book up. It is still in print. + + Two books that are no longer in print but are definitely worth +getting if you find them are `Guide to Shogi Openings' and `Better +Moves for Better Shogi', both by Aono Teriuchi. They are published in a +bilingual edition (English/Japanese) and are the only books on shogi in +English written by a Japanese professional shogi player. John Fairbairn +did the translation from Japanese to English. + + Shogi sets are available from: + + + George F. Hodges + P.O. Box 77 + Bromley, Kent + United Kingdom BR1 2WT + + + George also sells equipment for all the historical shogi variants +(*note Shogi variants::.) (except for Kyoku tai shogi) and also sells +back issues of the magazine "Shogi" which he published for 70 issues in +the late 70's to late 80's. This magazine is STRONGLY recommended; it +contains more information about shogi in English than you will ever +find anywhere else. + + Here are some useful URLs: + + +Pieter Stouten's shogi page: `http://www.halcyon.com/stouten/shogi.html' + This is the main shogi-related site on the internet, with links to + almost all the other sites. + +Roger Hare's shogi page: `http://www.ed.ac.uk/~rjhare/shogi' + This has lots of information, including full rules to most of the + shogi variants. + +Patrick Davin's Shogi Nexus: `http://www.vega.or.jp/~patrick/shogi/' + There's lots of cool stuff on this site; my favorite is the + extensive collection of Tsume-shogi (mating) problems, both for + beginners and more advanced players. + +Steve Evans' shogi page: `http://www.netspace.net.au/~trout/index.html' + Steve has written a program that plays almost all of the shogi + variants, unfortunately it only runs on Windows :-( + +Hans Bodlaender's chess variant pages: `http://www.cs.ruu.nl/~hansb/d.chessvar' + This page has an almost unimaginable variety of rules for different + chess variants, including many shogi variants (historical and + non-historical). + + + +File: gnushogi.info, Node: Acknowledgements, Next: Bugs, Prev: References and links, Up: Top + +Acknowledgements +**************** + + I would like to thank the following people: + + + * Matthias Mutz, who originally developed GNU shogi as a spin-off of + GNU chess and who very kindly let me take over the maintenance of + this very interesting project. + + * Richard Stallman and the Free Software Foundation, for creating an + organization where anyone can contribute software for the common + good of all, for making GNU/Linux possible, and especially for + writing emacs and gcc, without which my working life would be + intolerable. + + * Georges Hodges, for starting the Shogi Association in England, + without which I would probably never have heard of shogi, for + supplying shogi equipment, for publishing the excellent magazine + "Shogi" (now sadly defunct), for personally answering all my silly + questions by mail, and for being the ambassador of shogi to the + West. + + * Pieter Stouten, for having the most comprehensive shogi site on the + World Wide Web `http://www.halcyon.com/stouten/shogi.html', and for + maintaining the shogi-l mailing list. Go to Pieter's web site for + more information on subscribing to the list. Also thanks to + everyone who contributes and has contributed to that list. + + * Matt Casters, for testing GNU shogi. Matt and I will be working + together on improving the solution engine in future versions of + this program. + + + + +File: gnushogi.info, Node: Bugs, Next: Index, Prev: Acknowledgements, Up: Top + +Bugs +**** + + The motto of GNU shogi is "100% bug-free or you don't pay!" :-) In +the extremely unlikely case (*ahem*) that you do find a bug, please +send me (Mike Vanier) an email at . Also, feel +free to send me comments, complaints, out-and-out raves, suggestions, +plane tickets to Hawaii, and/or large suitcases filled with unmarked, +untraceable hundred-dollar bills. + + +File: gnushogi.info, Node: Index, Prev: Bugs, Up: Top + +Index +***** + +* Menu: + +* Acknowledgements: Acknowledgements. +* Books: References and links. +* Chu Shogi: Shogi variants. +* Dai Shogi: Shogi variants. +* Dai-dai Shogi: Shogi variants. +* Draws: Draws. +* Drops: Drops. +* GPL: License. +* Handicaps: Handicaps. +* Introduction: Introduction. +* Kyoku Tai Shogi: Shogi variants. +* License: License. +* Mailing lists: References and links. +* Maka-dai-dai Shogi: Shogi variants. +* Opening setup: The opening setup. +* Piece moves: The moves of the pieces. +* Piece promotion: Promotion of pieces. +* References: References and links. +* Rules: The rules of shogi. +* Sample game: Sample game. +* Shogi variants: Shogi variants. +* Shogi vs. Chess: Differences between shogi and chess. +* Tai Shogi: Shogi variants. +* Tenjiku Shogi: Shogi variants. +* Tori Shogi: Shogi variants. +* Variants: Shogi variants. +* Wa Shogi: Shogi variants. +* Web sites: References and links. +* Winning the game: Winning the game. +* gnushogi: gnushogi. +* xshogi: xshogi. + + diff --git a/doc/gnushogi.ps b/doc/gnushogi.ps new file mode 100644 index 0000000..58de818 --- /dev/null +++ b/doc/gnushogi.ps @@ -0,0 +1,4297 @@ +%!PS-Adobe-2.0 +%%Creator: dvips(k) 5.85 Copyright 1999 Radical Eye Software +%%Title: gnushogi.dvi +%%Pages: 52 +%%PageOrder: Ascend +%%BoundingBox: 0 0 612 792 +%%EndComments +%DVIPSWebPage: (www.radicaleye.com) +%DVIPSCommandLine: dvips -t letter gnushogi.dvi -o gnushogi.ps +%DVIPSParameters: dpi=600, compressed +%DVIPSSource: TeX output 1999.06.29:0328 +%%BeginProcSet: texc.pro +%! +/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S +N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72 +mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0 +0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{ +landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize +mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[ +matrix currentmatrix{A A round sub abs 0.00001 lt{round}if}forall round +exch round exch]setmatrix}N/@landscape{/isls true N}B/@manualfeed{ +statusdict/manualfeed true put}B/@copies{/#copies X}B/FMat[1 0 0 -1 0 0] +N/FBB[0 0 0 0]N/nn 0 N/IEn 0 N/ctr 0 N/df-tail{/nn 8 dict N nn begin +/FontType 3 N/FontMatrix fntrx N/FontBBox FBB N string/base X array +/BitMaps X/BuildChar{CharBuilder}N/Encoding IEn N end A{/foo setfont}2 +array copy cvx N load 0 nn put/ctr 0 N[}B/sf 0 N/df{/sf 1 N/fntrx FMat N +df-tail}B/dfs{div/sf X/fntrx[sf 0 0 sf neg 0 0]N df-tail}B/E{pop nn A +definefont setfont}B/Cw{Cd A length 5 sub get}B/Ch{Cd A length 4 sub get +}B/Cx{128 Cd A length 3 sub get sub}B/Cy{Cd A length 2 sub get 127 sub} +B/Cdx{Cd A length 1 sub get}B/Ci{Cd A type/stringtype ne{ctr get/ctr ctr +1 add N}if}B/id 0 N/rw 0 N/rc 0 N/gp 0 N/cp 0 N/G 0 N/CharBuilder{save 3 +1 roll S A/base get 2 index get S/BitMaps get S get/Cd X pop/ctr 0 N Cdx +0 Cx Cy Ch sub Cx Cw add Cy setcachedevice Cw Ch true[1 0 0 -1 -.1 Cx +sub Cy .1 sub]/id Ci N/rw Cw 7 add 8 idiv string N/rc 0 N/gp 0 N/cp 0 N{ +rc 0 ne{rc 1 sub/rc X rw}{G}ifelse}imagemask restore}B/G{{id gp get/gp +gp 1 add N A 18 mod S 18 idiv pl S get exec}loop}B/adv{cp add/cp X}B +/chg{rw cp id gp 4 index getinterval putinterval A gp add/gp X adv}B/nd{ +/cp 0 N rw exit}B/lsh{rw cp 2 copy get A 0 eq{pop 1}{A 255 eq{pop 254}{ +A A add 255 and S 1 and or}ifelse}ifelse put 1 adv}B/rsh{rw cp 2 copy +get A 0 eq{pop 128}{A 255 eq{pop 127}{A 2 idiv S 128 and or}ifelse} +ifelse put 1 adv}B/clr{rw cp 2 index string putinterval adv}B/set{rw cp +fillstr 0 4 index getinterval putinterval adv}B/fillstr 18 string 0 1 17 +{2 copy 255 put pop}for N/pl[{adv 1 chg}{adv 1 chg nd}{1 add chg}{1 add +chg nd}{adv lsh}{adv lsh nd}{adv rsh}{adv rsh nd}{1 add adv}{/rc X nd}{ +1 add set}{1 add clr}{adv 2 chg}{adv 2 chg nd}{pop nd}]A{bind pop} +forall N/D{/cc X A type/stringtype ne{]}if nn/base get cc ctr put nn +/BitMaps get S ctr S sf 1 ne{A A length 1 sub A 2 index S get sf div put +}if put/ctr ctr 1 add N}B/I{cc 1 add D}B/bop{userdict/bop-hook known{ +bop-hook}if/SI save N @rigin 0 0 moveto/V matrix currentmatrix A 1 get A +mul exch 0 get A mul add .99 lt{/QV}{/RV}ifelse load def pop pop}N/eop{ +SI restore userdict/eop-hook known{eop-hook}if showpage}N/@start{ +userdict/start-hook known{start-hook}if pop/VResolution X/Resolution X +1000 div/DVImag X/IEn 256 array N 2 string 0 1 255{IEn S A 360 add 36 4 +index cvrs cvn put}for pop 65781.76 div/vsize X 65781.76 div/hsize X}N +/p{show}N/RMat[1 0 0 -1 0 0]N/BDot 260 string N/Rx 0 N/Ry 0 N/V{}B/RV/v{ +/Ry X/Rx X V}B statusdict begin/product where{pop false[(Display)(NeXT) +(LaserWriter 16/600)]{A length product length le{A length product exch 0 +exch getinterval eq{pop true exit}if}{pop}ifelse}forall}{false}ifelse +end{{gsave TR -.1 .1 TR 1 1 scale Rx Ry false RMat{BDot}imagemask +grestore}}{{gsave TR -.1 .1 TR Rx Ry scale 1 1 false RMat{BDot} +imagemask grestore}}ifelse B/QV{gsave newpath transform round exch round +exch itransform moveto Rx 0 rlineto 0 Ry neg rlineto Rx neg 0 rlineto +fill grestore}B/a{moveto}B/delta 0 N/tail{A/delta X 0 rmoveto}B/M{S p +delta add tail}B/b{S p tail}B/c{-4 M}B/d{-3 M}B/e{-2 M}B/f{-1 M}B/g{0 M} +B/h{1 M}B/i{2 M}B/j{3 M}B/k{4 M}B/w{0 rmoveto}B/l{p -4 w}B/m{p -3 w}B/n{ +p -2 w}B/o{p -1 w}B/q{p 1 w}B/r{p 2 w}B/s{p 3 w}B/t{p 4 w}B/x{0 S +rmoveto}B/y{3 2 roll p a}B/bos{/SS save N}B/eos{SS restore}B end + +%%EndProcSet +TeXDict begin 40258431 52099146 1000 600 600 (gnushogi.dvi) +@start +%DVIPSBitmapFont: Fa cmbxti10 14.4 1 +/Fa 1 47 df<13FCEA03FF000F13804813C05AA25AA2B5FCA31480A214006C5A6C5A6C5A +EA0FE0121271912B>46 D E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fb cmti9 9 1 +/Fb 1 47 df<121C127F12FFA412FE12380808778718>46 D E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fc cmr9 9 52 +/Fc 52 122 df45 D<123C127E12FFA4127E123C08087A8715> +I<13075B5B137FEA07FFB5FC13BFEAF83F1200B3B3A2497E007FB51280A319327AB126> +49 DIII<000C14C0380FC00F90B5128015005C5C14F014C0D80C18C7FC90C8 +FCA9EB0FC0EB7FF8EBF07C380FC03F9038001F80EC0FC0120E000CEB07E0A2C713F01403 +A215F8A41218127E12FEA315F0140712F8006014E01270EC0FC06C131F003C14806CEB7F +00380F80FE3807FFF8000113E038003F801D347CB126>I<14FE903807FF80011F13E090 +383F00F0017C13703901F801F8EBF003EA03E01207EA0FC0EC01F04848C7FCA248C8FCA3 +5A127EEB07F0EB1FFC38FE381F9038700F809038E007C039FFC003E0018013F0EC01F813 +0015FC1400A24814FEA5127EA4127F6C14FCA26C1301018013F8000F14F0EBC0030007EB +07E03903E00FC03901F81F806CB51200EB3FFCEB0FE01F347DB126>I<1230123C003FB6 +FCA34814FEA215FC0070C7123800601430157015E04814C01401EC0380C7EA0700140614 +0E5C141814385CA25CA2495A1303A3495AA2130FA3131F91C7FCA25BA55BA9131C20347C +B126>III<15E0A34A7EA24A7EA34A7EA3EC0DFE140CA2EC187FA34A6C7EA202707FEC601F +A202E07FECC00FA2D901807F1507A249486C7EA301066D7EA2010E80010FB5FCA2498001 +18C77EA24981163FA2496E7EA3496E7EA20001821607487ED81FF04A7ED8FFFE49B512E0 +A333367DB53A>65 DII< +B77E16F016FE3A01FE0001FF00009138003FC0EE0FE0707E707E707E707E177E177FEF3F +80A2EF1FC0A3EF0FE0A418F0AA18E0A3171F18C0A21880173F18005F17FE5F4C5AEE07F0 +4C5AEE3FC000014AB45AB748C7FC16F8168034337EB23B>I71 DII75 +DII79 DI82 +D<90381FE00390387FFC0748B5FC3907F01FCF390F8003FF48C7FC003E80814880A20078 +8000F880A46C80A27E92C7FC127F13C0EA3FF013FF6C13F06C13FF6C14C06C14F0C68001 +3F7F01037F9038003FFF140302001380157F153FED1FC0150F12C0A21507A37EA26CEC0F +80A26C15006C5C6C143E6C147E01C05B39F1FC03F800E0B512E0011F138026C003FEC7FC +22377CB42B>I<007FB712FEA390398007F001D87C00EC003E0078161E0070160EA20060 +160600E01607A3481603A6C71500B3AB4A7E011FB512FCA330337DB237>I86 DI< +EB7F803803FFF0380F80FC381C003E003F133F6D6C7E6E7EA26E7EEA1F00C7FCA4EB01FF +131FEBFF873803FC07EA0FF0EA1FC0EA3F80127F13004815C05AA3140FA26C131F6C133B +3A3F8071F180391FC1E1FF2607FFC013003900FE003C22237DA126>97 +DII<153FEC0FFFA3EC007F81AEEB07F0EB3FFCEBFC0F3901F003BF39 +07E001FF48487E48487F8148C7FCA25A127E12FEAA127E127FA27E6C6C5BA26C6C5B6C6C +4813803A03F007BFFC3900F81E3FEB3FFCD90FE0130026357DB32B>III<151F90391FC07F809039FFF8E3C03901F07FC73907E03F033A0FC01F8380 +9039800F8000001F80EB00074880A66C5CEB800F000F5CEBC01F6C6C48C7FCEBF07C380E +FFF8380C1FC0001CC9FCA3121EA2121F380FFFFEECFFC06C14F06C14FC4880381F000100 +3EEB007F4880ED1F8048140FA56C141F007C15006C143E6C5C390FC001F83903F007E0C6 +B51280D91FFCC7FC22337EA126>IIIIII<2703F01FE013FF00FF90267FF80313C0903BF1E07C0F03E0 +903BF3803E1C01F02807F7003F387FD803FE1470496D486C7EA2495CA2495CB3486C496C +487EB53BC7FFFE3FFFF0A33C217EA041>I<3903F01FC000FFEB7FF09038F1E0FC9038F3 +807C3907F7007EEA03FE497FA25BA25BB3486CEB7F80B538C7FFFCA326217EA02B>II<3903F03F8000FFEBFFE09038 +F3C0F89038F7007ED807FE7F6C48EB1F804914C049130F16E0ED07F0A3ED03F8A9150716 +F0A216E0150F16C06D131F6DEB3F80160001FF13FC9038F381F89038F1FFE0D9F07FC7FC +91C8FCAA487EB512C0A325307EA02B>I<3803E07C38FFE1FF9038E38F809038E71FC0EA +07EEEA03ECA29038FC0F8049C7FCA35BB2487EB512E0A31A217FA01E>114 +DI<1330A51370A313F0A21201 +A212031207381FFFFEB5FCA23803F000AF1403A814073801F806A23800FC0EEB7E1CEB1F +F8EB07E0182F7FAD1E>IIIII<3A7FFF807FF8A33A07F8001FC00003 +EC0F800001EC070015066C6C5BA26D131C017E1318A26D5BA2EC8070011F1360ECC0E001 +0F5BA2903807E180A214F3010390C7FC14FBEB01FEA26D5AA31478A21430A25CA214E05C +A2495A1278D8FC03C8FCA21306130EEA701CEA7838EA1FF0EA0FC025307F9F29>I +E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fd cmti10 10.95 18 +/Fd 18 118 df<387FFFFCA3B5FCA21605799521>45 D<120FEA3FC0127FA212FFA31380 +EA7F00123C0A0A77891C>I<147E49B47E903907C1C38090391F80EFC090383F00FF017E +137F4914804848133F485AA248481400120F5B001F5C157E485AA215FE007F5C90C7FCA2 +1401485C5AA21403EDF0385AA21407EDE078020F1370127C021F13F0007E013F13E0003E +137FECF3E1261F01E313C03A0F8781E3803A03FF00FF00D800FC133E252977A72E>97 +D99 DII< +EC03F0EC0FFC91383E0E1C9138FC077E903901F003FE1303903807E001D90FC013FCEB1F +80A2EB3F004914F8137E01FE1303A2484814F0A2150712034914E0A2150F12074914C0A2 +151FA216805B153F1203ED7F006D5BA200015B0000495A9038F80F7E90387C1EFEEB1FF8 +903807E0FC90C7FC1401A25DA21403A25D001C1307007F5C48130F5D4A5A4AC7FC48137E +00F85B387C03F0381FFFC0D803FEC8FC273B7CA72A>103 DI<1478EB01 +FCA21303A314F8EB00E01400AD137C48B4FC38038F80EA0707000E13C0121E121CEA3C0F +1238A2EA781F00701380A2EAF03F140012005B137E13FE5BA212015BA212035B14381207 +13E0000F1378EBC070A214F0EB80E0A2EB81C01383148038078700EA03FEEA00F8163E79 +BC1C>I108 DIII<903903E001F890390FF807FE903A1E7C1E0F8090 +3A1C3E3C07C0013C137801389038E003E0EB783F017001C013F0ED80019038F07F0001E0 +15F8147E1603000113FEA2C75AA20101140717F05CA20103140F17E05CA20107EC1FC0A2 +4A1480163F010F15005E167E5E131F4B5A6E485A4B5A90393FB80F80DA9C1FC7FCEC0FFC +EC03E049C9FCA2137EA213FEA25BA21201A25BA21203A2387FFFE0B5FCA22D3A80A72E> +I114 +DII<137C48B4141C26038F +80137EEA0707000E7F001E15FE121CD83C0F5C12381501EA781F007001805BA2D8F03F13 +03140000005D5B017E1307A201FE5C5B150F1201495CA2151F0003EDC1C0491481A2153F +1683EE0380A2ED7F07000102FF13005C01F8EBDF0F00009038079F0E90397C0F0F1C9039 +1FFC07F8903907F001F02A2979A731>I E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fe cmbx12 13.14 35 +/Fe 35 122 df46 D<15F014011407141F147FEB03FF137FB6FCA313FC1380C7FCB3B3B200 +7FB712E0A52B4777C63D>49 DIIIII<121F7F7F13FE90B812E0A45A18C0188018005F5FA25F485E90 +C8EA07E0007E4B5A5F007C151F4CC7FC167E5E485D15014B5A4B5AC8485A4B5AA24BC8FC +157EA25D1401A24A5A1407A24A5AA2141FA24A5AA2147FA314FFA3495BA45BA55BAA6D5B +A26D90C9FCEB007C334B79C93D>II68 D72 +D78 D80 D<003FBB12C0A5DA80019038FC001FD9FC001601D87FF09438007FE001C018 +3F49181F90C7170FA2007E1907A3007C1903A500FC1AF0481901A5C894C7FCB3B3A749B8 +12FCA54C4A7CC955>84 D87 D97 +D<91380FFF8091B512F8010314FF010F158090263FFE0013C0D97FF8EB1FE0D9FFE0EB3F +F04849EB7FF8484913FF4890C7FC5A5B121F5B003FED7FF0EE3FE0007FED1FC093C7FC5B +A212FFAC127F7FA2123FA26D153E121F6D157E6C167C6C6D14FC6C16F86C6D13036C01F0 +EB07F0D97FFCEB1FE06DB4EBFFC0010F90B5120001035C010014F0020F13802F337CB137 +>99 DIIIII<13FCEA03FF487F487FA2487FA66C5BA26C5B6C90C7FCEA00 +FC90C8FCACEB7FC0B5FCA512037EB3B3B61280A5194D7BCC22>I108 D<90287FC001FFE0EC7FF8B5010F01FC0103B5FC +033F6D010F804B6D6C4814E0DBFE079026C03F817F9126C3F0019138FC007F0003D9C7E0 +DAE1F8806CDA8000D9F1E06D7E02CFC7EBF3C002DE91267FF780131F02FC03FFC77FA24A +5DA24A5DA34A5DB3A9B6D8C03FB5D8F00FB512FCA55E317BB067>I<903A7FC001FFC0B5 +010F13F8033F13FE4B7F9126C1FE077F9126C3F0037F00039038C7C0016CD9CF80801500 +02DE7F02FC81A25CA25CA35CB3A9B6D8C07FEBFFE0A53B317BB044>I<913807FF80027F +13F80103B6FC010F15C090261FFE017F903A7FF0003FF8D9FFC0EB0FFC48496D7E4890C7 +6C7E4817804980000F17C048486E13E0A2003F17F049157FA2007F17F8A400FF17FCAB00 +7F17F8A36C6CEDFFF0A3001F17E06D5C000F17C06C6C4A13806C17006C6D495A6C01E0EB +1FFC6D6C495A903A3FFE01FFF0010FB612C0010392C7FCD9007F13F80207138036337DB1 +3D>I<90397FC00FFFB5017F13F002C1B512FC02C714FF9126CFF80F7F9126FFC00313E0 +000391C77F6C01FC6E7E4A6E7E5C4A6E7E848319808319C0A47113E0AC4D13C0A319805F +A219004D5A804D5A6E4A5A6E4A5A02FF495BDB80075B9126EFF01F5B02E7B548C7FC02E3 +14F802E014E0DB0FFEC8FC92CAFCAFB612C0A53B467CB044>I<9039FF803FE0B5EBFFF8 +028113FE02837FDA87E11380EC8F830003D99F0713C06C139E14BCA214F8A24A6C13806F +13004A6C5A93C7FCA45CB3A7B612E0A52A317CB032>114 D<90390FFF8070017FEBF1F0 +48B6FC1207380FFC01391FE0003F4848130F491307127F90C712035A1501A27FA213E06D +90C7FC13FE387FFFF0ECFFC015F06C14FC6C14FF6C15806C15C06C15E0C615F0013F14F8 +010714FCEB007F14019138003FFE150F0078140700F81403A26C1401A37E16FC6C14036D +14F87F6DEB07F001F8EB1FE001FFEBFFC091B51280D8FC7F1400D8F81F13FCD8E00313C0 +27337CB130>I<14F8A61301A41303A21307A2130FA2131F133F137F13FF1203000F90B5 +12F0B7FCA426007FF8C7FCB3A6167CAA013F14F880A290391FFE01F0010F1303903907FF +87E06DEBFFC06D14806D6C1300EC0FFC26467EC430>IIII<007FB500C090387FFFE0A5C601F0C73803F8006E5D017F5E6E1407013F5E6E140F +011F5E6E141FA26D6D91C7FC5F6D153E6F137E6D157C6F13FC6D5DEDF0016D5DEDF80302 +7F5C15FC1607DA3FFE5B160F021F5CEDFF1F6E91C8FC16BF6E13BE16FE6E5BA36E5BA26E +5BA26F5AA26F5AA26F5AA393C9FC5D153E157E157CD81F8013FC486C5B387FE001D8FFF0 +5B14035D14074A5A49485A007F49CAFCEBC07E383F81FC6CB45A6C5B6C13C0C648CBFC3B +467EAF41>121 D E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Ff cmsl10 10.95 42 +/Ff 42 123 df12 +D39 D44 +D<121EEA3F80EA7FC012FFA41380EA7F00123C0A0A788919>46 D50 D<13F0EA01FC1203EA07FEA313FCA2EA03F8EA01E0C7FCB3121EEA3F80EA7FC0 +12FFA41380EA7F00123C0F2778A619>58 D<17E016011603831607A2160FA2161F83163F +A2167F167716F7EEE7FCED01E316C3150316831507EE03FEED0F01150E151E151C153C03 +387FED7800157015F05D4A4880177F4A5AA24AC7FCA2020E81173F5C021FB6FC5CA20270 +C7EA3FE0171F5CA2495AA2494881170F49C8FCA2130EA24982013C1507A2137CD801FE4B +7E2607FF80EC3FFEB500F00107B512FC19F85E3E417DC044>65 D<013FB7FC18E018FC90 +3B007FE00007FE6E48903801FF809438007FC05DF03FE0F01FF0A3027F16F892C8FCA54A +16F04A153F19E0187F19C0F0FF8001014B13004A4A5A4D5AEF1FF04D5ADC03FFC7FC49B6 +12F8EFFF8002F8C7EA3FE0EF0FF0EF07FC717E010715014A81711380A319C0130F5CA501 +1F4B13805C19005F601707013F4B5A4A4A5A4D5A4D5A017F913801FF8001FF020F90C7FC +B812FC17F094C8FC3D3E7DBD40>I +I<013FB812F8A39026007FF0C7127F6E48140F18034B14011800A31978147F4B1570A502 +FF147092C7FCA3190017F0495D4A1301A21607161F91B6FC495DA29138FC003F160F1607 +160301075D5CA219E0180119C0010FEC07004A90C712031980A218071900011F5E5C181E +A2183E183C013F167C4A15FC4D5A1707017F151F01FF4AB45AB9FCA2603D3E7DBD3E>69 +D<4BB46C1370031F01F013F0037F9038FC01E0913A03FF807E03913A0FF8000F83DA1FE0 +EB07C7DA7F80EB01EF4AC812FFD903FE16C04948157F4948153F495A4948151F495A4948 +168091C9120F5A485AA2485A000F18004982121FA248485EA295C7FC485AA412FF5BA604 +3FB512E05BA29339001FFC00715AA2607F127FA2171F123F6D5EA2121F7F000F163F6C7E +6C6C4B5A7F6C6C15FF6C6DEB01EFD93FC0EB07C7D91FF0EB1F87D907FE9038FE03800101 +B5EAF8016D6C01E0C8FCDA07FEC9FC3C4276BF47>71 D<021FB512FCA3DA000713006F5A +A25EA41507A25EA4150FA25EA4151FA25EA4153FA25EA4157FA25EA415FFA293C7FCA45C +121FD87F805BEAFFC0A214035D13804A5AEAFE0000F8495A48495A00705C6C495A6C01FE +C8FC380F81FC3803FFE0C690C9FC2E407ABD2F>74 D<90263FFFF093381FFFF85013F062 +9026007FF8EFF000023F4D5AA2023B933801DFC0A2DA39FCED039FA2F1073F1479027104 +0E5BEC70FE191C19381A7F02F01670DAE07F94C7FC19E0A2F001C06201016D6C495A02C0 +5FF00700A2180E6F6C14010103161C028003385BA218706F7EF0E00313070200DA01C05B +A2923907F00380A294380700075B010E902603F80E5C5FA25F190F011E6D6C5A011C605F +A2EEFDC0DB00FF141F013C5D013860013C92C7FC017C5C01FE027E143F2607FF80017C4A +7EB500FC037FB512E004785E4A1338553E7CBD53>77 D<90263FFFE0023FB5FC6F16FEA2 +9026003FF8020313C0021F030013004A6C157C023B163C6F15381439810238167802787F +DA707F157082153F82031F15F002F07FDAE00F5D8215078203031401010180DAC0015D82 +811780047F1303010315C04A013F5C17E0161F17F0040F1307010715F891C7000791C7FC +17FC160317FE04015B4915FF010E6E130E188E177F18CEEF3FDE011E16FE011C6F5AA217 +0FA21707133C01386F5A133C017C150113FE2607FF801400B512FC18705C483E7DBD44> +I<923803FF80031F13F09238FE01FE913903F0003FDA0FC0EB1FC0DA3F80EB07E0027EC7 +6C7E49486E7E49488149486E7E4948157F495A013F17804948ED3FC049C9FCA24848EE1F +E012035B000718F05B120FA2485A19F8123F5BA2127FA219F04848163FA5F07FE0A35BF0 +FFC0A219805F19007F4D5A127F4D5A60003F160F6D5E001F4C5A4D5A6C6C4B5A95C7FC6C +6C15FE00034B5A6C6C4A5A6C6C4A5A017FEC1FC06D6C495AD90FE001FEC8FC903903F807 +F80100B512C0DA0FFCC9FC3D4276BF47>I<013FB612F017FF18E0903B007FF0003FF86E +48EB07FCEF01FE4B6D7EF07F8019C0183F19E0147F4B15F0A502FFED7FE092C8FCA219C0 +F0FF80A2494B13004A5D4D5AEF0FF04D5AEF7F800103DA07FEC7FC91B612F017809139FC +0007E0EE03F8EE00FC0107814A147F717EA284A2130F5CA484011F157F5CA41902013F17 +075CA2F0F00F017F170E496C143FB600E0011F131C94380FF83C4B01071378CA3801FFE0 +9438003F8040407DBD43>82 D<9238FF80070207EBE00F021FEBF81E91387F00FE02FCEB +1F3ED903F0EB0FFE49481307494813034AEB01FC49C7FC491400133E137E177C491578A5 +7F1770A26D1500808080EB7FFEECFFE06D13FEEDFFC06D14F06D14FC010380010080143F +02031480DA003F13C015031500EE7FE0163F161FA2160F121CA31607160F003C16C0A317 +80003E151F1700007E5D007F153E6D5C16FC01E0495AD87DF0495AD8FCFCEB0FC03AF87F +803F8027F01FFFFEC7FCD8E00713F839C0007FC030427BBF33>I<0007B912F0A33C0FFE +000FF8003F01F0160F01C04A13034848160190C7FC121EF000E048141F5E1238A2127812 +70153F5E5AA3C81600157F5EA515FF93C9FCA55C5DA514035DA514075DA5140F5DA3141F +EC7FFC0003B7FCA33C3D76BC42>I86 D97 DIIIII<177C913907 +F803FE91393FFE0F8F9139FC0F9C3F903901F007F8903907E003E0D90FC013F0011F9038 +01F80C02801400133FD97F007FA315035B495CA3017E495A5E150F6D5C6D495A90263F80 +3EC7FCECC0FC903871FFF09038E07F8091C9FC485AA47FA27F90B512F8EDFF806C15E016 +F86D8048B6FC3A07E0000FFED80F801300003FC8127F003E815A00FC815AA25E163EA25E +6C15FC007C4A5A6C4A5A6CEC0FC0D80FC0013FC7FC3903F801FCC6B512F0010F90C8FC30 +3D7FA82D>I<147FEB3FFFA313017FA25CA513015CA513035CA4ED07F80107EB1FFF9139 +F0781FC09138F1E00F9139F38007E0ECF70002FE14F0495A5CA25CA24A130F131F4A14E0 +A4161F133F4A14C0A4163F137F91C71380A4167F5B491500A300015D486C491380B5D8F8 +7F13FCA32E3F7DBE33>I<1478EB01FE130314FFA25B14FE130314FCEB00F01400ACEB03 +F8EA01FF14F0A2EA001F130FA314E0A5131F14C0A5133F1480A5137F1400A55B5BA4EA03 +FF007F13F0A2B5FC183E7DBD1A>I<147FEB3FFFA313017FA25CA513015CA513035CA501 +070103B5FC02F014FEA26F13F06F1380EEFE00010F14F84A485AED03C04B5A031FC7FC15 +3E011F13784A5AECC3E0ECC7F0ECCFF814FF497F14F9ECE1FE14C04A7E4A7E4980017E13 +3F82151F82150F01FE8049130782A2000181486C49B4FCB5D8F03F13F04B13E0A2303F7E +BE30>107 D<143FEB1FFF5BA213017FA214FEA5130114FCA5130314F8A5130714F0A513 +0F14E0A5131F14C0A5133F1480A5137F1400A55B5BA4EA03FF007F13F8A2B5FC183F7DBE +1A>I<902707F007F8EB03FCD803FFD91FFF90380FFF80913CE0781FC03C0FE09126E1E0 +0FEBF0073E001FE38007E1C003F090260FE700EBE38002EEDAF70013F802FC14FE02D85C +14F84A5CA24A5C011F020F14074A4A14F0A5013F021F140F4A4A14E0A5017F023F141F91 +C74914C0A549027F143F4992C71380A300014B147F486C496DEBFFC0B5D8F87FD9FC3F13 +FEA347287DA74C>I<903907F007F8D803FFEB1FFF9139E0781FC09138E1E00F3B001FE3 +8007E090380FE70002EE14F014FC14D814F85CA24A130F131F4A14E0A4161F133F4A14C0 +A4163F137F91C71380A4167F5B491500A300015D486C491380B5D8F87F13FCA32E287DA7 +33>II<91387F01FE903A7FFF0FFFC09139FE3E03F09238F801 +F8903A03FFE000FE6D49137F4B7F92C713804A15C04A141FA218E0A20103150F5C18F0A3 +171F010716E05CA3173F18C0130F4A147F1880A2EFFF004C5A011F5D16034C5A6E495AEE +1FC06E495AD93FDC017EC7FC91388F01F8913883FFE0028090C8FC92C9FC137FA291CAFC +A45BA25BA31201487EB512F8A3343A81A733>I<903907F01F80D803FFEB7FE09138E1E1 +F09138E387F839001FE707EB0FE614EE02FC13F002D813E09138F801804AC7FCA25C131F +A25CA4133F5CA5137F91C8FCA55B5BA31201487EB512FEA325287EA724>114 +D<9138FF81C0010713E390381F807F90397C003F8049131F4848130F5B00031407A24848 +1400A27FA27F6D90C7FCEBFF8014FC6C13FF6C14C015F06C6C7F011F7F13079038007FFE +1403140100381300157EA2123C153E157E007C147CA2007E147815F8007F495A4A5A486C +485A26F9E01FC7FC38E0FFFC38C01FE0222A7DA824>II<01FE147F00FFEC7FFF4914FEA20007140300031401A34914FCA4 +150312074914F8A41507120F4914F0A4150F121F4914E0A2151FA3153F4914C0157F15FF +EC01DF3A0FC003BFE09138073FFF3803F01E3801FFF826003FE01380282977A733>III<90B539E007FFF05E18E0902707FE000313006D48EB01FC +705A5F01014A5A5F16036E5C0100140794C7FC160E805E805E1678ED8070023F13F05EED +81C015C191381FC38015C793C8FC15EF15EEEC0FFCA25DA26E5AA25DA26E5A5DA24AC9FC +5C140E141E141C5C121C003F5B5A485B495A130300FE5B4848CAFCEA701EEA783CEA3FF0 +EA0FC0343A80A630>121 D<017FB512FEA2ECC00190397E0003FC49EB07F849EB0FF049 +EB1FE049EB3FC0ED7F8000011500495B4A5A4A5A4848485A4A5AC7485A4A5A5D147F4AC7 +FC495A495A49481370494813E0495A5C133F90387F8001D9FF0013C0485A48481303485A +4848EB078049130F4848131F003F143F397F8001FFB71200A227277EA628>I +E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fg cmtt10 10.95 81 +/Fg 81 127 df39 +D<141E147F14FF5BEB03FEEB07FCEB0FF0EB1FE0EB3FC0EB7F80EBFF00485A5B12035B48 +5A120F5BA2485AA2123F5BA2127F90C7FCA412FEAD127FA47F123FA27F121FA26C7EA27F +12076C7E7F12017F6C7EEB7F80EB3FC0EB1FE0EB0FF0EB07FCEB03FEEB01FF7F147F141E +184771BE30>I<127812FE7E7F6C7E6C7EEA0FF06C7E6C7E6C7E6C7EEB7F80133F14C013 +1FEB0FE014F01307A2EB03F8A214FC1301A214FE1300A4147FAD14FEA4130114FCA21303 +14F8A2EB07F0A2130F14E0EB1FC0133F1480137FEBFF00485A485A485A485AEA3FE0485A +485A90C7FC5A1278184778BE30>I<143EA2147FAF007FB7FCA2B81280A36C1600A2C76C +C8FCAF143EA229297DAF30>43 DI<007FB612F0A2B712F8A36C15F0A225077B9E30>I<120FEA3FC0EA7FE0A2EAFFF0A4 +EA7FE0A2EA3FC0EA0F000C0C6E8B30>I<16F01501ED03F8A21507A2ED0FF0A2ED1FE0A2 +ED3FC0A2ED7F80A2EDFF00A24A5AA25D1403A24A5AA24A5AA24A5AA24A5AA24A5AA24AC7 +FCA2495AA25C1303A2495AA2495AA2495AA2495AA2495AA249C8FCA2485AA25B1203A248 +5AA2485AA2485AA2485AA2485AA248C9FCA25AA2127CA225477BBE30>I<14FE903807FF +C0497F013F13F8497F90B57E48EB83FF4848C6138049137F4848EB3FC04848EB1FE04913 +0F001F15F0491307A24848EB03F8A290C712014815FCA400FEEC00FEAD6C14016C15FCA3 +6D1303003F15F8A26D1307001F15F0A26D130F6C6CEB1FE0A26C6CEB3FC06C6CEB7F806D +13FF2601FF8313006CEBFFFE6D5B6D5B010F13E06D5BD900FEC7FC273A7CB830>IIIII<000FB612804815C05AA316800180C8FCAE +EB83FF019F13C090B512F015FC8181D9FE0313809039F0007FC049133F0180EB1FE06CC7 +120F000E15F0C81207A216F81503A31218127EA2B4FC150716F048140F6C15E06C141F6D +EB3FC06D137F3A3FE001FF80261FFC0F13006CB55A6C5C6C5C6C14E06C6C1380D90FFCC7 +FC25397BB730>II<127CB712FC16FEA416FC48C7EA0FF816F0ED1FE0007CEC3F +C0C8EA7F80EDFF00A24A5A4A5A5D14075D140F5D4A5AA24A5AA24AC7FCA25C5C13015CA2 +13035CA213075CA4495AA6131F5CA96D5A6DC8FC273A7CB830>I<49B4FC011F13F0017F +13FC90B57E0003ECFF804815C048010113E03A1FF8003FF049131FD83FC0EB07F8A24848 +EB03FC90C71201A56D1303003F15F86D13076C6CEB0FF06C6CEB1FE0D807FCEB7FC03A03 +FF83FF806C90B512006C6C13FC011F13F0497F90B512FE48802607FE0013C0D80FF8EB3F +E0D81FE0EB0FF04848EB07F8491303007F15FC90C712014815FE481400A66C14016C15FC +6D1303003F15F86D1307D81FF0EB1FF06D133F3A0FFF01FFE06C90B512C06C1580C6ECFE +006D5B011F13F0010190C7FC273A7CB830>I<49B4FC010F13E0013F13F890B57E488048 +8048010113803A0FFC007FC0D81FF0EB3FE04848131F49EB0FF048481307A290C7EA03F8 +5A4815FC1501A416FEA37E7E6D1303A26C6C13076C6C130F6D133FD80FFC13FF6CB6FC7E +6C14FE6C14F9013FEBE1FC010F138190380060011400ED03F8A2150716F0150F000F15E0 +486C131F486CEB3FC0157FEDFF804A1300EC07FE391FF01FFC90B55A6C5C6C5C6C1480C6 +49C7FCEB3FF0273A7CB830>I<120FEA3FC0EA7FE0A2EAFFF0A4EA7FE0A2EA3FC0EA0F00 +C7FCAF120FEA3FC0EA7FE0A2EAFFF0A4EA7FE0A2EA3FC0EA0F000C276EA630>II<16F01503ED07F8151F157FEDFFF014034A13C0021F13809138 +3FFE00ECFFF8495B010713C0495BD93FFEC7FC495A3801FFF0485B000F13804890C8FCEA +7FFC5BEAFFE05B7FEA7FF87FEA1FFF6C7F000313E06C7F38007FFC6D7E90380FFF806D7F +010113F06D7FEC3FFE91381FFF80020713C06E13F01400ED7FF8151F1507ED03F0150025 +2F7BB230>I +64 D<147F4A7EA2497FA4497F14F7A401077F14E3A3010F7FA314C1A2011F7FA490383F +80FEA590387F007FA4498049133F90B6FCA34881A39038FC001F00038149130FA4000781 +491307A2D87FFFEB7FFFB56CB51280A46C496C130029397DB830>I<007FB512F0B612FE +6F7E82826C813A03F8001FF815076F7E1501A26F7EA615015EA24B5A1507ED1FF0ED7FE0 +90B65A5E4BC7FC6F7E16E0829039F8000FF8ED03FC6F7E1500167FA3EE3F80A6167F1700 +A25E4B5A1503ED1FFC007FB6FCB75A5E16C05E6C02FCC7FC29387EB730>I<91387F803C +903903FFF03E49EBFC7E011F13FE49EBFFFE5B9038FFE07F48EB801F3903FE000F484813 +075B48481303A2484813015B123F491300A2127F90C8FC167C16005A5AAC7E7EA2167C6D +14FE123FA27F121F6D13016C6C14FCA26C6CEB03F86D13076C6CEB0FF03901FF801F6C90 +38E07FE06DB512C06D14806D1400010713FC6D13F09038007FC0273A7CB830>I<003FB5 +12E04814FCB67E6F7E6C816C813A03F8007FF0ED1FF8150F6F7E6F7E15016F7EA2EE7F80 +A2163F17C0161FA4EE0FE0AC161F17C0A3163F1780A2167F17005E4B5A15034B5A150F4B +5AED7FF0003FB65A485DB75A93C7FC6C14FC6C14E02B387FB730>I<007FB7FCB81280A4 +7ED803F8C7123FA8EE1F0093C7FCA4157C15FEA490B5FCA6EBF800A4157C92C8FCA5EE07 +C0EE0FE0A9007FB7FCB8FCA46C16C02B387EB730>I<003FB712804816C0B8FCA27E7ED8 +01FCC7121FA8EE0F8093C7FCA5153E157FA490B6FCA69038FC007FA4153E92C8FCAE383F +FFF8487FB5FCA27E6C5B2A387EB730>I<02FF13F00103EBC0F8010F13F1013F13FD4913 +FF90B6FC4813C1EC007F4848133F4848131F49130F485A491307121F5B123F491303A212 +7F90C7FC6F5A92C8FC5A5AA892B5FC4A14805CA26C7F6C6D1400ED03F8A27F003F1407A2 +7F121F6D130F120F7F6C6C131FA2D803FE133F6C6C137FECC1FF6C90B5FC7F6D13FB010F +13F30103EBC1F0010090C8FC293A7DB830>I<3B3FFF800FFFE0486D4813F0B56C4813F8 +A26C496C13F06C496C13E0D803F8C7EAFE00B290B6FCA601F8C7FCB3A23B3FFF800FFFE0 +486D4813F0B56C4813F8A26C496C13F06C496C13E02D387FB730>I<007FB6FCB71280A4 +6C1500260007F0C7FCB3B3A8007FB6FCB71280A46C1500213879B730>I<49B512F04914 +F85BA27F6D14F090C7EAFE00B3B3123C127EB4FCA24A5A1403EB8007397FF01FF86CB55A +5D6C5C00075C000149C7FC38003FF025397AB730>II<383FFFF8487FB57EA26C +5B6C5BD801FCC9FCB3B0EE0F80EE1FC0A9003FB7FC5AB8FCA27E6C16802A387EB730>I< +D83FF8ECFFE0486C4913F0486C4913F8A2007F16F06C6C4913E00007160001EF14BFEC80 +0FA39039E7C01F3FA4ECE03F01E3133EA2ECF07EA201E1137CA2ECF8FCA201E013F8A214 +FDEC7DF0A3147FEC3FE0A3EC1FC0A2EC070091C7FCADD83FFC903801FFE0486C4913F0B5 +4913F8A26C486D13F06C486D13E02D387FB730>II<90383FFFE048B512FC000714FF4815804815C04815E0EBF80001E0133FD87F80EB0F +F0A290C71207A44815F8481403B3A96C1407A26C15F0A36D130FA26D131F6C6CEB3FE001 +F813FF90B6FC6C15C06C15806C1500000114FCD8003F13E0253A7BB830>I<007FB512F0 +B612FE6F7E16E0826C813903F8003FED0FFCED03FE15016F7EA2821780163FA6167F1700 +5EA24B5A1503ED0FFCED3FF890B6FC5E5E16804BC7FC15F001F8C9FCB0387FFFC0B57EA4 +6C5B29387EB730>I<90383FFFE048B512FC000714FF4815804815C04815E0EBF80001E0 +133F4848EB1FF049130F90C71207A44815F8481403B3A8147E14FE6CEBFF076C15F0EC7F +87A2EC3FC7018013CF9038C01FFFD83FE014E0EBF80F90B6FC6C15C06C15806C15000001 +14FCD8003F7FEB00016E7EA21680157F16C0153F16E0151F16F0150FED07E025467BB830 +>I<003FB57E4814F0B612FC15FF6C816C812603F8017F9138003FF0151F6F7E15071503 +821501A515035E1507150F4B5A153F4AB45A90B65A5E93C7FC5D8182D9F8007FED3FE015 +1F150F821507A817F8EEF1FCA53A3FFF8003FB4801C0EBFFF8B56C7E17F06C496C13E06C +49EB7FC0C9EA1F002E397FB730>I<90390FF803C0D97FFF13E048B512C74814F74814FF +5A381FF80F383FE001497E4848137F90C7123F5A48141FA2150FA37EED07C06C91C7FC7F +7FEA3FF0EA1FFEEBFFF06C13FF6C14E0000114F86C80011F13FF01031480D9003F13C014 +019138007FE0151FED0FF0A2ED07F8A2007C140312FEA56C140716F07F6DEB0FE06D131F +01F8EB3FC001FF13FF91B51280160000FD5CD8FC7F13F8D8F81F5BD878011380253A7BB8 +30>I<003FB712C04816E0B8FCA43AFE003F800FA8007CED07C0C791C7FCB3B1011FB5FC +4980A46D91C7FC2B387EB730>I<3B7FFFC007FFFCB56C4813FEA46C496C13FCD803F8C7 +EA3F80B3B16D147F00011600A36C6C14FE6D13016D5CEC800390393FE00FF890391FF83F +F06DB55A6D5C6D5C6D91C7FC9038007FFCEC1FF02F3980B730>III<3A3FFF01FFF84801837F02C77FA202835B6C +01015B3A01FC007F806D91C7FC00005C6D5BEB7F01EC81FCEB3F8314C3011F5B14E7010F +5B14FF6D5BA26D5BA26D5BA26D90C8FCA4497FA2497FA2815B81EB0FE781EB1FC381EB3F +8181EB7F0081497F49800001143F49800003141F49800007140FD87FFEEB7FFFB590B512 +8080A25C6C486D130029387DB730>II<007FB5FCB61280A4150048C8FCB3B3B3A5 +B6FC1580A46C140019476DBE30>91 D<127CA212FEA27EA26C7EA26C7EA26C7EA26C7EA2 +6C7EA26C7EA212017FA26C7EA26D7EA26D7EA26D7EA26D7EA26D7EA26D7EA2130180A26D +7EA26E7EA26E7EA26E7EA26E7EA26E7EA26E7EA2140181A26E7EA2ED7F80A2ED3FC0A2ED +1FE0A2ED0FF0A2ED07F8A21503A2ED01F0150025477BBE30>I<007FB5FCB61280A47EC7 +123FB3B3B3A5007FB5FCB6FCA46C140019477DBE30>I<1307EB1FC0EB7FF0497E000313 +FE000FEBFF80003F14E0D87FFD13F039FFF07FF8EBC01FEB800F38FE0003007CEB01F000 +10EB00401D0E77B730>I<007FB612F0A2B712F8A36C15F0A225077B7D30>I<1338137CEA +01FE12031207EA0FFC13F0EA1FE013C0EA3F8013005A127EA212FE5AA5EAFFC013E013F0 +127FA2123FA2EA1FE0EA07C00F1D70BE30>IIII<913801FFE04A7F5CA28080EC0007AA +EB03FE90381FFF874913E790B6FC5A5A481303380FFC00D81FF0133F49131F485A150F48 +48130790C7FCA25AA25AA87E6C140FA27F003F141F6D133F6C7E6D137F390FF801FF2607 +FE07EBFFC06CB712E06C16F06C14F76D01C713E0011F010313C0D907FCC8FC2C397DB730 +>I<49B4FC010713E0011F13F8017F7F90B57E488048018113803A07FC007FC04848133F +D81FE0EB1FE0150F484814F0491307127F90C7FCED03F85A5AB7FCA516F048C9FC7E7EA2 +7F003FEC01F06DEB03F86C7E6C7E6D1307D807FEEB1FF03A03FFC07FE06C90B5FC6C15C0 +013F14806DEBFE00010713F8010013C0252A7CA830>I +III<14E0EB03F8A249 +7EA36D5AA2EB00E091C8FCA9381FFFF8487F5AA27E7EEA0001B3A9003FB612C04815E0B7 +FCA27E6C15C023397AB830>III<38 +7FFFF8B57EA47EEA0001B3B3A8007FB612F0B712F8A46C15F025387BB730>I<02FC137E +3B7FC3FF01FF80D8FFEF01877F90B500CF7F15DF92B57E6C010F13872607FE07EB03F801 +FC13FE9039F803FC01A201F013F8A301E013F0B3A23C7FFE0FFF07FF80B548018F13C0A4 +6C486C01071380322881A730>II<49B4FC010F13E0 +013F13F8497F90B57E0003ECFF8014013A07FC007FC04848EB3FE0D81FE0EB0FF0A24848 +EB07F8491303007F15FC90C71201A300FEEC00FEA86C14016C15FCA26D1303003F15F86D +13076D130F6C6CEB1FF06C6CEB3FE06D137F3A07FF01FFC06C90B512806C15006C6C13FC +6D5B010F13E0010190C7FC272A7CA830>II<49B413F8010FEBC1FC013F13F14913FD48B6FC5A481381390FFC007F49 +131F4848130F491307485A491303127F90C7FC15015A5AA77E7E15037FA26C6C1307150F +6C6C131F6C6C133F01FC137F3907FF01FF6C90B5FC6C14FD6C14F9013F13F1010F13C190 +3803FE0190C7FCAD92B512F84A14FCA46E14F82E3C7DA730>II<90381FFC +1E48B5129F000714FF5A5A5A387FF007EB800100FEC7FC4880A46C143E007F91C7FC13E0 +6CB4FC6C13FC6CEBFF806C14E0000114F86C6C7F01037F9038000FFF02001380007C147F +00FEEC1FC0A2150F7EA27F151F6DEB3F806D137F9039FC03FF0090B6FC5D5D00FC14F0D8 +F83F13C026780FFEC7FC222A79A830>III<3B3FFFC07FFF80486D +B512C0B515E0A26C16C06C496C13803B01F80003F000A26D130700005DA26D130F017E5C +A2017F131F6D5CA2EC803F011F91C7FCA26E5A010F137EA2ECE0FE01075BA214F101035B +A3903801FBF0A314FF6D5BA36E5A6E5A2B277EA630>I<3B3FFFC01FFFE0486D4813F0B5 +15F8A26C16F06C496C13E0D807E0C7EA3F00A26D5C0003157EA56D14FE00015DEC0F80EC +1FC0EC3FE0A33A00FC7FF1F8A2147DA2ECFDF9017C5C14F8A3017E13FBA290393FF07FE0 +A3ECE03FA2011F5C90390F800F802D277FA630>I<3A3FFF81FFFC4801C37FB580A26C5D +6C01815BC648C66CC7FC137FEC80FE90383F81FC90381FC3F8EB0FE3ECE7F06DB45A6D5B +7F6D5B92C8FC147E147F5C497F81903803F7E0EB07E790380FE3F0ECC1F890381F81FC90 +383F80FE90387F007E017E137F01FE6D7E48486D7E267FFF80B5FCB500C1148014E3A214 +C16C0180140029277DA630>I<3B3FFFC07FFF80486DB512C0B515E0A26C16C06C496C13 +803B01FC0003F000A2000014076D5C137E150F017F5C7F151FD91F805BA214C0010F49C7 +FCA214E00107137EA2EB03F0157C15FCEB01F85DA2EB00F9ECFDF0147D147FA26E5AA36E +5AA35DA2143F92C8FCA25C147EA2000F13FE486C5AEA3FC1EBC3F81387EB8FF0EBFFE06C +5B5C6C90C9FC6C5AEA01F02B3C7EA630>I<001FB612FC4815FE5AA316FC90C7EA0FF8ED +1FF0ED3FE0ED7FC0EDFF80003E491300C7485A4A5A4A5A4A5A4A5A4A5A4A5A4990C7FC49 +5A495A495A495A495A495A4948133E4890C7127F485A485A485A485A485A48B7FCB8FCA4 +6C15FE28277DA630>I<127CA212FEB3B3B3AD127CA207476CBE30>124 +D<017C133848B4137C48EB80FE4813C14813C348EBEFFC397FEFFFF0D8FF8713E0010713 +C0486C1380D87C0113003838007C1F0C78B730>126 D E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fh cmbx12 17.28 45 +/Fh 45 121 df<167C16FC1501ED07F0150FED1FE0ED3FC0ED7F80EDFF004A5A14034A5A +4A5A5D141F4A5A147F4A5A5D5B4990C7FCA2495A130F5C131FA2495AA2495AA213FF5C5A +A25C5AA25A5CA25AA291C8FCA25AA35B123FA5127F5BA612FFB3A4127FA67F123FA5121F +7FA37EA280A27EA2807EA27E80A27E80137FA26D7EA26D7EA2130F8013076D7EA26D7F7F +816E7E143F6E7E140F816E7E6E7E14016E7EED7F80ED3FC0ED1FE0ED0FF01507ED01FC15 +00167C269071EB3F>40 D<127812FC127E6C7E7F6C7E6C7E6C7E6C7E6C7E7F6C7F6D7E13 +3F806D7E806D7E1307806D7EA26D7F817F81A26E7EA26E7EA281141F81A2140F81A21680 +80A216C0A280A216E0A38016F0A516F880A616FCB3A416F8A65C16F0A516E05CA316C0A2 +5CA21680A25C1600A25D141FA25D143F5DA24A5AA24A5AA25D5B5D4990C7FCA2495A5C13 +0F495A5C495A5C137F495A4890C8FC5B485A485A485A485A485A5B007EC9FC5A12782690 +77EB3F>I<16F04B7E1507151F153FEC01FF1407147F010FB5FCB7FCA41487EBF007C7FC +B3B3B3B3007FB91280A6395E74DD51>49 D<913801FFF8021FEBFFC091B612F8010315FF +010F16C0013F8290267FFC0114F89027FFE0003F7F4890C7000F7F48486E7FD807F86E14 +8048486E14C048486E14E048486F13F001FC17F8486C816D17FC6E80B56C16FE8380A219 +FFA283A36C5BA26C5B6C90C8FCD807FC5DEA01F0CA14FEA34D13FCA219F85F19F04D13E0 +A294B512C019804C14004C5B604C5B4C5B604C13804C90C7FC4C5A4C5A4B13F05F4B1380 +4B90C8FC4B5AED1FF84B5A4B5A4B48143F4A5B4A48C8FC4A5A4A48157E4A5A4A5AEC7F80 +92C9FC02FE16FE495A495A4948ED01FCD90FC0150749B8FC5B5B90B9FC5A4818F85A5A5A +5A5ABAFCA219F0A4405E78DD51>I<92B5FC020F14F8023F14FF49B712C04916F0010FD9 +C01F13FC90271FFC00077FD93FE001017F49486D8049C86C7F484883486C6F7F14C0486D +826E806E82487FA4805CA36C5E4A5E6C5B6C5B6C495E011FC85A90C95CA294B55A614C91 +C7FC604C5B4C5B4C5B4C5B047F138092260FFFFEC8FC020FB512F817E094C9FC17F817FF +91C7003F13E0040713F8040113FE707F717F7113E085717FA2717F85A285831A80A31AC0 +EA03FCEA0FFF487F487F487FA2B57EA31A80A34D14005C7E4A5E5F6C495E49C8485BD81F +F85F000F5ED807FE92B55A6C6C6C4914806C01F0010791C7FC6C9026FF803F5B6D90B65A +011F16F0010716C001014BC8FCD9001F14F0020149C9FC426079DD51>II<01C0EE01C0D801F8160F01 +FF167F02F0EC07FFDAFF8090B5FC92B7128019006060606060606095C7FC17FC5F17E017 +8004FCC8FC16E09026FC3FFCC9FC91CBFCADED3FFE0203B512F0020F14FE023F6E7E91B7 +12E001FDD9E00F7F9027FFFE00037F02F801007F02E06EB4FC02806E138091C8FC496F13 +C04917E07113F0EA00F090C914F8A219FC83A219FEA419FFA3EA03F0EA0FFC487E487E48 +7FA2B57EA319FEA35C4D13FC6C90C8FC5B4917F8EA3FF001804B13F06D17E0001F5E6C6C +17C06D4B1380D807FC92B512006C6C4A5B6C6C6C01075B6C01E0011F5BD97FFE90B55A6D +B712C0010F93C7FC6D15FC010115F0D9003F1480020301F0C8FC406078DD51>III< +92383FFF800203B512FC021FECFF80027F15E049B712F849D9F0077F010F90C76C7ED91F +FCEC1FFFD93FF06E7F494802037F494882717F484980854890C9127FA24884183FA25A80 +A380806E157F6E5E14FE6E7E6F4A5A6C14F003FC495B03FF495B6C1580DCE0075B6CDBF8 +0F90C7FC9338FE1FFE6C9238FF7FF84D5A6D16C06D5E6D4BC8FC6D6F7E6D16E00101826D +16FC023F814A8149B87E010783498390263FFE3F8190267FFC0F819026FFF003814849C6 +FC48496D804849131F4890C7000780160148486E1580003F163F49150F007F7014C04915 +01717E8400FF835B8484A384A21A80A27F007F1900607F003F606D160F001F606D4C5A6C +6D153F6C6D4B5A6C01F04B5A6C01FC02035B6C01FF021F5B6D9027F001FFFEC7FC6D90B6 +5A010F16F001035E010093C8FC020F14F8DA007F90C9FC426079DD51>I65 DI<4DB5 +ED03C0057F02F014070407B600FE140F047FDBFFC0131F4BB800F0133F030F05FC137F03 +3F9127F8007FFE13FF92B6C73807FF814A02F0020113C3020702C09138007FE74A91C900 +1FB5FC023F01FC16074A01F08291B54882490280824991CB7E4949844949844949844986 +5D49498490B5FC484A84A2484A84A24891CD127FA25A4A1A3F5AA348491A1FA44899C7FC +A25CA3B5FCB07EA380A27EA2F50FC0A26C7FA37E6E1A1F6C1D80A26C801D3F6C6E1A00A2 +6C6E616D1BFE6D7F6F4E5A7F6D6D4E5A6D6D4E5A6D6D4E5A6D6E171F6D02E04D5A6E6DEF +FF806E01FC4C90C7FC020F01FFEE07FE6E02C0ED1FF8020102F8ED7FF06E02FF913803FF +E0033F02F8013F1380030F91B648C8FC030117F86F6C16E004071680DC007F02F8C9FC05 +0191CAFC626677E375>I69 D<4DB5ED03C0057F02F014070407B600FE140F +047FDBFFC0131F4BB800F0133F030F05FC137F033F9127F8007FFE13FF92B6C73807FF81 +4A02F0020113C3020702C09138007FE74A91C9001FB5FC023F01FC16074A01F08291B548 +82490280824991CB7E49498449498449498449865D49498490B5FC484A84A2484A84A248 +91CD127FA25A4A1A3F5AA348491A1FA44899C8FCA25CA3B5FCB07E071FB812F880A37EA2 +96C70001ECC000A26C7FA37E807EA26C80A26C80A26C807F6D7F816D7F7F6D7F6D6D5F6D +14C06D6E5E6E7F6E01FC5E020F01FF5E6E02C0ED7FEF020102F8EDFFC76E02FF02071383 +033F02FC013F1301030F91B638FC007F03014D131F6F6C04E01307040704801301DC007F +02F8CAFC050191CBFC6D6677E37F>71 D73 D<020FB812F0A691C70001EC8000B3B3B3ACEA03FCEA0FFF487F487F487F +A2B57EA45E96C7FCA36C49495B604A5B6C90C75C6C484A5B01F84A5BD80FFE4A5B6C6C6C +90B55A0001D9F80749C8FC6C90B65A013F15F0010F15C001014AC9FCD9001F13C044647C +E153>I76 +D78 D80 D82 DI<001FBEFCA64849C79126E0000F +148002E0180091C8171F498601F81A0349864986A2491B7FA2491B3F007F1DC090C9181F +A4007E1C0FA600FE1DE0481C07A5CA95C7FCB3B3B3A3021FBAFCA663617AE070>II<913803FFFE027FEBFF +F00103B612FE010F6F7E4916E090273FFE001F7FD97FE001077FD9FFF801017F486D6D7F +717E486D6E7F85717FA2717FA36C496E7FA26C5B6D5AEB1FC090C9FCA74BB6FC157F0207 +B7FC147F49B61207010F14C0013FEBFE004913F048B512C04891C7FC485B4813F85A5C48 +5B5A5CA2B55AA45FA25F806C5E806C047D7F6EEB01F96C6DD903F1EBFF806C01FED90FE1 +14FF6C9027FFC07FC01580000191B5487E6C6C4B7E011F02FC130F010302F001011400D9 +001F90CBFC49437CC14E>97 D<903807FF80B6FCA6C6FC7F7FB3A8EFFFF8040FEBFF8004 +7F14F00381B612FC038715FF038F010014C0DBBFF0011F7FDBFFC001077F93C76C7F4B02 +007F03F8824B6F7E4B6F13804B17C0851BE0A27313F0A21BF8A37313FCA41BFEAE1BFCA4 +4F13F8A31BF0A24F13E0A24F13C06F17804F1300816F4B5A6F4A5B4AB402075B4A6C6C49 +5B9126F83FE0013F13C09127F00FFC03B55A4A6CB648C7FCDAC00115F84A6C15E091C700 +1F91C8FC90C8000313E04F657BE35A>I<92380FFFF04AB67E020F15F0023F15FC91B77E +01039039FE001FFF4901F8010113804901E0010713C04901804913E0017F90C7FC49484A +13F0A2485B485B5A5C5A7113E0485B7113C048701380943800FE0095C7FC485BA4B5FCAE +7EA280A27EA2806C18FCA26C6D150119F87E6C6D15036EED07F06C18E06C6D150F6D6DEC +1FC06D01E0EC7F806D6DECFF00010701FCEB03FE6D9039FFC03FFC010091B512F0023F5D +020F1580020102FCC7FCDA000F13C03E437BC148>II<92380FFFC04AB512FC020FECFF8002 +3F15E091B712F80103D9FE037F499039F0007FFF011F01C0011F7F49496D7F4990C76C7F +49486E7F48498048844A804884485B727E5A5C48717EA35A5C721380A2B5FCA391B9FCA4 +1A0002C0CBFCA67EA380A27EA27E6E160FF11F806C183F6C7FF17F006C7F6C6D16FE6C17 +016D6C4B5A6D6D4A5A6D01E04A5A6D6DEC3FE0010301FC49B45A6D9026FFC01F90C7FC6D +6C90B55A021F15F8020715E0020092C8FC030713F041437CC14A>III<903807FF80B6FCA6C6FC7F7FB3A8EF1FFF94B512F0040714FC041F14FF4C8193267F +E07F7F922781FE001F7FDB83F86D7FDB87F07FDB8FC0814C7F039FC78015BE03BC8003FC +825DA25DA25DA45DB3B2B7D8F007B71280A651647BE35A>II<903807FF80B6FCA6C6FC7F7FB3A90503 +B61280A6DD003FEB8000DE0FFCC7FCF01FF04E5AF0FFC04D5B4D90C8FCEF07FC4D5AEF3F +F04D5A4D5A4C90C9FC4C5AEE0FFC4C5A4C5AEE7FC04C7E03837F03877F158F039F7F03BF +7F92B5FC838403FC804B7E03F0804B6C7F4B6C7F1580707F707F707FA270807080717FA2 +717F717F717FA2717F717F83867180727F95B57EB7D8E00FECFFF0A64C647BE355>107 +D<903807FF80B6FCA6C6FC7F7FB3B3B3B3ADB712E0A623647BE32C>I<902607FF80D91F +FFEEFFF8B691B500F00207EBFF80040702FC023F14E0041F02FF91B612F84C6F48819326 +7FE07F6D4801037F922781FE001F9027E00FF0007FC6DA83F86D9026F01FC06D7F6DD987 +F06D4A487F6DD98FC0DBF87EC7804C6D027C80039FC76E488203BEEEFDF003BC6E4A8003 +FC04FF834B5FA24B5FA24B94C8FCA44B5EB3B2B7D8F007B7D8803FB612FCA67E417BC087 +>I<902607FF80EB1FFFB691B512F0040714FC041F14FF4C8193267FE07F7F922781FE00 +1F7FC6DA83F86D7F6DD987F07F6DD98FC0814C7F039FC78015BE03BC8003FC825DA25DA2 +5DA45DB3B2B7D8F007B71280A651417BC05A>I<923807FFE092B6FC020715E0021F15F8 +027F15FE494848C66C6C7E010701F0010F13E04901C001037F49496D7F4990C87F49486F +7E49486F7E48496F13804819C04A814819E048496F13F0A24819F8A348496F13FCA34819 +FEA4B518FFAD6C19FEA46C6D4B13FCA36C19F8A26C6D4B13F0A26C19E06C6D4B13C0A26C +6D4B13806C6D4B13006D6C4B5A6D6D495B6D6D495B010701F0010F13E06D01FE017F5B01 +0090B7C7FC023F15FC020715E0020092C8FC030713E048437CC151>I<902607FF80EBFF +F8B6010FEBFF80047F14F00381B612FC038715FF038F010114C09227BFF0003F7FC6DAFF +C0010F7F6D91C76C7F6D496E7F03F86E7F4B6E7F4B17804B6F13C0A27313E0A27313F0A2 +1BF885A21BFCA3851BFEAE4F13FCA41BF861A21BF0611BE0611BC06F92B512801B006F5C +6F4A5B6F4A5B03FF4A5B70495B04E0017F13C09226CFFC03B55A03C7B648C7FC03C115F8 +03C015E0041F91C8FC040313E093CBFCB3A3B712F0A64F5D7BC05A>I114 D<913A3FFF8007800107B5EAF81F011FECFE7F017F91B5FC48 +B8FC48EBE0014890C7121FD80FFC1407D81FF0801600485A007F167F49153FA212FF171F +A27F7F7F6D92C7FC13FF14E014FF6C14F8EDFFC06C15FC16FF6C16C06C16F06C826C826C +826C82013F1680010F16C01303D9007F15E0020315F0EC001F1500041F13F81607007C15 +0100FC81177F6C163FA2171F7EA26D16F0A27F173F6D16E06D157F6D16C001FEEDFF806D +0203130002C0EB0FFE02FCEB7FFC01DFB65A010F5DD8FE0315C026F8007F49C7FC48010F +13E035437BC140>II<902607FFC0ED3FFEB60207B5FCA6C6EE00076D826D82B3B3A260A360A2607F60 +183E6D6D147E4E7F6D6D4948806D6DD907F0ECFF806D01FFEB3FE06D91B55A6E1500021F +5C020314F8DA003F018002F0C7FC51427BC05A>I119 +D<007FB600C0017FB512F8A6D8001F01F8C70007EBF0006D040190C7FC6D6D5D6D6D4A5A +6D6D4A5A70495A6D4C5A6E7F6E6D495A6E6D495A7049C8FC6E4A5A6E6D485A6E6D485A6E +13FFEF8FF06EEC9FE06FEBFFC06F5C6F91C9FC5F6F5B816F7F6F7F8481707F8493B57E4B +805D4B80DB0FF37FDB1FE17F04C080153F4B486C7F4B486C7F4A486D7F4A486D7F4A5A4B +6D7F020F6E7F4A486D7F4A486D804A5A4AC86C7F49486F7F4A6F7F0107707FEB3FFFB600 +F049B7FCA650407EBF55>I E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fi cmsy10 10.95 3 +/Fi 3 16 df<007FB812F8B912FCA26C17F83604789847>0 D13 +D15 +D E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fj cmr10 10.95 86 +/Fj 86 125 df<4AB4EB0FE0021F9038E03FFC913A7F00F8FC1ED901FC90383FF03FD907 +F090397FE07F80494801FF13FF4948485BD93F805C137F0200ED7F00EF003E01FE6D91C7 +FC82ADB97EA3C648C76CC8FCB3AE486C4A7E007FD9FC3FEBFF80A339407FBF35>11 +DIII<121EEA7F80EAFFC0A9EA7F80ACEA3F00AC +121EAB120CC7FCA8121EEA7F80A2EAFFC0A4EA7F80A2EA1E000A4179C019>33 +D<001E130F397F803FC000FF137F01C013E0A201E013F0A3007F133F391E600F30000013 +00A401E01370491360A3000114E04913C00003130101001380481303000EEB070048130E +0018130C0038131C003013181C1C7DBE2D>I<4B6C130C4B6C131EA20307143EA24C133C +A2030F147CA293C71278A24B14F8A2031E5CA2033E1301A2033C5CA3037C1303A203785C +A203F81307A24B5CA20201140F007FBAFCBB1280A26C1900C72707C0003EC8FC4B133CA3 +020F147CA292C71278A24A14F8A2021E5CA3023E1301007FBAFCBB1280A26C1900C727F8 +0007C0C8FC4A5CA20101140FA24A91C9FCA301035CA24A131EA20107143EA24A133CA201 +0F147CA291C71278A34914F8A2011E5CA2013E1301A2013C5CA201186D5A41517BBE4C> +I<013F1603D9FFC04B7E2601E0E0150F2607C070151F48486C4BC7FC023E157E48486C15 +FE48D90FC0EB03FC003ED90EF0EB0FF8DA0F3F13FD007E903A070FFFF1F0007C0200EB03 +E0160000FC6D6C495A170F604DC8FC5F173E5F17FC5F4C5A1603007CD907005B4C5A007E +150F003E495C020E49C9FC003F5D6C49133E260F803C5B023813FC6C6C485B3A01E0E001 +F03800FFC090273F0003E0133F90C70007ECFFC09339C001E0E0923A0F8007C070031F49 +487E0400143C033E90381F001C037E497F037C133E4B150F0201027E7F4B137C4A5A0207 +02FCEB03805D4A5A141F92C7FC143E147E147C5CA2495A0103037CEB07005C4948147E01 +0F033E5B4A160E49C8123F496F5B013E92380F803C49173801FC6F6C5A49923801E0E049 +6FB45A0160043FC7FC41497BC34C>37 D<121EEA7F8012FF13C0A213E0A3127FEA1E6012 +00A413E013C0A312011380120313005A120E5A1218123812300B1C79BE19>39 +D<1430147014E0EB01C0EB03801307EB0F00131E133E133C5B13F85B12015B1203A2485A +A2120F5BA2121F90C7FCA25AA3123E127EA6127C12FCB2127C127EA6123E123FA37EA27F +120FA27F1207A26C7EA212017F12007F13787F133E131E7FEB07801303EB01C0EB00E014 +701430145A77C323>I<12C07E12707E7E121E7E6C7E7F12036C7E7F12007F1378137CA2 +7FA2133F7FA21480130FA214C0A3130714E0A6130314F0B214E01307A614C0130FA31480 +A2131F1400A25B133EA25BA2137813F85B12015B485A12075B48C7FC121E121C5A5A5A5A +145A7BC323>II<121EEA7F8012FF13C0A213E0A3127FEA1E601200A413E013C0A3120113 +80120313005A120E5A1218123812300B1C798919>44 DI<121E +EA7F80A2EAFFC0A4EA7F80A2EA1E000A0A798919>IIIIII< +150E151E153EA2157EA215FE1401A21403EC077E1406140E141CA214381470A214E0EB01 +C0A2EB0380EB0700A2130E5BA25B5BA25B5B1201485A90C7FC5A120E120C121C5AA25A5A +B8FCA3C8EAFE00AC4A7E49B6FCA3283E7EBD2D>I<00061403D80780131F01F813FE90B5 +FC5D5D5D15C092C7FC14FCEB3FE090C9FCACEB01FE90380FFF8090383E03E090387001F8 +496C7E49137E497F90C713800006141FC813C0A216E0150FA316F0A3120C127F7F12FFA4 +16E090C7121F12FC007015C012780038EC3F80123C6CEC7F00001F14FE6C6C485A6C6C48 +5A3903F80FE0C6B55A013F90C7FCEB07F8243F7CBC2D>II<1238123C123F90B612FCA316F85A16F016E00078C712010070EC +03C0ED078016005D48141E151C153C5DC8127015F04A5A5D14034A5A92C7FC5C141EA25C +A2147C147814F8A213015C1303A31307A3130F5CA2131FA6133FAA6D5A0107C8FC26407B +BD2D>III<121EEA7F80A2EAFFC0A4EA7F80A2EA1E00C7FC +B3121EEA7F80A2EAFFC0A4EA7F80A2EA1E000A2779A619>I<121EEA7F80A2EAFFC0A4EA +7F80A2EA1E00C7FCB3121E127FEAFF80A213C0A4127F121E1200A412011380A312031300 +5A1206120E120C121C5A1230A20A3979A619>I<007FB912E0BA12F0A26C18E0CDFCAE00 +7FB912E0BA12F0A26C18E03C167BA147>61 D63 D<15074B7EA34B7EA34B7EA34B7E +A34B7E15E7A2913801C7FC15C3A291380381FEA34AC67EA3020E6D7EA34A6D7EA34A6D7E +A34A6D7EA34A6D7EA349486D7E91B6FCA249819138800001A249C87EA24982010E157FA2 +011E82011C153FA2013C820138151FA2017882170F13FC00034C7ED80FFF4B7EB500F001 +0FB512F8A33D417DC044>65 DIIIIIIII<011FB512FCA3D9000713 +006E5A1401B3B3A6123FEA7F80EAFFC0A44A5A1380D87F005B007C130700385C003C495A +6C495A6C495A2603E07EC7FC3800FFF8EB3FC026407CBD2F>IIIIIIIIII<003FB91280A3903AF000 +7FE001018090393FC0003F48C7ED1FC0007E1707127C00781703A300701701A548EF00E0 +A5C81600B3B14B7E4B7E0107B612FEA33B3D7DBC42>IIII<007FB5 +D8C003B512E0A3C649C7EBFC00D93FF8EC3FE06D48EC1F806D6C92C7FC171E6D6C141C6D +6C143C5F6D6C14706D6D13F04C5ADA7FC05B023F13036F485ADA1FF090C8FC020F5BEDF8 +1E913807FC1C163C6E6C5A913801FF7016F06E5B6F5AA26F7E6F7EA28282153FED3BFEED +71FF15F103E07F913801C07F0203804B6C7EEC07004A6D7E020E6D7E5C023C6D7E02386D +7E14784A6D7E4A6D7F130149486E7E4A6E7E130749C86C7E496F7E497ED9FFC04A7E0007 +6DEC7FFFB500FC0103B512FEA33F3E7EBD44>II91 +D<486C13C00003130101001380481303000EEB070048130E0018130C0038131C00301318 +0070133800601330A300E01370481360A400CFEB678039FFC07FE001E013F0A3007F133F +A2003F131F01C013E0390F0007801C1C73BE2D>II96 DII<49B4FC010F13E090383F00F801 +7C131E4848131F4848137F0007ECFF80485A5B121FA24848EB7F00151C007F91C7FCA290 +C9FC5AAB6C7EA3003FEC01C07F001F140316806C6C13076C6C14000003140E6C6C131E6C +6C137890383F01F090380FFFC0D901FEC7FC222A7DA828>IIII< +167C903903F801FF903A1FFF078F8090397E0FDE1F9038F803F83803F001A23B07E000FC +0600000F6EC7FC49137E001F147FA8000F147E6D13FE00075C6C6C485AA23901F803E039 +03FE0FC026071FFFC8FCEB03F80006CAFC120EA3120FA27F7F6CB512E015FE6C6E7E6C15 +E06C810003813A0FC0001FFC48C7EA01FE003E140048157E825A82A46C5D007C153E007E +157E6C5D6C6C495A6C6C495AD803F0EB0FC0D800FE017FC7FC90383FFFFC010313C0293D +7EA82D>III<1478EB01FEA2EB03FFA4EB01FEA2EB00781400AC +147FEB7FFFA313017F147FB3B3A5123E127F38FF807E14FEA214FCEB81F8EA7F01387C03 +F0381E07C0380FFF803801FC00185185BD1C>III<2701F801FE14FF00FF902707FFC00313E0913B1E07E00F03F0913B +7803F03C01F80007903BE001F87000FC2603F9C06D487F000101805C01FBD900FF147F91 +C75B13FF4992C7FCA2495CB3A6486C496CECFF80B5D8F87FD9FC3F13FEA347287DA74C> +I<3901F801FE00FF903807FFC091381E07E091387803F000079038E001F82603F9C07F00 +01138001FB6D7E91C7FC13FF5BA25BB3A6486C497EB5D8F87F13FCA32E287DA733>I<14 +FF010713E090381F81F890387E007E01F8131F4848EB0F804848EB07C04848EB03E0000F +15F04848EB01F8A2003F15FCA248C812FEA44815FFA96C15FEA36C6CEB01FCA3001F15F8 +6C6CEB03F0A26C6CEB07E06C6CEB0FC06C6CEB1F80D8007EEB7E0090383F81FC90380FFF +F0010090C7FC282A7EA82D>I<3901FC03FC00FF90381FFF8091387C0FE09039FDE003F0 +3A07FFC001FC6C496C7E6C90C7127F49EC3F805BEE1FC017E0A2EE0FF0A3EE07F8AAEE0F +F0A4EE1FE0A2EE3FC06D1580EE7F007F6E13FE9138C001F89039FDE007F09039FC780FC0 +DA3FFFC7FCEC07F891C9FCAD487EB512F8A32D3A7EA733>I<02FF131C0107EBC03C9038 +1F80F090397F00387C01FC131CD803F8130E4848EB0FFC150748481303121F485A150148 +5AA448C7FCAA6C7EA36C7EA2001F14036C7E15076C6C130F6C7E6C6C133DD8007E137990 +383F81F190380FFFC1903801FE0190C7FCAD4B7E92B512F8A32D3A7DA730>I<3901F807 +E000FFEB1FF8EC787CECE1FE3807F9C100031381EA01FB1401EC00FC01FF1330491300A3 +5BB3A5487EB512FEA31F287EA724>I<90383FC0603901FFF8E03807C03F381F000F003E +1307003C1303127C0078130112F81400A27E7E7E6D1300EA7FF8EBFFC06C13F86C13FE6C +7F6C1480000114C0D8003F13E0010313F0EB001FEC0FF800E01303A214017E1400A27E15 +F07E14016C14E06CEB03C0903880078039F3E01F0038E0FFFC38C01FE01D2A7DA824>I< +131CA6133CA4137CA213FCA2120112031207001FB512C0B6FCA2D801FCC7FCB3A215E0A9 +12009038FE01C0A2EB7F03013F138090381F8700EB07FEEB01F81B397EB723>IIII< +B539F01FFFE0A30003D9C00F1300C690388007F8D97F0013E002805BD93FC05B011F49C7 +FC90380FE00EECF01E6D6C5A01035B6D6C5A6E5AEB00FF6E5A6E5A81141F814A7E81147B +ECF1FC903801E1FEECC0FF01037F49486C7ED90F007F011E6D7E013E130F496D7E01FC80 +486C80000F4A7EB539803FFFF8A32D277FA630>II<001FB61280A2EBE0000180140049485A001E +495A121C4A5A003C495A141F00385C4A5A147F5D4AC7FCC6485AA2495A495A130F5C495A +90393FC00380A2EB7F80EBFF005A5B484813071207491400485A48485BA248485B484813 +7F00FF495A90B6FCA221277EA628>I124 +D E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fk cmbx12 14.4 60 +/Fk 60 122 df<922601FFFC903801FFE0033F9026FF801F13F84AB6D8E07F13FE020F03 +F9B6FC023FD9C00FB500C0138091277FFC0003D9FE0113C0902601FFE049495A49494949 +4813E04990C714F049484A13E0495A19C0495A7413C0017F17804A6E6E1380719138007E +007192C7FCAEBCFCA526007FF8C7000301C0C8FCB3B3A7007FB5D8F803B612F0A553547D +D34E>11 D<151E153E157E15FCEC01F8EC07F0EC0FE0EC1FC01580143FEC7F0014FE1301 +495A5C1307495AA2495A133F5C137FA2495AA24890C7FCA25A5BA21207A2485AA3121F5B +A3123FA25BA3127FA55B12FFB3A3127F7FA5123FA37FA2121FA37F120FA36C7EA21203A2 +7F7EA26C7FA26D7EA2133F80131F6D7EA26D7E1303806D7E1300147FEC3F80141F15C0EC +0FE0EC07F0EC01F8EC00FC157E153E151E1F7973D934>40 D<127012F8127C127E7EEA1F +C06C7E6C7E12037F6C7E6C7E7F6D7E133F806D7EA26D7E80130780A26D7EA26D7EA21580 +7FA215C0A2EC7FE0A315F0143FA315F8A2141FA315FCA5140F15FEB3A315FC141FA515F8 +A3143FA215F0A3147F15E0A3ECFFC0A21580A25B1500A2495AA2495AA25C130F5C495AA2 +495A5C137F49C7FC5B485A485A5B1207485A485A48C8FC127E127C5A12701F7979D934> +I44 D46 +D<157815FC14031407141F14FF130F0007B5FCB6FCA2147F13F0EAF800C7FCB3B3B3A600 +7FB712FEA52F4E76CD43>49 DI<91380FFFC091B512 +FC0107ECFF80011F15E090263FF8077F9026FF800113FC4848C76C7ED803F86E7E491680 +D807FC8048B416C080486D15E0A4805CA36C17C06C5B6C90C75AD801FC1680C9FC4C1300 +5FA24C5A4B5B4B5B4B13C04B5BDBFFFEC7FC91B512F816E016FCEEFF80DA000713E00301 +13F89238007FFE707E7013807013C018E07013F0A218F8A27013FCA218FEA2EA03E0EA0F +F8487E487E487EB57EA318FCA25E18F891C7FC6C17F0495C6C4816E001F04A13C06C484A +1380D80FF84A13006CB44A5A6CD9F0075BC690B612F06D5D011F1580010302FCC7FCD900 +1F1380374F7ACD43>I<177C17FEA2160116031607160FA2161F163F167FA216FF5D5DA2 +5D5DED1FBFED3F3F153E157C15FCEC01F815F0EC03E01407EC0FC01580EC1F005C147E14 +7C5C1301495A495A5C495A131F49C7FC133E5B13FC485A5B485A1207485A485A90C8FC12 +3E127E5ABA12C0A5C96C48C7FCAF020FB712C0A53A4F7CCE43>III<121F7F7FEBFF8091B81280A45A1900606060A2606060485F0180C86CC7 +FC007EC95A4C5A007C4B5A5F4C5A160F4C5A484B5A4C5A94C8FC16FEC812014B5A5E4B5A +150F4B5AA24B5AA24B5A15FFA24A90C9FCA25C5D1407A2140FA25D141FA2143FA4147F5D +A314FFA55BAC6D5BA2EC3FC06E5A395279D043>I<913807FFC0027F13FC0103B67E010F +15E090261FFC0113F8903A3FE0003FFCD97F80EB0FFE49C76C7E48488048486E13800007 +17C04980120F18E0177FA2121F7FA27F7F6E14FF02E015C014F802FE4913806C7FDBC003 +13009238F007FE6C02F85B9238FE1FF86C9138FFBFF06CEDFFE017806C4BC7FC6D806D81 +010F15E06D81010115FC010781011F81491680EBFFE748018115C048D9007F14E0484801 +1F14F048487F48481303030014F8484880161F4848020713FC1601824848157F173FA217 +1FA2170FA218F8A27F007F17F06D151FA26C6CED3FE0001F17C06D157F6C6CEDFF806C6C +6C010313006C01E0EB0FFE6C01FCEBFFFC6C6CB612F06D5D010F1580010102FCC7FCD900 +0F13C0364F7ACD43>I<171F4D7E4D7EA24D7EA34C7FA24C7FA34C7FA34C7FA24C7FA34C +8083047F80167E8304FE804C7E03018116F8830303814C7E03078116E083030F814C7E03 +1F81168083033F8293C77E4B82157E8403FE824B800201835D840203834B800207835D84 +4AB87EA24A83A3DA3F80C88092C97E4A84A2027E8202FE844A82010185A24A820103854A +82010785A24A82010F855C011F717FEBFFFCB600F8020FB712E0A55B547BD366>65 +DI<932601FFFCEC01C0047F +D9FFC013030307B600F81307033F03FE131F92B8EA803F0203DAE003EBC07F020F01FCC7 +383FF0FF023F01E0EC0FF94A01800203B5FC494848C9FC4901F882494982494982494982 +4949824990CA7E494883A2484983485B1B7F485B481A3FA24849181FA3485B1B0FA25AA2 +98C7FC5CA2B5FCAE7EA280A2F307C07EA36C7FA21B0F6C6D1980A26C1A1F6C7F1C006C6D +606C6D187EA26D6C606D6D4C5A6D6D16036D6D4C5A6D6D4C5A6D01FC4C5A6D6DEE7F806D +6C6C6C4BC7FC6E01E0EC07FE020F01FEEC1FF80203903AFFE001FFF0020091B612C0033F +93C8FC030715FCDB007F14E0040101FCC9FC525479D261>IIII<9326 +01FFFCEC01C0047FD9FFC013030307B600F81307033F03FE131F92B8EA803F0203DAE003 +EBC07F020F01FCC7383FF0FF023F01E0EC0FF94A01800203B5FC494848C9FC4901F88249 +49824949824949824949824990CA7E494883A2484983485B1B7F485B481A3FA24849181F +A3485B1B0FA25AA298C8FC5CA2B5FCAE6C057FB712E0A280A36C94C7003FEBC000A36C7F +A36C7FA27E6C7FA26C7F6C7FA26D7E6D7F6D7F6D6D5E6D7F6D01FC93B5FC6D13FF6D6C6D +5C6E01F0EC07FB020F01FEEC1FF10203903AFFF001FFE0020091B6EAC07F033FEE001F03 +0703FC1307DB007F02E01301040149CAFC5B5479D26A>III<027FB71280A591C76C90C7FCB3 +B3B3EA07F0EA1FFC487E487EA2B57EA44C5AA34A485B7E49495BD83FF8495BD81FE05DD8 +0FFC011F5B2707FF807F90C8FC000190B512FC6C6C14F0011F14C0010101F8C9FC39537D +D145>IIII< +B600FC93B7FC8181A282D800076E9239003FFC0070EE07E08282A28202EF7F02E77F02E3 +80A202E18002E0806F7F6F7F6F7FA26F7F6F7F6F806F80A26F80707F707F707F707FA270 +7F7080708070808583717F717F717F717FA27114807114C07114E07213F07213F8A27213 +FC7213FE7213FF721487A27214C77214E77313F77313FF85A285858585A28586868686A2 +86868686A2D93FFC187FB7173F1B1F1B0F1B07755A60527CD169>I<93380FFFC00303B6 +FC031F15E092B712FC0203D9FC0013FF020F01C0010F13C0023F90C7000313F0DA7FFC02 +007F494848ED7FFE4901E0ED1FFF49496F7F49496F7F4990C96C7F49854948707F494870 +7FA24849717E48864A83481B804A83481BC0A2481BE04A83A2481BF0A348497113F8A5B5 +1AFCAF6C1BF86E5FA46C1BF0A26E5F6C1BE0A36C6D4D13C0A26C6D4D1380A26C1B006C6D +4D5A6E5E6C626D6C4C5B6D6D4B5B6D6D4B5B6D6D4B5B6D6D4B5B6D6D4B90C7FC6D6D4B5A +6D01FF02035B023F01E0011F13F0020F01FC90B512C0020390B7C8FC020016FC031F15E0 +030392C9FCDB001F13E0565479D265>II82 D<91260FFF80130791B500F85B010702FF5B011FEDC03F49EDF07F9026FFFC00 +6D5A4801E0EB0FFD4801800101B5FC4848C87E48488149150F001F824981123F4981007F +82A28412FF84A27FA26D82A27F7F6D93C7FC14C06C13F014FF15F86CECFF8016FC6CEDFF +C017F06C16FC6C16FF6C17C06C836C836D826D82010F821303010082021F16801400030F +15C0ED007F040714E01600173F050F13F08383A200788200F882A3187FA27EA219E07EA2 +6CEFFFC0A27F6D4B13806D17006D5D01FC4B5A01FF4B5A02C04A5A02F8EC7FF0903B1FFF +C003FFE0486C90B65AD8FC0393C7FC48C66C14FC48010F14F048D9007F90C8FC3C5479D2 +4B>I<003FBC1280A59126C0003F9038C0007F49C71607D87FF8060113C001E08449197F +49193F90C8171FA2007E1A0FA3007C1A07A500FC1BE0481A03A6C994C7FCB3B3AC91B912 +F0A553517BD05E>IIII<003FB7D88003B7FCA5D8000749C8 +000701F8C7FC6D6D9238007F806D6E93C8FC7015FE6D17016E6D5D704A5A6E16076E6D4A +5A6E6D5D4F5A6E6D143F6E6D4A5A7191C9FC6E16FE6EECC00171485A6F5D6F6D485A6FEB +F80F71485A6F5D6F6D485AEFFF7F6F4ACAFC6F5C6F5CA2705B705B8482707F707FA2707F +7080855E4C80855E4C80DC3FCF7F058F7FEE7F074C6C7FDB01FE814C7E4B486C8003076E +7F4B48814C7F4B486D7F033F824C7F4BC76C7F4B6E7F4A5A4B6E804A486E800207844A48 +814B6F7F4A4883023F824A486F7F92C96C7F02FE840101830103718090263FFFC084B76C +0103B712F8A55D527CD166>II97 DI<913801FFF8021FEBFF8091B612F00103 +15FC010F9038C00FFE903A1FFE0001FFD97FFC491380D9FFF05B4817C048495B5C5A485B +A2486F138091C7FC486F1300705A4892C8FC5BA312FFAD127F7FA27EA2EF03E06C7F1707 +6C6D15C07E6E140F6CEE1F806C6DEC3F006C6D147ED97FFE5C6D6CEB03F8010F9038E01F +F0010390B55A01001580023F49C7FC020113E033387CB63C>I<4DB47E0407B5FCA5EE00 +1F1707B3A4913801FFE0021F13FC91B6FC010315C7010F9038E03FE74990380007F7D97F +FC0101B5FC49487F4849143F484980485B83485B5A91C8FC5AA3485AA412FFAC127FA36C +7EA37EA26C7F5F6C6D5C7E6C6D5C6C6D49B5FC6D6C4914E0D93FFED90FEFEBFF80903A0F +FFC07FCF6D90B5128F0101ECFE0FD9003F13F8020301C049C7FC41547CD24B>I<913803 +FFC0023F13FC49B6FC010715C04901817F903A3FFC007FF849486D7E49486D7E4849130F +48496D7E48178048497F18C0488191C7FC4817E0A248815B18F0A212FFA490B8FCA318E0 +49CAFCA6127FA27F7EA218E06CEE01F06E14037E6C6DEC07E0A26C6DEC0FC06C6D141F6C +6DEC3F806D6CECFF00D91FFEEB03FE903A0FFFC03FF8010390B55A010015C0021F49C7FC +020113F034387CB63D>II +II<137F497E000313E0487FA2487FA76C5BA26C5BC613806DC7FC +90C8FCADEB3FF0B5FCA512017EB3B3A6B612E0A51B547BD325>I107 DIII<913801FFE002 +1F13FE91B612C0010315F0010F9038807FFC903A1FFC000FFED97FF86D6C7E49486D7F48 +496D7F48496D7F4A147F48834890C86C7EA24883A248486F7EA3007F1880A400FF18C0AC +007F1880A3003F18006D5DA26C5FA26C5F6E147F6C5F6C6D4A5A6C6D495B6C6D495B6D6C +495BD93FFE011F90C7FC903A0FFF807FFC6D90B55A010015C0023F91C8FC020113E03A38 +7CB643>I<903A3FF001FFE0B5010F13FE033FEBFFC092B612F002F301017F913AF7F800 +7FFE0003D9FFE0EB1FFFC602806D7F92C76C7F4A824A6E7F4A6E7FA2717FA285187F85A4 +721380AC1A0060A36118FFA2615F616E4A5BA26E4A5B6E4A5B6F495B6F4990C7FC03F0EB +FFFC9126FBFE075B02F8B612E06F1480031F01FCC8FC030313C092CBFCB1B612F8A5414D +7BB54B>I<90397FE003FEB590380FFF80033F13E04B13F09238FE1FF89139E1F83FFC00 +03D9E3E013FEC6ECC07FECE78014EF150014EE02FEEB3FFC5CEE1FF8EE0FF04A90C7FCA5 +5CB3AAB612FCA52F367CB537>114 D<903903FFF00F013FEBFE1F90B7FC120348EB003F +D80FF81307D81FE0130148487F4980127F90C87EA24881A27FA27F01F091C7FC13FCEBFF +C06C13FF15F86C14FF16C06C15F06C816C816C81C681013F1580010F15C01300020714E0 +EC003F030713F015010078EC007F00F8153F161F7E160FA27E17E07E6D141F17C07F6DEC +3F8001F8EC7F0001FEEB01FE9039FFC00FFC6DB55AD8FC1F14E0D8F807148048C601F8C7 +FC2C387CB635>I<143EA6147EA414FEA21301A313031307A2130F131F133F13FF5A000F +90B6FCB8FCA426003FFEC8FCB3A9EE07C0AB011FEC0F8080A26DEC1F0015806DEBC03E6D +EBF0FC6DEBFFF86D6C5B021F5B020313802A4D7ECB34>IIII<007FB500F090387FFFFEA5C66C48C7000F90C7FC6D6CEC07F8 +6D6D5C6D6D495A6D4B5A6F495A6D6D91C8FC6D6D137E6D6D5B91387FFE014C5A6E6C485A +6EEB8FE06EEBCFC06EEBFF806E91C9FCA26E5B6E5B6F7E6F7EA26F7F834B7F4B7F92B5FC +DA01FD7F03F87F4A486C7E4A486C7E020F7FDA1FC0804A486C7F4A486C7F02FE6D7F4A6D +7F495A49486D7F01076F7E49486E7E49486E7FEBFFF0B500FE49B612C0A542357EB447> +II E +%EndDVIPSBitmapFont +%DVIPSBitmapFont: Fl cmbx12 20.736 17 +/Fl 17 116 df[<17F0EE03F81607EE0FF0163FEE7FE0EEFFC04B13804B13004B5A4B5A +4B5A153F4B5A4B5A5C5E4A5B5C4A90C7FC4A5AA24A5A147F5D14FF5D5B495BA2495BA25B +5D5B92C8FC5BA2495AA213FF5CA25A5CA25AA25C5AA35A5CA35AA25CA25AA55C5AA8B5FC +A391C9FCB280A37EA87E80A57EA280A27EA3807EA37E80A27EA2807EA280137FA26D7EA2 +7F817F817FA26D7FA26D7F7F81147F81143F6E7EA26E7E6E7F806E7F82806F7E6F7E151F +6F7E6F7E6F7E6F13806F13C0EE7FE0EE3FF0160FEE07F81603EE00F0>45 +172 110 256 75 40 D[<127812FE7E6C7E13E06C7E6C7E6C7E6C7E6C7E6C7F6C7F806D +7E6D7E80131F6D7E806D7F6D7FA26D7F817F81147F816E7EA26E7EA28280828082A26E7F +A28280A28280A282A2157F82A3178081A317C0A281A217E0A58117F0A817F8A381B25DA3 +17F0A817E05DA517C0A25DA21780A35D1700A35E15FFA25EA25C5EA25C5EA24A5BA25E5C +5E5C93C7FCA24A5AA24A5A5D14FF5D5B5D495BA2495B4990C8FC5C495A133F5C495A495A +5C485B4890C9FC485A485A485A485A485A138048CAFC5A1278>45 +172 117 256 75 I<96267FFFE01670063FB6ED01F80503B700F01403053F04FC14074C +B96C130F040706E0131F043F72133F93BA00FC137F0303DC00076D13FF030F03C0903900 +3FFF814B02FCC8000713C3037F02E0030113F792B600806F6CB5FC02034ACA121F4A02F8 +834A02E0834A4A1701027F4A8391B548CC7E494A85495C4C854988494A85494A85495C8A +4991CDFC90B54886A2484A1B7FA2481E3F5D481E1F5D5A1F0FA2485CA3481E075DA2795A +489BC9FCA45DA2B6FCB27EA26F0403BA12C0A47EA3816C96C8000302F8C7FCA36C80A36C +80A27E817E817E817F6D80827F6D806D806D80826D6E606D806E80021F6E5F6E02F05F6E +806E02FE5F0200DAFFC05E6F02F04BB6FC031F02FE030713CF6FDAFFE0021F1387030392 +26FF8003B51201030093B6EAFC00043F4E133F040706E0131F04014E1307DC003F4CC712 +01050304F8EC0070DD003F038092C8FCDE007F01F0CCFC827A75F798>71 +D<037FB912F8A892C86C49C7FCB3B3B3B3A6EBFF80000313E0487F001F13FCA2487F487F +A2B67EA46295B5FCA26292C8FC6C4C5CA24A4A5C6C5B6C494A5C4A4A5C6C01C04A91C8FC +6C90C8485B6C01E04A5B6C01F849B55A6C9026FFC00F14E0013F90B71280010F4CC9FC01 +0316F8010016C0021F4ACAFC0200148055787CF564>74 D78 +D<922603FFF8150E037FD9FFC0143F0203B600FC5C021F03FF5C027FEEC00149B8EAF003 +49EFFC07010FDA000F13FE4901F09039007FFF8F4901C0020F13DF4990C8000390B5FC49 +4815004801F8163F48844A8248498248844A8248844A834885A291CB7E5A86A286B5FC86 +80A28680A280A26E8380806E187E6E95C7FC6C8015E015FCEDFFC06C15FCEEFFE06C16FF +18F06CEFFF8019F06C18FE737E6C856C19F06C19FC6D846D846D856D856D850101856D85 +023F846E841407020084031F18801500040F17C0EE007F050716E0EF003F1803DE007F14 +F0191F8585070114F8A28586007E85B4FC86A286A37F86A36D1AF0A37F1CE06D60A26D1A +C06D607F6D1A806E5F6E4D13006E606E17FF02FC4C5B02FF4C5B03E04B5B03FC031F5B01 +FBD9FF80027F5B01F102FE0107B55AD9E07F90B8C7FC6E17FCD9C00F5FD9800317E090C7 +6C168048020F4BC8FC48020015F00070030349C9FC557A75F76C>83 +D85 D<92383FFFF80207B612E002 +7F15FC49B87E010717E0011F83499026F0007F13FC4948C7000F7F90B502036D7E486E6D +806F6D80727F486E6E7F8486727FA28684A26C5C72806C5C6D90C8FC6D5AEB0FF8EB03E0 +90CAFCA70507B6FC041FB7FC0303B8FC157F0203B9FC021FECFE0391B612800103ECF800 +010F14C04991C7FC017F13FC90B512F04814C0485C4891C8FC485B5A485B5C5A5CA2B5FC +5CA360A36E5DA26C5F6E5D187E6C6D846E4A48806C6D4A4814FC6C6ED90FF0ECFFFC6C02 +E090263FE07F14FE00019139FC03FFC06C91B6487E013F4B487E010F4B1307010303F013 +01D9003F0280D9003F13FC020101F8CBFC57507ACE5E>97 D<93383FFFF00307B612C003 +3F15F84AB712FE0207707E021F17E0027F8391B526FC001F7F010302C001037F4991C748 +7F49495C495B4901F04A7F5B90B55A485CA2485C4891C8FCA248715B5C48715B725B4A6F +5B489438007FC0071FC7FC96C8FC5AA25CA3B5FCAF7E80A47E80A27E806CF11F80F23FC0 +6C6E167FA26C6EEEFF80816C606C6E17006D6D4B5A6D6D15076D6D4B5A6D6D6C4A5A6D02 +E0EC7FF06D02F849485A01009126FF801F5B6E91B6C7FC021F5E020716F8020116E06E6C +1580030702FCC8FCDB003F13804A507ACE56>99 D<93387FFF80030FB512FC037FECFF80 +4AB712E0020716F8021F16FE027FD9F8077F49B5D8C000804991C7003F13E04901FC020F +7F49496E7F49498049496E7F49496E7F90B55A48727E92C914804884485B1BC048841BE0 +485BA27313F05AA25C5AA21BF885A2B5FCA391BAFCA41BF002F8CCFCA67EA3807EA47E80 +6CF103F0F207F86C7F1A0F6C6E17F06C191F6F17E06C6E163F6D6DEE7FC06D6D16FF6D6D +4B13806D6D4B13006D6D6CEC0FFE6D02E0EC3FFC6D02F8ECFFF86D9126FFC00F5B023F91 +B65A020F178002034CC7FC020016F8031F15E0030392C8FCDB000F13E04D507BCE58> +101 D103 +D<903801FFFCB6FCA8C67E131F7FB3AD95380FFFE095B512FE05036E7E050F15E0053F15 +F84D81932701FFF01F7F4CD900077FDC07FC6D80DC0FF06D80DC1FC07F4C48824CC8FC04 +7E6F7F5EEDFDF85E03FF707F5EA25EA25EA293C9FCA45DB3B3A6B8D8E003B81280A86178 +79F76C>II<902601FFF891380FFFE0B692B512FE05036E7E050F15E0053F +15F84D81932701FFF01F7F4CD900077FDC07FC6D80C66CDA0FF06D80011FDA1FC07F6D4A +48824CC8FC047E6F7F5EEDF9F85E03FB707F5E15FF5EA25EA293C9FCA45DB3B3A6B8D8E0 +03B81280A8614E79CD6C>110 D<93381FFFE00303B6FC031F15E092B712FC020316FF02 +0F17C0023FD9FC0014F091B500C0010F13FC4991C700037F4901FC02007F010F496F13C0 +49496F7F49496F7F4B8149496F7F90B5C96C7F4886A24849707F481B80A248497014C0A2 +481BE0A348497113F0A3481BF8A5B51AFCAE6C1BF8A46C1BF06E94B5FCA36C1BE0A26C6D +4C14C0A26C1B806E5E6C1B006C6E4B5BA26C6E4B5B6D6D4B5B6D6D4B5B6D6D4B5B6D6D92 +B55A6D01FF02035C6D02C0010F91C7FC010002FC90B512FC6E90B75A021F17E002071780 +02014CC8FCDA003F15F0030392C9FCDB001F13E056507BCE61>I<902601FFFCEC7FFEB6 +020FB512F0057F14FE4CB712C0040716F0041F82047F16FE93B5C66C7F92B500F0010F14 +C0C66C0380010380011F4AC76C806D4A6E8004F06F7F4C6F7F4C6F7F4C8193C915804B70 +14C0861DE0A27414F0A27414F8A47513FCA57513FEAF5113FCA598B512F8A31DF0621DE0 +621DC0621D806F5E701800704B5B505B704B5B7092B55A04FC4A5C704A5C706C010F5C05 +E0013F49C7FC9227FE7FFC01B55A70B712F0040F16C0040393C8FC040015F8053F14C005 +0301F0C9FC94CCFCB3A6B812E0A85F6F7ACD6C>I<912603FFFCEB0780027F9039FFE00F +C00103B6EAF83F010FEDFEFF013F92B5FC49EB000F2601FFF01300480180143F4890C812 +0F4848814848814981123F83485A187FA212FF6D163FA37F7F6DEE1F8002C092C7FC14F0 +14FEECFFF06CECFF8016FEEEFFE06C16FC6C16FF18C06C836C17F86C836C836C83013F17 +806D17C0010717E0010117F0EB003F020716F8EC001F030015FC1607EE007F051F13FE17 +07007E82B482836D167FA2183F7F181FA27F19FC7FA26D163F6D17F86D167F19F06D16FF +6E4A13E002E04A13C06E4A138002FE023F1300913AFFC003FFFE01E790B65A01C316F001 +8016C026FE003F92C7FC48010714F80070D9007F90C8FC3F507ACE4C>115 +D E +%EndDVIPSBitmapFont +end +%%EndProlog +%%BeginSetup +%%Feature: *Resolution 600dpi +TeXDict begin +%%BeginPaperSize: Letter +letter +%%EndPaperSize + +%%EndSetup +%%Page: 1 1 +1 0 bop 727 2424 a Fl(GNU)65 b(Shogi)f(\(Japanese)i(c)-5 +b(hess\))150 5340 y Fk(Mik)l(e)45 b(V)-11 b(anier)p eop +%%Page: 2 2 +2 1 bop 150 5322 a Fj(Cop)m(yrigh)m(t)602 5319 y(c)577 +5322 y Fi(\015)30 b Fj(1999)i(Mic)m(hael)f(C.)f(V)-8 +b(anier)30 b(and)g(the)g(F)-8 b(ree)32 b(Soft)m(w)m(are)f(F)-8 +b(oundation)p eop +%%Page: 1 3 +1 2 bop 150 -116 a Fj(GNU)31 b(Shogi)e(\(Japanese)i(c)m(hess\))2414 +b(1)150 299 y Fh(GNU)54 b(Shogi)f(\(Japanese)g(c)l(hess\))275 +533 y Fj(This)41 b(do)s(cumen)m(t)i(describ)s(es)e(GNU)j(shogi,)i(a)d +(program)g(whic)m(h)f(pla)m(ys)g(Japanese)h(c)m(hess)h(\(shogi\))150 +643 y(against)31 b(a)f(h)m(uman)g(opp)s(onen)m(t.)p eop +%%Page: 2 4 +2 3 bop 150 -116 a Fj(2)2779 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Page: 3 5 +3 4 bop 150 -116 a Fj(Chapter)30 b(1:)41 b(In)m(tro)s(duction)2591 +b(3)150 299 y Fh(1)80 b(In)l(tro)t(duction)275 533 y +Fj(GNU)45 b(shogi)g(is)f(a)i(program)f(that)h(pla)m(ys)f(shogi,)j(the)e +(Japanese)f(v)m(ersion)g(of)g(c)m(hess,)50 b(against)c(a)150 +643 y(h)m(uman)33 b(\(or)h(computer\))h(opp)s(onen)m(t.)51 +b(This)32 b(\014le)h(describ)s(es)f(ho)m(w)i(to)h(use)e(GNU)i(shogi)e +(and)h(also)g(giv)m(es)150 752 y(bac)m(kground)c(information)f(ab)s +(out)h(the)g(game)i(of)e(shogi.)275 887 y(This)21 b(\014le)i(describ)s +(es)e(GNU)j(shogi)f(v)m(ersion)g(1.3.)39 b(It)24 b(w)m(as)f(written)g +(b)m(y)g(me,)i(Mik)m(e)f(V)-8 b(anier,)25 b(the)e(curren)m(t)150 +996 y(main)m(tainer)29 b(of)i(GNU)g(shogi.)40 b(My)31 +b(email)e(address)h(is)f Fg(mvanier@bbb.caltech.edu)p +Fj(.)275 1131 y(GNU)i(shogi)e(is)h(actually)g(t)m(w)m(o)h(programs:)150 +1375 y(`)p Fg(gnushogi)p Fj(')630 1484 y(is)e(the)i(text-based)g +(program)g(whic)m(h)e(also)h(con)m(tains)h(the)f(game-pla)m(ying)h +(engine.)150 1644 y(`)p Fg(xshogi)p Fj(')142 b(is)29 +b(the)i(X-windo)m(ws)e(graphical)g(in)m(terface)i(to)g(gn)m(ushogi.)275 +1913 y(Since)e(xshogi)h(in)m(v)m(ok)m(es)h(gn)m(ushogi,)f(most)h(pla)m +(y)m(ers)f(will)e(just)h(t)m(yp)s(e)i(\\xshogi")g(and)e(start)i(pla)m +(ying.)275 2047 y(Disclaimer:)58 b(I)40 b(use)f(the)h(p)s(ersonal)f +(pronouns)f(\\him",)k(\\his")d(etc.)70 b(to)41 b(refer)f(to)g(a)h +(shogi)e(pla)m(y)m(er)150 2157 y(regardless)f(of)h(gender.)67 +b(That's)39 b(easier)g(than)f(writing)f(\\his)h(or)h(her")g(all)f(o)m +(v)m(er)i(the)g(place.)66 b(I)39 b(don't)150 2267 y(mean)34 +b(to)h(infer)d(that)j(w)m(omen)f(don't)g(pla)m(y)f(shogi;)j(in)c(fact)j +(shogi)e(is)g(v)m(ery)i(p)s(opular)c(in)i(Japan)g(among)150 +2376 y(w)m(omen)e(as)f(w)m(ell)g(as)g(men.)p eop +%%Page: 4 6 +4 5 bop 150 -116 a Fj(4)2779 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Page: 5 7 +5 6 bop 150 -116 a Fj(GNU)31 b(GENERAL)f(PUBLIC)h(LICENSE)2052 +b(5)150 299 y Fh(GNU)54 b(GENERAL)g(PUBLIC)f(LICENSE)1537 +508 y Fj(V)-8 b(ersion)30 b(2,)h(June)f(1991)390 637 +y(Cop)m(yrigh)m(t)842 634 y(c)817 637 y Fi(\015)g Fj(1989,)j(1991)f(F) +-8 b(ree)31 b(Soft)m(w)m(are)h(F)-8 b(oundation,)30 b(Inc.)390 +741 y(675)i(Mass)e(Av)m(e,)i(Cam)m(bridge,)e(MA)h(02139,)h(USA)390 +948 y(Ev)m(ery)m(one)f(is)f(p)s(ermitted)f(to)i(cop)m(y)g(and)f +(distribute)e(v)m(erbatim)i(copies)390 1052 y(of)h(this)e(license)g(do) +s(cumen)m(t,)i(but)e(c)m(hanging)i(it)f(is)f(not)i(allo)m(w)m(ed.)150 +1309 y Fk(Pream)l(ble)275 1502 y Fj(The)39 b(licenses)h(for)g(most)h +(soft)m(w)m(are)g(are)g(designed)e(to)i(tak)m(e)h(a)m(w)m(a)m(y)h(y)m +(our)d(freedom)g(to)h(share)g(and)150 1611 y(c)m(hange)g(it.)70 +b(By)40 b(con)m(trast,)k(the)c(GNU)h(General)f(Public)e(License)i(is)f +(in)m(tended)g(to)h(guaran)m(tee)i(y)m(our)150 1721 y(freedom)24 +b(to)h(share)f(and)f(c)m(hange)i(free)f(soft)m(w)m(are|to)j(mak)m(e)e +(sure)e(the)h(soft)m(w)m(are)i(is)d(free)h(for)g(all)f(its)h(users.)150 +1831 y(This)38 b(General)i(Public)d(License)j(applies)e(to)i(most)g(of) +g(the)g(F)-8 b(ree)41 b(Soft)m(w)m(are)g(F)-8 b(oundation's)39 +b(soft)m(w)m(are)150 1940 y(and)c(to)h(an)m(y)g(other)g(program)f +(whose)h(authors)f(commit)g(to)i(using)d(it.)55 b(\(Some)36 +b(other)g(F)-8 b(ree)37 b(Soft)m(w)m(are)150 2050 y(F)-8 +b(oundation)31 b(soft)m(w)m(are)i(is)d(co)m(v)m(ered)j(b)m(y)e(the)g +(GNU)h(Library)e(General)h(Public)e(License)h(instead.\))43 +b(Y)-8 b(ou)150 2159 y(can)31 b(apply)e(it)h(to)h(y)m(our)f(programs,)g +(to)s(o.)275 2294 y(When)37 b(w)m(e)g(sp)s(eak)g(of)g(free)h(soft)m(w)m +(are,)i(w)m(e)e(are)g(referring)d(to)j(freedom,)h(not)f(price.)60 +b(Our)36 b(General)150 2403 y(Public)c(Licenses)h(are)i(designed)e(to)i +(mak)m(e)g(sure)f(that)g(y)m(ou)h(ha)m(v)m(e)g(the)g(freedom)f(to)g +(distribute)e(copies)150 2513 y(of)k(free)h(soft)m(w)m(are)g(\(and)f(c) +m(harge)i(for)e(this)f(service)h(if)f(y)m(ou)i(wish\),)g(that)f(y)m(ou) +h(receiv)m(e)g(source)f(co)s(de)h(or)150 2623 y(can)e(get)h(it)e(if)f +(y)m(ou)i(w)m(an)m(t)h(it,)f(that)g(y)m(ou)g(can)g(c)m(hange)h(the)e +(soft)m(w)m(are)i(or)f(use)f(pieces)h(of)f(it)g(in)g(new)g(free)150 +2732 y(programs;)c(and)g(that)h(y)m(ou)g(kno)m(w)f(y)m(ou)h(can)f(do)h +(these)g(things.)275 2867 y(T)-8 b(o)40 b(protect)h(y)m(our)f(righ)m +(ts,)i(w)m(e)e(need)g(to)h(mak)m(e)g(restrictions)d(that)j(forbid)d(an) +m(y)m(one)j(to)g(den)m(y)f(y)m(ou)150 2976 y(these)d(righ)m(ts)f(or)g +(to)h(ask)g(y)m(ou)f(to)h(surrender)e(the)h(righ)m(ts.)58 +b(These)36 b(restrictions)f(translate)i(to)g(certain)150 +3086 y(resp)s(onsibilities)25 b(for)31 b(y)m(ou)f(if)g(y)m(ou)g +(distribute)e(copies)i(of)h(the)f(soft)m(w)m(are,)j(or)d(if)f(y)m(ou)i +(mo)s(dify)e(it.)275 3220 y(F)-8 b(or)30 b(example,)f(if)g(y)m(ou)g +(distribute)e(copies)j(of)f(suc)m(h)g(a)h(program,)g(whether)e(gratis)i +(or)f(for)g(a)h(fee,)h(y)m(ou)150 3330 y(m)m(ust)i(giv)m(e)h(the)g +(recipien)m(ts)e(all)h(the)g(righ)m(ts)g(that)h(y)m(ou)g(ha)m(v)m(e.)51 +b(Y)-8 b(ou)34 b(m)m(ust)g(mak)m(e)g(sure)f(that)h(they)-8 +b(,)35 b(to)s(o,)150 3440 y(receiv)m(e)j(or)g(can)g(get)g(the)g(source) +g(co)s(de.)62 b(And)37 b(y)m(ou)h(m)m(ust)f(sho)m(w)h(them)f(these)h +(terms)f(so)h(they)g(kno)m(w)150 3549 y(their)29 b(righ)m(ts.)275 +3684 y(W)-8 b(e)29 b(protect)g(y)m(our)f(righ)m(ts)f(with)g(t)m(w)m(o)i +(steps:)40 b(\(1\))29 b(cop)m(yrigh)m(t)f(the)g(soft)m(w)m(are,)j(and)c +(\(2\))i(o\013er)g(y)m(ou)f(this)150 3793 y(license)h(whic)m(h)g(giv)m +(es)i(y)m(ou)g(legal)f(p)s(ermission)d(to)k(cop)m(y)-8 +b(,)32 b(distribute)c(and/or)i(mo)s(dify)f(the)i(soft)m(w)m(are.)275 +3928 y(Also,)45 b(for)d(eac)m(h)i(author's)f(protection)f(and)g(ours,)j +(w)m(e)e(w)m(an)m(t)h(to)f(mak)m(e)h(certain)e(that)h(ev)m(ery)m(one) +150 4037 y(understands)29 b(that)j(there)f(is)f(no)h(w)m(arran)m(t)m(y) +h(for)f(this)f(free)h(soft)m(w)m(are.)44 b(If)30 b(the)i(soft)m(w)m +(are)g(is)e(mo)s(di\014ed)f(b)m(y)150 4147 y(someone)i(else)e(and)g +(passed)h(on,)g(w)m(e)g(w)m(an)m(t)h(its)e(recipien)m(ts)g(to)h(kno)m +(w)g(that)g(what)g(they)g(ha)m(v)m(e)h(is)e(not)h(the)150 +4257 y(original,)e(so)h(that)g(an)m(y)h(problems)d(in)m(tro)s(duced)g +(b)m(y)i(others)g(will)d(not)j(re\015ect)h(on)f(the)g(original)e +(authors')150 4366 y(reputations.)275 4501 y(Finally)-8 +b(,)24 b(an)m(y)h(free)f(program)g(is)g(threatened)g(constan)m(tly)h(b) +m(y)g(soft)m(w)m(are)h(paten)m(ts.)39 b(W)-8 b(e)26 b(wish)c(to)j(a)m +(v)m(oid)150 4610 y(the)30 b(danger)g(that)h(redistributors)c(of)k(a)f +(free)h(program)f(will)d(individually)e(obtain)30 b(paten)m(t)h +(licenses,)e(in)150 4720 y(e\013ect)39 b(making)e(the)h(program)f +(proprietary)-8 b(.)62 b(T)-8 b(o)38 b(prev)m(en)m(t)g(this,)h(w)m(e)f +(ha)m(v)m(e)h(made)f(it)f(clear)g(that)i(an)m(y)150 4829 +y(paten)m(t)31 b(m)m(ust)g(b)s(e)e(licensed)g(for)h(ev)m(ery)m(one's)i +(free)f(use)f(or)g(not)h(licensed)e(at)i(all.)275 4964 +y(The)e(precise)h(terms)g(and)g(conditions)f(for)h(cop)m(ying,)h +(distribution)26 b(and)k(mo)s(di\014cation)f(follo)m(w.)p +eop +%%Page: 6 8 +6 7 bop 150 -116 a Fj(6)2779 b(GNU)31 b(Shogi)f(man)m(ual)150 +166 y Fk(TERMS)44 b(AND)h(CONDITIONS)g(F)l(OR)g(COPYING,)150 +299 y(DISTRIBUTION)f(AND)h(MODIFICA)-11 b(TION)199 515 +y Fj(0.)61 b(This)41 b(License)h(applies)e(to)k(an)m(y)f(program)f(or)g +(other)h(w)m(ork)g(whic)m(h)e(con)m(tains)i(a)g(notice)f(placed)330 +625 y(b)m(y)33 b(the)h(cop)m(yrigh)m(t)g(holder)e(sa)m(ying)i(it)f(ma)m +(y)h(b)s(e)f(distributed)e(under)h(the)h(terms)h(of)g(this)e(General) +330 735 y(Public)37 b(License.)67 b(The)39 b(\\Program",)j(b)s(elo)m +(w,)f(refers)e(to)h(an)m(y)g(suc)m(h)f(program)g(or)g(w)m(ork,)j(and)d +(a)330 844 y(\\w)m(ork)29 b(based)f(on)h(the)g(Program")g(means)f +(either)h(the)f(Program)h(or)g(an)m(y)g(deriv)-5 b(ativ)m(e)28 +b(w)m(ork)g(under)330 954 y(cop)m(yrigh)m(t)k(la)m(w:)42 +b(that)32 b(is)e(to)j(sa)m(y)-8 b(,)33 b(a)e(w)m(ork)h(con)m(taining)f +(the)g(Program)h(or)f(a)h(p)s(ortion)e(of)h(it,)g(either)330 +1063 y(v)m(erbatim)e(or)g(with)e(mo)s(di\014cations)g(and/or)i +(translated)g(in)m(to)g(another)g(language.)40 b(\(Hereinafter,)330 +1173 y(translation)26 b(is)g(included)f(without)h(limitation)f(in)h +(the)h(term)g(\\mo)s(di\014cation".\))40 b(Eac)m(h)27 +b(licensee)g(is)330 1282 y(addressed)i(as)i(\\y)m(ou".)330 +1429 y(Activities)38 b(other)h(than)f(cop)m(ying,)k(distribution)35 +b(and)j(mo)s(di\014cation)f(are)i(not)g(co)m(v)m(ered)h(b)m(y)f(this) +330 1538 y(License;)33 b(they)g(are)f(outside)g(its)f(scop)s(e.)47 +b(The)32 b(act)h(of)g(running)c(the)k(Program)f(is)f(not)i(restricted,) +330 1648 y(and)24 b(the)g(output)g(from)g(the)h(Program)f(is)g(co)m(v)m +(ered)i(only)d(if)g(its)h(con)m(ten)m(ts)i(constitute)f(a)g(w)m(ork)f +(based)330 1758 y(on)h(the)h(Program)f(\(indep)s(enden)m(t)f(of)i(ha)m +(ving)f(b)s(een)f(made)i(b)m(y)f(running)e(the)i(Program\).)40 +b(Whether)330 1867 y(that)31 b(is)e(true)i(dep)s(ends)d(on)i(what)h +(the)f(Program)h(do)s(es.)199 2014 y(1.)61 b(Y)-8 b(ou)42 +b(ma)m(y)g(cop)m(y)g(and)e(distribute)f(v)m(erbatim)i(copies)g(of)h +(the)f(Program's)h(source)f(co)s(de)h(as)g(y)m(ou)330 +2123 y(receiv)m(e)32 b(it,)f(in)f(an)m(y)h(medium,)f(pro)m(vided)g +(that)h(y)m(ou)h(conspicuously)d(and)h(appropriately)g(publish)330 +2233 y(on)j(eac)m(h)h(cop)m(y)g(an)f(appropriate)f(cop)m(yrigh)m(t)i +(notice)f(and)g(disclaimer)d(of)k(w)m(arran)m(t)m(y;)h(k)m(eep)f(in)m +(tact)330 2342 y(all)d(the)g(notices)h(that)h(refer)e(to)h(this)f +(License)g(and)g(to)i(the)f(absence)g(of)g(an)m(y)g(w)m(arran)m(t)m(y;) +h(and)e(giv)m(e)330 2452 y(an)m(y)g(other)f(recipien)m(ts)g(of)g(the)h +(Program)f(a)h(cop)m(y)g(of)g(this)e(License)h(along)g(with)f(the)i +(Program.)330 2598 y(Y)-8 b(ou)31 b(ma)m(y)g(c)m(harge)h(a)f(fee)g(for) +f(the)h(ph)m(ysical)e(act)j(of)f(transferring)e(a)i(cop)m(y)-8 +b(,)32 b(and)e(y)m(ou)h(ma)m(y)g(at)g(y)m(our)330 2708 +y(option)f(o\013er)h(w)m(arran)m(t)m(y)g(protection)g(in)e(exc)m(hange) +j(for)e(a)g(fee.)199 2854 y(2.)61 b(Y)-8 b(ou)24 b(ma)m(y)h(mo)s(dify)d +(y)m(our)i(cop)m(y)g(or)g(copies)g(of)g(the)g(Program)g(or)g(an)m(y)g +(p)s(ortion)e(of)i(it,)h(th)m(us)f(forming)f(a)330 2964 +y(w)m(ork)k(based)g(on)f(the)h(Program,)h(and)f(cop)m(y)g(and)g +(distribute)d(suc)m(h)j(mo)s(di\014cations)e(or)h(w)m(ork)h(under)330 +3074 y(the)k(terms)f(of)g(Section)h(1)f(ab)s(o)m(v)m(e,)i(pro)m(vided)d +(that)i(y)m(ou)g(also)f(meet)h(all)f(of)g(these)h(conditions:)379 +3220 y(a.)61 b(Y)-8 b(ou)43 b(m)m(ust)f(cause)i(the)e(mo)s(di\014ed)f +(\014les)g(to)i(carry)g(prominen)m(t)e(notices)i(stating)f(that)i(y)m +(ou)510 3330 y(c)m(hanged)31 b(the)g(\014les)e(and)h(the)g(date)h(of)g +(an)m(y)g(c)m(hange.)374 3476 y(b.)60 b(Y)-8 b(ou)31 +b(m)m(ust)g(cause)g(an)m(y)h(w)m(ork)f(that)g(y)m(ou)g(distribute)d(or) +j(publish,)d(that)j(in)f(whole)g(or)h(in)e(part)510 3586 +y(con)m(tains)35 b(or)h(is)e(deriv)m(ed)g(from)h(the)g(Program)g(or)g +(an)m(y)h(part)f(thereof,)i(to)f(b)s(e)e(licensed)g(as)i(a)510 +3695 y(whole)30 b(at)h(no)f(c)m(harge)i(to)f(all)e(third)f(parties)i +(under)f(the)i(terms)f(of)g(this)g(License.)384 3842 +y(c.)61 b(If)39 b(the)h(mo)s(di\014ed)e(program)h(normally)f(reads)i +(commands)f(in)m(teractiv)m(ely)h(when)f(run,)i(y)m(ou)510 +3951 y(m)m(ust)30 b(cause)h(it,)f(when)g(started)h(running)c(for)k(suc) +m(h)f(in)m(teractiv)m(e)h(use)f(in)f(the)i(most)g(ordinary)510 +4061 y(w)m(a)m(y)-8 b(,)25 b(to)d(prin)m(t)e(or)h(displa)m(y)f(an)h +(announcemen)m(t)g(including)d(an)k(appropriate)e(cop)m(yrigh)m(t)i +(notice)510 4170 y(and)i(a)g(notice)h(that)f(there)h(is)e(no)h(w)m +(arran)m(t)m(y)h(\(or)g(else,)g(sa)m(ying)f(that)h(y)m(ou)g(pro)m(vide) +e(a)i(w)m(arran)m(t)m(y\))510 4280 y(and)35 b(that)g(users)g(ma)m(y)g +(redistribute)e(the)j(program)f(under)e(these)j(conditions,)f(and)g +(telling)510 4390 y(the)f(user)f(ho)m(w)h(to)g(view)f(a)i(cop)m(y)f(of) +g(this)f(License.)50 b(\(Exception:)e(if)32 b(the)i(Program)g(itself)f +(is)510 4499 y(in)m(teractiv)m(e)i(but)e(do)s(es)h(not)g(normally)e +(prin)m(t)h(suc)m(h)g(an)h(announcemen)m(t,)h(y)m(our)f(w)m(ork)g +(based)510 4609 y(on)c(the)h(Program)f(is)g(not)g(required)f(to)i(prin) +m(t)e(an)h(announcemen)m(t.\))330 4792 y(These)41 b(requiremen)m(ts)g +(apply)f(to)i(the)g(mo)s(di\014ed)e(w)m(ork)h(as)h(a)g(whole.)73 +b(If)42 b(iden)m(ti\014able)d(sections)330 4902 y(of)j(that)h(w)m(ork)g +(are)f(not)h(deriv)m(ed)e(from)h(the)h(Program,)i(and)d(can)h(b)s(e)e +(reasonably)h(considered)330 5011 y(indep)s(enden)m(t)24 +b(and)j(separate)g(w)m(orks)g(in)e(themselv)m(es,)j(then)e(this)g +(License,)h(and)f(its)h(terms,)g(do)g(not)330 5121 y(apply)36 +b(to)i(those)f(sections)g(when)g(y)m(ou)g(distribute)e(them)i(as)g +(separate)h(w)m(orks.)61 b(But)37 b(when)g(y)m(ou)330 +5230 y(distribute)27 b(the)i(same)g(sections)h(as)f(part)g(of)g(a)h +(whole)e(whic)m(h)g(is)g(a)h(w)m(ork)h(based)e(on)h(the)h(Program,)330 +5340 y(the)h(distribution)d(of)j(the)h(whole)e(m)m(ust)h(b)s(e)g(on)g +(the)g(terms)g(of)h(this)e(License,)h(whose)g(p)s(ermissions)p +eop +%%Page: 7 9 +7 8 bop 150 -116 a Fj(GNU)31 b(GENERAL)f(PUBLIC)h(LICENSE)2052 +b(7)330 299 y(for)22 b(other)h(licensees)e(extend)i(to)g(the)f(en)m +(tire)g(whole,)i(and)d(th)m(us)h(to)h(eac)m(h)h(and)d(ev)m(ery)i(part)g +(regardless)330 408 y(of)31 b(who)e(wrote)i(it.)330 538 +y(Th)m(us,)48 b(it)d(is)f(not)i(the)f(in)m(ten)m(t)g(of)h(this)e +(section)h(to)h(claim)f(righ)m(ts)f(or)h(con)m(test)i(y)m(our)f(righ)m +(ts)e(to)330 648 y(w)m(ork)34 b(written)e(en)m(tirely)h(b)m(y)h(y)m +(ou;)h(rather,)g(the)f(in)m(ten)m(t)g(is)e(to)j(exercise)e(the)h(righ)m +(t)f(to)i(con)m(trol)f(the)330 757 y(distribution)27 +b(of)j(deriv)-5 b(ativ)m(e)30 b(or)h(collectiv)m(e)f(w)m(orks)h(based)f +(on)g(the)h(Program.)330 887 y(In)41 b(addition,)h(mere)f(aggregation)i +(of)f(another)f(w)m(ork)g(not)h(based)f(on)g(the)g(Program)h(with)e +(the)330 996 y(Program)22 b(\(or)g(with)e(a)i(w)m(ork)g(based)f(on)h +(the)g(Program\))g(on)f(a)h(v)m(olume)g(of)g(a)g(storage)h(or)f +(distribution)330 1106 y(medium)28 b(do)s(es)j(not)f(bring)f(the)h +(other)h(w)m(ork)f(under)f(the)i(scop)s(e)f(of)h(this)e(License.)199 +1235 y(3.)61 b(Y)-8 b(ou)38 b(ma)m(y)f(cop)m(y)h(and)f(distribute)d +(the)k(Program)f(\(or)g(a)h(w)m(ork)f(based)g(on)g(it,)i(under)c +(Section)i(2\))330 1345 y(in)29 b(ob)5 b(ject)31 b(co)s(de)g(or)g +(executable)g(form)f(under)e(the)j(terms)f(of)h(Sections)f(1)h(and)f(2) +h(ab)s(o)m(v)m(e)g(pro)m(vided)330 1455 y(that)g(y)m(ou)g(also)f(do)g +(one)h(of)f(the)h(follo)m(wing:)379 1584 y(a.)61 b(Accompan)m(y)47 +b(it)e(with)f(the)i(complete)g(corresp)s(onding)e(mac)m(hine-readable)h +(source)g(co)s(de,)510 1694 y(whic)m(h)25 b(m)m(ust)h(b)s(e)f +(distributed)e(under)h(the)j(terms)e(of)i(Sections)e(1)i(and)e(2)h(ab)s +(o)m(v)m(e)i(on)d(a)i(medium)510 1803 y(customarily)i(used)h(for)g +(soft)m(w)m(are)i(in)m(terc)m(hange;)f(or,)374 1933 y(b.)60 +b(Accompan)m(y)30 b(it)f(with)f(a)i(written)e(o\013er,)j(v)-5 +b(alid)27 b(for)i(at)i(least)e(three)h(y)m(ears,)g(to)g(giv)m(e)g(an)m +(y)g(third)510 2042 y(part)m(y)-8 b(,)32 b(for)f(a)h(c)m(harge)g(no)f +(more)h(than)f(y)m(our)g(cost)h(of)f(ph)m(ysically)f(p)s(erforming)f +(source)i(distri-)510 2152 y(bution,)c(a)h(complete)h(mac)m +(hine-readable)e(cop)m(y)h(of)g(the)g(corresp)s(onding)e(source)i(co)s +(de,)h(to)g(b)s(e)510 2262 y(distributed)i(under)i(the)h(terms)g(of)h +(Sections)f(1)g(and)g(2)h(ab)s(o)m(v)m(e)g(on)f(a)h(medium)d +(customarily)510 2371 y(used)e(for)g(soft)m(w)m(are)i(in)m(terc)m +(hange;)f(or,)384 2501 y(c.)61 b(Accompan)m(y)33 b(it)e(with)g(the)h +(information)e(y)m(ou)i(receiv)m(ed)g(as)g(to)g(the)g(o\013er)g(to)h +(distribute)c(cor-)510 2610 y(resp)s(onding)i(source)i(co)s(de.)50 +b(\(This)31 b(alternativ)m(e)j(is)e(allo)m(w)m(ed)h(only)g(for)g +(noncommercial)f(dis-)510 2720 y(tribution)e(and)h(only)g(if)g(y)m(ou)i +(receiv)m(ed)f(the)g(program)g(in)f(ob)5 b(ject)33 b(co)s(de)f(or)g +(executable)g(form)510 2829 y(with)d(suc)m(h)h(an)g(o\013er,)h(in)e +(accord)j(with)d(Subsection)g(b)h(ab)s(o)m(v)m(e.\))330 +2979 y(The)j(source)h(co)s(de)g(for)f(a)h(w)m(ork)g(means)f(the)h +(preferred)e(form)h(of)h(the)g(w)m(ork)f(for)h(making)f(mo)s(di\014-) +330 3088 y(cations)e(to)g(it.)40 b(F)-8 b(or)31 b(an)f(executable)h(w)m +(ork,)g(complete)f(source)h(co)s(de)f(means)h(all)e(the)h(source)h(co)s +(de)330 3198 y(for)25 b(all)g(mo)s(dules)f(it)h(con)m(tains,)i(plus)c +(an)m(y)j(asso)s(ciated)g(in)m(terface)h(de\014nition)c(\014les,)j +(plus)d(the)j(scripts)330 3308 y(used)41 b(to)i(con)m(trol)g +(compilation)d(and)i(installation)e(of)i(the)h(executable.)76 +b(Ho)m(w)m(ev)m(er,)48 b(as)42 b(a)g(sp)s(e-)330 3417 +y(cial)30 b(exception,)i(the)f(source)g(co)s(de)g(distributed)d(need)i +(not)h(include)e(an)m(ything)h(that)i(is)e(normally)330 +3527 y(distributed)37 b(\(in)h(either)h(source)h(or)f(binary)f(form\))i +(with)e(the)i(ma)5 b(jor)39 b(comp)s(onen)m(ts)h(\(compiler,)330 +3636 y(k)m(ernel,)35 b(and)f(so)g(on\))g(of)h(the)f(op)s(erating)g +(system)g(on)g(whic)m(h)f(the)h(executable)h(runs,)f(unless)e(that)330 +3746 y(comp)s(onen)m(t)f(itself)e(accompanies)i(the)f(executable.)330 +3875 y(If)39 b(distribution)c(of)40 b(executable)g(or)f(ob)5 +b(ject)40 b(co)s(de)f(is)g(made)g(b)m(y)g(o\013ering)g(access)h(to)g +(cop)m(y)g(from)330 3985 y(a)e(designated)f(place,)i(then)f(o\013ering) +f(equiv)-5 b(alen)m(t)37 b(access)h(to)h(cop)m(y)f(the)f(source)h(co)s +(de)g(from)f(the)330 4095 y(same)29 b(place)f(coun)m(ts)g(as)h +(distribution)24 b(of)k(the)h(source)f(co)s(de,)h(ev)m(en)g(though)e +(third)g(parties)g(are)i(not)330 4204 y(comp)s(elled)g(to)i(cop)m(y)g +(the)g(source)f(along)h(with)e(the)h(ob)5 b(ject)31 b(co)s(de.)199 +4334 y(4.)61 b(Y)-8 b(ou)35 b(ma)m(y)h(not)f(cop)m(y)-8 +b(,)37 b(mo)s(dify)-8 b(,)35 b(sublicense,)f(or)g(distribute)f(the)i +(Program)f(except)i(as)f(expressly)330 4443 y(pro)m(vided)k(under)g +(this)h(License.)70 b(An)m(y)41 b(attempt)h(otherwise)e(to)h(cop)m(y)-8 +b(,)45 b(mo)s(dify)-8 b(,)42 b(sublicense)c(or)330 4553 +y(distribute)24 b(the)j(Program)g(is)e(v)m(oid,)i(and)f(will)e +(automatically)j(terminate)f(y)m(our)h(righ)m(ts)f(under)f(this)330 +4663 y(License.)70 b(Ho)m(w)m(ev)m(er,)45 b(parties)40 +b(who)g(ha)m(v)m(e)h(receiv)m(ed)g(copies,)i(or)d(righ)m(ts,)j(from)d +(y)m(ou)g(under)f(this)330 4772 y(License)d(will)e(not)j(ha)m(v)m(e)h +(their)e(licenses)f(terminated)i(so)g(long)f(as)h(suc)m(h)f(parties)g +(remain)g(in)f(full)330 4882 y(compliance.)199 5011 y(5.)61 +b(Y)-8 b(ou)38 b(are)g(not)g(required)d(to)j(accept)h(this)e(License,)i +(since)e(y)m(ou)g(ha)m(v)m(e)i(not)f(signed)e(it.)62 +b(Ho)m(w)m(ev)m(er,)330 5121 y(nothing)23 b(else)g(gran)m(ts)i(y)m(ou)f +(p)s(ermission)c(to)25 b(mo)s(dify)d(or)h(distribute)f(the)i(Program)g +(or)f(its)g(deriv)-5 b(ativ)m(e)330 5230 y(w)m(orks.)38 +b(These)23 b(actions)g(are)h(prohibited)c(b)m(y)j(la)m(w)g(if)f(y)m(ou) +h(do)g(not)h(accept)g(this)e(License.)38 b(Therefore,)330 +5340 y(b)m(y)e(mo)s(difying)d(or)j(distributing)c(the)k(Program)g(\(or) +h(an)m(y)f(w)m(ork)g(based)g(on)f(the)i(Program\),)h(y)m(ou)p +eop +%%Page: 8 10 +8 9 bop 150 -116 a Fj(8)2779 b(GNU)31 b(Shogi)f(man)m(ual)330 +299 y(indicate)h(y)m(our)i(acceptance)h(of)f(this)e(License)h(to)i(do)e +(so,)h(and)f(all)f(its)h(terms)g(and)g(conditions)f(for)330 +408 y(cop)m(ying,)g(distributing)26 b(or)31 b(mo)s(difying)c(the)k +(Program)f(or)h(w)m(orks)f(based)g(on)g(it.)199 545 y(6.)61 +b(Eac)m(h)43 b(time)e(y)m(ou)h(redistribute)e(the)i(Program)g(\(or)g +(an)m(y)h(w)m(ork)f(based)f(on)h(the)g(Program\),)k(the)330 +655 y(recipien)m(t)31 b(automatically)i(receiv)m(es)g(a)g(license)e +(from)h(the)g(original)f(licensor)g(to)i(cop)m(y)-8 b(,)34 +b(distribute)330 765 y(or)i(mo)s(dify)f(the)h(Program)h(sub)5 +b(ject)36 b(to)h(these)g(terms)f(and)g(conditions.)57 +b(Y)-8 b(ou)37 b(ma)m(y)g(not)f(imp)s(ose)330 874 y(an)m(y)27 +b(further)f(restrictions)f(on)i(the)g(recipien)m(ts')f(exercise)h(of)g +(the)g(righ)m(ts)f(gran)m(ted)h(herein.)38 b(Y)-8 b(ou)28 +b(are)330 984 y(not)j(resp)s(onsible)c(for)j(enforcing)g(compliance)g +(b)m(y)g(third)e(parties)i(to)h(this)e(License.)199 1121 +y(7.)61 b(If,)27 b(as)g(a)g(consequence)h(of)f(a)g(court)g(judgmen)m(t) +f(or)h(allegation)f(of)h(paten)m(t)h(infringemen)m(t)c(or)j(for)g(an)m +(y)330 1230 y(other)h(reason)f(\(not)h(limited)d(to)j(paten)m(t)h +(issues\),)e(conditions)f(are)h(imp)s(osed)f(on)h(y)m(ou)h(\(whether)f +(b)m(y)330 1340 y(court)c(order,)h(agreemen)m(t)g(or)f(otherwise\))f +(that)h(con)m(tradict)h(the)e(conditions)f(of)i(this)f(License,)i(they) +330 1450 y(do)34 b(not)g(excuse)h(y)m(ou)f(from)g(the)g(conditions)f +(of)h(this)f(License.)52 b(If)33 b(y)m(ou)i(cannot)g(distribute)c(so)k +(as)330 1559 y(to)f(satisfy)f(sim)m(ultaneously)f(y)m(our)h +(obligations)g(under)f(this)g(License)h(and)g(an)m(y)h(other)g(p)s +(ertinen)m(t)330 1669 y(obligations,)41 b(then)f(as)g(a)g(consequence)h +(y)m(ou)f(ma)m(y)g(not)g(distribute)e(the)i(Program)g(at)g(all.)68 +b(F)-8 b(or)330 1778 y(example,)25 b(if)e(a)i(paten)m(t)g(license)e(w)m +(ould)g(not)h(p)s(ermit)f(ro)m(y)m(alt)m(y-free)j(redistribution)20 +b(of)k(the)h(Program)330 1888 y(b)m(y)35 b(all)f(those)h(who)f(receiv)m +(e)i(copies)f(directly)e(or)i(indirectly)e(through)h(y)m(ou,)i(then)f +(the)g(only)f(w)m(a)m(y)330 1998 y(y)m(ou)27 b(could)e(satisfy)h(b)s +(oth)f(it)h(and)g(this)f(License)h(w)m(ould)f(b)s(e)h(to)h(refrain)d +(en)m(tirely)i(from)g(distribution)330 2107 y(of)31 b(the)f(Program.) +330 2244 y(If)43 b(an)m(y)g(p)s(ortion)f(of)h(this)g(section)g(is)f +(held)g(in)m(v)-5 b(alid)41 b(or)i(unenforceable)f(under)g(an)m(y)i +(particular)330 2354 y(circumstance,)i(the)e(balance)f(of)g(the)h +(section)f(is)f(in)m(tended)g(to)i(apply)e(and)g(the)i(section)f(as)h +(a)330 2463 y(whole)30 b(is)f(in)m(tended)g(to)i(apply)e(in)g(other)i +(circumstances.)330 2600 y(It)41 b(is)e(not)i(the)f(purp)s(ose)f(of)i +(this)e(section)i(to)g(induce)e(y)m(ou)i(to)g(infringe)d(an)m(y)j +(paten)m(ts)g(or)g(other)330 2710 y(prop)s(ert)m(y)e(righ)m(t)h(claims) +e(or)i(to)h(con)m(test)h(v)-5 b(alidit)m(y)38 b(of)i(an)m(y)g(suc)m(h)g +(claims;)j(this)c(section)h(has)g(the)330 2819 y(sole)30 +b(purp)s(ose)e(of)j(protecting)f(the)g(in)m(tegrit)m(y)g(of)g(the)h +(free)f(soft)m(w)m(are)h(distribution)c(system,)j(whic)m(h)330 +2929 y(is)k(implemen)m(ted)g(b)m(y)h(public)d(license)i(practices.)55 +b(Man)m(y)36 b(p)s(eople)e(ha)m(v)m(e)i(made)f(generous)h(con)m(tri-) +330 3039 y(butions)e(to)i(the)f(wide)g(range)g(of)h(soft)m(w)m(are)h +(distributed)32 b(through)j(that)h(system)f(in)f(reliance)h(on)330 +3148 y(consisten)m(t)h(application)e(of)h(that)h(system;)i(it)d(is)g +(up)f(to)i(the)g(author/donor)f(to)h(decide)f(if)g(he)g(or)330 +3258 y(she)i(is)g(willing)d(to)k(distribute)d(soft)m(w)m(are)k(through) +e(an)m(y)g(other)h(system)g(and)f(a)g(licensee)g(cannot)330 +3367 y(imp)s(ose)29 b(that)i(c)m(hoice.)330 3504 y(This)25 +b(section)j(is)e(in)m(tended)g(to)i(mak)m(e)g(thoroughly)e(clear)h +(what)g(is)f(b)s(eliev)m(ed)g(to)i(b)s(e)f(a)g(consequence)330 +3614 y(of)k(the)f(rest)h(of)f(this)f(License.)199 3751 +y(8.)61 b(If)35 b(the)g(distribution)c(and/or)k(use)g(of)g(the)g +(Program)g(is)f(restricted)h(in)f(certain)h(coun)m(tries)f(either)330 +3861 y(b)m(y)h(paten)m(ts)h(or)g(b)m(y)f(cop)m(yrigh)m(ted)h(in)m +(terfaces,)h(the)e(original)f(cop)m(yrigh)m(t)i(holder)e(who)h(places)g +(the)330 3970 y(Program)h(under)f(this)g(License)h(ma)m(y)h(add)e(an)i +(explicit)d(geographical)j(distribution)32 b(limitation)330 +4080 y(excluding)27 b(those)i(coun)m(tries,)g(so)g(that)g(distribution) +c(is)i(p)s(ermitted)h(only)f(in)g(or)i(among)g(coun)m(tries)330 +4189 y(not)k(th)m(us)f(excluded.)47 b(In)32 b(suc)m(h)g(case,)j(this)c +(License)i(incorp)s(orates)f(the)h(limitation)d(as)j(if)f(written)330 +4299 y(in)d(the)i(b)s(o)s(dy)d(of)j(this)e(License.)199 +4436 y(9.)61 b(The)26 b(F)-8 b(ree)28 b(Soft)m(w)m(are)g(F)-8 +b(oundation)26 b(ma)m(y)i(publish)23 b(revised)i(and/or)i(new)f(v)m +(ersions)g(of)h(the)g(General)330 4545 y(Public)35 b(License)h(from)h +(time)g(to)g(time.)61 b(Suc)m(h)36 b(new)h(v)m(ersions)f(will)f(b)s(e)h +(similar)e(in)i(spirit)f(to)j(the)330 4655 y(presen)m(t)30 +b(v)m(ersion,)h(but)e(ma)m(y)i(di\013er)e(in)g(detail)h(to)h(address)e +(new)h(problems)f(or)h(concerns.)330 4792 y(Eac)m(h)46 +b(v)m(ersion)e(is)g(giv)m(en)h(a)g(distinguishing)40 +b(v)m(ersion)45 b(n)m(um)m(b)s(er.)83 b(If)44 b(the)h(Program)g(sp)s +(eci\014es)f(a)330 4902 y(v)m(ersion)35 b(n)m(um)m(b)s(er)g(of)h(this)e +(License)i(whic)m(h)e(applies)g(to)j(it)e(and)g(\\an)m(y)i(later)e(v)m +(ersion",)j(y)m(ou)e(ha)m(v)m(e)330 5011 y(the)d(option)f(of)h(follo)m +(wing)e(the)i(terms)g(and)f(conditions)f(either)i(of)g(that)g(v)m +(ersion)f(or)h(of)g(an)m(y)g(later)330 5121 y(v)m(ersion)d(published)c +(b)m(y)k(the)g(F)-8 b(ree)31 b(Soft)m(w)m(are)g(F)-8 +b(oundation.)41 b(If)29 b(the)i(Program)f(do)s(es)g(not)g(sp)s(ecify)f +(a)330 5230 y(v)m(ersion)e(n)m(um)m(b)s(er)g(of)h(this)e(License,)i(y)m +(ou)g(ma)m(y)h(c)m(ho)s(ose)f(an)m(y)h(v)m(ersion)e(ev)m(er)h +(published)c(b)m(y)k(the)g(F)-8 b(ree)330 5340 y(Soft)m(w)m(are)31 +b(F)-8 b(oundation.)p eop +%%Page: 9 11 +9 10 bop 150 -116 a Fj(GNU)31 b(GENERAL)f(PUBLIC)h(LICENSE)2052 +b(9)154 299 y(10.)61 b(If)29 b(y)m(ou)g(wish)f(to)i(incorp)s(orate)f +(parts)g(of)g(the)g(Program)h(in)m(to)f(other)h(free)f(programs)g +(whose)g(distri-)330 408 y(bution)e(conditions)g(are)j(di\013eren)m(t,) +e(write)g(to)i(the)f(author)f(to)i(ask)e(for)h(p)s(ermission.)37 +b(F)-8 b(or)29 b(soft)m(w)m(are)330 518 y(whic)m(h)23 +b(is)g(cop)m(yrigh)m(ted)h(b)m(y)g(the)g(F)-8 b(ree)25 +b(Soft)m(w)m(are)g(F)-8 b(oundation,)25 b(write)e(to)i(the)f(F)-8 +b(ree)25 b(Soft)m(w)m(are)g(F)-8 b(oun-)330 628 y(dation;)28 +b(w)m(e)g(sometimes)g(mak)m(e)g(exceptions)g(for)f(this.)39 +b(Our)26 b(decision)g(will)f(b)s(e)h(guided)h(b)m(y)g(the)h(t)m(w)m(o) +330 737 y(goals)23 b(of)g(preserving)e(the)h(free)h(status)g(of)f(all)g +(deriv)-5 b(ativ)m(es)22 b(of)g(our)g(free)h(soft)m(w)m(are)h(and)e(of) +h(promoting)330 847 y(the)31 b(sharing)e(and)g(reuse)h(of)h(soft)m(w)m +(are)h(generally)-8 b(.)p eop +%%Page: 10 12 +10 11 bop 150 -116 a Fj(10)2734 b(GNU)31 b(Shogi)f(man)m(ual)330 +299 y Fk(NO)45 b(W)-15 b(ARRANTY)154 491 y Fj(11.)61 +b(BECA)m(USE)40 b(THE)f(PR)m(OGRAM)i(IS)e(LICENSED)g(FREE)g(OF)h(CHAR)m +(GE,)h(THERE)e(IS)g(NO)330 601 y(W)-10 b(ARRANTY)26 b(F)m(OR)f(THE)g +(PR)m(OGRAM,)h(TO)e(THE)h(EXTENT)f(PERMITTED)h(BY)g(APPLI-)330 +711 y(CABLE)i(LA)-10 b(W.)27 b(EX)m(CEPT)g(WHEN)h(OTHER)-10 +b(WISE)25 b(ST)-8 b(A)g(TED)28 b(IN)e(WRITING)i(THE)e(COPY-)330 +820 y(RIGHT)35 b(HOLDERS)g(AND/OR)h(OTHER)f(P)-8 b(AR)g(TIES)35 +b(PR)m(O)m(VIDE)h(THE)f(PR)m(OGRAM)h(\\AS)330 930 y(IS")22 +b(WITHOUT)f(W)-10 b(ARRANTY)23 b(OF)f(ANY)g(KIND,)h(EITHER)e(EXPRESSED) +g(OR)h(IMPLIED,)330 1039 y(INCLUDING,)33 b(BUT)g(NOT)g(LIMITED)f(TO,)g +(THE)h(IMPLIED)g(W)-10 b(ARRANTIES)32 b(OF)h(MER-)330 +1149 y(CHANT)-8 b(ABILITY)28 b(AND)g(FITNESS)e(F)m(OR)i(A)g(P)-8 +b(AR)g(TICULAR)27 b(PURPOSE.)g(THE)g(ENTIRE)330 1259 +y(RISK)19 b(AS)h(TO)g(THE)g(QUALITY)g(AND)h(PERF)m(ORMANCE)g(OF)f(THE)g +(PR)m(OGRAM)h(IS)f(WITH)330 1368 y(YOU.)h(SHOULD)g(THE)f(PR)m(OGRAM)i +(PR)m(O)m(VE)f(DEFECTIVE,)g(YOU)g(ASSUME)f(THE)g(COST)330 +1478 y(OF)30 b(ALL)g(NECESSAR)-8 b(Y)30 b(SER)-10 b(VICING,)30 +b(REP)-8 b(AIR)30 b(OR)g(CORRECTION.)154 1612 y(12.)61 +b(IN)26 b(NO)g(EVENT)g(UNLESS)f(REQUIRED)h(BY)h(APPLICABLE)f(LA)-10 +b(W)26 b(OR)g(A)m(GREED)h(TO)f(IN)330 1722 y(WRITING)37 +b(WILL)f(ANY)i(COPYRIGHT)e(HOLDER,)h(OR)f(ANY)h(OTHER)f(P)-8 +b(AR)g(TY)38 b(WHO)330 1831 y(MA)-8 b(Y)52 b(MODIFY)g(AND/OR)g +(REDISTRIBUTE)e(THE)h(PR)m(OGRAM)h(AS)f(PERMITTED)330 +1941 y(ABO)m(VE,)40 b(BE)f(LIABLE)f(TO)g(YOU)h(F)m(OR)g(D)m(AMA)m(GES,) +h(INCLUDING)f(ANY)h(GENERAL,)330 2051 y(SPECIAL,)e(INCIDENT)-8 +b(AL)40 b(OR)e(CONSEQUENTIAL)g(D)m(AMA)m(GES)j(ARISING)e(OUT)g(OF)330 +2160 y(THE)44 b(USE)g(OR)g(INABILITY)h(TO)f(USE)g(THE)g(PR)m(OGRAM)h +(\(INCLUDING)h(BUT)e(NOT)330 2270 y(LIMITED)29 b(TO)g(LOSS)f(OF)h(D)m +(A)-8 b(T)g(A)31 b(OR)e(D)m(A)-8 b(T)g(A)31 b(BEING)f(RENDERED)g(INA)m +(CCURA)-8 b(TE)29 b(OR)330 2379 y(LOSSES)38 b(SUST)-8 +b(AINED)40 b(BY)h(YOU)f(OR)g(THIRD)g(P)-8 b(AR)g(TIES)40 +b(OR)g(A)h(F)-10 b(AILURE)40 b(OF)g(THE)330 2489 y(PR)m(OGRAM)f(TO)f +(OPERA)-8 b(TE)38 b(WITH)h(ANY)g(OTHER)f(PR)m(OGRAMS\),)h(EVEN)g(IF)f +(SUCH)330 2599 y(HOLDER)33 b(OR)h(OTHER)f(P)-8 b(AR)g(TY)34 +b(HAS)f(BEEN)h(AD)m(VISED)g(OF)g(THE)f(POSSIBILITY)f(OF)330 +2708 y(SUCH)e(D)m(AMA)m(GES.)150 2966 y Fk(END)45 b(OF)g(TERMS)f(AND)h +(CONDITIONS)p eop +%%Page: 11 13 +11 12 bop 150 -116 a Fj(GNU)31 b(GENERAL)f(PUBLIC)h(LICENSE)2006 +b(11)150 299 y Fk(Ho)l(w)46 b(to)f(Apply)f(These)h(T)-11 +b(erms)45 b(to)g(Y)-11 b(our)44 b(New)i(Programs)275 +498 y Fj(If)38 b(y)m(ou)i(dev)m(elop)f(a)g(new)g(program,)j(and)c(y)m +(ou)i(w)m(an)m(t)g(it)e(to)i(b)s(e)f(of)g(the)h(greatest)h(p)s(ossible) +36 b(use)j(to)150 607 y(the)i(public,)g(the)h(b)s(est)e(w)m(a)m(y)i(to) +g(ac)m(hiev)m(e)g(this)e(is)g(to)i(mak)m(e)g(it)f(free)g(soft)m(w)m +(are)h(whic)m(h)e(ev)m(ery)m(one)j(can)150 717 y(redistribute)28 +b(and)i(c)m(hange)h(under)e(these)i(terms.)275 858 y(T)-8 +b(o)29 b(do)h(so,)g(attac)m(h)h(the)f(follo)m(wing)e(notices)h(to)i +(the)e(program.)40 b(It)30 b(is)f(safest)h(to)g(attac)m(h)h(them)f(to)g +(the)150 967 y(start)j(of)g(eac)m(h)h(source)e(\014le)g(to)h(most)g +(e\013ectiv)m(ely)h(con)m(v)m(ey)g(the)e(exclusion)g(of)g(w)m(arran)m +(t)m(y;)j(and)d(eac)m(h)i(\014le)150 1077 y(should)28 +b(ha)m(v)m(e)k(at)f(least)g(the)f(\\cop)m(yrigh)m(t")i(line)d(and)g(a)i +(p)s(oin)m(ter)f(to)h(where)f(the)g(full)e(notice)j(is)e(found.)390 +1212 y Ff(one)i(line)d(to)j(giv)m(e)g(the)g(program's)f(name)h(and)e(a) +i(brief)e(idea)h(of)g(what)h(it)f(do)s(es.)390 1316 y +Fg(Copyright)45 b(\(C\))i(19)p Ff(yy)103 b(name)30 b(of)h(author)390 +1523 y Fg(This)47 b(program)e(is)j(free)e(software;)g(you)g(can)h +(redistribute)e(it)i(and/or)f(modify)390 1627 y(it)h(under)g(the)f +(terms)h(of)g(the)g(GNU)g(General)f(Public)g(License)g(as)h(published)e +(by)390 1731 y(the)i(Free)g(Software)e(Foundation;)g(either)h(version)g +(2)h(of)g(the)g(License,)f(or)390 1835 y(\(at)h(your)g(option\))e(any)i +(later)g(version.)390 2042 y(This)g(program)e(is)j(distributed)c(in)k +(the)e(hope)h(that)g(it)g(will)g(be)g(useful,)390 2146 +y(but)g(WITHOUT)f(ANY)h(WARRANTY;)e(without)h(even)g(the)h(implied)f +(warranty)g(of)390 2250 y(MERCHANTABILITY)e(or)j(FITNESS)f(FOR)h(A)g +(PARTICULAR)e(PURPOSE.)93 b(See)47 b(the)390 2354 y(GNU)g(General)f +(Public)g(License)g(for)h(more)f(details.)390 2561 y(You)h(should)f +(have)h(received)e(a)j(copy)e(of)h(the)g(GNU)g(General)f(Public)g +(License)390 2665 y(along)g(with)h(this)g(program;)e(if)i(not,)g(write) +f(to)i(the)e(Free)h(Software)390 2769 y(Foundation,)e(Inc.,)h(675)h +(Mass)g(Ave,)f(Cambridge,)f(MA)i(02139,)g(USA.)275 2909 +y Fj(Also)30 b(add)f(information)g(on)h(ho)m(w)h(to)g(con)m(tact)i(y)m +(ou)d(b)m(y)g(electronic)h(and)f(pap)s(er)f(mail.)275 +3050 y(If)f(the)g(program)h(is)e(in)m(teractiv)m(e,)j(mak)m(e)g(it)e +(output)g(a)h(short)f(notice)h(lik)m(e)f(this)f(when)h(it)g(starts)h +(in)e(an)150 3160 y(in)m(teractiv)m(e)k(mo)s(de:)390 +3295 y Fg(Gnomovision)45 b(version)h(69,)g(Copyright)g(\(C\))h(19)p +Ff(yy)55 b(name)30 b(of)g(author)390 3399 y Fg(Gnomovision)45 +b(comes)h(with)h(ABSOLUTELY)e(NO)i(WARRANTY;)e(for)i(details)390 +3502 y(type)g(`show)f(w'.)390 3606 y(This)h(is)g(free)f(software,)g +(and)h(you)g(are)f(welcome)g(to)h(redistribute)e(it)390 +3710 y(under)h(certain)g(conditions;)f(type)i(`show)f(c')h(for)g +(details.)275 3851 y Fj(The)27 b(h)m(yp)s(othetical)g(commands)h(`)p +Fg(show)h(w)p Fj(')f(and)f(`)p Fg(show)j(c)p Fj(')d(should)f(sho)m(w)i +(the)g(appropriate)f(parts)h(of)150 3960 y(the)38 b(General)g(Public)d +(License.)63 b(Of)37 b(course,)j(the)f(commands)e(y)m(ou)h(use)g(ma)m +(y)g(b)s(e)f(called)g(something)150 4070 y(other)25 b(than)f(`)p +Fg(show)29 b(w)p Fj(')c(and)f(`)p Fg(show)29 b(c)p Fj(';)e(they)d +(could)g(ev)m(en)h(b)s(e)f(mouse-clic)m(ks)g(or)h(men)m(u)f +(items|whatev)m(er)150 4179 y(suits)29 b(y)m(our)h(program.)275 +4320 y(Y)-8 b(ou)28 b(should)e(also)i(get)h(y)m(our)f(emplo)m(y)m(er)g +(\(if)f(y)m(ou)h(w)m(ork)g(as)h(a)f(programmer\))g(or)g(y)m(our)f(sc)m +(ho)s(ol,)i(if)e(an)m(y)-8 b(,)150 4430 y(to)34 b(sign)f(a)g(\\cop)m +(yrigh)m(t)i(disclaimer")c(for)j(the)f(program,)h(if)f(necessary)-8 +b(.)51 b(Here)34 b(is)e(a)i(sample;)g(alter)g(the)150 +4539 y(names:)390 4674 y Fg(Yoyodyne,)45 b(Inc.,)i(hereby)f(disclaims)f +(all)i(copyright)e(interest)h(in)h(the)g(program)390 +4778 y(`Gnomovision')d(\(which)i(makes)h(passes)f(at)h(compilers\))e +(written)h(by)h(James)f(Hacker.)390 4986 y Ff(signature)30 +b(of)g(T)m(y)h(Co)s(on)p Fg(,)47 b(1)g(April)g(1989)390 +5090 y(Ty)g(Coon,)g(President)e(of)i(Vice)275 5230 y +Fj(This)19 b(General)h(Public)f(License)h(do)s(es)h(not)g(p)s(ermit)e +(incorp)s(orating)g(y)m(our)i(program)f(in)m(to)h(proprietary)150 +5340 y(programs.)38 b(If)22 b(y)m(our)h(program)f(is)g(a)h(subroutine)e +(library)-8 b(,)23 b(y)m(ou)g(ma)m(y)g(consider)f(it)g(more)h(useful)e +(to)j(p)s(ermit)p eop +%%Page: 12 14 +12 13 bop 150 -116 a Fj(12)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(linking)j(proprietary)i(applications)g(with)g(the)h(library)-8 +b(.)57 b(If)35 b(this)h(is)f(what)h(y)m(ou)h(w)m(an)m(t)g(to)g(do,)h +(use)e(the)150 408 y(GNU)31 b(Library)e(General)h(Public)e(License)i +(instead)f(of)i(this)e(License.)p eop +%%Page: 13 15 +13 14 bop 150 -116 a Fj(Chapter)30 b(2:)41 b(Ab)s(out)30 +b(the)g(game)i(of)e(shogi)2061 b(13)150 299 y Fh(2)80 +b(Ab)t(out)53 b(the)g(game)g(of)h(shogi)390 518 y Fj(\\Japanese)34 +b(c)m(hess)h(cedes)f(nothing)e(in)h(depth)g(or)g(b)s(eaut)m(y)h(to)h +(the)f(Europ)s(ean)e(game...)52 b(it)390 622 y(is)29 +b(at)j(least)e(as)h(in)m(teresting.")390 749 y(|)f(Alexander)g +(Alekhine)390 853 y(\(quoted)h(in)e(Da)m(vid)h(Pritc)m(hard,)g +Ff(The)g(Encyclop)s(edia)f(of)h(Chess)g(V)-8 b(arian)m(ts)t +Fj(\))390 1084 y(\\...)69 b(shogi)39 b([is])g(b)m(y)h(far)f(the)h(most) +f(complex)h(form)f(of)g(c)m(hess)h(that)h(has)e(ev)m(er)h(ac)m(hiev)m +(ed)390 1187 y(widespread)28 b(p)s(opularit)m(y)-8 b(.")390 +1314 y(|)30 b(R.)h(W)-8 b(a)m(yne)32 b(Sc)m(hmittb)s(erger,)d +Ff(New)i(Rules)e(for)h(Classic)f(Games)275 1557 y Fj(Shogi)22 +b(is)f(the)j(v)m(ersion)e(of)h(c)m(hess)g(pla)m(y)m(ed)g(in)f(Japan.)37 +b(It)23 b(is)f(strikingly)f(di\013eren)m(t)h(from)g(standard)g(c)m +(hess)150 1666 y(\(whic)m(h)37 b(I)h(shall)e(refer)i(to)g(henceforth)g +(as)g(\\in)m(ternational)f(c)m(hess"\))j(and)d(also)h(to)h(all)d(other) +j(regional)150 1776 y(v)-5 b(arian)m(ts,)37 b(b)s(ecause)f(captured)f +(pieces)h(can)g(re-en)m(ter)h(pla)m(y)e(on)h(the)g(side)f(of)h(the)f +(capturer.)57 b(This)34 b(has)150 1886 y(sev)m(eral)d(in)m(teresting)e +(e\013ects)j(on)e(the)h(pla)m(y)f(of)h(the)f(game:)199 +2105 y(1.)61 b(Shogi)30 b(is)g(m)m(uc)m(h)h(more)h(complex)e(than)h(in) +m(ternational)f(c)m(hess,)i(at)g(least)f(in)f(terms)h(of)g(the)g(a)m(v) +m(erage)330 2214 y(n)m(um)m(b)s(er)i(of)i(p)s(ossible)c(mo)m(v)m(es)36 +b(p)s(er)e(turn)f(\(estimated)i(at)g(ab)s(out)f(35)h(for)f(c)m(hess)h +(and)f(at)h(ab)s(out)f(80)330 2324 y(for)c(shogi\).)199 +2457 y(2.)61 b(There)30 b(are)h(almost)f(no)g(dra)m(ws)g(\(ab)s(out)h +(1-2\045)g(of)f(all)g(games)h(in)e(professional)g(pla)m(y\).)199 +2589 y(3.)61 b(Exc)m(hanges)31 b(complicate)g(the)f(pla)m(y)g(rather)h +(than)f(simplifying)c(it.)199 2722 y(4.)61 b(There)23 +b(are)g(no)h(\\endgames")g(in)e(the)h(standard)g(c)m(hess)g(sense;)j +(all)c(pieces)h(remain)g(in)e(pla)m(y)i(through-)330 +2832 y(out)h(the)g(game.)40 b(Games)25 b(t)m(ypically)d(end)i(in)e(a)j +(race)f(to)h(c)m(hec)m(kmate)h(the)f(other)f(pla)m(y)m(er)g(b)s(efore)f +(b)s(eing)330 2941 y(c)m(hec)m(kmated)32 b(oneself.)199 +3074 y(5.)61 b(Ownership)38 b(of)j(a)h(piece)f(is)f(not)i(indicated)d +(b)m(y)i(the)h(color)f(of)g(the)h(piece;)k(instead,)e(pieces)d(are)330 +3184 y(w)m(edge-shap)s(ed)32 b(and)g(p)s(oin)m(t)f(to)m(w)m(ards)i(the) +g(opp)s(onen)m(t.)46 b(The)31 b(name)i(of)f(the)h(piece)f(is)f(inscrib) +s(ed)e(in)330 3293 y(Kanji)g(c)m(haracters)j(on)e(the)h(fron)m(t)f(of)h +(the)f(piece.)199 3426 y(6.)61 b(Most)31 b(imp)s(ortan)m(tly:)39 +b(it's)30 b(more)h(fun)e(than)h(other)h(forms)f(of)g(c)m(hess)h(:-\)) +275 3691 y(Shogi)26 b(is)g(extremely)h(p)s(opular)e(in)h(Japan;)i(it)e +(has)h(b)s(een)g(estimated)g(that)h(20)g(million)23 b(Japanese)28 +b(can)150 3801 y(pla)m(y)d(shogi,)i(of)f(whic)m(h)e(p)s(erhaps)g(1)i +(million)d(are)j(activ)m(e)h(pla)m(y)m(ers.)39 b(It)26 +b(is)e(ev)m(en)j(more)f(p)s(opular)d(there)j(than)150 +3911 y(the)39 b(game)h(of)f(go,)j(Japan's)d(other)g(fa)m(v)m(orite)h(b) +s(oard)e(game.)67 b(There)38 b(are)i(a)f(n)m(um)m(b)s(er)f(of)h +(professional)150 4020 y(pla)m(y)m(ers)33 b(who)f(mak)m(e)i(a)g +(considerable)d(amoun)m(t)j(of)f(money)g(pla)m(ying)e(in)h(shogi)g +(tournamen)m(ts,)i(and)f(the)150 4130 y(game)h(receiv)m(es)g(extensiv)m +(e)f(newpap)s(er)f(and)g(television)g(co)m(v)m(erage.)51 +b(Despite)33 b(this,)g(the)g(game)h(has)f(y)m(et)150 +4239 y(to)k(b)s(ecome)g(p)s(opular)c(outside)j(of)g(Japan.)58 +b(P)m(art)37 b(of)f(this)f(is)h(b)s(ecause)g(the)g(Kanji)f(c)m +(haracters)j(on)e(the)150 4349 y(pieces)27 b(scare)h(a)m(w)m(a)m(y)h +(some)e(p)s(eople,)g(but)g(mostly)g(it's)f(due,)i(I)f(think,)f(to)i +(lac)m(k)g(of)f(exp)s(osure)g(to)h(the)f(game)150 4459 +y(and)h(to)h(the)g(di\016cult)m(y)e(of)i(\014nding)d(opp)s(onen)m(ts.) +39 b(I)29 b(hop)s(e)f(that)h(GNU)g(shogi)f(will)e(help)h(in)m(tro)s +(duce)g(shogi)150 4568 y(to)k(a)g(wider)e(audience.)150 +4820 y Fk(2.1)68 b(The)45 b(rules)g(of)g(shogi)275 5011 +y Fj(Shogi)28 b(is)g(a)h(t)m(w)m(o-p)s(erson)h(abstract)g(strategy)g(b) +s(oard)f(game)h(with)d(full)g(information)h(\(i.e.)40 +b(all)28 b(pieces)150 5121 y(and)c(mo)m(v)m(es)j(are)e(visible)e(to)i +(b)s(oth)g(pla)m(y)m(ers)g(at)g(all)f(times\).)39 b(It)25 +b(is)f(in)g(the)h(c)m(hess)h(family)-8 b(,)25 b(b)s(eing)f(descended) +150 5230 y(from)29 b(the)g(same)h(ancestral)g(game)g(as)g(in)m +(ternational)e(c)m(hess:)40 b(the)30 b(Indian)d(game)k(of)e +(Chaturanga.)40 b(The)150 5340 y(t)m(w)m(o)j(pla)m(y)m(ers)e(are)h +(referred)f(to)h(as)f(\\Blac)m(k")j(and)d(\\White",)k(with)40 +b(Blac)m(k)i(mo)m(ving)f(\014rst)g(\(unlik)m(e)f(in)p +eop +%%Page: 14 16 +14 15 bop 150 -116 a Fj(14)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(in)m(ternational)e(c)m(hess,)i(where)f(White)g(mo)m(v)m(es)i +(\014rst\),)e(and)g(with)f(mo)m(v)m(emen)m(t)j(alternating)e(b)s(et)m +(w)m(een)h(the)150 408 y(t)m(w)m(o)38 b(pla)m(y)m(ers.)61 +b(Note)38 b(that)f(\\Blac)m(k")i(and)e(\\White")g(are)h(just)e(names;)k +(the)d(pieces)g(are)g(not)h(colored.)150 518 y(Instead,)27 +b(they)f(are)g(\015at,)i(w)m(edge-shap)s(ed)d(pieces)h(whic)m(h)f(p)s +(oin)m(t)f(to)m(w)m(ards)j(the)f(opp)s(onen)m(t.)39 b(The)25 +b(iden)m(tit)m(y)150 628 y(of)32 b(a)g(giv)m(en)g(piece)f(is)g +(indicated)f(b)m(y)i(t)m(w)m(o)h(Japanese)e(Kanji)g(c)m(haracters)i(on) +e(eac)m(h)i(piece.)45 b(In)31 b(fact,)i(only)150 737 +y(the)d(top)h(c)m(haracter)h(is)d(needed)h(to)h(iden)m(tify)e(the)h +(piece)h(and)e(th)m(us)h(only)g(the)g(top)h(c)m(haracter)g(is)f(used)f +(in)150 847 y(shogi)35 b(diagrams.)55 b(I)35 b(will)e(use)i(alphab)s +(etical)f(equiv)-5 b(alen)m(ts)35 b(in)f(the)h(diagrams)g(here;)j(to)e +(see)g(what)g(the)150 956 y(Kanji)d(c)m(haracters)i(lo)s(ok)e(lik)m(e,) +i(start)f(up)f(xshogi)g(\(see)i(Chapter)e(4)i([xshogi],)f(page)h(33\))g +(and)e(compare)150 1066 y(the)e(starting)g(setup)g(there)h(with)e(the)h +(starting)g(setup)g(in)f(this)g(\014le)g(\(see)i(Section)f(2.1.2)i +([The)e(op)s(ening)150 1176 y(setup],)f(page)i(15\).)275 +1304 y(The)h(ob)5 b(ject)35 b(of)f(the)g(game)h(is)e(to)h(capture)g +(the)g(opp)s(onen)m(t's)g(King.)50 b(The)33 b(b)s(oard)g(is)g(a)h(grid) +f(of)h(9x9)150 1414 y(uncolored)26 b(squares,)i(and)f(pieces)g(are)h +(placed)e(on)i(the)f(squares.)40 b(Eac)m(h)28 b(pla)m(y)m(er)f(b)s +(egins)f(with)g(20)i(pieces,)150 1524 y(describ)s(ed)g(in)h(the)i(next) +f(section.)41 b(Capture)30 b(is)g(b)m(y)g(displacemen)m(t,)f(as)i(in)e +(in)m(ternational)g(c)m(hess.)150 1731 y Fe(2.1.1)63 +b(The)41 b(mo)m(v)m(es)f(of)h(the)g(pieces)275 1918 y +Fj(Eac)m(h)33 b(pla)m(y)m(er)g(at)h(the)f(b)s(eginning)e(of)i(a)g +(shogi)g(game)h(has)f(a)g(total)h(of)f(20)h(pieces)f(of)g(eigh)m(t)g +(di\013eren)m(t)150 2027 y(t)m(yp)s(es.)49 b(The)32 b(mo)m(v)m(es)i(of) +g(the)f(shogi)f(pieces)h(can)g(b)s(e)g(divided)d(in)m(to)j(three)g +(classes:)46 b(\\stepping")33 b(pieces,)150 2137 y(that)21 +b(only)f(mo)m(v)m(e)i(one)e(square)h(at)g(a)g(time;)j(\\ranging")c +(pieces)g(that)h(mo)m(v)m(e)h(an)m(y)f(n)m(um)m(b)s(er)e(of)i +(unobstructed)150 2246 y(squares)26 b(in)f(a)h(line,)g(and)f +(\\jumping")g(pieces)h(that)g(can)h(jump)d(o)m(v)m(er)k(obstructing)d +(pieces)h(to)h(reac)m(h)g(their)150 2356 y(destination)39 +b(squares.)71 b(Most)42 b(pieces)e(can)h(also)f(promote)h(to)g +(di\013eren)m(t)f(\(usually)f(stronger\))i(pieces)150 +2466 y(under)33 b(certain)i(circumstances)f(\(see)h(the)g(next)g +(section\).)54 b(All)33 b(pieces)h(capture)h(the)g(same)g(w)m(a)m(y)g +(that)150 2575 y(they)c(mo)m(v)m(e)h(\(ev)m(en)f(pa)m(wns\).)42 +b(The)30 b(piece)g(mo)m(v)m(es)i(and)e(promotions)g(are)h(as)g(follo)m +(ws;)f(eac)m(h)h(piece)g(name)150 2685 y(is)e(follo)m(w)m(ed)h(b)m(y)h +(the)f(standard)g(piece)g(abbreviation:)199 2814 y(1.)61 +b(The)35 b(king)f(\(K\).)i(The)f(king)g(can)g(mo)m(v)m(e)i(one)f +(square)f(in)f(an)m(y)i(horizon)m(tal,)g(v)m(ertical,)h(or)f(diagonal) +330 2923 y(direction,)29 b(just)h(lik)m(e)g(the)g(king)g(in)f(in)m +(ternational)g(c)m(hess.)41 b(The)30 b(king)g(do)s(es)g(not)g(promote.) +199 3052 y(2.)61 b(The)36 b(ro)s(ok)h(\(R\).)g(The)g(ro)s(ok)f(can)h +(mo)m(v)m(e)i(an)m(y)e(n)m(um)m(b)s(er)e(of)i(squares)f(in)g(a)h +(horizon)m(tal)f(or)h(v)m(ertical)330 3162 y(direction.)78 +b(The)43 b(ro)s(ok)g(is)g(the)g(same)h(as)f(the)h(ro)s(ok)f(in)f(in)m +(ternational)g(c)m(hess)i(\(except)g(that)g(it)330 3271 +y(can)34 b(promote\).)51 b(A)33 b(ro)s(ok)h(promotes)g(to)g(a)g +(\\dragon)g(king")f(or)g(\\dragon")i(for)e(short)g(\(often)i(just)330 +3381 y(referred)c(to)i(as)f(a)g(\\promoted)h(ro)s(ok"\),)g(whic)m(h)e +(can)h(mo)m(v)m(e)h(as)f(a)h(ro)s(ok)e(or)h(can)h(mo)m(v)m(e)g(one)f +(square)330 3490 y(in)d(an)m(y)i(diagonal)e(direction.)199 +3619 y(3.)61 b(The)32 b(bishop)e(\(B\).)k(The)e(bishop)f(can)i(mo)m(v)m +(e)g(an)m(y)g(n)m(um)m(b)s(er)e(of)i(squares)f(in)f(a)i(diagonal)f +(direction.)330 3729 y(The)21 b(bishop)f(is)h(the)h(same)h(as)f(the)g +(bishop)e(in)g(in)m(ternational)h(c)m(hess)h(\(except)i(that)e(it)g +(can)g(promote\).)330 3838 y(A)33 b(bishop)d(promotes)j(to)g(a)g +(\\dragon)g(horse")g(or)g(\\horse")g(for)f(short)g(\(often)i(just)e +(referred)f(to)j(as)330 3948 y(a)40 b(\\promoted)h(bishop"\),)g(whic)m +(h)d(can)j(mo)m(v)m(e)g(as)f(a)g(bishop)e(or)i(can)g(mo)m(v)m(e)h(one)f +(square)g(in)f(an)m(y)330 4058 y(horizon)m(tal)31 b(or)g(v)m(ertical)g +(direction.)42 b(Note:)i(the)31 b(horse)g(should)e(not)j(b)s(e)e +(confused)h(with)f(a)h(knigh)m(t)330 4167 y(\(see)g(b)s(elo)m(w\),)g +(as)f(they)h(are)f(t)m(w)m(o)i(completely)e(di\013eren)m(t)g(pieces.) +199 4296 y(4.)61 b(The)27 b(gold)g(general)g(\(G\).)h(A)g(gold)e +(general)i(can)f(mo)m(v)m(e)i(one)e(square)g(in)f(an)m(y)i(horizon)m +(tal)f(or)g(v)m(ertical)330 4406 y(direction,)f(or)f(one)h(square)g(in) +e(a)j(forw)m(ard)e(diagonal)g(direction.)38 b(Gold)25 +b(generals)h(do)f(not)h(promote.)199 4534 y(5.)61 b(The)29 +b(silv)m(er)f(general)h(\(S\).)h(A)f(silv)m(er)f(general)i(can)f(mo)m +(v)m(e)i(one)f(square)f(in)f(an)m(y)h(diagonal)g(direction,)330 +4644 y(or)h(one)h(square)f(straigh)m(t)h(forw)m(ard.)40 +b(A)30 b(silv)m(er)g(general)g(promotes)h(to)g(a)g(gold)e(general.)199 +4773 y(6.)61 b(The)26 b(knigh)m(t)h(\(N\).)g(A)g(knigh)m(t)g(can)g(mo)m +(v)m(e)h(one)f(square)g(straigh)m(t)g(forw)m(ard)f(follo)m(w)m(ed)g(b)m +(y)h(one)g(square)330 4882 y(to)42 b(either)e(forw)m(ard)h(diagonal,)i +(jumping)c(o)m(v)m(er)j(in)m(terv)m(ening)e(pieces)h(if)f(an)m(y)-8 +b(.)74 b(In)40 b(other)h(w)m(ords,)330 4992 y(a)f(knigh)m(t)f(mo)m(v)m +(es)i(lik)m(e)e(its)g(in)m(ternational)f(c)m(hess)i(coun)m(terpart,)j +(but)c(forw)m(ard)g(only)-8 b(.)68 b(A)39 b(knigh)m(t)330 +5102 y(promotes)31 b(to)g(a)g(gold)f(general.)40 b(The)30 +b(knigh)m(t)g(is)f(the)i(only)e(jumping)g(piece,)h(as)h(in)e(c)m(hess.) +199 5230 y(7.)61 b(The)39 b(lance)h(\(L\).)h(A)e(lance)h(can)g(mo)m(v)m +(e)i(an)m(y)e(n)m(um)m(b)s(er)e(of)i(squares)g(straigh)m(t)g(forw)m +(ard.)68 b(A)40 b(lance)330 5340 y(promotes)31 b(to)g(a)g(gold)f +(general.)p eop +%%Page: 15 17 +15 16 bop 150 -116 a Fj(Chapter)30 b(2:)41 b(Ab)s(out)30 +b(the)g(game)i(of)e(shogi)2061 b(15)199 299 y(8.)61 b(The)29 +b(pa)m(wn)g(\(P\).)h(A)g(pa)m(wn)f(can)h(mo)m(v)m(e)h(one)f(square)f +(straigh)m(t)h(forw)m(ard.)40 b(The)29 b(pa)m(wn)g(captures)h(the)330 +408 y(same)40 b(w)m(a)m(y)h(that)g(it)e(mo)m(v)m(es,)44 +b(in)39 b(con)m(trast)i(to)g(in)m(ternational)e(c)m(hess.)69 +b(There)40 b(is)f(also)h(no)g(initial)330 518 y(t)m(w)m(o-space)i(mo)m +(v)m(e)g(for)e(pa)m(wns)g(and)f(no)h Fd(en-p)-5 b(assant)51 +b Fj(capture.)70 b(A)41 b(pa)m(wn)e(promotes)i(to)g(a)f(gold)330 +628 y(general;)31 b(a)f(promoted)h(pa)m(wn)f(is)f(usually)f(kno)m(wn)i +(as)h(a)f(\\T)-8 b(okin".)150 867 y Fe(2.1.2)63 b(The)41 +b(op)s(ening)i(setup)275 1067 y Fj(The)29 b(op)s(ening)g(setup)h(for)g +(shogi)g(is)g(as)g(follo)m(ws:)293 1291 y Fg(9)191 b(8)f(7)h(6)g(5)f(4) +h(3)g(2)f(1)150 1400 y(+-----------------------)o(----)o(----)o(---)o +(----)o(----)o(--+)150 1510 y(|)47 b(wL)h(|)f(wN)g(|)h(wS)f(|)g(wG)h(|) +f(wK)g(|)h(wG)f(|)g(wS)g(|)h(wN)f(|)h(wL)f(|)95 b(a)150 +1620 y(+-----------------------)o(----)o(----)o(---)o(----)o(----)o +(--+)150 1729 y(|)191 b(|)47 b(wR)g(|)191 b(|)g(|)f(|)h(|)f(|)48 +b(wB)f(|)191 b(|)95 b(b)150 1839 y(+-----------------------)o(----)o +(----)o(---)o(----)o(----)o(--+)150 1948 y(|)47 b(wP)h(|)f(wP)g(|)h(wP) +f(|)g(wP)h(|)f(wP)g(|)h(wP)f(|)g(wP)g(|)h(wP)f(|)h(wP)f(|)95 +b(c)150 2058 y(+-----------------------)o(----)o(----)o(---)o(----)o +(----)o(--+)150 2168 y(|)191 b(|)f(|)h(|)g(|)f(|)h(|)f(|)h(|)g(|)95 +b(d)150 2277 y(+-----------------------)o(----)o(----)o(---)o(----)o +(----)o(--+)150 2387 y(|)191 b(|)f(|)h(|)g(|)f(|)h(|)f(|)h(|)g(|)95 +b(e)150 2496 y(+-----------------------)o(----)o(----)o(---)o(----)o +(----)o(--+)150 2606 y(|)191 b(|)f(|)h(|)g(|)f(|)h(|)f(|)h(|)g(|)95 +b(f)150 2716 y(+-----------------------)o(----)o(----)o(---)o(----)o +(----)o(--+)150 2825 y(|)47 b(bP)h(|)f(bP)g(|)h(bP)f(|)g(bP)h(|)f(bP)g +(|)h(bP)f(|)g(bP)g(|)h(bP)f(|)h(bP)f(|)95 b(g)150 2935 +y(+-----------------------)o(----)o(----)o(---)o(----)o(----)o(--+)150 +3044 y(|)191 b(|)47 b(bB)g(|)191 b(|)g(|)f(|)h(|)f(|)48 +b(bR)f(|)191 b(|)95 b(h)150 3154 y(+-----------------------)o(----)o +(----)o(---)o(----)o(----)o(--+)150 3263 y(|)47 b(bL)h(|)f(bN)g(|)h(bS) +f(|)g(bG)h(|)f(bK)g(|)h(bG)f(|)g(bS)g(|)h(bN)f(|)h(bL)f(|)95 +b(i)150 3373 y(+-----------------------)o(----)o(----)o(---)o(----)o +(----)o(--+)275 3739 y Fj(Here,)40 b(\\b")e(stands)f(for)h(\\blac)m(k") +h(and)e(\\w")h(stands)g(for)f(\\white",)j(so)e(that,)j(for)c(instance,) +j(\\bL")150 3849 y(means)30 b(\\blac)m(k)h(lance".)41 +b(The)30 b(n)m(um)m(b)s(ers)f(ab)s(o)m(v)m(e)j(the)e(\014les)g(and)g +(the)g(letters)h(to)g(the)f(righ)m(t)g(of)h(the)g(ranks)150 +3958 y(represen)m(t)39 b(the)g(most)g(common)h(notation)f(system)g +(used)f(for)h(shogi)f(b)m(y)h(w)m(esterners)g(\(the)h(Japanese)150 +4068 y(also)30 b(use)g(Arabic)g(n)m(umerals)f(for)h(the)h(\014les)e +(but)h(use)g(Japanese)h(n)m(umerals)e(for)h(the)g(ranks\).)150 +4307 y Fe(2.1.3)63 b(Promotion)41 b(of)g(pieces)275 4507 +y Fj(In)24 b(sharp)g(con)m(trast)i(to)g(in)m(ternational)d(c)m(hess,)k +(where)d(only)g(pa)m(wns)h(can)g(promote)g(to)h(higher-rank)m(ed)150 +4617 y(pieces,)34 b(most)f(of)g(the)g(pieces)g(in)f(shogi)g(can)h +(promote.)49 b(The)33 b(promoted)f(ranks)h(are)g(discussed)e(in)h(the) +150 4726 y(section)22 b(on)g(piece)g(mo)m(v)m(es)i(\(see)f(Section)f +(2.1.1)i([The)e(mo)m(v)m(es)h(of)f(the)h(pieces],)h(page)f(14\))g(but)e +(are)i(rep)s(eated)150 4836 y(here)30 b(for)g(reference:)150 +5006 y(P)m(a)m(wn)262 b(promotes)31 b(to)g(gold)f(general)g(\(called)g +(a)h(`tokin')f(in)f(this)h(case)h(only\).)150 5173 y(Lance)247 +b(promotes)31 b(to)g(gold)f(general.)150 5340 y(Knigh)m(t)204 +b(promotes)31 b(to)g(gold)f(general.)p eop +%%Page: 16 18 +16 17 bop 150 -116 a Fj(16)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(Silv)m(er)f(general)630 408 y(promotes)i(to)g(gold)f(general.)150 +569 y(Gold)g(general)630 678 y(do)s(es)g(not)h(promote.)150 +838 y(Bishop)207 b(promotes)28 b(to)h(\\dragon)g(horse")f(or)g(just)g +(\\horse")h(for)f(short.)39 b(The)28 b(horse)g(can)h(mo)m(v)m(e)g(as)g +(a)630 948 y(bishop)f(or)j(can)f(mo)m(v)m(e)i(one)f(square)f(in)f(an)m +(y)i(orthogonal)g(direction.)150 1108 y(Ro)s(ok)272 b(promotes)35 +b(to)h(\\dragon)g(king")e(or)i(just)e(\\dragon")i(for)f(short.)54 +b(The)35 b(dragon)g(can)g(mo)m(v)m(e)630 1218 y(as)c(a)f(ro)s(ok)h(or)f +(can)h(mo)m(v)m(e)h(one)e(square)g(in)f(an)m(y)i(diagonal)f(direction.) +150 1378 y(King)287 b(do)s(es)30 b(not)h(promote.)275 +1648 y(The)c(three)h(ranks)f(furthest)g(a)m(w)m(a)m(y)j(from)e(eac)m(h) +h(pla)m(y)m(er)f(constitute)g(his/her)e(\\promotion)i(zone".)41 +b(A)150 1758 y(pla)m(y)m(er)29 b(ma)m(y)-8 b(,)30 b(but)e(is)g(not)h +(required)e(to,)k(promote)e(a)g(piece)g(after)g(making)f(a)i(mo)m(v)m +(e)g(in)d(whic)m(h)h(the)h(piece)150 1867 y(b)s(egins)c(and/or)i(ends)f +(in)g(the)h(promotion)g(zone.)40 b(Th)m(us)26 b(y)m(ou)h(can)g(promote) +h(a)f(piece)g(when)f(mo)m(ving)h(the)150 1977 y(piece)i(in)m(to)f(the)h +(promotion)f(zone,)i(out)f(of)g(the)g(promotion)f(zone,)i(or)f(en)m +(tirely)f(within)e(the)j(promotion)150 2087 y(zone.)41 +b(Promotion)30 b(is)g(mandatory)g(in)f(these)i(cases:)199 +2306 y(1.)61 b(Y)-8 b(ou)31 b(m)m(ust)f(promote)h(a)g(pa)m(wn)f(or)g(a) +h(lance)f(after)h(mo)m(ving)f(it)g(to)h(the)g(last)f(rank.)199 +2441 y(2.)61 b(Y)-8 b(ou)31 b(m)m(ust)f(promote)h(a)g(knigh)m(t)f +(after)g(mo)m(ving)h(it)f(to)h(either)e(of)i(the)g(last)f(t)m(w)m(o)i +(ranks.)275 2711 y(These)27 b(forced)i(promotions)e(ensure)g(that)i(a)g +(piece)f(cannot)h(b)s(e)e(mo)m(v)m(ed)i(to)g(a)g(square)f(from)f(whic)m +(h)g(it)150 2820 y(w)m(ould)i(ha)m(v)m(e)j(no)e(further)f(mo)m(v)m(e.) +275 2956 y(Pieces)f(\\dropp)s(ed")f(on)m(to)i(the)f(b)s(oard)f(\(see)i +(Section)f(2.1.4)h([Drops],)h(page)e(16\))h(alw)m(a)m(ys)g(drop)e(in)g +(the)150 3065 y(unpromoted)i(state,)j(ev)m(en)f(if)f(they)g(drop)g(in)m +(to)g(the)h(promotion)e(zone.)150 3291 y Fe(2.1.4)63 +b(Drops)275 3485 y Fj(When)24 b(a)i(pla)m(y)m(er)f(captures)g(a)g +(piece,)h(that)g(piece)f(is)f(not)h(remo)m(v)m(ed)h(from)e(pla)m(y)-8 +b(.)39 b(Instead,)26 b(it)f(b)s(ecomes)150 3594 y(the)30 +b(prop)s(ert)m(y)g(of)g(the)h(capturer)f(and)f(can)i(re-en)m(ter)g(pla) +m(y)e(b)m(y)i(b)s(eing)d(placed)i(on)g(\(almost\))h(an)m(y)f(v)-5 +b(acan)m(t)150 3704 y(square)32 b(during)e(the)i(pla)m(y)m(er's)h(mo)m +(v)m(e.)47 b(This)31 b(is)g(kno)m(wn)h(as)g(a)h(\\drop")f(and)g(coun)m +(ts)g(as)h(a)f(full)e(mo)m(v)m(e)k(\(in)150 3813 y(other)25 +b(w)m(ords,)g(y)m(ou)g(can)f(either)g(mo)m(v)m(e)i(a)f(piece)f(on)g +(the)h(b)s(oard)e(or)h(drop)g(a)g(piece)h(on)m(to)g(the)g(b)s(oard)e +(during)150 3923 y(y)m(our)31 b(mo)m(v)m(e,)i(but)d(not)i(b)s(oth\).)42 +b(All)30 b(pieces)g(drop)h(in)e(the)j(unpromoted)e(state.)44 +b(Pieces)31 b(ma)m(y)h(b)s(e)e(legally)150 4032 y(dropp)s(ed)e(in)h +(their)h(promotion)f(zone,)j(but)d(they)i(do)f(not)h(promote)g(on)f +(that)h(turn.)275 4168 y(There)e(are)i(sev)m(eral)g(restrictions)e(on)h +(drops:)199 4303 y(1.)61 b(A)26 b(pa)m(wn)f(ma)m(y)h(not)f(b)s(e)g +(dropp)s(ed)e(on)m(to)k(a)f(\014le)e(if)h(there)g(is)g(already)g(an)g +(unpromoted)g(pa)m(wn)g(b)s(elong-)330 4413 y(ing)31 +b(to)h(the)f(same)h(pla)m(y)m(er)g(on)f(that)h(\014le.)43 +b(It)31 b(is)g(legal)g(to)h(drop)e(a)i(pa)m(wn)f(on)g(a)h(\014le)f +(whic)m(h)f(con)m(tains)330 4522 y(a)h Fd(pr)-5 b(omote)g(d)43 +b Fj(pa)m(wn)30 b(b)s(elonging)e(to)j(the)g(same)g(pla)m(y)m(er,)f(ho)m +(w)m(ev)m(er.)199 4657 y(2.)61 b(A)35 b(pa)m(wn)g(ma)m(y)h(not)f(b)s(e) +f(dropp)s(ed)g(to)h(giv)m(e)h(immediate)e(c)m(hec)m(kmate)k(on)d(the)g +(mo)m(v)m(e.)57 b(A)35 b(pa)m(wn)g(is,)330 4767 y(ho)m(w)m(ev)m(er,)d +(p)s(ermitted)c(to)j(b)s(e)f(mo)m(v)m(ed)h(on)f(the)g(b)s(oard)f(to)i +(giv)m(e)g(immediate)e(c)m(hec)m(kmate.)43 b(This)28 +b(is)i(a)330 4876 y(curious)f(rule,)h(and)h(if)e(an)m(y)m(one)j(kno)m +(ws)f(the)g(reason)g(for)g(it)f(I)h(w)m(ould)f(appreciate)h(it)f(if)g +(they)h(w)m(ould)330 4986 y(con)m(tact)i(me)d(and)g(explain)f(it)h(to)h +(me)f(:-\))199 5121 y(3.)61 b(A)36 b(pa)m(wn)f(or)h(piece)g(ma)m(y)g +(not)g(b)s(e)g(dropp)s(ed)d(on)m(to)38 b(a)e(square)f(from)h(whic)m(h)e +(they)i(w)m(ould)f(ha)m(v)m(e)i(no)330 5230 y(legal)27 +b(mo)m(v)m(e.)41 b(This)26 b(means)h(that)h(pa)m(wns)f(and)g(lances)g +(ma)m(y)h(not)g(b)s(e)e(dropp)s(ed)g(on)m(to)i(the)g(last)f(rank,)330 +5340 y(and)j(the)g(knigh)m(t)g(ma)m(y)h(not)g(b)s(e)e(dropp)s(ed)g(on)m +(to)i(the)g(last)f(or)g(second-to-last)i(rank.)p eop +%%Page: 17 19 +17 18 bop 150 -116 a Fj(Chapter)30 b(2:)41 b(Ab)s(out)30 +b(the)g(game)i(of)e(shogi)2061 b(17)275 299 y(It)36 b(is)f(en)m(tirely) +h(p)s(ermissible)c(\(and)k(often)h(advisable\))e(to)i(drop)f(a)g(piece) +g(or)h(pa)m(wn)f(b)s(et)m(w)m(een)h(one's)150 408 y(King)28 +b(and)g(an)h(attac)m(king)i(ranging)d(piece.)40 b(F)-8 +b(or)30 b(this)e(reason,)i(the)f(\014nal)f(c)m(hec)m(kmating)i(mo)m(v)m +(e)h(is)d(nearly)150 518 y(alw)m(a)m(ys)j(an)f(attac)m(k)j(on)d(the)h +(King)e(from)h(an)g(adjacen)m(t)i(square)e(\(except)i(for)e(an)g(attac) +m(k)j(b)m(y)d(a)h(Knigh)m(t\).)275 650 y(Captured)e(pieces)h(are)h +(said)e(to)i(b)s(e)f(pieces)g(\\in)g(hand".)275 781 y(The)h(drop)g(is)g +(the)h(primary)e(distinguishing)d(feature)32 b(of)g(Japanese)g(c)m +(hess,)h(shared)e(with)g(no)h(other)150 891 y(p)s(opular)21 +b(c)m(hess-t)m(yp)s(e)k(game.)39 b(It)24 b(giv)m(es)f(shogi)g(a)h(v)m +(ery)g(aggressiv)m(e)h(qualit)m(y)-8 b(,)24 b(and)f(dramatically)f +(increases)150 1000 y(the)h(n)m(um)m(b)s(er)f(of)h(p)s(ossible)d(mo)m +(v)m(es)k(once)g(a)f(few)f(pieces)h(ha)m(v)m(e)h(b)s(een)e(captured.)38 +b(Another)23 b(in)m(teresting)f(fea-)150 1110 y(ture)h(of)h(shogi)f(is) +g(that)h(exc)m(hanges)h(complicate)e(pla)m(y)h(rather)f(than)g +(simplifying)d(it)j(\(as)h(in)e(in)m(ternational)150 +1220 y(c)m(hess\),)31 b(b)s(ecause)g(of)f(the)h(drop)e(rule.)150 +1435 y Fe(2.1.5)63 b(Winning)41 b(the)g(game)275 1625 +y Fj(A)36 b(game)g(of)h(shogi)e(is)g(w)m(on)h(b)m(y)g(capturing)f(the)h +(opp)s(onen)m(t's)f(king.)57 b(In)35 b(general,)j(this)c(is)h(done)h(b) +m(y)150 1734 y(c)m(hec)m(kmating)26 b(the)e(king:)37 +b(attac)m(king)26 b(the)f(king)e(in)g(suc)m(h)i(a)f(w)m(a)m(y)i(that)f +(the)f(king)g(cannot)h(b)s(e)f(defended)f(no)150 1844 +y(matter)32 b(what)f(the)h(defending)d(pla)m(y)m(er)i(mo)m(v)m(es.)45 +b(Note,)33 b(though,)e(that)h(there)f(is)g(no)g(rule)f(that)h(requires) +150 1954 y(a)f(pla)m(y)m(er)g(to)g(defend)f(a)h(king)f(whic)m(h)f(is)h +(b)s(eing)g(attac)m(k)m(ed.)43 b(Ho)m(w)m(ev)m(er,)32 +b(if)d(he)g(do)s(es)h(not)g(defend)e(his)h(king,)150 +2063 y(the)36 b(opp)s(onen)m(t)f(is)g(en)m(tirely)f(free)i(to)g +(capture)g(it)f(on)h(the)g(next)f(mo)m(v)m(e,)k(th)m(us)c(winning)e +(the)j(game.)57 b(As)150 2173 y(in)31 b(in)m(ternational)g(c)m(hess,)j +(in)d(practice)i(most)g(games)g(end)f(b)m(y)g(resignation)g(when)f(one) +i(pla)m(y)m(er)f(realizes)150 2282 y(that)f(he)f(cannot)h(escap)s(e)g +(c)m(hec)m(kmate.)150 2498 y Fe(2.1.6)63 b(Dra)m(ws)275 +2687 y Fj(There)26 b(are)h(v)m(ery)g(few)f(dra)m(ws)g(in)f(shogi;)j +(only)e(ab)s(out)g(1-2\045)i(of)e(professional)f(games)j(end)e(in)f(a)i +(dra)m(w.)150 2797 y(One)37 b(reason)g(for)g(this)g(is)f(that)i +(material)e(can)i(nev)m(er)g(b)s(e)e(depleted)h(as)g(in)f(c)m(hess,)k +(b)s(ecause)d(captured)150 2907 y(pieces)e(are)h(constan)m(tly)g(re-en) +m(tering)f(pla)m(y)g(as)h(a)g(consequence)g(of)f(the)h(drop)e(rule.)55 +b(In)34 b(fact,)k(most)e(of)150 3016 y(the)31 b(w)m(a)m(ys)g(a)g(game)g +(can)g(b)s(e)e(dra)m(wn)h(in)f(c)m(hess)i(are)f(not)h(allo)m(w)m(ed)f +(in)f(shogi:)225 3235 y Fi(\017)60 b Fj(Dra)m(ws)31 b(cannot)g(b)s(e)f +(o\013ered.)225 3367 y Fi(\017)60 b Fj(There)30 b(is)f(no)i(\014ft)m +(y-mo)m(v)m(e)h(rule.)225 3499 y Fi(\017)60 b Fj(A)33 +b(stalemate)i(coun)m(ts)f(as)f(a)h(win)e(for)h(the)h(stalemater.)50 +b(Stated)34 b(otherwise:)46 b(if)32 b(y)m(ou)i(can't)g(mo)m(v)m(e,)330 +3608 y(y)m(ou)d(lose.)225 3740 y Fi(\017)60 b Fj(P)m(erp)s(etual)30 +b(c)m(hec)m(k)i(is)d(illegal)g(\(see)i(b)s(elo)m(w\).)275 +4003 y(There)e(are)i(only)f(t)m(w)m(o)h(legal)g(w)m(a)m(ys)g(in)e(whic) +m(h)g(a)i(dra)m(w)f(can)g(o)s(ccur:)199 4222 y(1.)61 +b(A)29 b(p)s(osition)e(\(including)f(the)k(pieces)e(in)g(hand\))g(o)s +(ccurs)h(4)h(times)e(with)g(the)h(same)h(pla)m(y)m(er)f(to)g(mo)m(v)m +(e)330 4332 y(\(called)j(\\Sennic)m(hite"\).)47 b(Ho)m(w)m(ev)m(er,)35 +b(if)c(this)h(is)f(caused)i(b)m(y)f(consecutiv)m(e)i(c)m(hec)m(ks)f +(\(direct)g(attac)m(ks)330 4441 y(on)27 b(the)g(King,)g(threatening)g +(to)h(capture)f(it)g(on)g(the)g(next)g(mo)m(v)m(e\))i(b)m(y)e(one)h +(side,)f(the)g(pla)m(y)m(er)g(giving)330 4551 y(these)34 +b(c)m(hec)m(ks)i(loses)e(the)g(game.)53 b(In)33 b(other)h(w)m(ords,)h +(p)s(erp)s(etual)d(c)m(hec)m(k)k(results)c(in)h(a)i(loss)e(for)h(the) +330 4660 y(attac)m(k)m(er)f(who)d(recreates)i(the)f(same)f(p)s(osition) +f(the)h(4th)h(time.)199 4792 y(2.)61 b(Both)36 b(pla)m(y)m(ers)f(ha)m +(v)m(e)h(mo)m(v)m(ed)g(their)e(King)g(in)m(to)h(the)h(the)f(promotion)f +(zone)i(\(or)g(they)f(cannot)h(b)s(e)330 4902 y(prev)m(en)m(ted)22 +b(from)g(doing)f(so\))h(and)g(the)g(Kings)f(cannot)h(b)s(e)f(c)m(hec)m +(kmated.)40 b(A)22 b(King)f(who)h(has)f(en)m(tered)330 +5011 y(the)31 b(promotion)e(zone)j(is)d(kno)m(wn)h(as)h(an)f(\\en)m +(tering)h(King";)f(due)g(to)h(the)f(forw)m(ard)g(orien)m(tation)h(of) +330 5121 y(most)j(shogi)g(pieces,)h(it)f(is)f(v)m(ery)h(hard)g(to)g +(mate)h(suc)m(h)f(a)h(King.)51 b(In)33 b(that)i(case)g(the)f(pla)m(y)m +(ers)g(ma)m(y)330 5230 y(decide)29 b(to)i(coun)m(t)f(their)f(pieces)g +(as)h(follo)m(ws:)40 b(the)29 b(King)g(do)s(es)g(not)h(coun)m(t,)h(the) +f(Ro)s(ok)g(and)f(Bishop)330 5340 y(coun)m(t)h(as)g(5)g(p)s(oin)m(ts,)f +(and)g(all)g(other)h(pieces)f(as)h(one)g(p)s(oin)m(t.)39 +b(Promotion)30 b(is)e(disregarded.)39 b(If)30 b(b)s(oth)p +eop +%%Page: 18 20 +18 19 bop 150 -116 a Fj(18)2734 b(GNU)31 b(Shogi)f(man)m(ual)330 +299 y(pla)m(y)m(ers)k(ha)m(v)m(e)i(at)f(least)g(24)g(p)s(oin)m(ts)e +(the)h(game)i(is)d(a)i(dra)m(w)f(\(called)g(\\Jishogi"\).)52 +b(If)34 b(a)h(pla)m(y)m(er)f(has)330 408 y(less,)c(he)g(loses)g(the)h +(game.)330 545 y(Of)41 b(course,)k(a)d(pla)m(y)m(er)f(can)h(refuse)f +(to)i(coun)m(t)f(pieces)f(when)g(he)g(still)f(has)h(mating)g(c)m +(hances)i(or)330 655 y(c)m(hances)32 b(to)g(gain)f(material)g(whic)m(h) +f(w)m(ould)g(a\013ect)j(the)e(outcome)i(of)e(the)h(coun)m(ting.)43 +b(There)31 b(is)f(no)330 765 y(strict)38 b(rule)f(ab)s(out)h(what)g(to) +h(do)f(if)f(this)g(is)g(not)i(the)f(case,)k(but)37 b(nonetheless)h(a)g +(pla)m(y)m(er)h(refuses)330 874 y(to)f(coun)m(t)g(up)e(\(e.g.)63 +b(b)s(ecause)38 b(he)f(do)s(es)g(not)h(ha)m(v)m(e)g(enough)f(p)s(oin)m +(ts)g(for)g(a)g(dra)m(w\).)62 b(It)38 b(has)f(b)s(een)330 +984 y(generally)30 b(accepted)i(that)g(in)e(suc)m(h)g(a)h(case)h(the)g +(game)f(ends)g(and)f(the)h(pieces)g(are)g(coun)m(ted)g(after)330 +1093 y(one)g(pla)m(y)m(er)f(has)g(managed)h(to)g(get)h(all)d(his)g +(pieces)h(protected)h(in)e(the)i(promotion)f(zone.)150 +1355 y Fe(2.1.7)63 b(Handicaps)275 1552 y Fj(Unlik)m(e)34 +b(in)m(ternational)g(c)m(hess,)j(shogi)e(has)g(a)h(w)m(ell-established) +d(handicap)h(system)h(whic)m(h)f(is)h(used)150 1662 y(when)28 +b(pla)m(y)m(ers)i(of)f(di\013eren)m(t)g(strengths)g(pla)m(y)g(against)g +(eac)m(h)i(other.)41 b(Handicaps)28 b(range)i(from)e(small)g(to)150 +1771 y(h)m(uge,)h(whic)m(h)d(mak)m(es)j(it)e(p)s(ossible)f(for)h(w)m +(eak)i(pla)m(y)m(ers)e(to)i(pla)m(y)e(against)h(ev)m(en)h(v)m(ery)f +(strong)g(pla)m(y)m(ers)g(and)150 1881 y(ha)m(v)m(e)k(an)e(ev)m(en)h(c) +m(hance)g(of)g(winning.)275 2020 y(Shogi)f(pla)m(y)m(ers)i(are)f(rank)m +(ed)h(as)f(follo)m(ws:)42 b(the)32 b(w)m(eak)m(est)i(rank)c(is)h +(around)f(15)j(\\kyu",)f(whic)m(h)e(repre-)150 2130 y(sen)m(ts)j(a)g(b) +s(eginner.)46 b(14)33 b(kyu)f(is)g(higher)f(than)h(15)i(kyu,)f(13)g +(kyu)f(is)g(higher)f(still,)g(and)h(so)h(on)g(un)m(til)e(y)m(ou)150 +2240 y(get)e(to)g(1)g(kyu.)40 b(The)27 b(next)i(highest)e(rank)h(is)f +(1)i(\\dan",)g(follo)m(w)m(ed)f(b)m(y)g(2)h(dan,)f(3)h(dan)f(and)f(so)i +(forth.)39 b(The)150 2349 y(highest)34 b(amateur)g(rank)g(is)g(6)g +(dan;)i(professionals)d(go)i(up)e(to)i(9)g(dan.)52 b(Ho)m(w)m(ev)m(er,) +38 b(professional)33 b(ranks)150 2459 y(are)c(not)g(the)h(same)f(as)g +(amateur)g(ranks;)g(a)h(professional)d(1)i(dan)g(is)f +Fd(much)36 b Fj(stronger)29 b(than)g(an)f(amateur)150 +2568 y(1)35 b(dan.)55 b(This)33 b(system)i(is)f(similar)f(to)j(that)f +(used)f(b)m(y)h(go)h(pla)m(y)m(ers)f(\(and)g(also)g(other)h(Japanese)f +(sp)s(orts)150 2678 y(suc)m(h)30 b(as)h(k)-5 b(arate\).)275 +2817 y(A)40 b(handicap)f(consists)g(of)i(the)f(stronger)h(pla)m(y)m(er) +f(pla)m(ying)f(White)h(and)g(remo)m(ving)g(one)h(or)f(more)150 +2927 y(pieces)35 b(from)f(his)g(side)g(of)h(the)g(b)s(oard)f(at)i(the)f +(start)g(of)h(the)f(game.)55 b(These)35 b(pieces)g(are)g(p)s(ermanen)m +(tly)150 3037 y(remo)m(v)m(ed)c(from)f(pla)m(y;)g(they)h(are)g(not)f +(in)f(hand.)275 3176 y(The)e(follo)m(wing)g(is)h(a)h(list)e(of)h(the)h +(accepted)h(handicaps,)d(from)h(w)m(eak)m(est)i(to)f(strongest.)41 +b(The)28 b(degree)150 3286 y(of)37 b(the)g(handicap,)h(represen)m(ted)f +(b)m(y)g(the)g(p)s(osition)e(in)h(the)h(list,)g(represen)m(ts)g(the)g +(di\013erence)g(in)e(rank)150 3395 y(b)s(et)m(w)m(een)45 +b(the)f(t)m(w)m(o)h(pla)m(y)m(ers)f(for)f(whic)m(h)g(the)h(handicap)e +(is)h(appropriate.)80 b(These)44 b(rules)f(are)h(tak)m(en)150 +3505 y(from)32 b(the)g(b)s(o)s(oks)f(\\Shogi)h(for)g(Beginners")f(b)m +(y)h(John)g(F)-8 b(airbairn)30 b(and)i(\\The)g(Art)g(of)g(Shogi")g(b)m +(y)g(T)-8 b(on)m(y)150 3614 y(Hoskings)33 b(\(see)i(Chapter)f(5)g +([References)h(and)e(links],)g(page)i(41\))g(and,)f(I)g(b)s(eliev)m(e,) +g(represen)m(t)g(curren)m(t)150 3724 y(Japanese)d(practice.)199 +3943 y(1.)61 b(The)30 b(stronger)g(pla)m(y)m(er)h(remo)m(v)m(es)h(his)d +(left)h(lance)g(\(on)h(1a\).)199 4080 y(2.)61 b(The)31 +b(pla)m(y)m(ers)h(pla)m(y)f(a)h(t)m(w)m(o-game)i(matc)m(h;)f(in)d(the)i +(\014rst)f(game)h(the)g(stronger)g(pla)m(y)m(er)f(remo)m(v)m(es)i(his) +330 4190 y(left)d(lance)g(\(on)h(1a\),)h(while)c(in)h(the)i(second)f +(game)i(he)e(remo)m(v)m(es)i(his)d(bishop.)199 4327 y(3.)61 +b(The)30 b(stronger)g(pla)m(y)m(er)h(remo)m(v)m(es)h(his)d(bishop.)199 +4463 y(4.)61 b(The)30 b(stronger)g(pla)m(y)m(er)h(remo)m(v)m(es)h(his)d +(ro)s(ok.)199 4600 y(5.)61 b(The)30 b(stronger)g(pla)m(y)m(er)h(remo)m +(v)m(es)h(his)d(ro)s(ok)h(and)g(left)g(lance.)199 4737 +y(6.)61 b(The)31 b(pla)m(y)m(ers)h(pla)m(y)f(a)h(t)m(w)m(o-game)i(matc) +m(h;)f(in)d(the)i(\014rst)f(game)h(the)g(stronger)g(pla)m(y)m(er)f +(remo)m(v)m(es)i(his)330 4847 y(ro)s(ok)d(and)f(left)h(lance)g(\(on)g +(1a\),)h(while)d(in)h(the)h(second)g(game)h(he)f(remo)m(v)m(es)h(his)d +(ro)s(ok)i(and)g(bishop.)199 4984 y(7.)61 b(The)30 b(stronger)i(pla)m +(y)m(er)f(remo)m(v)m(es)h(his)d(ro)s(ok)i(and)g(bishop.)40 +b(This)29 b(is)h(usually)f(called)h(a)h(\\t)m(w)m(o-piece")330 +5093 y(handicap.)199 5230 y(8.)61 b(The)31 b(stronger)g(pla)m(y)m(er)g +(remo)m(v)m(es)h(his)e(ro)s(ok,)h(bishop,)f(and)g(b)s(oth)g(lances.)43 +b(This)29 b(is)h(called)g(a)i(\\four-)330 5340 y(piece")f(handicap.)p +eop +%%Page: 19 21 +19 20 bop 150 -116 a Fj(Chapter)30 b(2:)41 b(Ab)s(out)30 +b(the)g(game)i(of)e(shogi)2061 b(19)199 299 y(9.)61 b(The)33 +b(stronger)h(pla)m(y)m(er)g(remo)m(v)m(es)h(his)d(ro)s(ok,)i(bishop,)f +(b)s(oth)g(lances,)h(and)f(b)s(oth)g(knigh)m(ts.)50 b(This)32 +b(is)330 408 y(called)e(a)g(\\six-piece")h(handicap.)154 +545 y(10.)61 b(The)41 b(stronger)h(pla)m(y)m(er)f(remo)m(v)m(es)i(his)d +(ro)s(ok,)45 b(bishop,)e(b)s(oth)e(lances,)j(b)s(oth)d(knigh)m(ts,)j +(and)d(b)s(oth)330 655 y(silv)m(ers.)e(This)29 b(is)g(called)h(an)g +(\\eigh)m(t-piece")i(handicap.)275 930 y(Another)j(adv)-5 +b(an)m(tage)38 b(of)e(pla)m(ying)e(handicap)h(games)h(is)f(that)h(the)g +(handicaps)e(alter)i(the)g(optimal)150 1040 y(strategy)g(for)e(b)s(oth) +g(pla)m(y)m(ers.)54 b(F)-8 b(or)35 b(instance,)h(handicaps)d(all)g(ha)m +(v)m(e)j(their)e(o)m(wn)g(op)s(ening)f(lines)g(whic)m(h)150 +1150 y(ma)m(y)j(b)s(ear)g(little)e(or)i(no)f(resem)m(blance)h(to)h +(those)f(used)f(in)f(non-handicap)g(shogi.)57 b(This)34 +b(means)h(that)150 1259 y(when)26 b(learning)f(handicap)g(shogi,)i(y)m +(ou)g(are)g(essen)m(tially)e(learning)g(completely)h(new)g(games)i +(whic)m(h)d(use)150 1369 y(the)31 b(same)f(equipmen)m(t!)275 +1508 y(The)c(reader)g(ma)m(y)h(w)m(onder)f(ho)m(w)h(on)f(earth)h(a)g +(pla)m(y)m(er)g(giving)e(an)i(eigh)m(t-piece)g(handicap,)f(sa)m(y)-8 +b(,)29 b(could)150 1617 y(p)s(ossibly)37 b(hop)s(e)j(to)h(win.)68 +b(Don't)41 b(forget,)j(though,)f(that)d(in)f(shogi)h(the)g(opp)s(onen)m +(t's)g(pieces)g(can)h(b)s(e)150 1727 y(captured)g(and)h(then)f(b)s +(ecome)h(part)g(of)g(one's)g(o)m(wn)g(arm)m(y)-8 b(.)76 +b(Th)m(us,)44 b(if)d(the)h(opp)s(onen)m(t)f(pla)m(ys)g(badly)150 +1837 y(enough,)30 b(the)h(n)m(um)m(b)s(er)e(of)i(pieces)f(will)d(so)s +(on)j(ev)m(en)i(out.)150 2070 y Fe(2.1.8)63 b(Notes)41 +b(for)g(c)m(hess)g(pla)m(y)m(ers)275 2267 y Fj(Here)29 +b(are)h(a)f(few)g(miscellaneous)f(things)f(that)j(ma)m(y)g(confuse)f(c) +m(hess)g(pla)m(y)m(ers.)41 b(Some)29 b(of)g(these)h(ha)m(v)m(e)150 +2376 y(b)s(een)g(men)m(tioned)g(elsewhere,)g(but)f(they)i(b)s(ear)f +(rep)s(eating.)199 2595 y(1.)61 b(There)30 b(is)f(no)i(queen.)199 +2732 y(2.)61 b(P)m(a)m(wns)29 b(capture)h(the)f(same)h(w)m(a)m(y)g +(they)f(mo)m(v)m(e.)42 b(There)29 b(is)f(no)h(initial)e(t)m(w)m +(o-space)k(pa)m(wn)e(mo)m(v)m(e)i(and)330 2842 y(no)f +Fd(en-p)-5 b(assant)41 b Fj(mo)m(v)m(e.)199 2979 y(3.)61 +b(There)42 b(is)g(no)h(sp)s(ecial)e(castling)h(mo)m(v)m(e.)80 +b(There)42 b Fd(ar)-5 b(e)51 b Fj(a)43 b(large)g(n)m(um)m(b)s(er)e(of)i +(p)s(ossible)d(defensiv)m(e)330 3088 y(formations)31 +b(referred)f(to)i(as)g(\\castles")h(\(see)f(Section)f(2.2)h([Sample)f +(game],)i(page)f(19\))g(but)f(there)330 3198 y(is)e(no)i(need)f(for)g +(sp)s(ecial)f(mo)m(v)m(es)j(to)f(create)h(them.)199 3334 +y(4.)61 b(A)30 b(giv)m(en)h(piece)f(can)h(only)e(promote)i(to)g +Fd(one)38 b Fj(other)30 b(kind)f(of)h(piece.)150 3630 +y Fk(2.2)68 b(Sample)46 b(game)275 3827 y Fj(This)e(game)k(w)m(as)f +(annotated)g(b)m(y)g(Pieter)f(Stouten)h(\(see)g(Chapter)f(5)h +([References)h(and)e(links],)150 3937 y(page)40 b(41\).)70 +b(I)39 b(ha)m(v)m(e)i(made)f(some)f(minor)g(corrections.)68 +b(Note)41 b(that)f(captures)g(are)g(denoted)f(b)m(y)h(the)150 +4046 y(\\x")34 b(sym)m(b)s(ol)f(e.g.)51 b(Rx3f)34 b(and)e(drops)h(are)h +(denoted)f(b)m(y)h(the)g(\\*")g(sym)m(b)s(ol)f(e.g.)51 +b(R*3f.)g(Chec)m(k)34 b(is)e(indi-)150 4156 y(cated)k(b)m(y)g(a)g(\\)p +Fg(+)p Fj(")g(after)g(the)f(mo)m(v)m(e,)k(e.g.)56 b(R3f)p +Fg(+)p Fj(.)g(I)35 b(recommend)h(y)m(ou)f(use)g(gn)m(ushogi/xshogi)g +(to)h(pla)m(y)150 4266 y(along)i(with)f(this)g(game.)66 +b(In)37 b(xshogi)h(simply)e(hit)h(the)h(\\F)-8 b(orce)41 +b(Mo)m(v)m(es")f(button)e(after)h(starting)f(up,)150 +4375 y(while)26 b(in)h(gn)m(ushogi)g(en)m(ter)i(the)f(w)m(ord)f +(\\force")j(at)f(the)f(prompt.)39 b(This)26 b(will)f(allo)m(w)j(y)m(ou) +g(to)h(en)m(ter)g(mo)m(v)m(es)150 4485 y(for)h(b)s(oth)g(sides.)275 +4624 y(Note)d(also)f(that)h(the)g(mo)m(v)m(e)g(n)m(um)m(b)s(ering)e +(system)h(used)f(here)h(is)g(the)g(c)m(hess-t)m(yp)s(e)h(system)g +(where)f(one)150 4733 y(mo)m(v)m(e)33 b(means)d(one)i(mo)m(v)m(e)g(b)m +(y)f(eac)m(h)h(pla)m(y)m(er.)43 b(The)31 b(Japanese)g(coun)m(t)h(one)f +(mo)m(v)m(e)i(made)e(b)m(y)g(eac)m(h)h(pla)m(y)m(er)150 +4843 y(as)f(t)m(w)m(o)g(mo)m(v)m(es.)275 4982 y +(|||||||||||||||||||||||||)275 5121 y(Belo)m(w)c(y)m(ou)g(will)d +(\014nd)h(\(the)i(English)d(translation)i(of)7 b(\))27 +b(an)f(annotated)i(game)f(whic)m(h)f(w)m(as)h(published)150 +5230 y(in)41 b(the)i(Dutc)m(h)h(Shogi)d(magazine)j(\\81")g(and)e(in)g +(the)g(Dutc)m(h)i(b)s(eginners)c(b)s(o)s(oklet.)77 b(It)43 +b(has)g(pro)m(v)m(en)150 5340 y(to)e(b)s(e)e(a)h(v)m(ery)g(useful)e +(game)j(to)g(explain)d(some)i(basic)f(principles)d(of)k(Shogi.)69 +b(Also,)42 b(it)d(is)g(a)h(rather)p eop +%%Page: 20 22 +20 21 bop 150 -116 a Fj(20)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(straigh)m(tforw)m(ard)44 b(game)i(compared)e(to)h(professional)e +(games)i(where)f(in)f(most)i(cases)h(v)m(ery)e(di\013use)150 +408 y(middle)28 b(game)j(\014gh)m(ts)g(tak)m(e)h(place.)275 +543 y(Pieter)e(Stouten,)g(14th)h(Ma)m(y)h(1990.)275 678 +y(|||||||||||||||||||||||||)275 813 y(Blac)m(k:)41 b(Mic)m(hael)31 +b(T)-8 b(ren)m(t)30 b(\(1-dan\).)42 b(White:)e(Da)m(vid)31 +b(Murph)m(y)e(\(2-dan\).)275 948 y(1.)41 b(P2f)30 b(P3d)g(2.)41 +b(P2e)31 b(B3c)150 1058 y([)j(This)f(mo)m(v)m(e)i(is)f(necessary)-8 +b(,)36 b(as)e(otherwise)g(white)f(can)i(exc)m(hange)g(pa)m(wns:)48 +b(3.)53 b(P2d)33 b(Px2d)h(4.)53 b(Rx2d.)150 1167 y(He)31 +b(w)m(ould)e(th)m(us)h(get)i(a)e(pa)m(wn)g(in)f(hand)h(and)f(op)s(en)h +(up)f(his)g(ro)s(ok)i(\014le.)39 b(])275 1302 y(3.)i(P7f)30 +b(P4d)150 1412 y([)39 b(White)f(closes)h(the)g(bishop)d(diagonal)i +(again.)66 b(He)39 b(plans)e(to)i(pla)m(y)f(ranging)g(ro)s(ok)h(\(the)g +(ro)s(ok)f(go)s(es)150 1521 y(to)h(5b,)g(4b,)h(3)e(or)g(2b;)k(a)c +(defensiv)m(e)f(strategy\))i(and)f(in)e(that)i(case)h(he'd)f(b)s(etter) +f(a)m(v)m(oid)i(an)e(exc)m(hange)150 1631 y(of)32 b(bishops.)42 +b(One)32 b(of)f(the)h(reasons)g(is)f(that)h(he)g(will)d(ha)m(v)m(e)j +(problems)e(dev)m(eloping)h(his)f(pieces)i(without)150 +1740 y(lea)m(ving)e(holes)g(for)g(bishop)e(drops.)40 +b(])275 1875 y(4.)h(S4h)29 b(R3b)i(5.)41 b(P3f)30 b(S4b)g(6.)41 +b(K6h)30 b(K6b)150 1985 y([)36 b(In)g(general)g(the)h(ro)s(ok)f(pla)m +(ys)f(an)i(imp)s(ortan)m(t)e(role)h(in)f(the)h(attac)m(ks.)61 +b(It)36 b(is)f(wise)h(to)h(mo)m(v)m(e)g(the)g(king)150 +2094 y(a)m(w)m(a)m(y)h(from)d(the)h(area)g(where)f(the)h(initial)d +(\014gh)m(ts)j(will)d(b)s(e)i(and)g(b)s(oth)g(pla)m(y)m(ers)h(act)h +(according)e(to)i(the)150 2204 y(Shogi)29 b(pro)m(v)m(erb)i(\\k)m(eep)g +(the)g(ro)s(ok)f(and)g(king)f(apart".)42 b(])275 2339 +y(7.)f(K7h)30 b(K7b)g(8.)41 b(P5f)30 b(P5d)g(9.)41 b(G4i-5h)31 +b(G4a-5b)150 2449 y([)g(Both)g(pla)m(y)m(ers)f(use)g(their)f(second)i +(gold)f(general)g(to)h(build)d(their)h(castle.)41 b(])275 +2583 y(10.)g(S6h)150 2693 y([)25 b(In)f(itself)f(this)g(mo)m(v)m(e)j +(is)e(not)h(bad.)38 b(Ho)m(w)m(ev)m(er,)28 b(it)c(will)e(b)s(ecome)j +(clear)g(that)g(blac)m(k)f(plans)f(a)i(quic)m(k)g(attac)m(k)150 +2803 y(and)30 b(in)f(that)i(case)g(it)f(is)g(wiser)f(to)i(omit)f(this)f +(mo)m(v)m(e.)42 b(])275 2937 y(10...)g(S5c)30 b(11.)42 +b(P1f)30 b(P1d)150 3047 y([)38 b(The)e(adv)-5 b(ance)38 +b(of)g(the)f(edge)h(pa)m(wns)f(m)m(ust)g(b)s(e)g(timed)g(v)m(ery)g(w)m +(ell.)61 b(The)37 b(remark)g(at)h(blac)m(k's)f(ten)m(th)150 +3157 y(mo)m(v)m(e)i(applies)c(here)i(to)s(o:)54 b(this)36 +b(mo)m(v)m(e)j(is)d(go)s(o)s(d)h(if)f(blac)m(k)h(w)m(an)m(ts)h(to)g +(pla)m(y)e(a)i(slo)m(w)e(game,)k(b)s(ecause)d(it)150 +3266 y(eliminates)29 b(a)i(future)e(B1e.)42 b(])275 3401 +y(12.)f(P4f)31 b(K8b)e(13.)42 b(N3g)31 b(S7b)150 3511 +y([)25 b(Blac)m(k)g(dev)m(elops)f(his)f(knigh)m(t)h(in)f(order)h(to)h +(start)g(an)g(attac)m(k)h(o)m(v)m(er)g(the)f(second,)h(third)c(and)i +(fourth)g(\014les.)150 3620 y(White)36 b(strengthens)f(his)g(king's)g +(p)s(osition)f(and)h(a)m(w)m(aits)i(the)f(attac)m(k.)60 +b(He)37 b(aims)e(at)i(a)f(coun)m(terattac)m(k)150 3730 +y(as)c(so)s(on)g(as)g(blac)m(k)g(has)g(brok)m(en)g(through)f(in)m(to)h +(the)g(white)f(camp.)46 b(Probably)30 b(white's)i(breakthrough)150 +3839 y(will)e(tak)m(e)k(place)e(later,)i(but)d(he)i(has)f(go)s(o)s(d)g +(comp)s(ensation)g(in)f(the)i(form)f(of)h(a)f(stronger)h(castle.)48 +b(This)150 3949 y(theme)31 b(o)s(ccurs)f(v)m(ery)h(often)f(in)f(static) +i(ro)s(ok)g(v)m(ersus)f(ranging)f(ro)s(ok)i(games.)41 +b(])275 4084 y(14.)g(P4e)31 b(R4b)150 4194 y([)c(Blac)m(k)h(starts)f +(his)e(attac)m(k)30 b(and)c(white)g(puts)g(up)g(a)h(v)m(ery)g(passiv)m +(e)g(defence.)40 b(His)26 b(ro)s(ok)h(has)f(a)h(hard)f(task)150 +4303 y(no)m(w)34 b(to)h(p)s(enetrate)g(the)f(blac)m(k)h(p)s(osition.)50 +b(Moreo)m(v)m(er,)38 b(he)c(blo)s(c)m(ks)g(his)e(o)m(wn)j(bishop.)50 +b(It)34 b(seems)h(m)m(uc)m(h)150 4413 y(b)s(etter)29 +b(to)h(start)g(a)g(coun)m(terattac)m(k)i(with)c(14...)42 +b(P3e,)30 b(later)f(to)h(b)s(e)f(follo)m(w)m(ed)g(b)m(y)g(B2b,)h(B5a)g +(or)g(Bx4d)f(in)150 4522 y(order)h(to)h(use)f(his)f(ro)s(ok)h(more)h +(activ)m(ely)-8 b(.)41 b(])275 4657 y(15.)g(Px4d)30 b(Sx4d)g(16.)42 +b(P*4e)31 b(S5c)150 4767 y([)j(16...)52 b(Sx4e)34 b(is)f(more)g(activ)m +(e.)52 b(A)34 b(silv)m(er)e(general)i(is)f(normally)f(more)i(v)-5 +b(aluable)32 b(than)h(a)h(knigh)m(t,)h(but)150 4876 y(white)f(gets)h(t) +m(w)m(o)h(pa)m(wns)e(in)f(hand)h(and)g(blac)m(k)g(none,)i(while)d(the)i +(knigh)m(t)f(migh)m(t)g(come)h(in)f(handy)f(for)150 4986 +y(white)c(to)s(o.)42 b(])275 5121 y(17.)f(Bx3c)p Fg(+)31 +b Fj(Nx3c)h(18.)41 b(P2d)30 b(Px2d)150 5230 y([)38 b(Blac)m(k)i +(threatens)e(to)h(break)f(through)g(and)g(white)f(has)h(to)h(consider)e +(taking)h(the)h(pa)m(wn)f(on)g(2d)g(or)150 5340 y(starting)28 +b(a)h(coun)m(terattac)m(k)j(with)27 b(Nx4e.)41 b(If)28 +b(he)g(c)m(ho)s(oses)i(the)f(latter,)g(blac)m(k)g(can)f(pla)m(y)g(Px2c) +p Fg(+)h Fj(follo)m(w)m(ed)p eop +%%Page: 21 23 +21 22 bop 150 -116 a Fj(Chapter)30 b(2:)41 b(Ab)s(out)30 +b(the)g(game)i(of)e(shogi)2061 b(21)150 299 y(b)m(y)33 +b Fg(+)p Fj(P3c.)48 b(The)33 b(disadv)-5 b(an)m(tage)33 +b(is)f(the)h(blac)m(k)g(\\tokin")g(\(=promoted)g(pa)m(wn\))g(that)g +(white)f(will)e(get)k(in)150 408 y(his)k(camp;)44 b(the)39 +b(adv)-5 b(an)m(tage)41 b(is)d(that)i(it)f(will)d(cost)k(blac)m(k)f(t)m +(w)m(o)i(more)e(mo)m(v)m(es)i(to)e(promote)h(his)e(ro)s(ok.)150 +518 y(Because)32 b(white)d(did)f(not)j(trust)e(that)i(the)g(result)e +(after)h(engaging)h(in)e(a)i(\\semeai")g(\(=m)m(utual)e(attac)m(k\))150 +628 y(with)g(18...Nx4e)j(w)m(ould)d(giv)m(e)h(a)g(p)s(ositiv)m(e)f +(result,)g(he)h(captured)f(the)h(pa)m(wn)f(on)h(2d.)41 +b(Making)29 b(the)h(righ)m(t)150 737 y(decision)c(in)g(momen)m(ts)i +(lik)m(e)f(this)f(often)i(mak)m(es)g(the)g(di\013erence)f(b)s(et)m(w)m +(een)h(a)g(win)d(and)i(a)h(loss:)39 b(miss)26 b(one)150 +847 y(attac)m(king)39 b(c)m(hance)f(and)f(y)m(ou)g(will)d(b)s(e)j +(forced)g(to)h(defend)e(the)i(whole)e(game)i(un)m(til)d(the)j(una)m(v)m +(oidable)150 956 y(defeat;)i(on)c(the)g(other)g(hand,)h(an)e(unsound)f +(attac)m(k)39 b(can)d(destro)m(y)g(all)f(\\a)5 b(ji")37 +b(\(=p)s(oten)m(tial,)g(meaning)150 1066 y(p)s(ossibilities,)26 +b(threats\))31 b(without)f(getting)h(an)m(ything)f(in)f(return.)39 +b(])275 1200 y(19.)i(Rx2d)30 b(Nx4e)i(20.)41 b(Nx4e)31 +b(Rx4e)h(21.)41 b(R2a)p Fg(+)31 b Fj(P*4g)150 1310 y([)k(No)m(w)h(it)f +(b)s(ecomes)g(clear)g(wh)m(y)g(blac)m(k's)g(10.)56 b(S6h)35 +b(w)m(as)g(not)h(go)s(o)s(d.)54 b(Had)36 b(this)e(mo)m(v)m(e)i(b)s(een) +f(omitted,)150 1420 y(then)f(white)f(w)m(ould)g(not)i(ha)m(v)m(e)h(had) +d(the)i(time)f(to)h(pla)m(y)f(13...)54 b(S7b)33 b(and)h(after)h(R2a)p +Fg(+)g Fj(the)f(gold)g(on)g(6a)150 1529 y(w)m(ould)25 +b(hang.)40 b(Th)m(us)25 b(blac)m(k)i(w)m(ould)e(ha)m(v)m(e)j(k)m(ept)f +(\\sen)m(te")i(\(=initiativ)m(e\).)38 b(Instead)27 b(of)g(21...)40 +b(P*4g,)29 b(B*6d)150 1639 y(is)h(a)h(v)m(ery)g(go)s(o)s(d)g(mo)m(v)m +(e,)h(b)s(ecause)f(after)h(22.)42 b(P*2h)31 b(blac)m(k)g(do)s(es)g(not) +g(ha)m(v)m(e)h(a)f(pa)m(wn)f(in)g(hand)f(an)m(ymore)150 +1748 y(and)g(he)h(is)f(b)s(eing)g(threatened)h(with)f(the)h(anno)m +(ying)g(22...)42 b(N*4f)31 b(23.)41 b(G5g)31 b(N3h)p +Fg(+)f Fj(24.)42 b(S4g)30 b Fg(+)p Fj(N4h)g(also.)150 +1858 y(Blac)m(k)j(can)g(also)f(coun)m(ter)h(21...)47 +b(B*6d)33 b(with)e(22.)47 b(N*3g.)h(White)32 b(w)m(ould)f(then)h(reply) +f(with)g(22...)47 b(R4b)150 1968 y(23.)40 b(B*3c)29 b(P*4g)e(24.)41 +b(Bx4b)p Fg(+)26 b Fj(Sx4b.)39 b(The)26 b(white)g(ro)s(ok)h(has)f(pla)m +(y)m(ed)h(its)f(role)g(and)g(instead)g(of)g(sp)s(ending)150 +2077 y(mo)m(v)m(es)k(on)f(sa)m(ving)g(it)g(white)f(starts)h(to)h +(scatter)h(blac)m(k's)e(defences)g(b)m(y)g(successiv)m(e)g(pa)m(wn)g +(drops)f(on)h(the)150 2187 y(fourth)i(\014le:)42 b(25.)j(Gx4g)33 +b(P*4f)f(26.)46 b(G5g)32 b(N*6e)h(27.)46 b(G5h)32 b(P4g)p +Fg(+)g Fj(28.)45 b(Gx4g)33 b(P*4f.)45 b(This)29 b(analysis)i(w)m(as)150 +2296 y(pro)m(vided)k(b)m(y)h(Kato)i(Hifumi,)d(9-dan)i(professional)e +(\(the)i(highest)e(regular)h(grade\).)60 b(Destro)m(ying)37 +b(the)150 2406 y(coherence)25 b(of)g(the)f(enem)m(y)h(pieces)f(\(their) +g(shap)s(e\))g(b)m(y)g(dropping)e(pa)m(wns)i(is)f(one)i(of)g(the)f +(most)h(imp)s(ortan)m(t)150 2516 y(Shogi)k(tec)m(hniques.)41 +b(With)30 b(the)g(actual)h(mo)m(v)m(e)h(21...)42 b(P*4g)31 +b(white)f(missed)f(a)i(go)s(o)s(d)f(c)m(hance.)42 b(])275 +2650 y(22.)f(Sx4g)31 b(P*4f)g(23.)41 b(B*3g)32 b(Px4g)p +Fg(+)f Fj(24.)42 b Fg(+)p Fj(Rx6a)30 b Fg(+)p Fj(Px3g)150 +2760 y([)38 b(23.)64 b(B*3g)40 b(seems)e(p)s(oin)m(tless,)g(but)g(a)g +(closer)g(lo)s(ok)f(rev)m(eals)i(that)f(it)g(is)f(actually)g(quite)g +(mean.)64 b(On)150 2869 y(mo)m(v)m(e)38 b(24)f(white)e(cannot)i +(capture)g(blac)m(k's)f(\\Ryu")g(\(=dragon)h(=promoted)f(ro)s(ok\))g +(with)f(his)g(silv)m(er:)150 2979 y(24...)53 b(Sx6a)35 +b(25.)53 b(N*7d)34 b(K7b)g(26.)53 b(G*8b)34 b(mate.)53 +b(By)35 b(attac)m(king)g(the)g(fron)m(t)f(of)g(the)h(white)e(castle)i +(and)150 3088 y(threatening)26 b(to)h(mate)g(him)e(there,)i(blac)m(k)g +(has)f(the)g(c)m(hance)h(to)g(break)f(do)m(wn)g(the)h(white)e(defences) +h(from)150 3198 y(the)31 b(side.)39 b(])275 3333 y(25.)i +Fg(+)p Fj(Rx5b)30 b(S*6b)150 3442 y([)h(Here)h(25...)44 +b(B*4d)32 b(w)m(ould)e(b)s(e)g(m)m(uc)m(h)h(b)s(etter,)h(b)s(ecause)f +(it)g(is)f(defensiv)m(e)g(and)h(attac)m(king)h(at)g(the)g(same)150 +3552 y(time.)44 b(After)32 b(e.g.)45 b(26.)g(G*4c)34 +b(Bx9i)p Fg(+)d Fj(27.)45 b(Gx5c)33 b(blac)m(k)e(threatens)h(28.)46 +b Fg(+)p Fj(Rx7b)31 b(Kx7b)g(29.)45 b(S*6a)32 b(K8b)150 +3661 y(30.)44 b(S*7a)33 b(Kx7a)e(31.)45 b(G*7b)32 b(mate.)44 +b(White)31 b(is)g(one)g(mo)m(v)m(e)i(quic)m(k)m(er,)f(ho)m(w)m(ev)m +(er.)45 b(He)32 b(has)f(the)g(follo)m(wing)150 3771 y(b)s(eautiful)d +(\\tsume")k(\(mating)f(sequence)h(where)e(ev)m(ery)i(mo)m(v)m(e)g(is)e +(c)m(hec)m(k\):)44 b(27...)g(N*8f)32 b(28.)43 b(Px8f)31 +b(S*8g)150 3880 y(29.)53 b(Kx8g)35 b(B*9h)g(30.)54 b(K7h)34 +b(Bx8i)p Fg(+)g Fj(31.)53 b(K8g)35 b Fg(+)p Fj(B8i-8h)f(32.)54 +b(K9f)34 b(L*9e)h(mate.)54 b(This)32 b(illustrates)h(the)150 +3990 y(sharpness)c(of)h(Shogi:)40 b(one)31 b(mo)m(v)m(e)h(can)e(mak)m +(e)i(the)e(di\013erence)g(b)s(et)m(w)m(een)h(winning)d(and)h(losing.)40 +b(])275 4125 y(26.)h(P*4f)31 b(Rx4f)150 4234 y([)37 b(This)d(mo)m(v)m +(e)39 b(eliminates)34 b(white's)i(last)h(c)m(hances.)60 +b(26...)g(R4b)37 b(27.)60 b Fg(+)p Fj(Rx4b)36 b(Sx4b)g(28.)60 +b(R*4a)38 b(seems)150 4344 y(anno)m(ying,)33 b(but)e(after)i(28...)48 +b(B*3c)34 b(29.)48 b(S7g)33 b(B*3b)g(white)e(wins)g(the)h(ro)s(ok)h +(and)e(with)g(his)g(\\tokin")i(on)150 4453 y(3g)e(there)g(still)d(is)h +(some)i(hop)s(e.)40 b(])275 4588 y(27.)h(N*6e)32 b Fg(+)p +Fj(P4g)150 4697 y([)j(White)g(cannot)h(defend)e(an)m(ymore,)j(so)f(he)f +(starts)g(a)h(desp)s(erate)f(attac)m(k.)57 b(Blac)m(k)36 +b(do)s(es)f(not)h(lose)f(the)150 4807 y(righ)m(t)30 b(trac)m(k,)i(ho)m +(w)m(ev)m(er.)42 b(])275 4941 y(28.)52 b(Nx5c)p Fg(+)35 +b(+)p Fj(Px5h)e(29.)52 b Fg(+)p Fj(Nx6b)34 b Fg(+)p Fj(Px6h)g(30.)52 +b(Gx6h)34 b(N*8f)h(31.)52 b(Px8f)34 b(B*6i)h(32.)52 b(Gx6i)34 +b(R4h)p Fg(+)g Fj(33.)150 5051 y(N*6h)d Fg(+)p Fj(Rx6h)f(34.)41 +b(Gx6h)31 b(S*8g)g(35.)42 b(Kx8g)31 b(N*9e)g(36.)42 b(K7h)30 +b(Resigns)150 5161 y([)h(White)f(resigns)f(here,)i(b)s(ecause)f(after)h +(36...)42 b(B*8g)32 b(27.)41 b(K7g)31 b(his)e(attac)m(k)k(has)d(p)s +(etered)g(out.)41 b(])p eop +%%Page: 22 24 +22 23 bop 150 -116 a Fj(22)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y Fk(2.3)68 b(Mating)46 b(problems)275 491 y Fj(One)29 +b(go)s(o)s(d)h(w)m(a)m(y)h(to)f(impro)m(v)m(e)g(at)h(shogi)e(is)g(to)i +(solv)m(e)f(mating)g(problems.)39 b(There)29 b(are)i(sev)m(eral)f(t)m +(yp)s(es)150 601 y(of)38 b(these)h(problems,)f(but)f(the)i(most)f +(common)g(is)f(called)h(a)g(\\tsume-shogi")h(problem,)f(or)g(\\tsume") +150 711 y(problem)26 b(for)i(short.)40 b(In)27 b(a)i(tsume)e(problem,)g +(all)g(pieces)h(that)h(are)f(not)g(on)g(the)h(b)s(oard)e(are)h(assumed) +f(to)150 820 y(b)s(e)h(in)f(the)i(opp)s(onen)m(t's)f(hand)g(\(except)i +(for)e(y)m(our)h(King,)f(whic)m(h)f(is)h(usually)e(not)j(sho)m(wn\).)40 +b(Ev)m(ery)28 b(mo)m(v)m(e)150 930 y(y)m(ou)33 b(mak)m(e)g(m)m(ust)g(b) +s(e)f(c)m(hec)m(k)i(un)m(til)c(the)j(\014nal)e(c)m(hec)m(kmate.)50 +b(Y)-8 b(our)33 b(opp)s(onen)m(t)f(ma)m(y)h(pla)m(y)f(an)m(y)h(piece)f +(on)150 1039 y(the)37 b(b)s(oard)e(or)i(drop)e(an)m(y)i(of)g(his)e +(pieces)h(in)f(hand)g(in)h(order)g(to)h(prev)m(en)m(t)g(the)g(mate.)60 +b(In)35 b(a)i(prop)s(erly)150 1149 y(constructed)32 b(tsume)g(problem,) +g(all)f(of)h(y)m(our)g(pieces)g(on)g(the)h(b)s(oard)e(and)h(in)e(hand)i +(m)m(ust)g(b)s(e)f(essen)m(tial)150 1259 y(to)i(the)g(solution.)46 +b(One)32 b(consequence)h(of)g(this)e(is)h(that)h(all)e(of)i(y)m(our)g +(pieces)f(in)f(hand)h(m)m(ust)g(b)s(e)g(pla)m(y)m(ed)150 +1368 y(during)38 b(the)h(solution.)68 b(There)39 b(should)f(only)h(b)s +(e)g(one)h(correct)h(solution)d(for)i(the)g(giv)m(en)f(n)m(um)m(b)s(er) +g(of)150 1478 y(mo)m(v)m(es.)59 b(Tsume)36 b(problems)e(use)i +(Japanese-st)m(yle)h(mo)m(v)m(e)g(n)m(um)m(b)s(ering;)g(th)m(us,)h(a)e +(problem)f(where)h(y)m(ou)150 1587 y(mo)m(v)m(e)e(\(and)f(giv)m(e)h(c)m +(hec)m(k\),)i(y)m(our)c(opp)s(onen)m(t)h(mo)m(v)m(es,)i(and)e(y)m(ou)g +(mo)m(v)m(e)i(to)e(giv)m(e)h(c)m(hec)m(kmate)h(is)d(called)h(a)150 +1697 y(three-mo)m(v)m(er.)42 b(Here)31 b(is)f(a)g(really)g(trivial)e +(three-mo)m(v)m(er:)293 1916 y Fg(3)191 b(2)f(1)150 2026 +y(----------------+)198 2135 y(|)g(|)h(|)g(|)95 b(a)150 +2245 y(----------------+)198 2355 y(|)190 b(|)h(|)47 +b(wK)h(|)95 b(b)150 2464 y(----------------+)198 2574 +y(|)190 b(|)h(|)g(|)95 b(c)150 2683 y(----------------+)198 +2793 y(|)47 b(bN)g(|)191 b(|)g(|)95 b(d)150 2902 y(----------------+) +198 3012 y(|)190 b(|)h(|)g(|)95 b(e)150 3122 y(----------------+)198 +3231 y(|)190 b(|)48 b(bN)f(|)191 b(|)95 b(f)150 3341 +y(----------------+)150 3450 y(Black)46 b(in)i(hand:)94 +b(S,)47 b(G)275 3794 y Fj(Here,)40 b(Blac)m(k)e(pla)m(ys)f(G*2b,)k +(White)c(pla)m(ys)g(K1c,)j(and)e(Blac)m(k)g(pla)m(ys)f(S*1d)h(mate.)63 +b(More)38 b(t)m(ypical)150 3904 y(tsume)28 b(problems)f(range)i(from)g +(5)g(mo)m(v)m(es)h(to)f(arbitrarily)d(high)h(n)m(um)m(b)s(ers)g(of)i +(mo)m(v)m(es,)i(and)d(they)h(can)g(b)s(e)150 4013 y(quite)k +(brain-busting.)49 b(Tsume)33 b(problems)f(ma)m(y)j(seem)f +(arti\014cial,)g(but)f(in)g(the)h(closing)f(stages)j(of)e(the)150 +4123 y(game)d(where)e(b)s(oth)h(pla)m(y)m(ers)g(ha)m(v)m(e)h(a)f(lot)g +(of)g(pieces)g(in)f(hand,)g(it)h(is)f(often)h(necessary)g(to)h(giv)m(e) +g(c)m(hec)m(k)g(at)150 4232 y(ev)m(ery)h(mo)m(v)m(e,)h(or)e(else)f(y)m +(our)h(opp)s(onen)m(t)g(will)d(start)k(a)f(coun)m(terattac)m(k)j(and)d +(will)d(mate)k(y)m(ou)f(b)s(efore)g(y)m(ou)150 4342 y(mate)25 +b(him.)37 b(A)23 b(tsume)h(problem)e(is)h(a)h(w)m(orst-case)i(scenario) +d(for)h(the)g(attac)m(k)m(er:)40 b(y)m(ou)24 b(ha)m(v)m(e)h(to)f(mate)h +(y)m(our)150 4452 y(opp)s(onen)m(t)k(ev)m(en)h(though)f(he)g(has)g(ev)m +(ery)h(piece)f(not)h(on)f(the)g(b)s(oard)f(in)g(hand,)h(whic)m(h)f +(means)h(y)m(ou)h(ha)m(v)m(e)150 4561 y(to)d(dev)m(elop)g(sharp)e +(attac)m(king)j(skills.)37 b(Man)m(y)27 b(more)f(tsume)h(problems)d +(can)j(b)s(e)f(found)f(on)h(the)h(in)m(ternet;)150 4671 +y(I)36 b(particularly)f(recommend)h(P)m(atric)m(k)i(Da)m(vin's)f +(\\Shogi)f(Nexus")h(\(see)h(Chapter)e(5)h([References)h(and)150 +4780 y(links],)29 b(page)i(41\).)p eop +%%Page: 23 25 +23 24 bop 150 -116 a Fj(Chapter)30 b(2:)41 b(Ab)s(out)30 +b(the)g(game)i(of)e(shogi)2061 b(23)150 299 y Fk(2.4)68 +b(Shogi)45 b(v)-7 b(arian)l(ts)275 500 y Fj(Sev)m(eral)39 +b(historical)e(v)-5 b(arian)m(ts)39 b(of)g(shogi)g(exist.)67 +b(Most)40 b(of)f(these)h(w)m(ere)f(in)m(v)m(en)m(ted)h(b)s(efore)e(mo)s +(dern)150 610 y(shogi)29 b(\(in)f(some)h(cases)h(h)m(undreds)d(of)i(y)m +(ears)h(b)s(efore\),)g(are)f(m)m(uc)m(h)g(larger)g(than)g(mo)s(dern)f +(shogi)g(and)h(are)150 719 y(not)38 b(pla)m(y)m(ed)g(with)e(drops.)62 +b(Th)m(us,)39 b(in)e(man)m(y)h(w)m(a)m(ys)g(they)g(are)h(really)d(more) +i(lik)m(e)g(gian)m(t)g(c)m(hess)g(games)150 829 y(than)g(lik)m(e)g(mo)s +(dern)f(shogi.)65 b(The)38 b(only)f(one)i(of)g(these)g(games)g(to)g(ha) +m(v)m(e)h(surviv)m(ed)d(in)g(Japan)h(is)g(Ch)m(u)150 +938 y(\(middle\))e(shogi,)i(whic)m(h)e(is)g(still)g(pla)m(y)m(ed)h(a)g +(little)g(bit.)60 b(Thanks)36 b(to)i(the)f(e\013orts)h(of)g(George)h +(Ho)s(dges)150 1048 y(and)c(John)g(F)-8 b(airbairn)34 +b(of)i(the)g(Shogi)f(Asso)s(ciation)g(\(t)m(w)m(o)i(British)d(shogi)h +(en)m(th)m(usiasts\),)j(these)e(games)150 1157 y(w)m(ere)h(resurrected) +g(and)f(rules)g(and)g(sets)h(for)g(them)g(can)g(still)d(b)s(e)j(purc)m +(hased)f(from)g(George)j(Ho)s(dges)150 1267 y(\(see)31 +b(Chapter)e(5)h([References)h(and)e(links],)f(page)j(41\).)41 +b(I)30 b(hop)s(e)f(to)h(ev)m(en)m(tually)g(extend)g(GNU)g(shogi)g(so) +150 1377 y(that)f(it)f(can)g(pla)m(y)g(at)h(least)g(some)g(of)f(these)h +(games.)41 b(There)28 b(are)h(also)f(sev)m(eral)h(non-historical)d(v)-5 +b(arian)m(ts)150 1486 y(of)33 b(shogi;)h(I)e(don't)h(kno)m(w)g(m)m(uc)m +(h)g(ab)s(out)g(them)g(but)f(y)m(ou)h(can)g(\014nd)e(information)h(ab)s +(out)g(them)h(on)g(the)150 1596 y(in)m(ternet)d(\(see)h(Chapter)f(5)h +([References)g(and)f(links],)f(page)i(41\).)275 1739 +y(The)e(historical)g(v)-5 b(arian)m(ts)30 b(include:)199 +1958 y(1.)61 b(T)-8 b(ori)32 b(\(bird\))f(shogi,)h(pla)m(y)m(ed)h(on)f +(a)h(7x7)g(b)s(oard)e(with)g(32)i(pieces)g(in)e(all;)h(this)f(is)h(the) +g(only)g(v)-5 b(arian)m(t)330 2068 y(that)31 b(is)e(kno)m(wn)h(to)h(ha) +m(v)m(e)h(b)s(een)e(pla)m(y)m(ed)g(with)f(drops.)199 +2206 y(2.)61 b(W)-8 b(a)32 b(shogi,)e(pla)m(y)m(ed)h(on)g(an)f(11x11)j +(b)s(oard)d(with)f(54)j(pieces.)41 b(This)29 b(game)j(can)f(b)s(e)f +(pla)m(y)m(ed)h(with)e(or)330 2316 y(without)34 b(drops)g(but)h(the)g +(historical)f(evidence)h(fa)m(v)m(ors)h(the)g(view)e(that)i(it)f(w)m +(as)h(pla)m(y)m(ed)f(without)330 2425 y(drops.)57 b(Ho)m(w)m(ev)m(er,) +40 b(most)c(p)s(eople)f(who)h(ha)m(v)m(e)h(tried)f(it)f(claim)g(it)h +(is)f(a)i(m)m(uc)m(h)f(b)s(etter)g(game)h(with)330 2535 +y(drops,)29 b(b)s(eing)g(ev)m(en)j(more)e(in)m(tricate)g(than)h +(standard)e(shogi.)199 2674 y(3.)61 b(Ch)m(u)30 b(\(middle\))f(shogi,)i +(pla)m(y)m(ed)f(on)h(a)g(12x12)i(b)s(oard)d(with)f(92)j(pieces.)42 +b(This)29 b(w)m(as)i(\(and)f(is\))g(b)m(y)h(far)330 2783 +y(the)36 b(most)f(p)s(opular)f(of)h(the)h(v)-5 b(arian)m(ts,)37 +b(and)e(has)g(21)h(di\013eren)m(t)f(kinds)f(of)h(pieces)g(in)g(the)g +(starting)330 2893 y(line-up)28 b(alone)i(\(along)h(with)e(sev)m(eral)h +(others)h(that)f(app)s(ear)g(up)s(on)f(promotion\).)40 +b(Unlik)m(e)29 b(mo)s(dern)330 3003 y(shogi,)h(there)g(are)g(a)h +(tremendous)e(n)m(um)m(b)s(er)g(of)h(ranging)f(pieces)h(and)f(the)i +(game)g(is)e(de\014nitely)f(not)330 3112 y(pla)m(y)m(ed)j(with)f +(drops.)42 b(There)30 b(is)g(also)h(an)g(amazing)h(piece)f(called)f +(the)h(Lion)f(whic)m(h)g(has)h(a)g(double)330 3222 y(king)36 +b(mo)m(v)m(e)j(and)d(can)i(capture)f(t)m(w)m(o)i(pieces)d(at)i(once!)62 +b(Ch)m(u)36 b(shogi)h(has)g(a)g(small)f(but)g(fanatical)330 +3331 y(follo)m(wing,)29 b(some)i(of)f(whom)g(consider)f(it)h(b)s(etter) +h(than)f(mo)s(dern)f(shogi.)199 3470 y(4.)61 b(Dai)40 +b(\(great\))h(shogi,)h(pla)m(y)m(ed)d(on)h(a)f(15x15)j(b)s(oard)c(with) +g(130)j(pieces.)68 b(Other)39 b(than)h(the)f(larger)330 +3580 y(b)s(oard,)30 b(this)f(game)i(is)f(v)m(ery)g(similar)e(to)j(Ch)m +(u)f(shogi.)199 3718 y(5.)61 b(T)-8 b(enjiku)26 b(\(exotic\))j(shogi,)e +(pla)m(y)m(ed)g(on)h(a)f(16x16)i(b)s(oard)e(with)f(176)i(pieces.)40 +b(This)25 b(game)j(is)f(p)s(ossibly)330 3828 y(the)35 +b(most)g(complex)f(tactical)i(game)g(in)d(existence.)54 +b(There)35 b(are)g(man)m(y)g(astoundingly)d(p)s(o)m(w)m(erful)330 +3938 y(pieces,)c(including)c(one)k(\(the)g(Fire)f(Demon\))i(that)f(can) +g(capture)f(up)g(to)h(eigh)m(t)g(opp)s(osing)e(pieces)h(in)330 +4047 y(a)j(single)e(mo)m(v)m(e!)42 b(Despite)30 b(the)f(size)h(of)g +(the)f(game,)i(c)m(hec)m(kmates)h(can)e(o)s(ccur)f(v)m(ery)h(suddenly)d +(\(and)330 4157 y(often)34 b(v)m(ery)h(early)f(on\))g(if)f(one)h(pla)m +(y)m(er)g(mak)m(es)h(a)g(wrong)e(mo)m(v)m(e.)53 b(T)-8 +b(enjiku)33 b(also)h(has)g(a)g(small)f(but)330 4266 y(fanatical)27 +b(follo)m(wing,)f(one)h(of)g(whom)f(\(Colin)g(Adams\))h(has)f(written)g +(a)h(b)s(o)s(ok)g(on)f(the)h(game)h(whic)m(h)330 4376 +y(is)h(a)m(v)-5 b(ailable)30 b(for)g(do)m(wnload)g(at)h +Fg(http://www.colina.demon.)o(co.u)o(k/te)o(nji)o(ku.h)o(tml)o +Fj(.)199 4515 y(6.)61 b(Dai-dai)39 b(\(great-great\))k(shogi,)e(pla)m +(y)m(ed)e(on)g(a)h(17x17)h(b)s(oard)d(with)g(192)j(pieces.)67 +b(The)38 b(op)s(ening)330 4624 y(setup)29 b(alone)g(has)h(64)g +(di\013eren)m(t)f(kinds)e(of)j(pieces!)40 b(This)28 b(game)i(and)f(the) +h(larger)f(ones)h(that)g(follo)m(w)330 4734 y(sound)35 +b(prett)m(y)j(outlandish,)e(but)g(they)h(ha)m(v)m(e)h(actually)e(b)s +(een)g(pla)m(y)m(ed;)k(a)d(game)h(of)e(Dai-dai)h(can)330 +4843 y(supp)s(osedly)28 b(b)s(e)h(pla)m(y)m(ed)i(in)e(ab)s(out)h(12)h +(hours.)199 4982 y(7.)61 b(Mak)-5 b(a-dai-dai)33 b +(\(great-great-great\))k(shogi,)c(pla)m(y)m(ed)g(on)g(a)g(19x19)h(b)s +(oard)e(with)f(192)j(pieces.)47 b(F)-8 b(or)330 5092 +y(those)31 b(for)f(whom)g(Dai-dai)g(shogi)f(is)h(just)g(to)s(o)h(small) +e(:-\))199 5230 y(8.)61 b(T)-8 b(ai)35 b(\(grand\))g(shogi,)h(pla)m(y)m +(ed)f(on)g(a)h(25x25)h(b)s(oard)d(with)g(377)i(pieces!)55 +b(Un)m(til)34 b(recen)m(tly)-8 b(,)38 b(this)c(w)m(as)330 +5340 y(though)m(t)d(to)g(b)s(e)f(the)g(biggest)h(c)m(hess)g(game)g(ev)m +(er)g(devised,)f(but)f(no)m(w)i(there)f(is...)p eop +%%Page: 24 26 +24 25 bop 150 -116 a Fj(24)2734 b(GNU)31 b(Shogi)f(man)m(ual)199 +299 y(9.)61 b(Ky)m(oku)36 b(tai)g(\(extremely)h(grand?\))57 +b(shogi,)37 b(pla)m(y)m(ed)f(on)g(a)g(36x36)i(b)s(oard)d(with)g(402)i +(pieces.)57 b(The)330 408 y(rules)22 b(for)g(this)g(ha)m(v)m(e)j(just)d +(b)s(een)h(unearthed)f(in)g(an)h(old)f(Japanese)h(b)s(o)s(ok.)38 +b(Hop)s(efully)21 b(someone)j(will)330 518 y(so)s(on)36 +b(organize)h(a)f(p)s(ostal)g(Ky)m(oku)g(tai)g(shogi)g(c)m(hampionship;) +h(ma)m(yb)s(e)f(their)f(distan)m(t)h(ancestors)330 628 +y(could)29 b(\014nish)f(it)i(:-\))330 768 y(It)40 b(is)g(though)m(t)h +(that)f(the)h(really)e(h)m(uge)i(games)g(\(Dai-dai)f(and)g(up\))f(w)m +(ere)i(nev)m(er)g(really)e(pla)m(y)m(ed)330 877 y(to)k(an)m(y)f +(signi\014can)m(t)f(exten)m(t)i(\(gee,)j(w)m(onder)c(wh)m(y?\))75 +b(and)41 b(w)m(ere)h(devised)f(merely)g(so)h(that)h(the)330 +987 y(creators)38 b(could)e(ha)m(v)m(e)j(the)e(fun)f(of)h(in)m(v)m(en)m +(ting)g(enormous)g(games,)j(amazing)d(their)g(friends)e(and)330 +1096 y(confounding)27 b(their)h(enemies.)40 b(Ho)m(w)m(ev)m(er,)32 +b(the)d(games)h(up)d(to)j(T)-8 b(enjiku)28 b(shogi)g(at)i(least)f(app)s +(ear)f(to)330 1206 y(b)s(e)i(quite)g(pla)m(y)m(able,)g(assuming)f(one)h +(has)h(the)f(time.)150 1521 y Fk(2.5)68 b(Di\013erences)46 +b(b)t(et)l(w)l(een)g(shogi)g(and)f(c)l(hess)275 1725 +y Fj(Some)22 b(di\013erences)g(b)s(et)m(w)m(een)h(shogi)f(and)g(in)m +(ternational)g(c)m(hess)h(ha)m(v)m(e)g(b)s(een)f(men)m(tioned)g +(elsewhere)g(in)150 1834 y(this)h(do)s(cumen)m(t;)j(I)e(summarize)f +(them)h(here)f(for)h(p)s(eople)f(who)h(are)g(in)m(terested)g(in)f(game) +i(comparisons.)37 b(I)150 1944 y(w)m(on't)27 b(try)g(to)g(deal)g(with)e +(the)i(thorn)m(y)f(question)g(of)h(whic)m(h)f(game)h(is)f(\\b)s(etter") +i(although)e(m)m(y)h(bias)e(ma)m(y)150 2053 y(ha)m(v)m(e)37 +b(already)e(come)h(through)f(:-\))h(In)f(fact,)j(the)d(drop)g(rule)f +(mak)m(es)i(the)g(t)m(w)m(o)g(games)h(so)e(di\013eren)m(t)g(in)150 +2163 y(c)m(haracter)28 b(that)g(arguing)e(o)m(v)m(er)i(whic)m(h)d(game) +j(is)e(b)s(etter)h(is)f(lik)m(e)g(comparing)g(apples)g(to)h(oranges)g +(\(y)m(ou'd)150 2273 y(b)s(e)43 b(b)s(etter)g(o\013)h(comparing)f(c)m +(hess)g(to)i(Ch)m(u)d(shogi)h(\(see)h(Section)f(2.4)i([Shogi)d(v)-5 +b(arian)m(ts],)47 b(page)d(23\).)150 2382 y(Ho)m(w)m(ev)m(er,)39 +b(I)c(b)s(eliev)m(e)f(that)i(if)e(y)m(ou)i(are)g(a)f(c)m(hess)h(fan)f +(y)m(ou'll)g(really)f(lik)m(e)g(shogi)h(as)h(w)m(ell,)f(and)g(shogi)g +(is)150 2492 y(also)30 b(p)s(opular)e(with)i(man)m(y)g(p)s(eople)f(who) +h(don't)h(particularly)d(lik)m(e)h(c)m(hess.)275 2637 +y(Here)h(are)h(the)g(signi\014can)m(t)e(di\013erences)h(b)s(et)m(w)m +(een)h(c)m(hess)g(and)e(shogi:)199 2856 y(1.)61 b(In)26 +b(shogi,)i(captured)f(pieces)g(b)s(ecome)g(the)g(prop)s(ert)m(y)g(of)g +(the)g(capturer)g(and)g(can)g(re-en)m(ter)h(pla)m(y)f(b)m(y)330 +2966 y(b)s(eing)h(dropp)s(ed)f(on)m(to)j(almost)g(an)m(y)f(v)-5 +b(acan)m(t)31 b(square.)40 b(In)28 b(c)m(hess,)i(captured)f(pieces)g +(are)h(out)f(of)h(the)330 3076 y(game.)45 b(Th)m(us,)32 +b(in)e(shogi,)h(piece)h(exc)m(hanges)h(complicate)f(the)g(pla)m(y)f +(signi\014can)m(tly)f(while)f(in)h(c)m(hess)330 3185 +y(they)h(simplify)26 b(it.)199 3325 y(2.)61 b(The)30 +b(shogi)g(b)s(oard)f(is)g(9x9;)j(the)e(c)m(hess)h(b)s(oard)f(is)f(8x8.) +199 3465 y(3.)61 b(Shogi)37 b(has)g(\014v)m(e)h(pieces)g(with)e(no)i +(coun)m(terpart)g(in)f(c)m(hess:)56 b(the)38 b(gold)f(and)g(silv)m(er)g +(generals,)j(the)330 3575 y(lance,)47 b(the)d(promoted)g(ro)s(ok)g(and) +f(the)h(promoted)g(bishop.)79 b(Chess)43 b(has)h(one)g(piece)g(with)e +(no)330 3684 y(coun)m(terpart)33 b(in)f(shogi:)45 b(the)33 +b(queen.)48 b(The)33 b(knigh)m(t's)f(mo)m(v)m(e)i(in)e(shogi)g(is)g(m)m +(uc)m(h)h(more)g(restrictiv)m(e)330 3794 y(than)f(in)f(c)m(hess.)46 +b(Pieces)32 b(in)f(shogi)g(generally)g(ha)m(v)m(e)j(a)e(m)m(uc)m(h)g +(smaller)f(range)h(of)g(mo)m(v)m(emen)m(t)i(than)330 +3903 y(in)29 b(c)m(hess)i(\(unless)e(they)h(are)h(in)e(hand\).)199 +4043 y(4.)61 b(In)30 b(shogi,)h(all)f(pieces)h(except)g(the)h(gold)e +(general)h(and)f(the)i(king)e(can)h(promote,)h(but)e(only)g(to)i(one) +330 4153 y(kind)c(of)i(piece.)41 b(Promotion)29 b(is)g(easier)h(in)e +(shogi)i(b)s(ecause)g(the)g(promotion)f(zone)h(is)f(closer)h(to)h(the) +330 4263 y(starting)25 b(p)s(osition)e(of)i(the)g(pieces)f(\(esp)s +(ecially)g(pa)m(wns\).)39 b(In)24 b(c)m(hess,)i(only)e(the)i(pa)m(wn)e +(can)h(promote,)330 4372 y(but)30 b(it)g(can)g(promote)h(to)g(an)m(y)g +(other)g(piece)f(except)h(the)g(king.)199 4512 y(5.)61 +b(In)32 b(shogi,)g(pa)m(wns)g(capture)h(the)f(same)h(w)m(a)m(y)g(they)g +(mo)m(v)m(e.)48 b(There)32 b(is)g(no)g(initial)e(t)m(w)m(o-space)k(pa)m +(wn)330 4622 y(mo)m(v)m(e)42 b(and)e(hence)h(no)f Fd(en-p)-5 +b(assant)51 b Fj(captures.)71 b(In)40 b(c)m(hess,)k(pa)m(wns)c(capture) +g(diagonally)f(whic)m(h)330 4731 y(means)30 b(that)h(opp)s(osing)e(pa)m +(wns)h(can)g(blo)s(c)m(k)g(eac)m(h)i(other.)199 4871 +y(6.)61 b(In)25 b(shogi,)i(y)m(ou)g(only)e(ha)m(v)m(e)j(one)e(ro)s(ok)g +(and)g(one)g(bishop.)38 b(Note)27 b(that)g(the)f(bishop)f(is)g(not)h +(restricted)330 4981 y(to)36 b(only)e(one)h(\\color")i(square)d +(\(squares)h(in)f(shogi)h(aren't)g(colored,)i(but)d(nev)m(er)i(mind\))d +(b)s(ecause)330 5090 y(promoted)d(bishops)f(can)h(also)h(mo)m(v)m(e)g +(one)g(square)f(orthogonally)-8 b(.)199 5230 y(7.)61 +b(There)26 b(is)g(no)g(sp)s(ecial)f(castling)h(mo)m(v)m(e)i(in)d +(shogi.)39 b(The)26 b(term)h(\\castle")h(is)d(used)h(in)f(shogi)h(to)h +(denote)330 5340 y(a)42 b(defensiv)m(e)g(formation)g(consisting)f(of)h +(\(usually\))e(three)j(generals)e(whic)m(h)g(protect)i(the)g(king.)p +eop +%%Page: 25 27 +25 26 bop 150 -116 a Fj(Chapter)30 b(2:)41 b(Ab)s(out)30 +b(the)g(game)i(of)e(shogi)2061 b(25)330 299 y(There)38 +b(are)g(man)m(y)h(suc)m(h)f(castles)h(\(ab)s(out)f(40)h(or)f(so)h(ha)m +(v)m(e)g(names\).)65 b(See)38 b(Section)h(2.2)g([Sample)330 +408 y(game],)32 b(page)f(19.)199 543 y(8.)61 b(Dra)m(ws)26 +b(are)f(m)m(uc)m(h)g(rarer)g(in)f(shogi)g(than)h(in)f(c)m(hess.)40 +b(P)m(erp)s(etual)24 b(c)m(hec)m(k)j(is)d(not)h(allo)m(w)m(ed.)39 +b(Stalemate)330 653 y(is)29 b(a)i(virtual)e(imp)s(ossibilit)m(y)-8 +b(,)26 b(and)k(is)g(a)g(loss)g(for)g(the)h(stalematee.)199 +787 y(9.)61 b(Since)33 b(pieces)h(are)g(nev)m(er)g(out)g(of)g(pla)m(y)g +(in)f(shogi,)h(c)m(hess-t)m(yp)s(e)h(endgames)f(in)m(v)m(olving)f(only) +g(a)h(few)330 897 y(pieces)c(do)g(not)h(o)s(ccur.)154 +1031 y(10.)61 b(Shogi)29 b(games)j(are)e(generally)g(longer)g(than)g(c) +m(hess)h(games)g(\(ab)s(out)g(60-70)h(mo)m(v)m(es)g(is)d(t)m(ypical\).) +154 1166 y(11.)61 b(Shogi)29 b(has)i(a)f(w)m(ell-dev)m(elop)s(ed)f +(handicap)g(system)i(whic)m(h)e(is)g(in)g(general)i(use;)f(c)m(hess)h +(do)s(es)f(not.)275 1435 y(The)f(e\013ects)j(of)f(all)e(these)i +(di\013erences)e(on)i(pla)m(y)f(include)e(\(in)h(m)m(y)i(opinion\):)199 +1654 y(1.)61 b(Piece/pa)m(wn)34 b(structures)f(in)f(c)m(hess)i(are)h +(more)e(rigid)f(than)h(in)g(shogi.)50 b(P)m(a)m(wns)34 +b(blo)s(c)m(k)f(eac)m(h)i(other)330 1763 y(and)22 b(pa)m(wns,)i(once)g +(adv)-5 b(anced,)25 b(cannot)e(ev)m(er)h(retreat.)39 +b(In)22 b(shogi,)i(y)m(ou)g(can)f(repair)e(the)i(hole)g(caused)330 +1873 y(b)m(y)32 b(a)h(pa)m(wn)g(adv)-5 b(ance)33 b(b)m(y)f(exc)m +(hanging)h(the)g(pa)m(wn)f(and)g(dropping)e(it)i(bac)m(k)i(where)e(y)m +(ou)h(w)m(an)m(t)g(it.)330 1983 y(Th)m(us)c(shogi)h(is)g(more)g +(\015uid)e(than)i(c)m(hess)h(and)f(less)g(\\structural".)199 +2117 y(2.)61 b(Coun)m(terattac)m(k)39 b(is)d(MUCH)h(more)f(common)h(in) +f(shogi)g(than)g(in)g(c)m(hess.)60 b(Games)37 b(t)m(ypically)f(end)330 +2227 y(in)e(m)m(utual)h(mating)g(attac)m(ks,)40 b(where)35 +b(eac)m(h)i(pla)m(y)m(er)e(is)g(trying)g(to)h(c)m(hec)m(kmate)i(the)e +(other)g(pla)m(y)m(er)330 2336 y(b)s(efore)k(b)s(eing)f(c)m(hec)m +(kmated)k(himself.)69 b(This)38 b(mak)m(es)k(temp)s(o)e(incredibly)d +(imp)s(ortan)m(t)j(and)g(also)330 2446 y(mak)m(es)31 +b(sacri\014cial)e(pla)m(y)h(quite)g(common.)199 2580 +y(3.)61 b(A)m(ttac)m(ks)43 b(in)m(v)m(olving)c(only)g(ranging)g(pieces) +i(are)f(more)h(a)f(feature)h(of)g(c)m(hess)f(than)g(of)h(shogi.)70 +b(A)330 2690 y(shogi)39 b(attac)m(k)j(t)m(ypically)c(uses)h(a)h +(ranging)f(piece)g(or)h(pieces)f(to)h(supp)s(ort)e(an)i(attac)m(k)i(b)m +(y)d(short-)330 2800 y(range)c(pieces)e(\(esp)s(ecially)g(generals\).) +53 b(It)34 b(is)f(v)m(ery)i(rare)f(to)h(mate)g(a)f(king)f(with)g(a)i +(non-adjacen)m(t)330 2909 y(ranging)40 b(piece)h(in)f(shogi)h(since)g +(the)g(pla)m(y)m(er)g(whose)g(king)g(is)f(threatened)i(can)f(almost)g +(alw)m(a)m(ys)330 3019 y(in)m(terp)s(ose)30 b(b)m(y)g(dropping)e(a)j +(piece.)p eop +%%Page: 26 28 +26 27 bop 150 -116 a Fj(26)2734 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Page: 27 29 +27 28 bop 150 -116 a Fj(Chapter)30 b(3:)41 b(gn)m(ushogi)2697 +b(27)150 299 y Fh(3)80 b(gn)l(ushogi)275 500 y Fj(This)28 +b(section)j(describ)s(es)d(ho)m(w)j(to)g(run)e(the)h(\\gn)m(ushogi")h +(program.)275 737 y(SYNOPSIS)275 975 y(gn)m(ushogi)d([)i([[-]a])h([-b)f +(b)s(o)s(ok\014le])e([-B)j(bin)m(b)s(o)s(ok\014le])c([-C])j([-h)f +(lang\014le])g([-L)h(lang\014le])e([-r)i(length])f([-R])150 +1084 y([-s)i(pathname])f([-l)g(pathname])h([-S)f(bin)m(b)s(o)s(oksize]) +f([-t])i([-c)h(size])e([-T)h(size])f([-v])h([-x])g([-X])h(arg1)f(arg2)g +(])275 1322 y(DESCRIPTION)275 1559 y(GNU)26 b(shogi)g(\(gn)m(ushogi\))h +(pla)m(ys)e(a)i(game)g(of)g(japanese)f(c)m(hess)h(\(shogi\))g(against)f +(the)h(user)e(or)i(it)e(pla)m(ys)150 1669 y(against)31 +b(itself.)275 1797 y(A)m(t)h(startup)f(gn)m(ushogi)g(reads)g(the)h(bin) +m(b)s(o)s(ok)e(\014le)g(if)h(it)g(is)f(presen)m(t.)45 +b(It)31 b(then)g(lo)s(oks)g(for)h(a)g(b)s(o)s(ok)f(\014le.)150 +1906 y(If)c(it)g(is)f(presen)m(t)h(it)g(adds)f(its)h(con)m(ten)m(ts)i +(to)f(the)f(bin)m(b)s(o)s(ok)f(data.)40 b(If)27 b(the)g(bin)m(b)s(o)s +(ok)f(\014le)g(is)g(writable)g(a)h(new)150 2016 y(com)m(bined)j(bin)m +(b)s(o)s(ok)e(\014le)i(is)f(written.)275 2144 y(Gn)m(ushogi)j(is)g(a)h +(mo)s(di\014ed)e(v)m(ersion)h(of)h(the)g(gn)m(uc)m(hess)h(program.)48 +b(It)33 b(has)g(a)g(simple)e(alphan)m(umeric)150 2253 +y(b)s(oard)g(displa)m(y)-8 b(,)31 b(or)h(it)f(can)h(b)s(e)g(used)f +(with)f(the)i(xshogi)f(program)h(under)e(X)i(windo)m(ws.)44 +b(The)31 b(program)150 2363 y(gets)j(its)e(op)s(ening)f(mo)m(v)m(es)j +(from)e(the)h(\014le)f(gn)m(ushogi.bbk)g(whic)m(h)f(is)h(lo)s(cated)h +(in)e(a)i(directory)g(sp)s(eci\014ed)150 2473 y(in)c(the)i(Mak)m +(e\014le.)41 b(T)-8 b(o)31 b(in)m(v)m(ok)m(e)g(the)g(program)f(t)m(yp)s +(e:)150 2710 y(`)p Fg(gnushogi)e(-C)p Fj(')630 2820 y(simple)g(curses)i +(based)g(v)m(ersion)150 2966 y(`)p Fg(gnushogi)e(-X)i(\(or)g(just)f +(gnushogi\))p Fj(')630 3075 y(xshogi)h(compatible)f(v)m(ersion)150 +3222 y(`)p Fg(gnushogi)f(-R)p Fj(')630 3331 y(ra)m(w)i(test)i(displa)m +(y)c(v)m(ersion)275 3587 y(TIME)i(CONTR)m(OLS)275 3824 +y(If)23 b(one)h(argumen)m(t)h(is)e(giv)m(en,)j(it)d(is)g(the)h(searc)m +(h)h(time)f(p)s(er)f(mo)m(v)m(e)i(in)e([min)m(utes:]seconds.)39 +b(So)24 b(gn)m(ushogi)150 3934 y(30)f(will)c(generate)k(one)f(mo)m(v)m +(e)h(ev)m(ery)g(30)g(seconds,)g(while)d(gn)m(ushogi)h(5:00)i(will)d +(generate)j(one)f(mo)m(v)m(e)h(ev)m(ery)150 4044 y(5)31 +b(min)m(utes.)275 4172 y(If)h(t)m(w)m(o)j(or)e(more)h(argumen)m(ts)g +(are)f(giv)m(en,)i(they)e(will)e(b)s(e)h(used)h(to)h(set)g(tournamen)m +(t)g(time)f(con)m(trols)150 4281 y(with)f(the)h(\014rst)f(argumen)m(t)i +(of)f(eac)m(h)h(pair)e(b)s(eing)f(the)i(n)m(um)m(b)s(er)f(of)h(mo)m(v)m +(es)i(and)d(the)h(second)g(b)s(eing)f(the)150 4391 y(total)e(clo)s(c)m +(k)g(time)f(in)g(min)m(utes[:seconds].)40 b(Th)m(us,)29 +b(en)m(tering)g(gn)m(ushogi)g(60)h(5)g(will)d(set)j(the)g(clo)s(c)m(ks) +f(for)h(5)150 4500 y(min)m(utes)d(\(300)i(seconds\))e(for)h(the)f +(\014rst)g(60)h(mo)m(v)m(es,)i(and)d(gn)m(ushogi)g(30)h(3:30)h(will)c +(allo)m(w)i(3)h(min)m(utes)f(and)150 4610 y(30)k(seconds)g(for)f(30)h +(mo)m(v)m(es.)275 4738 y(gn)m(ushogi)h(30)h(5)g(1)g(:30)h(will)29 +b(allo)m(w)k(5)g(min)m(utes)e(for)i(the)f(\014rst)g(30)i(mo)m(v)m(es)f +(and)f(30)i(seconds)e(for)h(eac)m(h)150 4847 y(mo)m(v)m(e)f(after)f +(that.)41 b(Up)30 b(to)h(4)g(pairs)e(of)h(con)m(trols)h(ma)m(y)g(b)s(e) +f(sp)s(eci\014ed.)275 4975 y(If)f(no)i(argumen)m(t)g(is)e(giv)m(en)h +(the)h(program)f(will)e(prompt)h(the)i(user)e(for)i(lev)m(el)f(of)g +(pla)m(y)-8 b(.)275 5103 y(F)g(or)37 b(use)g(with)f(xshogi)h(see)h(the) +f(do)s(cumen)m(tation)g(on)g(that)h(program.)61 b(See)38 +b(Chapter)e(4)i([xshogi],)150 5213 y(page)31 b(33.)p +eop +%%Page: 28 30 +28 29 bop 150 -116 a Fj(28)2734 b(GNU)31 b(Shogi)f(man)m(ual)275 +299 y(BOOK)275 541 y(The)36 b(b)s(o)s(ok)g(gn)m(ushogi.tbk)h(consists)f +(of)h(a)g(sequence)h(of)f(op)s(enings.)59 b(An)36 b(op)s(ening)g(b)s +(egins)f(with)h(a)150 650 y(line)25 b(starting)h(with)f(a)i(#)g(\(the)g +(rest)f(of)h(the)g(line)e(is)g(a)i(commen)m(t\).)41 b(F)-8 +b(ollo)m(wing)26 b(this)g(is)f(a)i(series)f(of)h(mo)m(v)m(es)150 +760 y(in)33 b(algebraic)h(notation)g(alternating)g(blac)m(k)g(and)g +(white)f(separated)i(b)m(y)f(white)f(space.)53 b(A)35 +b(mo)m(v)m(e)g(ma)m(y)150 870 y(ha)m(v)m(e)j(a)f(?)59 +b(after)38 b(it)e(indicating)f(this)g(mo)m(v)m(e)j(should)d(nev)m(er)i +(b)s(e)f(made)h(in)e(this)h(p)s(osition.)58 b(Mo)m(v)m(es)39 +b(are)150 979 y(stored)30 b(as)h(p)s(osition:mo)m(v)m(e)f(so)h(transp)s +(ositions)d(b)s(et)m(w)m(een)j(op)s(enings)e(can)i(tak)m(e)g(place.)275 +1221 y(HASHFILE)275 1463 y(The)37 b(hash\014le)f(if)g(created)j(should) +c(b)s(e)i(on)h(the)g(order)f(of)g(4)h(megab)m(ytes;)43 +b(y)m(ou)38 b(can)g(create)h(suc)m(h)f(a)150 1573 y(hash\014le)h(b)m(y) +h(t)m(yping)g(\\gn)m(ushogi)h(-c)g(22")g(\(see)h(b)s(elo)m(w\).)70 +b(This)39 b(\014le)h(con)m(tains)g(p)s(ositions)f(and)h(mo)m(v)m(es)150 +1682 y(learned)25 b(from)g(previous)g(games.)40 b(If)25 +b(a)i(hash\014le)d(is)h(used)g(the)h(computer)g(mak)m(es)h(use)e(of)h +(the)h(exp)s(erience)150 1792 y(it)h(gained)f(in)g(past)h(games.)40 +b(T)-8 b(ests)29 b(run)d(so)j(far)e(sho)m(w)h(that)h(it)e(pla)m(ys)h +(no)g(w)m(orse)g(with)f(the)h(hash\014le)e(than)150 1902 +y(without,)k(but)f(it)h(is)g(not)g(clear)h(y)m(et)g(whether)f(it)g(pro) +m(vides)f(a)i(real)f(adv)-5 b(an)m(tage.)275 2144 y(LEGAL)30 +b(MO)m(VES)275 2386 y(Note:)54 b(Piece)37 b(letters)f(are)h(determined) +f(b)m(y)g(the)h(language)g(\014le.)58 b(What)37 b(is)f(sp)s(eci\014ed)f +(here)h(is)g(the)150 2495 y(default)30 b(\(English\).)275 +2628 y(Once)44 b(gn)m(ushogi)f(is)g(in)m(v)m(ok)m(ed,)48 +b(the)d(program)f(will)d(displa)m(y)h(the)j(b)s(oard)e(and)g(prompt)g +(the)i(user)150 2737 y(for)d(a)h(mo)m(v)m(e.)78 b(T)-8 +b(o)43 b(en)m(ter)g(a)f(mo)m(v)m(e,)47 b(use)42 b(the)h(notation)f +(7g7f)i(where)d(the)i(\014rst)f(letter-n)m(um)m(b)s(er)f(pair)150 +2847 y(indicates)j(the)g(origin)f(square)i(and)f(the)h(second)f +(letter-n)m(um)m(b)s(er)g(pair)g(indicates)f(the)i(destination)150 +2956 y(square.)k(An)33 b(alternativ)m(e)g(is)f(to)i(use)f(the)g +(notation)h(P7f)f(where)f(the)i(\014rst)e(letter)i(indicates)e(the)h +(piece)150 3066 y(t)m(yp)s(e)c(\(P)-8 b(,L,N,S,G,B,R,K\).)32 +b(T)-8 b(o)29 b(promote)h(app)s(end)d(a)i Fg(+)g Fj(the)g(t)m(yp)s(e)g +(of)g(the)h(new)e(piece)h(to)h(the)f(mo)m(v)m(e,)i(as)150 +3176 y(in)e(2d2c)p Fg(+)i Fj(or)f(P2c)p Fg(+)p Fj(.)41 +b(Note)32 b(that)f(y)m(ou)g(m)m(ust)f(use)g(capital)g(letters)h(for)f +(the)g(pieces)g(b)m(y)h(default.)275 3418 y(COMMAND-LINE)g(OPTIONS)150 +3660 y(`)p Fg(-a)p Fj(')334 b(Do)31 b(not)g(searc)m(h)g(on)f(opp)s +(onen)m(t's)g(time.)150 3815 y(`)p Fg(a)p Fj(')382 b(Do)31 +b(searc)m(h)g(on)f(opp)s(onen)m(t's)h(time.)150 3970 +y(`)p Fg(-b)f Ff(b)s(o)s(ok\014le)5 b Fj(')630 4080 y(Use)31 +b(b)s(o)s(ok\014le)e(for)h(op)s(ening)f(b)s(o)s(ok.)150 +4235 y(`)p Fg(-B)h Ff(bin)m(b)s(o)s(ok\014le)5 b Fj(')630 +4345 y(Use)31 b(bin)m(b)s(o)s(ok\014le)c(for)k(binary)d(op)s(ening)h(b) +s(o)s(ok.)150 4500 y(`)p Fg(-c)h Ff(size)5 b Fj(')157 +b(Create)46 b(a)f(new)f(HASHFILE.)h(File)f(size)g(is)g(2)p +Fg(^)p Fj(size)h(en)m(tries)f(of)h(appro)m(ximately)f(65)p +Fg(+)p Fj(?)630 4609 y(b)m(ytes.)150 4765 y(`)p Fg(-C)p +Fj(')334 b(Use)31 b(curses-based)f(displa)m(y)e(mo)s(de.)150 +4920 y(`)p Fg(-h)p Fj(')334 b(Do)31 b(not)g(use)f(hash\014le.)150 +5075 y(`)p Fg(h)p Fj(')382 b(Do)31 b(use)f(hash\014le.)150 +5230 y(`)p Fg(-l)g Ff(pathname)5 b Fj(')630 5340 y(P)m(athname)31 +b(of)g(the)f(load\014le)f(used)h(with)f(get)i(or)g(xget.)p +eop +%%Page: 29 31 +29 30 bop 150 -116 a Fj(Chapter)30 b(3:)41 b(gn)m(ushogi)2697 +b(29)150 299 y(`)p Fg(-L)30 b Ff(lang)8 b Fj(')129 b(Use)31 +b(language)h(lang)e(from)h(the)g(\014le)f(gn)m(ushogi.lang.)42 +b(If)30 b(-L)h(is)f(not)h(sp)s(eci\014ed)f(it)g(uses)h(the)630 +408 y(\014rst)f(language)g(in)f(the)i(\014le.)150 567 +y(`)p Fg(-P)f Ff(plylev)m(els)t Fj(')630 676 y(Num)m(b)s(er)f(of)i +(plys)e(to)i(include)d(in)h(the)i(bin)m(b)s(o)s(ok\014le.)38 +b(F)-8 b(or)31 b(generating)f(a)h(bin)m(b)s(o)s(ok\014le.)150 +835 y(`)p Fg(-r)f Ff(length)p Fj(')630 944 y(Rehash)g +Fd(length)38 b Fj(times)30 b(in)f(searc)m(hing)h(en)m(tries)g(for)g(p)s +(osition)f(in)g(transp)s(osition)f(table.)150 1103 y(`)p +Fg(-R)p Fj(')334 b(Use)26 b(ra)m(w)g(text)g(displa)m(y)e(mo)s(de.)39 +b(This)23 b(can)j(b)s(e)f(used)g(for)g(dum)m(b)f(terminals)g(or)i(for)f +(systems)630 1212 y(that)31 b(don't)f(ha)m(v)m(e)i(curses.)150 +1370 y(`)p Fg(-s)e Ff(pathname)5 b Fj(')630 1480 y(P)m(athname)31 +b(of)g(the)f(sa)m(v)m(e)i(\014le)e(to)h(use)f(with)f(the)h(sa)m(v)m(e)i +(command.)150 1638 y(`)p Fg(-S)e Ff(size)5 b Fj(')157 +b(Size)30 b(of)g(bin)m(b)s(o)s(ok\014le)e(for)i(memory)g(based)g(b)s(o) +s(oks.)40 b(F)-8 b(or)32 b(creating)e(a)h(bin)m(b)s(o)s(ok\014le.)150 +1797 y(`)p Fg(-t)p Fj(')334 b(Sho)m(w)30 b(statistics)g(for)g +(HASHFILE.)150 1955 y(`)p Fg(-T)g Ff(size)5 b Fj(')157 +b(Set)31 b(the)f(transp)s(osition)e(table)j(size)f(to)h(2)p +Fg(^)p Fj(size)f(en)m(tries.)150 2113 y(`)p Fg(-v)p Fj(')334 +b(Sho)m(w)30 b(v)m(ersion)g(and)g(patc)m(hlev)m(el.)150 +2271 y(`)p Fg(-x)g Ff(v)-5 b(alue)5 b Fj(')94 b(Use)31 +b(v)-5 b(alue)30 b(as)g(the)h(ev)-5 b(aluation)30 b(windo)m(w)e(xwndw.) +150 2430 y(`)p Fg(-X)p Fj(')334 b(Use)31 b(xshogi)f(displa)m(y)e(mo)s +(de)i(\(the)h(default\).)275 2698 y(COMMANDS)275 2941 +y(In)42 b(addition)f(to)j(legal)f(mo)m(v)m(es,)48 b(the)43 +b(follo)m(wing)e(commands)i(can)g(b)s(e)g(en)m(tered)g(at)h(the)g(gn)m +(ushogi)150 3051 y(prompt.)39 b(Note:)h(command)26 b(names)g(are)h +(determined)e(b)m(y)h(the)h(language)g(\014le)e(and)h(ma)m(y)h(v)-5 +b(ary)27 b(with)e(the)150 3160 y(implemen)m(tation.)39 +b(The)30 b(default)g(language)h(is)e(English.)150 3319 +y(`)p Fg(alg)p Fj(')286 b(allo)m(w)30 b(algebraic)g(input)e(\(not)j +(implemen)m(ted\).)150 3477 y(`)p Fg(Awindow)p Fj(')94 +b(c)m(hange)32 b(Alpha)d(windo)m(w)g(\(default)g(score)i +Fg(+)f Fj(90\).)150 3635 y(`)p Fg(Bwindow)p Fj(')94 b(c)m(hange)32 +b(Beta)f(windo)m(w)e(\(default)h(score)h(-)g(90\).)150 +3794 y(`)p Fg(beep)p Fj(')238 b(toggles)32 b(b)s(eeping)c(after)j(eac)m +(h)h(mo)m(v)m(e)g(\(default:)40 b(on\).)150 3952 y(`)p +Fg(bd)p Fj(')334 b(up)s(dates)29 b(the)i(curren)m(t)f(b)s(oard)f(p)s +(osition)g(on)h(the)h(displa)m(y)-8 b(.)150 4110 y(`)p +Fg(book)p Fj(')238 b(turns)29 b(o\013)i(use)f(of)h(the)f(op)s(ening)f +(library)-8 b(.)150 4268 y(`)p Fg(both)p Fj(')238 b(causes)31 +b(the)f(computer)h(to)g(pla)m(y)f(b)s(oth)f(sides)h(of)g(a)h(shogi)f +(game.)150 4427 y(`)p Fg(black)p Fj(')190 b(causes)31 +b(the)f(computer)h(to)g(tak)m(e)h(the)e(white)g(pieces,)g(if)f(the)i +(computer)f(is)g(to)h(mo)m(v)m(e)h(\014rst.)150 4585 +y(`)p Fg(bsave)p Fj(')190 b(sa)m(v)m(es)33 b(a)f(game)g(to)g(disk)e(as) +i(a)g(b)s(o)s(ok)e(text\014le.)44 b(The)31 b(program)h(will)c(prompt)j +(the)g(user)g(for)630 4695 y(a)g(\014le)e(name.)150 4853 +y(`)p Fg(gamein)p Fj(')142 b(toggles)36 b(game)g(mo)s(de)f(time)g(con)m +(trol.)55 b(Assumes)34 b(the)i(time)f(sp)s(eci\014ed)e(for)i(time)f +(con)m(trol)630 4963 y(is)d(the)h(time)f(for)g(a)h(complete)g(game.)46 +b(Input)30 b(with)h(the)g(lev)m(el)h(command)f(should)f(b)s(e)h(the)630 +5072 y(game)36 b(time)f(and)g(the)g(exp)s(ected)h(n)m(um)m(b)s(er)e(of) +h(mo)m(v)m(es)i(in)d(a)i(game.)56 b(go)36 b(command)f(m)m(ust)630 +5182 y(b)s(e)30 b(giv)m(en.)150 5340 y(`)p Fg(coords)p +Fj(')142 b(sho)m(w)30 b(co)s(ordinates)g(on)h(the)f(displa)m(y)f +(\(visual)g(only\).)p eop +%%Page: 30 32 +30 31 bop 150 -116 a Fj(30)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(`)p Fg(contempt)p Fj(')630 408 y(allo)m(ws)g(the)g(v)-5 +b(alue)30 b(of)h Fd(c)-5 b(ontempt)40 b Fj(to)31 b(b)s(e)f(mo)s +(di\014ed.)150 565 y(`)p Fg(debug)p Fj(')190 b(asks)33 +b(for)g(a)h(piece)f(as)g(color)g(piece,)h(as)f(wb)g(or)g(bn,)g(and)f +(sho)m(ws)h(its)f(calculated)h(v)-5 b(alue)33 b(on)630 +674 y(eac)m(h)f(square.)150 830 y(`)p Fg(debuglevel)p +Fj(')630 940 y(sets)f(lev)m(el)f(of)g(debugging)g(output)g(if)f +(compiled)g(with)g(debug)h(options.)150 1096 y(`)p Fg(depth)p +Fj(')190 b(allo)m(ws)41 b(the)h(user)f(to)h(c)m(hange)h(the)f(searc)m +(h)g(depth)f(of)h(the)g(program.)74 b(The)41 b(maxim)m(um)630 +1205 y(depth)32 b(is)f(29)i(ply)-8 b(.)46 b(Normally)31 +b(the)i(depth)e(is)g(set)i(to)g(29)h(and)d(the)i(computer)f(terminates) +630 1315 y(its)23 b(searc)m(h)h(based)f(on)h(elapsed)f(time)g(rather)h +(than)f(depth.)38 b(If)23 b(depth)g(is)f(set)i(to)h(\(sa)m(y\))g(4)f +(ply)-8 b(,)630 1425 y(the)28 b(program)g(will)d(searc)m(h)j(un)m(til)e +(all)h(mo)m(v)m(es)i(ha)m(v)m(e)g(b)s(een)e(examined)g(to)i(a)f(depth)f +(of)h(4)g(ply)630 1534 y(\(with)g(extensions)h(up)f(to)i(11)g +(additional)d(ply)h(for)h(sequences)g(of)g(c)m(hec)m(ks)i(and)d +(captures\).)630 1644 y(If)38 b(y)m(ou)h(set)g(a)g(maxim)m(um)f(time)g +(p)s(er)g(mo)m(v)m(e)i(and)e(also)h(use)f(the)h(depth)f(command,)j(the) +630 1753 y(searc)m(h)36 b(will)c(stop)j(at)h(the)f(sp)s(eci\014ed)e +(time)i(or)g(the)g(sp)s(eci\014ed)e(depth,)j(whic)m(hev)m(er)e(comes) +630 1863 y(\014rst.)150 2019 y(`)p Fg(easy)p Fj(')238 +b(toggles)28 b(easy)f(mo)s(de)f(\(thinking)e(on)i(opp)s(onen)m(ts)g +(time\))h(on)f(and)g(o\013.)39 b(The)26 b(default)g(is)f(easy)630 +2129 y(mo)s(de)34 b(ON.)h(If)f(easy)h(mo)s(de)f(is)f(disabled,)h(the)g +(k)m(eyb)s(oard)h(is)e(p)s(olled)g(for)h(input)e(ev)m(ery)k(so)630 +2238 y(often)22 b(and)f(when)g(input)f(is)g(seen)i(the)g(searc)m(h)g +(is)f(terminated.)38 b(It)21 b(ma)m(y)i(also)e(b)s(e)g(terminated)630 +2348 y(with)29 b(a)i(sigin)m(t.)150 2504 y(`)p Fg(edit)p +Fj(')238 b(allo)m(ws)30 b(the)g(user)g(to)h(set)g(up)e(a)i(b)s(oard)e +(p)s(osition.)679 2637 y Fi(\000)60 b Fj(#)30 b(clear)g(the)h(b)s +(oard.)679 2770 y Fi(\000)60 b Fj(c)31 b(toggle)g(piece)g(color.)679 +2902 y Fi(\000)60 b Fj(.)41 b(command)30 b(will)e(exit)i(setup)g(mo)s +(de.)679 3035 y Fi(\000)60 b Fj(p3b)30 b(place)g(a)h(pa)m(wn)f(on)g(3b) +679 3168 y Fi(\000)60 b Fj(p3b)p Fg(+)29 b Fj(place)i(a)g(promoted)f +(pa)m(wn)g(on)g(3b)679 3301 y Fi(\000)60 b Fj(p*)30 b(place)h(a)f(pa)m +(wn)g(in)f(hand)h(\(among)h(the)f(captured)g(pieces\))630 +3457 y(Pieces)35 b(are)h(en)m(tered)f(b)m(y)g(t)m(yping)g(a)g(letter)g +(\(p,l,n,s,g,b,r,k\))g(for)g(the)g(piece)g(follo)m(w)m(ed)g(b)m(y)630 +3567 y(the)c(co)s(ordinate.)40 b(Here,)31 b(letter)g(case)g(is)f +(ignored.)630 3699 y(The)g(usual)f(w)m(arning)g(ab)s(out)h(the)h +(language)f(\014le)g(applies.)150 3856 y(`)p Fg(exit)p +Fj(')238 b(exits)30 b(gn)m(ushogi.)150 4012 y(`)p Fg(first)p +Fj(')190 b(tells)27 b(the)h(computer)f(to)i(mo)m(v)m(e)g(\014rst.)39 +b(Computer)27 b(b)s(egins)g(searc)m(hing)g(for)h(a)g(mo)m(v)m(e.)41 +b(\(same)630 4121 y(as)31 b(\\go"\).)150 4277 y(`)p Fg(force)p +Fj(')190 b(allo)m(ws)28 b(the)i(user)e(to)i(en)m(ter)g(mo)m(v)m(es)g +(for)f(b)s(oth)g(sides.)39 b(T)-8 b(o)29 b(get)i(the)e(program)g(to)h +(pla)m(y)e(after)630 4387 y(a)j(sequence)g(of)f(mo)m(v)m(es)i(has)e(b)s +(een)g(en)m(tered)g(use)h(the)f(\\blac)m(k")h(or)g(\\white")f +(commands.)150 4543 y(`)p Fg(get)p Fj(')286 b(retriev)m(es)31 +b(a)f(game)i(from)e(disk.)39 b(The)30 b(program)g(will)e(prompt)h(the)i +(user)e(for)i(a)f(\014le)g(name.)150 4699 y(`)p Fg(go)p +Fj(')334 b(tells)27 b(the)h(computer)f(to)i(mo)m(v)m(e)g(\014rst.)39 +b(Computer)27 b(b)s(egins)g(searc)m(hing)g(for)h(a)g(mo)m(v)m(e.)41 +b(\(same)630 4809 y(as)31 b(\\\014rst"\).)150 4965 y(`)p +Fg(hash)p Fj(')238 b(use/don't)31 b(use)f(hash\014le.)150 +5121 y(`)p Fg(hashdepth)p Fj(')630 5230 y(allo)m(ws)38 +b(the)g(user)g(to)h(c)m(hange)g(the)f(minim)m(um)e(depth)h(for)h(using) +f(the)h(hash\014le)f(and)h(the)630 5340 y(n)m(um)m(b)s(er)29 +b(of)i(mo)m(v)m(es)g(from)f(the)h(b)s(eginning)c(of)k(the)g(game)g(to)g +(use)f(it.)p eop +%%Page: 31 33 +31 32 bop 150 -116 a Fj(Chapter)30 b(3:)41 b(gn)m(ushogi)2697 +b(31)150 299 y(`)p Fg(help)p Fj(')238 b(displa)m(ys)25 +b(a)i(short)f(description)f(of)i(the)g(commands)f(and)g(the)h(curren)m +(t)f(status)i(of)e(options.)150 458 y(`)p Fg(hint)p Fj(')238 +b(causes)31 b(the)f(program)g(to)i(supply)c(the)i(user)g(with)f(its)h +(predicted)f(mo)m(v)m(e.)150 617 y(`)p Fg(level)p Fj(')190 +b(allo)m(ws)28 b(the)h(user)f(to)h(set)g(time)g(con)m(trols)g(suc)m(h)f +(as)h(60)h(mo)m(v)m(es)f(in)f(5)h(min)m(utes)f(etc.)41 +b(In)28 b(tour-)630 726 y(namen)m(t)f(mo)s(de,)h(the)f(program)g(will)d +(v)-5 b(ary)27 b(the)g(time)g(it)g(tak)m(es)h(for)f(eac)m(h)h(mo)m(v)m +(e)g(dep)s(ending)630 836 y(on)39 b(the)g(situation.)64 +b(If)39 b(easy)g(mo)s(de)f(is)g(disabled)f(\(using)g(the)i(\\easy")i +(command\),)g(the)630 945 y(program)28 b(will)d(often)j(resp)s(ond)e +(with)h(its)g(mo)m(v)m(e)j(immediately)-8 b(,)27 b(sa)m(ving)h(time)f +(on)h(its)g(clo)s(c)m(k)630 1055 y(for)i(use)g(later)h(on.)150 +1214 y(`)p Fg(list)p Fj(')238 b(writes)27 b(the)h(game)i(mo)m(v)m(es)f +(and)f(some)g(statistics)g(on)g(searc)m(h)h(depth,)f(no)s(des,)g(and)f +(time)h(to)630 1324 y(the)j(\014le)e(\\shogi.lst".)150 +1482 y(`)p Fg(material)p Fj(')630 1592 y(toggle)j(material)e(\015ag)g +(-)h(dra)m(ws)f(on)g(no)g(pa)m(wns)g(and)g(b)s(oth)f(sides)h +Fg(<)g Fj(ro)s(ok.)150 1751 y(`)p Fg(new)p Fj(')286 b(starts)31 +b(a)g(new)e(game.)150 1910 y(`)p Fg(p)p Fj(')382 b(ev)-5 +b(aluates)34 b(the)f(b)s(oard)f(and)h(sho)m(ws)g(the)h(p)s(oin)m(t)e +(score)i(for)f(eac)m(h)h(piece.)49 b(The)33 b(total)h(score)630 +2019 y(for)c(a)h(p)s(osition)d(is)i(the)g(sum)g(of)g(these)h +(individual)26 b(piece)k(scores.)150 2178 y(`)p Fg(post)p +Fj(')238 b(causes)31 b(the)h(program)e(to)i(displa)m(y)d(the)j +(principal)27 b(v)-5 b(ariation)31 b(and)f(the)h(score)h(during)d(the) +630 2288 y(searc)m(h.)41 b(A)31 b(score)g(of)f(100)i(is)d(equiv)-5 +b(alen)m(t)30 b(to)h(a)g(1)g(pa)m(wn)f(adv)-5 b(an)m(tage)32 +b(for)e(the)h(computer.)150 2447 y(`)p Fg(quit)p Fj(')238 +b(exits)30 b(the)h(game.)150 2606 y(`)p Fg(random)p Fj(')142 +b(causes)31 b(the)f(program)g(to)i(randomize)d(its)h(mo)m(v)m(e)i +(selection)e(sligh)m(tly)-8 b(.)150 2765 y(`)p Fg(rcptr)p +Fj(')190 b(set)31 b(recapture)f(mo)s(de.)150 2924 y(`)p +Fg(remove)p Fj(')142 b(bac)m(k)m(out)32 b(the)e(last)h(lev)m(el)f(for)g +(b)s(oth)g(sides.)39 b(Equal)29 b(to)j(2)e(undo's.)150 +3082 y(`)p Fg(reverse)p Fj(')94 b(causes)41 b(the)g(b)s(oard)f(displa)m +(y)f(to)j(b)s(e)e(rev)m(ersed.)72 b(That)41 b(is,)h(the)f(blac)m(k)g +(pieces)g(will)d(no)m(w)630 3192 y(app)s(ear)30 b(at)h(the)f(top)h(of)g +(the)f(b)s(oard.)150 3351 y(`)p Fg(rv)p Fj(')334 b(rev)m(erse)31 +b(b)s(oard)e(displa)m(y)-8 b(.)150 3510 y(`)p Fg(save)p +Fj(')238 b(sa)m(v)m(es)32 b(a)f(game)g(to)g(disk.)39 +b(The)30 b(program)g(will)e(prompt)i(the)g(user)g(for)g(a)h(\014le)e +(name.)150 3669 y(`)p Fg(switch)p Fj(')142 b(causes)31 +b(the)f(program)g(to)i(switc)m(h)d(places)i(with)e(the)h(opp)s(onen)m +(t)g(and)g(b)s(egin)f(searc)m(hing.)150 3828 y(`)p Fg(test)p +Fj(')238 b(p)s(erforms)52 b(some)i(sp)s(eed)e(tests)j(for)e(Mo)m(v)m +(eList)i(and)e(CaptureList)f(generation,)60 b(and)630 +3937 y(ScoreP)m(osition)30 b(p)s(osition)f(scoring)g(for)i(the)f +(curren)m(t)g(b)s(oard.)150 4096 y(`)p Fg(time)p Fj(')238 +b(set)28 b(computer's)g(time)f(remaining,)g(in)m(tended)f(for)h(sync)m +(hronizing)f(clo)s(c)m(ks)i(among)g(m)m(ulti-)630 4206 +y(ple)h(pla)m(y)m(ers.)150 4365 y(`)p Fg(tsume)p Fj(')190 +b(toggle)35 b(tsume)e(mo)s(de.)50 b(In)33 b(tsume)h(mo)s(de,)g(not)g +(all)f(p)s(ossible)e(mo)m(v)m(es)k(will)c(b)s(e)i(generated.)630 +4474 y(If)f(a)i(king)e(is)f(in)h(c)m(hec)m(k,)j(only)d(mo)m(v)m(es)i +(that)g(get)g(the)f(king)f(out)h(of)g(c)m(hec)m(k)h(are)g(generated.) +630 4584 y(If)f(the)h(king)e(is)h(not)h(in)e(c)m(hec)m(k,)k(only)d(mo)m +(v)m(es)h(that)h(giv)m(e)f(c)m(hec)m(k)h(to)f(the)g(opp)s(onen)m(t's)f +(king)630 4693 y(are)e(generated.)150 4852 y(`)p Fg(undo)p +Fj(')238 b(undo)s(es)29 b(the)h(last)g(mo)m(v)m(e)h(whether)f(it)f(w)m +(as)i(the)f(computer's)g(or)g(the)g(h)m(uman's.)40 b(Y)-8 +b(ou)30 b(ma)m(y)630 4962 y(also)i(t)m(yp)s(e)g(\\remo)m(v)m(e".)47 +b(This)30 b(is)g(equiv)-5 b(alen)m(t)31 b(to)i(t)m(w)m(o)g(\\undo"'s)f +(\(e.g.)46 b(retract)32 b(one)g(mo)m(v)m(e)630 5071 y(for)e(eac)m(h)i +(side\).)150 5230 y(`)p Fg(white)p Fj(')190 b(causes)34 +b(the)h(computer)e(to)i(tak)m(e)h(the)e(blac)m(k)g(pieces,)h(if)e(the)h +(computer)g(is)f(to)h(mo)m(v)m(e)i(\014rst)630 5340 y(the)31 +b(go)g(command)f(m)m(ust)g(b)s(e)g(giv)m(en.)p eop +%%Page: 32 34 +32 33 bop 150 -116 a Fj(32)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(`)p Fg(xget)p Fj(')238 b(read)30 b(an)h(xshogi)e(p)s(osition)g +(\014le.)150 458 y(`)p Fg(xsave)p Fj(')190 b(sa)m(v)m(e)32 +b(as)f(an)f(xshogi)g(p)s(osition)e(\014le.)150 618 y(`)p +Fg(xwndw)p Fj(')190 b(c)m(hange)32 b(X)e(windo)m(w.)39 +b(The)30 b(windo)m(w)f(around)g(alpha/b)s(eta)h(used)g(to)h(determine)f +(whether)630 727 y(the)k(p)s(osition)d(should)h(b)s(e)h(scored)g(or)h +(just)f(estimated.)50 b(Note:)f(this)32 b(has)h Fd(nothing)43 +b Fj(to)34 b(do)630 837 y(with)29 b(xshogi)h(or)g(X)h(windo)m(ws;)e +(the)h(terms)g(are)h(completely)f(separate.)p eop +%%Page: 33 35 +33 34 bop 150 -116 a Fj(Chapter)30 b(4:)41 b(xshogi)2793 +b(33)150 299 y Fh(4)80 b(xshogi)275 508 y Fj(This)28 +b(section)j(describ)s(es)d(ho)m(w)j(to)g(run)e(the)h(\\xshogi")h +(program.)275 747 y(SYNOPSIS)275 986 y(xshogi)e([)i(options)f(])275 +1225 y(DESCRIPTION)275 1465 y(xshogi)36 b(pro)m(vides)g(an)i(X11/Xt/A)m +(thena)i(Widgets)e(user)e(in)m(terface)i(for)f(gn)m(ushogi.)61 +b(With)36 b(xshogi)150 1574 y(y)m(ou)29 b(can)f(pla)m(y)g(gn)m(ushogi,) +g(set)h(up)f(arbitrary)f(p)s(ositions,)g(force)h(v)-5 +b(ariations,)28 b(or)h(w)m(atc)m(h)g(xshogi)f(manage)150 +1684 y(a)k(game)h(b)s(et)m(w)m(een)g(t)m(w)m(o)h(shogi)d(programs.)45 +b(F)-8 b(urthermore,)33 b(it)f(can)g(b)s(e)f(used)g(as)i(an)f(in)m +(terface)g(b)s(et)m(w)m(een)150 1793 y(t)m(w)m(o)g(pla)m(y)m(ers)e(on)g +(di\013eren)m(t)g(displa)m(ys.)275 1923 y(xshogi)d(can)h(also)g(b)s(e)f +(used)g(as)h(a)g(shogi)g(b)s(oard)f(to)h(pla)m(y)g(out)g(games.)41 +b(It)28 b(will)d(read)j(through)f(a)h(game)150 2032 y(\014le)j(or)g +(allo)m(w)g(a)h(pla)m(y)m(er)f(to)h(pla)m(y)f(through)g(a)h(v)-5 +b(ariation)30 b(man)m(ually)g(\(force)j(mo)s(de\).)43 +b(This)30 b(is)h(useful)e(for)150 2142 y(k)m(eeping)h(trac)m(k)i(of)e +(email)g(p)s(ostal)g(games)h(or)f(bro)m(wsing)f(games)i(o\013)g(the)g +(net.)275 2271 y(After)e(starting)g(xshogi,)f(y)m(ou)i(can)f(mak)m(e)h +(mo)m(v)m(es)g(b)m(y)f(pressing)f(mouse)g(button)h(1)g(while)e(the)j +(cursor)150 2381 y(is)36 b(o)m(v)m(er)i(a)f(square)g(with)f(y)m(our)h +(piece)f(on)h(it)g(and)f(dragging)h(the)g(mouse)f(to)i(another)f +(square.)60 b(If)37 b(the)150 2491 y(mo)m(v)m(e)32 b(is)d(illegal,)g +(gn)m(ushogi)h(will)e(not)i(allo)m(w)g(it.)40 b(xshogi)30 +b(will)e(then)i(retract)h(the)g(mo)m(v)m(e.)275 2730 +y(COMMAND-LINE)g(OPTIONS)275 2969 y(The)f(follo)m(wing)e(command)j +(line)e(options)g(also)i(corresp)s(ond)e(to)i(X)g(resources)f(that)i(y) +m(ou)e(can)h(set)g(in)150 3078 y(y)m(our)f(.Xdefaults)g(\014le.)150 +3318 y(`)p Fg([standard)e(Xt)i(options])p Fj(')630 3427 +y(xshogi)g(accepts)h(standard)f(Xt)h(options)f(lik)m(e)f(-displa)m(y)-8 +b(,)30 b(-geometry)-8 b(,)32 b(and)e(-iconic.)150 3577 +y(`)p Fg(-tc)g(or)f(-timeControl)f(minutes[:seconds])p +Fj(')630 3686 y(Amoun)m(t)42 b(of)g(time)g(for)f(a)h(set)h(of)f(mo)m(v) +m(es)h(determined)d(b)m(y)i(mo)m(v)m(esP)m(erSession.)76 +b(If)41 b(this)630 3796 y(n)m(um)m(b)s(er)e(of)h(mo)m(v)m(es)h(is)e +(pla)m(y)m(ed)h(within)d(the)j(time)g(con)m(trol)g(p)s(erio)s(d,)g +(xshogi)f(resets)i(the)630 3905 y(time)30 b(clo)s(c)m(ks.)41 +b(Default:)g(5)31 b(min)m(utes.)150 4055 y(`)p Fg(-mps)e(or)h +(-movesPerSession)c(moves)p Fj(')630 4164 y(Num)m(b)s(er)j(of)i(mo)m(v) +m(es)h(in)d(a)h(time)g(con)m(trol)h(p)s(erio)s(d.)39 +b(Default:)h(40)32 b(mo)m(v)m(es.)150 4314 y(`)p Fg(-st)e(or)f +(-searchTime)f(minutes[:seconds])p Fj(')630 4423 y(T)-8 +b(ell)30 b(gn)m(ushogi)g(to)i(sp)s(end)d(at)j(most)f(the)h(giv)m(en)f +(amoun)m(t)g(of)g(time)g(searc)m(hing)g(for)g(eac)m(h)h(of)630 +4533 y(its)f(mo)m(v)m(es.)46 b(Without)32 b(this)e(option,)i(gn)m +(ushogi)f(c)m(ho)s(oses)i(its)e(searc)m(h)h(time)g(based)f(on)h(the)630 +4643 y(n)m(um)m(b)s(er)k(of)i(mo)m(v)m(es)h(and)f(amoun)m(t)g(of)g +(time)f(remaining)f(un)m(til)g(the)i(next)g(time)f(con)m(trol.)630 +4752 y(Setting)30 b(this)f(option)h(also)h(sets)f(-clo)s(c)m(kMo)s(de)i +(to)f(F)-8 b(alse.)150 4902 y(`)p Fg(-sd)30 b(or)f(-searchDepth)f +(number)p Fj(')630 5011 y(T)-8 b(ell)26 b(gn)m(ushogi)g(to)i(lo)s(ok)f +(ahead)g(at)h(most)f(the)g(giv)m(en)g(n)m(um)m(b)s(er)f(of)h(mo)m(v)m +(es)h(when)e(searc)m(hing)630 5121 y(for)37 b(a)h(mo)m(v)m(e)i(to)e +(mak)m(e.)64 b(Without)37 b(this)g(option,)i(gn)m(ushogi)e(c)m(ho)s +(oses)h(its)f(searc)m(h)i(depth)630 5230 y(based)e(on)g(the)h(n)m(um)m +(b)s(er)e(of)h(mo)m(v)m(es)i(and)e(amoun)m(t)h(of)f(time)g(remaining)f +(un)m(til)f(the)j(next)630 5340 y(time)30 b(con)m(trol.)41 +b(Setting)30 b(this)g(option)f(also)i(sets)g(-clo)s(c)m(kMo)s(de)g(to)g +(F)-8 b(alse.)p eop +%%Page: 34 36 +34 35 bop 150 -116 a Fj(34)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(`)p Fg(-clock)f(or)h(-clockMode)d(\(True)i(|)h(False\))p +Fj(')630 408 y(Determines)36 b(whether)f(or)h(not)g(to)h(use)e(the)h +(clo)s(c)m(k.)58 b(If)36 b(clo)s(c)m(kMo)s(de)g(is)f(F)-8 +b(alse,)38 b(the)f(clo)s(c)m(k)630 518 y(do)s(es)30 b(not)h(run,)e(but) +h(the)g(side)f(that)i(is)f(to)h(pla)m(y)f(next)g(is)g(still)e(highligh) +m(ted.)150 667 y(`)p Fg(-td)i(or)f(-timeDelay)f(seconds)p +Fj(')630 777 y(Time)37 b(dela)m(y)h(b)s(et)m(w)m(een)g(mo)m(v)m(es)h +(during)d(\\Load)i(Game".)64 b(This)36 b(do)s(esn't)i(ha)m(v)m(e)h(to)f +(b)s(e)g(a)630 887 y(round)29 b(n)m(um)m(b)s(er.)39 b(T)-8 +b(ry)30 b(-td)h(0.4.)42 b(Default:)e(1)31 b(second.)150 +1036 y(`)p Fg(-nsp)e(or)h(-noShogiProgram)c(\(True)j(|)h(False\))p +Fj(')630 1146 y(If)k(this)f(option)h(is)f(T)-8 b(rue,)35 +b(xshogi)f(acts)i(as)e(a)h(passiv)m(e)f(shogi)g(b)s(oard;)h(it)f(do)s +(es)g(not)h(try)f(to)630 1255 y(start)h(a)g(shogi)e(program,)j(not)e +(ev)m(en)i(to)f(c)m(hec)m(k)h(whether)d(mo)m(v)m(es)j(made)e(in)f(F)-8 +b(orce)36 b(mo)s(de)630 1365 y(are)31 b(legal.)40 b(It)31 +b(also)f(sets)h(-clo)s(c)m(kMo)s(de)g(to)g(F)-8 b(alse.)42 +b(Default:)f(F)-8 b(alse.)150 1514 y(`)p Fg(-fsp)29 b(or)h +(-firstShogiProgram)c(program)p Fj(')630 1624 y(Name)33 +b(of)f(\014rst)f(shogi)g(program.)45 b(In)31 b(matc)m(hes)i(b)s(et)m(w) +m(een)g(t)m(w)m(o)g(mac)m(hines,)f(this)f(program)630 +1733 y(pla)m(ys)f(white.)40 b(Default:)h(\\gn)m(ushogi".)150 +1883 y(`)p Fg(-ssp)29 b(or)h(-secondShogiProgram)25 b(program)p +Fj(')630 1993 y(Name)34 b(of)g(second)g(shogi)f(program,)i(if)d +(needed.)51 b(In)33 b(matc)m(hes)i(b)s(et)m(w)m(een)f(t)m(w)m(o)h(mac)m +(hines,)630 2102 y(this)29 b(program)h(pla)m(ys)g(blac)m(k;)h +(otherwise)f(it)g(is)f(not)i(started.)41 b(Default:)g(\\gn)m(ushogi".) +150 2252 y(`)p Fg(-fh)30 b(or)f(-firstHost)f(host)p Fj(')630 +2361 y(Name)j(of)g(host)f(the)h(\014rst)e(shogi)h(program)g(pla)m(ys)g +(on.)41 b(Default:)g(\\lo)s(calhost".)150 2511 y(`)p +Fg(-sh)30 b(or)f(-secondHost)f(host)p Fj(')630 2620 y(Name)j(of)g(host) +f(the)h(second)f(shogi)g(program)g(pla)m(ys)g(on.)41 +b(Default:)f(\\lo)s(calhost".)150 2770 y(`)p Fg(-rsh)29 +b(or)h(-remoteShell)d(shell_name)p Fj(')630 2879 y(Some)k(systems)h(do) +f(not)h(use)f(rsh)f(as)i(the)g(remote)g(shell.)42 b(This)30 +b(option)h(allo)m(ws)g(a)g(user)g(to)630 2989 y(name)f(the)h(remote)g +(shell)e(command.)40 b(This)29 b(should)f(b)s(e)i(done)g(in)f(the)i +(resource)f(\014le.)150 3138 y(`)p Fg(-mm)g(or)f(-matchMode)f(\(False)h +(|)h(Init)f(|)h(Position)e(|)i(Opening\))p Fj(')630 3248 +y(Automatically)46 b(run)f(a)i(game)g(b)s(et)m(w)m(een)h +(\014rstShogiProgram)d(and)g(secondShogiPro-)630 3357 +y(gram.)52 b(If)33 b(matc)m(hMo)s(de)j(is)d(set)h(to)h(Init,)f(xshogi)g +(will)d(start)j(the)h(game)g(with)d(the)j(initial)630 +3467 y(shogi)26 b(p)s(osition.)38 b(If)26 b(matc)m(hMo)s(de)h(is)f(set) +h(to)g(P)m(osition,)g(xshogi)f(will)e(start)j(the)g(game)g(with)630 +3577 y(the)k(p)s(osition)e(sp)s(eci\014ed)g(b)m(y)i(the)g(loadP)m +(ositionFile)e(resource.)42 b(If)30 b(matc)m(hMo)s(de)i(is)e(set)h(to) +630 3686 y(Op)s(ening,)22 b(xshogi)h(will)d(pla)m(y)j(out)g(the)g(op)s +(ening)e(mo)m(v)m(es)k(sp)s(eci\014ed)c(b)m(y)i(the)g(-loadGameFile)630 +3796 y(resource.)40 b(If)26 b(the)i(-sa)m(v)m(eGameFile)h(resource)e +(is)f(set,)j(a)e(mo)m(v)m(e)i(record)e(for)f(the)i(matc)m(h)g(will)630 +3905 y(b)s(e)i(sa)m(v)m(ed)h(in)e(the)i(sp)s(eci\014ed)d(\014le.)40 +b(Default:)h(\\F)-8 b(alse".)150 4055 y(`)p Fg(-lgf)29 +b(or)h(-loadGameFile)d(file)p Fj(')630 4164 y(Name)j(of)f(\014le)g(to)h +(read)f(a)g(game)h(record)g(from.)39 b(Game)31 b(\014les)d(are)h(found) +f(in)g(the)h(directory)630 4274 y(named)h(b)m(y)f(the)i(SHOGIDIR)e(en)m +(vironmen)m(t)h(v)-5 b(ariable.)39 b(If)30 b(this)f(v)-5 +b(ariable)29 b(is)g(not)h(set,)h(the)630 4384 y(curren)m(t)f(directory) +g(is)f(used)h(unless)f(the)h(\014le)g(name)g(starts)h(with)e(a)i(/.)150 +4533 y(`)p Fg(-lpf)e(or)h(-loadPositionFile)c(file)p +Fj(')630 4643 y(Name)44 b(of)g(\014le)f(to)h(read)g(a)g(game)h(p)s +(osition)c(from.)80 b(P)m(osition)43 b(\014les)g(are)h(found)e(in)h +(the)630 4752 y(directory)38 b(named)g(b)m(y)g(the)g(SHOGIDIR)g(en)m +(vironmen)m(t)g(v)-5 b(ariable.)63 b(If)38 b(this)f(v)-5 +b(ariable)37 b(is)630 4862 y(not)31 b(set,)g(the)f(curren)m(t)h +(directory)e(is)h(used)f(unless)g(the)i(\014le)e(name)i(starts)f(with)f +(a)i(/.)150 5011 y(`)p Fg(-sgf)e(or)h(-saveGameFile)d(file)p +Fj(')630 5121 y(Name)37 b(of)g(\014le)e(to)j(sa)m(v)m(e)g(a)f(game)g +(record)g(to.)59 b(Game)38 b(\014les)d(are)i(sa)m(v)m(ed)h(in)d(the)h +(directory)630 5230 y(named)30 b(b)m(y)f(the)i(SHOGIDIR)e(en)m +(vironmen)m(t)h(v)-5 b(ariable.)39 b(If)30 b(this)f(v)-5 +b(ariable)29 b(is)g(not)h(set,)h(the)630 5340 y(curren)m(t)f(directory) +g(is)f(used)h(unless)f(the)h(\014le)g(name)g(starts)h(with)e(a)i(/.)p +eop +%%Page: 35 37 +35 36 bop 150 -116 a Fj(Chapter)30 b(4:)41 b(xshogi)2793 +b(35)150 299 y(`)p Fg(-spf)29 b(or)h(-savePositionFile)c(file)p +Fj(')630 408 y(Name)h(of)g(\014le)f(to)h(sa)m(v)m(e)h(a)f(game)h(p)s +(osition)d(to.)40 b(P)m(osition)26 b(\014les)g(are)h(sa)m(v)m(ed)g(in)f +(the)g(directory)630 518 y(named)k(b)m(y)f(the)i(SHOGIDIR)e(en)m +(vironmen)m(t)h(v)-5 b(ariable.)39 b(If)30 b(this)f(v)-5 +b(ariable)29 b(is)g(not)h(set,)h(the)630 628 y(curren)m(t)f(directory)g +(is)f(used)h(unless)f(the)h(\014le)g(name)g(starts)h(with)e(a)i(/.)150 +787 y(`)p Fg(-coords)e(or)g(-showCoords)f(\(True)h(|)h(False\))p +Fj(')630 897 y(If)35 b(this)f(option)h(is)f(T)-8 b(rue,)36 +b(xshogi)f(displa)m(ys)e(algebraic)i(co)s(ordinates)g(along)g(the)h(b)s +(oard's)630 1006 y(left)d(and)g(b)s(ottom)g(edges.)50 +b(The)33 b(default)f(is)g(F)-8 b(alse.)50 b(The)33 b(co)s(ordF)-8 +b(on)m(t)35 b(resource)e(sp)s(eci\014es)630 1116 y(what)d(fon)m(t)h(to) +g(use.)150 1275 y(`)p Fg(-mono)e(or)h(-monoMode)e(\(True)h(|)h(False\)) +p Fj(')630 1385 y(Determines)36 b(whether)f(xshogi)g(displa)m(ys)f(its) +h(pieces)h(and)f(squares)g(with)g(t)m(w)m(o)i(colors)f(or)630 +1494 y(four.)42 b(Y)-8 b(ou)31 b(shouldn't)e(ha)m(v)m(e)j(to)g(sp)s +(ecify)e(mono)s(c)m(hrome.)42 b(xshogi)31 b(will)d(determine)i(if)g +(this)630 1604 y(is)f(necessary)-8 b(.)150 1763 y(`)p +Fg(-wpc)29 b(or)h(-blackPieceColor)c(color)p Fj(')630 +1873 y(Color)37 b(sp)s(eci\014cation)g(for)g(blac)m(k)h(pieces)f +(suitable)g(for)g(XP)m(arseColor\(3X11\).)66 b(Default:)630 +1983 y(#FFFF)m(CC.)24 b(These)f(colors)g(lo)s(ok)g(go)s(o)s(d)g(on)g(a) +h(DEC)f(w)m(orkstation.)38 b(If)23 b(y)m(ou)h(need)e(di\013eren)m(t)630 +2092 y(colors,)28 b(try)g(using)e(the)h(xcolors)h(application.)38 +b(Source)27 b(for)g(xcolors)h(can)g(b)s(e)e(found)h(in)f(the)630 +2202 y(X11)31 b(con)m(trib)f(directory)-8 b(.)150 2361 +y(`)p Fg(-bpc)29 b(or)h(-whitePieceColor)c(color)p Fj(')630 +2471 y(Same)k(for)h(white)e(pieces.)41 b(Default:)f(#202020.)150 +2630 y(`)p Fg(-lsc)29 b(or)h(-lightSquareColor)c(color)p +Fj(')630 2740 y(Same)k(for)h(ligh)m(t)e(squares.)40 b(Default:)h +(#C8C365.)150 2899 y(`)p Fg(-dsc)29 b(or)h(-darkSquareColor)c(color)p +Fj(')630 3009 y(Same)k(for)h(dark)e(squares.)41 b(Default:)g(#77A26D.) +150 3168 y(`)p Fg(-wps)29 b(or)h(-westernPieceSet)c(\(True)j(|)h +(False\))p Fj(')630 3278 y(Cho)s(ose)g(the)h(W)-8 b(estern)31 +b(st)m(yle)g(piece)f(set.)150 3437 y(`)p Fg(-npb)f(or)h +(-normalPawnBitmap)c(file)p Fj(')150 3572 y(`)p Fg(-nnb)j(or)h +(-normalKnightBitmap)25 b(file)p Fj(')150 3706 y(`)p +Fg(-nbb)k(or)h(-normalBishopBitmap)25 b(file)p Fj(')150 +3841 y(`)p Fg(-nrb)k(or)h(-normalRookBitmap)c(file)p +Fj(')150 3975 y(`)p Fg(-nkb)j(or)h(-normalKingBitmap)c(file)p +Fj(')630 4085 y(Names)31 b(of)f(the)h(bitmap)e(\014les)h(for)g(the)g +(bitmap)f(piece)i(icons.)150 4244 y(`)p Fg(-rpb)e(or)h +(-reversePawnBitmap)c(file)p Fj(')150 4379 y(`)p Fg(-rnb)j(or)h +(-reverseKnightBitmap)25 b(file)p Fj(')150 4513 y(`)p +Fg(-rbb)k(or)h(-reverseBishopBitmap)25 b(file)p Fj(')150 +4648 y(`)p Fg(-rrb)k(or)h(-reverseRookBitmap)c(file)p +Fj(')150 4782 y(`)p Fg(-rkb)j(or)h(-reverseKingBitmap)c(file)p +Fj(')630 4892 y(Names)31 b(of)f(the)h(bitmap)e(\014les)h(for)g(the)g +(outline)f(piece)i(icons.)150 5051 y(`)p Fg(-debug)e(or)h(-debugMode)d +(\(True)i(|)h(False\))p Fj(')630 5161 y(T)-8 b(urns)29 +b(on)h(debugging)f(prin)m(tout.)p eop +%%Page: 36 38 +36 37 bop 150 -116 a Fj(36)2734 b(GNU)31 b(Shogi)f(man)m(ual)275 +299 y(OTHER)f(X)i(RESOUR)m(CES)150 542 y(`)p Fg(initString)p +Fj(')630 652 y(The)k(actual)h(string)f(that)h(is)f(sen)m(t)h(to)g +(initialize)d(the)j(shogi)f(program)g(can)h(b)s(e)f(set)h(from)630 +762 y(.Xdefaults.)k(It)29 b(can't)h(b)s(e)e(set)i(from)f(the)g(command) +g(line)e(b)s(ecause)i(of)h(syn)m(tax)f(problems.)630 +871 y(The)j(default)g(v)-5 b(alue)32 b(is)g(\\new)p Fg(\\)p +Fj(n)m(b)s(eep)p Fg(\\)p Fj(nrandom)p Fg(\\)p Fj(neasy)p +Fg(\\)p Fj(n".)45 b(The)32 b(\\new")i(and)e(\\b)s(eep")630 +981 y(commands)i(are)g(required.)51 b(Y)-8 b(ou)35 b(can)f(remo)m(v)m +(e)i(the)e(\\random")h(command)f(if)f(y)m(ou)h(lik)m(e;)630 +1090 y(including)28 b(it)j(causes)g(gn)m(ushogi)g(to)h(randomize)e(its) +h(mo)m(v)m(e)i(selection)e(sligh)m(tly)e(so)j(that)f(it)630 +1200 y(do)s(esn't)c(pla)m(y)g(the)h(same)g(mo)m(v)m(es)g(in)e(ev)m(ery) +i(game.)41 b(Ev)m(en)28 b(without)e(\\random",)j(gn)m(ushogi)630 +1310 y(randomizes)38 b(its)g(c)m(hoice)h(of)g(mo)m(v)m(es)h(from)e(its) +f(op)s(ening)h(b)s(o)s(ok.)64 b(Y)-8 b(ou)39 b(can)g(also)f(remo)m(v)m +(e)630 1419 y(\\easy")30 b(if)d(y)m(ou)i(lik)m(e;)f(including)d(it)j +(toggles)h(easy)g(mo)s(de)f(o\013,)h(causing)f(gn)m(ushogi)f(to)i +(think)630 1529 y(on)d(y)m(our)g(time.)39 b(That)25 b(is,)i(if)e +(\\easy")i(is)e(included)e(in)i(the)h(initString,)e(GNU)j(Shogi)e +(thinks)630 1638 y(on)33 b(y)m(our)h(time;)h(if)d(not,)j(it)e(do)s(es)g +(not.)50 b(\(Y)-8 b(es,)36 b(this)c(do)s(es)h(seem)h(bac)m(kw)m(ards,)h +(do)s(esn't)e(it.\))630 1748 y(Y)-8 b(ou)39 b(can)f(also)g(try)g +(adding)f(other)h(commands)g(to)h(the)f(initString;)h(see)g(the)g(gn)m +(ushogi)630 1857 y(do)s(cumen)m(tation)30 b(\(see)i(Chapter)d(3)i([gn)m +(ushogi],)g(page)g(27\))g(for)f(details.)150 2016 y(`)p +Fg(blackString)e(and)h(whiteString)p Fj(')630 2125 y(These)42 +b(resources)h(con)m(trol)g(what)f(is)g(sen)m(t)h(when)e(the)i(Mac)m +(hine)f(Blac)m(k)i(and)e(Mac)m(hine)630 2235 y(White)i(buttons)g(are)h +(selected.)84 b(This)43 b(is)g(mostly)h(for)g(compatibilit)m(y)f(with)g +(obsolete)630 2345 y(v)m(ersions)30 b(of)g(gn)m(ushogi.)630 +2478 y(Alternate)e(bitmaps)e(for)h(piece)h(icons)f(can)h(b)s(e)f(sp)s +(eci\014ed)e(either)i(b)m(y)h(c)m(ho)s(osing)f(one)h(of)g(the)630 +2588 y(built-in)j(sets)k(or)f(with)e(the)j(\014le)e(name)h(resources)g +(describ)s(ed)e(ab)s(o)m(v)m(e.)54 b(There)33 b(are)i(three)630 +2698 y(built-in)c(sets)j(of)g(piece)g(bitmaps)f(a)m(v)-5 +b(ailable,)34 b(large)g(\(the)g(default\),)h(medium,)e(or)h(small.)630 +2807 y(It)c(is)g(easiest)h(to)g(select)g(the)f(set)h(y)m(ou)g(prefer)f +(in)f(the)h(.Xdefaults)g(\014le:)630 2941 y(XShogi*b)s(oardSize:)39 +b(Medium)630 3075 y(The)25 b(fon)m(t)g(used)g(for)g(button)g(lab)s(els) +e(and)i(commen)m(ts)h(can)g(b)s(e)e(c)m(hanged)i(in)e(the)h(.Xdefaults) +630 3185 y(\014le.)40 b(Y)-8 b(ou)31 b(ma)m(y)g(w)m(an)m(t)g(to)g(c)m +(ho)s(ose)g(a)g(smaller)e(fon)m(t)i(if)e(y)m(ou)i(are)g(using)e(the)h +(small)f(pieces:)630 3319 y(XShogi*fon)m(t:)41 b(helv)m(etica)p +1536 3319 28 4 v 33 w(oblique12)630 3453 y(The)26 b(fon)m(t)i(used)e +(for)g(co)s(ordinates)h(\(when)f(the)h(sho)m(wCo)s(ords)f(option)g(is)g +(T)-8 b(rue\))27 b(can)g(b)s(e)f(set)630 3562 y(similarly:)630 +3696 y(XShogi*co)s(ordF)-8 b(on)m(t:)42 b(helv)m(etica)p +1780 3696 V 33 w(10)630 3830 y(If)30 b(y)m(ou)h(are)f(using)f(a)i(gra)m +(yscale)h(monitor,)e(try)g(setting)g(the)h(colors)f(to:)630 +3964 y(XShogi*blac)m(kPieceColor:)40 b(gra)m(y100)630 +4074 y(XShogi*whitePieceColor:)f(gra)m(y0)630 4183 y(XShogi*ligh)m +(tSquareColor:)g(gra)m(y60)630 4293 y(XShogi*darkSquareColor:)g(gra)m +(y40)275 4561 y(COMMAND)31 b(BUTTONS)e(AND)i(KEYS)150 +4804 y(`)p Fg(Quit)p Fj(')238 b(Quits)29 b(xshogi.)40 +b(Q)30 b(or)h(q)f(is)f(a)i(k)m(eyb)s(oard)f(equiv)-5 +b(alen)m(t.)150 4963 y(`)p Fg(Reset)p Fj(')190 b(Resets)34 +b(xshogi)e(to)h(the)g(b)s(eginning)e(of)h(a)i(shogi)e(game.)49 +b(It)33 b(also)g(deselects)g(an)m(y)g(game)h(or)630 5072 +y(p)s(osition)28 b(\014les.)150 5230 y(`)p Fg(Flip)h(View)p +Fj(')630 5340 y(in)m(v)m(erts)h(the)h(view)e(of)i(the)f(shogi)g(b)s +(oard.)p eop +%%Page: 37 39 +37 38 bop 150 -116 a Fj(Chapter)30 b(4:)41 b(xshogi)2793 +b(37)150 299 y(`)p Fg(Hint)p Fj(')238 b(displa)m(ys)28 +b(a)j(mo)m(v)m(e)h(hin)m(t)d(from)h(gn)m(ushogi.)150 +457 y(`)p Fg(Load)f(Game)p Fj(')630 567 y(pla)m(ys)34 +b(a)h(game)g(from)f(a)h(record)f(\014le.)52 b(If)34 b(no)h(\014le)e(is) +h(sp)s(eci\014ed)f(a)h(p)s(opup)f(dialog)h(asks)g(for)630 +676 y(a)39 b(\014lename.)63 b(Game)39 b(\014les)e(are)i(found)e(in)g +(the)h(directory)g(named)g(b)m(y)g(the)g(SHOGIDIR)630 +786 y(en)m(vironmen)m(t)26 b(v)-5 b(ariable.)39 b(If)26 +b(this)g(v)-5 b(ariable)25 b(is)h(not)h(declared)f(then)h(the)g(curren) +m(t)f(directory)630 896 y(is)34 b(used)g(unless)f(the)j(\014le)e(name)h +(starts)g(with)f(a)h(/.)55 b(G)35 b(or)g(g)g(is)f(a)h(k)m(eyb)s(oard)g +(equiv)-5 b(alen)m(t.)630 1005 y(The)24 b(game)i(\014le)d(parser)h +(will)e(accept)27 b(almost)d(an)m(y)h(\014le)f(that)h(con)m(tains)g(mo) +m(v)m(es)h(in)d(algebraic)630 1115 y(notation.)67 b(If)38 +b(the)i(\014rst)e(line)f(b)s(egins)g(with)h(`#',)k(it)c(is)g(assumed)h +(to)g(b)s(e)g(a)g(title)g(and)f(is)630 1224 y(displa)m(y)m(ed.)64 +b(T)-8 b(ext)39 b(enclosed)g(in)e(paren)m(theses)i(or)f(square)h(brac)m +(k)m(ets)h(is)d(assumed)h(to)i(b)s(e)630 1334 y(commen)m(tary)30 +b(and)f(is)f(displa)m(y)m(ed)g(in)g(a)h(p)s(op-up)f(windo)m(w.)38 +b(An)m(y)30 b(other)f(text)h(in)e(the)i(\014le)e(is)630 +1443 y(ignored.)150 1602 y(`)p Fg(Load)h(Position)p Fj(')630 +1711 y(sets)f(up)f(a)h(p)s(osition)e(from)h(a)h(p)s(osition)e(\014le.) +39 b(If)27 b(no)h(\014le)e(is)h(sp)s(eci\014ed)f(a)i(p)s(opup)e(dialog) +h(asks)630 1821 y(for)21 b(a)g(\014lename.)36 b(P)m(osition)21 +b(\014les)e(are)i(found)f(in)f(the)i(directory)f(named)h(b)m(y)f(the)h +(SHOGIDIR)630 1931 y(en)m(vironmen)m(t)26 b(v)-5 b(ariable.)39 +b(If)26 b(this)g(v)-5 b(ariable)25 b(is)h(not)h(declared)f(then)h(the)g +(curren)m(t)f(directory)630 2040 y(is)g(used)g(unless)f(the)i(\014le)f +(name)h(starts)h(with)d(a)j(/.)40 b(P)m(osition)26 b(\014les)g(m)m(ust) +h(b)s(e)f(in)f(the)j(format)630 2150 y(that)j(the)g(Sa)m(v)m(e)g(P)m +(osition)f(command)g(writes.)150 2308 y(`)p Fg(Save)f(Game)p +Fj(')630 2418 y(sa)m(v)m(es)42 b(a)e(game)i(to)f(a)g(record)f(\014le.) +70 b(If)39 b(no)i(\014le)e(is)g(sp)s(eci\014ed)g(a)i(p)s(opup)d(dialog) +i(asks)g(for)630 2527 y(a)34 b(\014lename.)50 b(If)33 +b(the)h(\014lename)f(exists,)i(the)e(user)g(is)g(ask)m(ed)h(whether)g +(the)f(curren)m(t)h(game)630 2637 y(record)24 b(is)g(b)s(e)g(app)s +(ended)e(to)j(this)f(\014le)f(or)i(if)e(the)i(\014le)e(should)g(b)s(e)h +(replaced.)38 b(Game)25 b(\014les)f(are)630 2746 y(sa)m(v)m(ed)33 +b(in)d(the)i(directory)g(named)f(b)m(y)h(the)g(SHOGIDIR)f(en)m +(vironmen)m(t)h(v)-5 b(ariable.)44 b(If)31 b(this)630 +2856 y(v)-5 b(ariable)31 b(is)f(not)i(declared)f(then)h(the)g(curren)m +(t)f(directory)g(is)g(used)g(unless)f(the)i(\014le)f(name)630 +2966 y(starts)h(with)f(a)h(/.)46 b(Game)33 b(\014les)e(are)h(h)m +(uman-readable,)g(and)f(can)h(also)g(b)s(e)g(read)f(bac)m(k)i(b)m(y)630 +3075 y(the)38 b(Load)g(Game)h(command.)63 b(F)-8 b(urthermore,)40 +b(they)e(are)g(accepted)h(as)g(gn)m(ushogi)e(text)630 +3185 y(b)s(o)s(ok\014les.)150 3343 y(`)p Fg(Save)29 b(Position)p +Fj(')630 3453 y(sa)m(v)m(es)j(a)f(p)s(osition)d(to)k(a)e(p)s(osition)f +(\014le.)40 b(If)30 b(no)h(\014le)e(is)h(sp)s(eci\014ed)f(a)h(p)s(opup) +f(dialog)h(asks)g(for)630 3562 y(a)j(\014lename.)46 b(P)m(osition)32 +b(\014les)g(are)h(sa)m(v)m(ed)g(in)e(the)i(directory)f(named)g(b)m(y)h +(the)f(SHOGIDIR)630 3672 y(en)m(vironmen)m(t)26 b(v)-5 +b(ariable.)39 b(If)26 b(this)g(v)-5 b(ariable)25 b(is)h(not)h(declared) +f(then)h(the)g(curren)m(t)f(directory)630 3781 y(is)k(used)h(unless)e +(the)j(\014le)e(name)h(starts)h(with)e(a)i(/.)43 b(P)m(osition)31 +b(\014les)f(are)i(h)m(uman-readable,)630 3891 y(and)e(can)g(also)h(b)s +(e)e(read)i(bac)m(k)g(b)m(y)f(the)h(Load)f(P)m(osition)g(command.)150 +4049 y(`)p Fg(Machine)f(White)p Fj(')630 4159 y(forces)i(gn)m(ushogi)f +(to)h(pla)m(y)f(white.)150 4317 y(`)p Fg(Machine)f(Black)p +Fj(')630 4427 y(forces)i(gn)m(ushogi)f(to)h(pla)m(y)f(blac)m(k.)150 +4585 y(`)p Fg(Force)f(Moves)p Fj(')630 4695 y(forces)h(a)g(series)g(of) +g(mo)m(v)m(es.)41 b(That)30 b(is,)f(gn)m(ushogi)h(stops)f(pla)m(ying)g +(and)g(xshogi)g(allo)m(ws)h(y)m(ou)630 4804 y(to)h(mak)m(e)g(mo)m(v)m +(es)h(for)e(b)s(oth)g(white)f(and)h(blac)m(k.)150 4963 +y(`)p Fg(Two)g(Machines)p Fj(')630 5072 y(pla)m(ys)g(a)h(game)g(b)s(et) +m(w)m(een)g(t)m(w)m(o)h(computer)e(programs.)150 5230 +y(`)p Fg(Forward)p Fj(')94 b(mo)m(v)m(es)41 b(forw)m(ard)e(through)g(a) +h(series)e(of)i(remem)m(b)s(ered)f(mo)m(v)m(es.)69 b(F)40 +b(or)f(f)h(is)e(a)i(k)m(eyb)s(oard)630 5340 y(equiv)-5 +b(alen)m(t.)p eop +%%Page: 38 40 +38 39 bop 150 -116 a Fj(38)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(`)p Fg(Backward)p Fj(')630 408 y(mo)m(v)m(es)j(bac)m(kw)m(ard)g +(through)e(a)i(series)e(of)h(remem)m(b)s(ered)g(mo)m(v)m(es.)47 +b(As)32 b(a)g(side)f(e\013ect,)k(puts)630 518 y(xshogi)30 +b(in)m(to)g(F)-8 b(orce)32 b(Mo)m(v)m(es)g(mo)s(de.)41 +b(B)30 b(or)h(b)f(is)f(a)i(k)m(eyb)s(oard)f(equiv)-5 +b(alen)m(t.)150 683 y(`)p Fg(Pause)p Fj(')190 b(pauses)24 +b(the)g(clo)s(c)m(ks)g(or)h(\(in)e(Load)h(Game)h(mo)s(de\))f(pauses)g +(the)g(game)i(b)s(eing)c(loaded.)38 b(Press)630 792 y(P)m(ause)31 +b(again)f(to)h(con)m(tin)m(ue.)41 b(P)31 b(or)f(p)g(is)f(a)i(k)m(eyb)s +(oard)f(equiv)-5 b(alen)m(t.)150 957 y(`)p Fg(Edit)29 +b(Position)p Fj(')630 1066 y(lets)f(y)m(ou)h(set)g(up)e(an)i(arbitrary) +e(b)s(oard)g(p)s(osition.)39 b(Use)28 b(mouse)h(button)f(1)h(to)g(drag) +f(pieces)630 1176 y(to)37 b(new)f(squares,)i(or)f(to)g(delete)g(a)g +(piece)g(b)m(y)f(dragging)g(it)g(o\013)h(the)g(b)s(oard)f(or)g +(dragging)630 1285 y(an)f(empt)m(y)g(square)g(on)g(top)h(of)f(it.)54 +b(T)-8 b(o)36 b(drop)e(a)h(new)g(piece)g(on)g(a)g(square,)i(press)d +(mouse)630 1395 y(button)26 b(2)g(or)g(3)h(o)m(v)m(er)g(the)g(square.) +39 b(This)24 b(brings)g(up)h(a)i(men)m(u)f(of)g(blac)m(k)g(pieces)g +(\(button)g(2\))630 1505 y(or)32 b(white)f(pieces)h(\(button)g(3\).)46 +b(Additional)29 b(men)m(u)j(c)m(hoices)h(let)e(y)m(ou)i(empt)m(y)f(the) +g(square)630 1614 y(or)g(clear)h(the)f(b)s(oard.)45 b(Y)-8 +b(ou)33 b(can)g(set)f(the)h(side)e(to)i(pla)m(y)f(next)g(b)m(y)g(clic)m +(king)f(on)i(the)f(Blac)m(k)630 1724 y(or)e(White)h(indicator)e(at)i +(the)f(top)h(of)g(the)f(screen.)150 1888 y(`)p Fg(Challenge)p +Fj(')630 1998 y(allo)m(ws)41 b(to)i(mak)m(e)g(a)g(t)m(w)m(o)g(displa)m +(y)e(game)i(b)s(et)m(w)m(een)g(t)m(w)m(o)g(h)m(uman)f(pla)m(y)m(ers.)75 +b(En)m(ter)43 b(the)630 2108 y(displa)m(y)36 b(y)m(ou)j(w)m(an)m(t)g +(to)g(connect)g(to.)65 b(If)37 b(y)m(ou)i(are)g(allo)m(w)m(ed)f(to)g +(connect,)k(a)c(new)g(b)s(oard)630 2217 y(is)h(displa)m(y)m(ed)f(at)j +(the)f(remote)h(displa)m(y)-8 b(.)68 b(Challenge)38 b(mo)s(de)i(can)g +(only)f(b)s(e)g(stopp)s(ed)g(b)m(y)630 2327 y(pressing)29 +b(\\quit".)150 2491 y(`)p Fg(Select)g(Level)p Fj(')630 +2601 y(allo)m(ws)g(to)h(reset)g(the)f(clo)s(c)m(ks)h(for)f(b)s(oth)f +(pla)m(y)m(ers.)41 b(En)m(ter)29 b(the)h(n)m(um)m(b)s(er)e(of)h(mo)m(v) +m(es)i(and)e(the)630 2710 y(n)m(um)m(b)s(er)g(of)i(min)m(utes)e(in)g +(whic)m(h)g(the)i(mo)m(v)m(es)g(should)e(b)s(e)h(done.)150 +2875 y(`)p Fg(Move)f(NOW)p Fj(')65 b(force)31 b(computer)f(to)h(stop)g +(thinking)d(and)i(to)h(mak)m(e)g(the)g(curren)m(t)f(b)s(est)g(mo)m(v)m +(e.)150 3040 y(`)p Fg(Iconify)f(I,)g(i,)h(C)g(or)g(c)p +Fj(')630 3149 y(iconi\014es)f(xshogi.)275 3426 y(LIMIT)-8 +b(A)g(TIONS)275 3675 y(If)28 b(y)m(ou)g(press)g(the)h(P)m(ause)f +(button)h(during)d(GNU)j(Shogi's)e(turn,)h(xshogi)g(will)e(stop)j(the)f +(clo)s(c)m(ks,)i(but)150 3785 y(gn)m(ushogi)g(will)d(still)i(mak)m(e)i +(a)g(mo)m(v)m(e.)275 3924 y(After)d(a)h(mate)h(or)f(dra)m(w)f(when)g +(pla)m(ying)f(against)i(gn)m(ushogi,)g(if)e(y)m(ou)i(bac)m(k)h(up)d +(with)h(the)h(Bac)m(kw)m(ard)150 4034 y(button,)h(the)h(clo)s(c)m(ks)f +(are)h(reset)g(\(b)s(ecause)g(gn)m(ushogi)f(has)g(exited)g(and)g(m)m +(ust)g(b)s(e)g(restarted\).)275 4173 y(The)f(game)j(parser)e +(recognizes)h(only)e(algebraic)h(notation.)275 4423 y(A)m(UTHORS)275 +4672 y(Original)d(authors)j(of)h(XBoard:)41 b(Chris)28 +b(Sears)i(and)g(Dan)h(Sears.)275 4812 y(Enhancemen)m(ts)f(for)g(XBoard) +h(\(V)-8 b(ersion)30 b(2.0\):)42 b(Tim)29 b(Mann.)275 +4951 y(Con)m(v)m(ersion)g(to)j(XShogi)d(\(V)-8 b(ersion)31 +b(1.1\):)42 b(Matthias)31 b(Mutz.)275 5091 y(Curren)m(t)e(main)m +(tainer:)40 b(Mik)m(e)30 b(V)-8 b(anier.)275 5340 y(COPYRIGHT)29 +b(INF)m(ORMA)-8 b(TION)p eop +%%Page: 39 41 +39 40 bop 150 -116 a Fj(Chapter)30 b(4:)41 b(xshogi)2793 +b(39)275 299 y(XShogi)29 b(b)s(orro)m(ws)h(its)f(piece)i(bitmaps)e +(from)h(CRANES)f(Shogi.)275 433 y(Cop)m(yrigh)m(t)83 +b(1991)j(b)m(y)e(Digital)f(Equipmen)m(t)f(Corp)s(oration,)97 +b(Ma)m(ynard,)h(Massac)m(h)m(usetts.)150 543 y(Enhancemen)m(ts)39 +b(Cop)m(yrigh)m(t)f(1992)j(F)-8 b(ree)40 b(Soft)m(w)m(are)g(F)-8 +b(oundation,)41 b(Inc.)66 b(Enhancemen)m(ts)39 b(Cop)m(yrigh)m(t)150 +653 y(1993)k(Matthias)f(Mutz.)74 b(F)-8 b(urther)41 b(enhancemen)m(ts)h +(cop)m(yrigh)m(t)f(1999)i(b)m(y)f(Mic)m(hael)f(V)-8 b(anier)41 +b(and)g(the)150 762 y(F)-8 b(ree)31 b(Soft)m(w)m(are)h(F)-8 +b(oundation,)30 b(Inc.)275 897 y(The)44 b(follo)m(wing)f(terms)i(apply) +e(to)j(Digital)e(Equipmen)m(t)f(Corp)s(oration's)h(cop)m(yrigh)m(t)h +(in)m(terest)g(in)150 1006 y(XBoard:)275 1141 y(All)29 +b(Righ)m(ts)h(Reserv)m(ed)275 1275 y(P)m(ermission)f(to)j(use,)f(cop)m +(y)-8 b(,)33 b(mo)s(dify)-8 b(,)30 b(and)h(distribute)d(this)i(soft)m +(w)m(are)j(and)e(its)f(do)s(cumen)m(tation)h(for)150 +1385 y(an)m(y)36 b(purp)s(ose)e(and)g(without)h(fee)h(is)e(hereb)m(y)i +(gran)m(ted,)h(pro)m(vided)d(that)i(the)g(ab)s(o)m(v)m(e)h(cop)m(yrigh) +m(t)f(notice)150 1494 y(app)s(ear)30 b(in)f(all)g(copies)h(and)f(that)i +(b)s(oth)f(that)h(cop)m(yrigh)m(t)f(notice)h(and)f(this)f(p)s +(ermission)e(notice)k(app)s(ear)150 1604 y(in)j(supp)s(orting)e(do)s +(cumen)m(tation,)k(and)f(that)g(the)h(name)f(of)g(Digital)f(not)i(b)s +(e)e(used)g(in)g(adv)m(ertising)g(or)150 1714 y(publicit)m(y)18 +b(p)s(ertaining)g(to)j(distribution)16 b(of)21 b(the)f(soft)m(w)m(are)i +(without)d(sp)s(eci\014c,)j(written)d(prior)g(p)s(ermission.)275 +1848 y(DIGIT)-8 b(AL)24 b(DISCLAIMS)f(ALL)h(W)-10 b(ARRANTIES)23 +b(WITH)h(REGARD)h(TO)e(THIS)g(SOFTW)-10 b(ARE,)150 1958 +y(INCLUDING)26 b(ALL)f(IMPLIED)g(W)-10 b(ARRANTIES)25 +b(OF)g(MER)m(CHANT)-8 b(ABILITY)26 b(AND)g(FITNESS,)150 +2067 y(IN)41 b(NO)g(EVENT)h(SHALL)e(DIGIT)-8 b(AL)42 +b(BE)g(LIABLE)f(F)m(OR)h(ANY)f(SPECIAL,)g(INDIRECT)f(OR)150 +2177 y(CONSEQUENTIAL)50 b(D)m(AMA)m(GES)k(OR)d(ANY)h(D)m(AMA)m(GES)i +(WHA)-8 b(TSOEVER)51 b(RESUL)-8 b(TING)150 2286 y(FR)m(OM)66 +b(LOSS)d(OF)i(USE,)g(D)m(A)-8 b(T)g(A)66 b(OR)f(PR)m(OFITS,)f(WHETHER)h +(IN)g(AN)g(A)m(CTION)g(OF)150 2396 y(CONTRA)m(CT,)43 +b(NEGLIGENCE)g(OR)g(OTHER)g(TOR)-8 b(TIOUS)42 b(A)m(CTION,)h(ARISING)g +(OUT)g(OF)150 2506 y(OR)30 b(IN)g(CONNECTION)f(WITH)i(THE)f(USE)f(OR)h +(PERF)m(ORMANCE)h(OF)f(THIS)g(SOFTW)-10 b(ARE.)275 2640 +y(The)36 b(follo)m(wing)g(terms)h(apply)f(to)i(the)g(enhanced)f(v)m +(ersion)g(of)g(XShogi)g(distributed)d(b)m(y)j(the)h(F)-8 +b(ree)150 2750 y(Soft)m(w)m(are)31 b(F)-8 b(oundation:)275 +2884 y(This)28 b(\014le)i(is)f(part)h(of)h(XSHOGI.)275 +3019 y(XSHOGI)h(is)f(distributed)f(in)h(the)i(hop)s(e)e(that)i(it)f +(will)e(b)s(e)i(useful,)g(but)f(WITHOUT)h(ANY)h(W)-10 +b(AR-)150 3128 y(RANTY.)30 b(No)g(author)f(or)h(distributor)d(accepts)k +(resp)s(onsibilit)m(y)25 b(to)31 b(an)m(y)m(one)f(for)g(the)g +(consequences)g(of)150 3238 y(using)e(it)h(or)g(for)g(whether)g(it)g +(serv)m(es)h(an)m(y)f(particular)f(purp)s(ose)g(or)h(w)m(orks)g(at)h +(all,)f(unless)f(he)h(sa)m(ys)h(so)f(in)150 3347 y(writing.)39 +b(Refer)30 b(to)h(the)g(XSHOGI)f(General)g(Public)e(License)i(for)g +(full)e(details.)275 3482 y(Ev)m(ery)m(one)43 b(is)f(gran)m(ted)h(p)s +(ermission)c(to)44 b(cop)m(y)-8 b(,)47 b(mo)s(dify)40 +b(and)i(redistribute)e(XSHOGI,)j(but)f(only)150 3592 +y(under)d(the)i(conditions)e(describ)s(ed)g(in)g(the)i(XSHOGI)f +(General)h(Public)d(License.)71 b(A)41 b(cop)m(y)g(of)g(this)150 +3701 y(license)34 b(is)f(supp)s(osed)g(to)i(ha)m(v)m(e)h(b)s(een)d(giv) +m(en)i(to)g(y)m(ou)g(along)g(with)e(XSHOGI)h(so)h(y)m(ou)g(can)f(kno)m +(w)h(y)m(our)150 3811 y(righ)m(ts)f(and)h(resp)s(onsibilities.)49 +b(It)35 b(should)e(b)s(e)i(in)e(a)j(\014le)e(named)g(COPYING.)h(Among)h +(other)f(things,)150 3920 y(the)c(cop)m(yrigh)m(t)f(notice)h(and)f +(this)f(notice)i(m)m(ust)f(b)s(e)g(preserv)m(ed)g(on)g(all)f(copies.)p +eop +%%Page: 40 42 +40 41 bop 150 -116 a Fj(40)2734 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Page: 41 43 +41 42 bop 150 -116 a Fj(Chapter)30 b(5:)41 b(References)31 +b(and)f(links)2231 b(41)150 299 y Fh(5)80 b(References)52 +b(and)i(links)275 506 y Fj(There)30 b(are)g(v)m(ery)h(few)f +(English-language)f(b)s(o)s(oks)h(for)g(p)s(eople)g(learning)f(shogi.) +40 b(The)30 b(t)m(w)m(o)i(I)e(recom-)150 616 y(mend)f(are:)199 +835 y(1.)61 b Ff(Shogi)40 b(for)h(Beginners,)i(2nd.)71 +b(Edition)p Fj(,)42 b(b)m(y)f(John)f(F)-8 b(airbairn.)71 +b(This)39 b(is)h(a)h(sup)s(erb)e(b)s(eginner's)330 945 +y(b)s(o)s(ok)57 b(in)f(ev)m(ery)j(w)m(a)m(y)-8 b(,)66 +b(co)m(v)m(ering)58 b(all)f(phases)g(of)h(the)g(game.)123 +b(It)58 b(w)m(as)g(out)g(of)g(prin)m(t)e(for)330 1054 +y(a)k(long)e(time,)67 b(but)58 b(has)h(no)m(w)g(b)s(een)g(reprin)m(ted) +f(and)g(is)h(a)m(v)-5 b(ailable)58 b(either)h(from)g(Kiseido)330 +1164 y(\()p Fg(http://www.labnet.or.jp/~k)o(ise)o(ido)p +Fj(\))24 b(or)31 b(from)f(George)h(Ho)s(dges)g(\(see)h(b)s(elo)m(w\).) +199 1293 y(2.)61 b Ff(The)54 b(Art)g(of)g(Shogi)p Fj(,)59 +b(b)m(y)54 b(T)-8 b(on)m(y)55 b(Hoskings.)111 b(This)52 +b(is)h(one)i(step)f(up)f(from)g(the)i(F)-8 b(airbairn)330 +1403 y(b)s(o)s(ok.)120 b(It)57 b(co)m(v)m(ers)i(a)e(lot)g(of)h(ground,) +63 b(and)56 b(is)g(esp)s(ecially)f(notew)m(orth)m(y)k(for)d(its)h +(detailed)330 1512 y(treatmen)m(t)36 b(of)f(op)s(ening)e(lines.)51 +b(Y)-8 b(ou)36 b(can)e(order)g(this)g(b)s(o)s(ok)g(from)g(Amazon.com's) +i(UK)f(branc)m(h)330 1622 y(\()p Fg(http://www.amazon.co.uk)p +Fj(\).)275 1880 y(Another)25 b(b)s(o)s(ok)g(y)m(ou)h(ma)m(y)g(\014nd)e +(is)h Ff(Shogi:)38 b(Japan's)25 b(Game)h(of)g(Strategy)35 +b Fj(b)m(y)25 b(T)-8 b(rev)m(or)26 b(Leggett.)42 b(This)150 +1990 y(b)s(o)s(ok)37 b(is)g(v)m(ery)h(elemen)m(tary)h(and)e(is)g +(somewhat)h(outdated,)j(ha)m(ving)c(b)s(een)g(published)d(\014rst)j(in) +g(1966.)150 2099 y(Ho)m(w)m(ev)m(er,)c(it)d(do)s(es)g(feature)h(a)f +(pap)s(er)g(shogi)g(b)s(oard)f(and)h(punc)m(h-out)g(pieces,)g(so)h(if)e +(y)m(ou)i(w)m(an)m(t)g(a)g(really)150 2209 y(c)m(heap)g(shogi)f(set)h +(y)m(ou)g(migh)m(t)f(pic)m(k)g(this)f(b)s(o)s(ok)h(up.)39 +b(It)31 b(is)e(still)f(in)h(prin)m(t.)275 2338 y(Tw)m(o)i(b)s(o)s(oks)f +(that)h(are)h(no)f(longer)f(in)g(prin)m(t)f(but)h(are)i(de\014nitely)d +(w)m(orth)i(getting)g(if)f(y)m(ou)i(\014nd)d(them)150 +2447 y(are)35 b Ff(Guide)e(to)i(Shogi)e(Op)s(enings)j +Fj(and)e Ff(Better)h(Mo)m(v)m(es)h(for)e(Better)i(Shogi)p +Fj(,)f(b)s(oth)e(b)m(y)h(Aono)h(T)-8 b(eriuc)m(hi.)150 +2557 y(They)38 b(are)h(published)c(in)i(a)i(bilingual)c(edition)j +(\(English/Japanese\))f(and)i(are)g(the)f(only)g(b)s(o)s(oks)g(on)150 +2667 y(shogi)e(in)g(English)e(written)i(b)m(y)g(a)i(Japanese)f +(professional)e(shogi)h(pla)m(y)m(er.)60 b(John)36 b(F)-8 +b(airbairn)35 b(did)g(the)150 2776 y(translation)29 b(from)h(Japanese)h +(to)g(English.)275 2905 y(Shogi)e(sets)i(are)g(a)m(v)-5 +b(ailable)29 b(from:)390 3138 y(George)j(F.)f(Ho)s(dges)390 +3242 y(P)-8 b(.O.)31 b(Bo)m(x)g(77)390 3346 y(Bromley)-8 +b(,)31 b(Ken)m(t)390 3450 y(United)f(Kingdom)e(BR1)k(2WT)275 +3688 y(George)k(also)g(sells)d(equipmen)m(t)i(for)g(all)f(the)h +(historical)f(shogi)h(v)-5 b(arian)m(ts)35 b(\(see)h(Section)f(2.4)i +([Shogi)150 3798 y(v)-5 b(arian)m(ts],)34 b(page)f(23\))h(\(except)g +(for)e(Ky)m(oku)h(tai)g(shogi\))f(and)g(also)h(sells)e(bac)m(k)i +(issues)f(of)g(the)h(magazine)150 3908 y(\\Shogi")39 +b(whic)m(h)f(he)i(published)35 b(for)k(70)h(issues)e(in)g(the)i(late)g +(70's)g(to)g(late)g(80's.)68 b(This)38 b(magazine)i(is)150 +4017 y(STR)m(ONGL)-8 b(Y)32 b(recommended;)g(it)f(con)m(tains)h(more)g +(information)e(ab)s(out)h(shogi)g(in)g(English)e(than)j(y)m(ou)150 +4127 y(will)c(ev)m(er)j(\014nd)e(an)m(ywhere)h(else.)275 +4256 y(Here)g(are)h(some)g(useful)e(URLs:)150 4495 y(Pieter)h +(Stouten's)h(shogi)f(page:)41 b Fg(http://www.halcyon.com/s)o(tout)o +(en/s)o(hog)o(i.ht)o(ml)630 4604 y Fj(This)29 b(is)h(the)h(main)e +(shogi-related)i(site)f(on)h(the)g(in)m(ternet,)g(with)e(links)g(to)i +(almost)g(all)f(the)630 4714 y(other)h(sites.)150 4863 +y(Roger)g(Hare's)g(shogi)f(page:)42 b Fg(http://www.ed.ac.uk/~r)o(jhar) +o(e/sh)o(ogi)630 4972 y Fj(This)29 b(has)h(lots)g(of)g(information,)f +(including)e(full)h(rules)h(to)i(most)g(of)g(the)f(shogi)g(v)-5 +b(arian)m(ts.)150 5121 y(P)m(atric)m(k)31 b(Da)m(vin's)g(Shogi)e +(Nexus:)41 b Fg(http://www.vega.or.jp/~)o(patr)o(ick/)o(sho)o(gi/)630 +5230 y Fj(There's)32 b(lots)h(of)f(co)s(ol)h(stu\013)f(on)h(this)e +(site;)j(m)m(y)f(fa)m(v)m(orite)h(is)d(the)i(extensiv)m(e)g(collection) +g(of)630 5340 y(Tsume-shogi)22 b(\(mating\))h(problems,)f(b)s(oth)g +(for)h(b)s(eginners)d(and)i(more)h(adv)-5 b(anced)23 +b(pla)m(y)m(ers.)p eop +%%Page: 42 44 +42 43 bop 150 -116 a Fj(42)2734 b(GNU)31 b(Shogi)f(man)m(ual)150 +299 y(Stev)m(e)h(Ev)-5 b(ans')31 b(shogi)e(page:)42 b +Fg(http://www.netspace.net.)o(au/~)o(tro)o(ut/i)o(ndex)o(.ht)o(ml)630 +408 y Fj(Stev)m(e)32 b(has)e(written)g(a)h(program)g(that)g(pla)m(ys)f +(almost)h(all)f(of)h(the)g(shogi)f(v)-5 b(arian)m(ts,)31 +b(unfor-)630 518 y(tunately)f(it)g(only)g(runs)e(on)j(Windo)m(ws)e +(:-\()150 677 y(Hans)h(Bo)s(dlaender's)g(c)m(hess)h(v)-5 +b(arian)m(t)30 b(pages:)41 b Fg(http://www.cs.ruu.nl/~han)o(sb/d)o(.ch) +o(essv)o(ar)630 787 y Fj(This)31 b(page)i(has)g(an)f(almost)h +(unimaginable)d(v)-5 b(ariet)m(y)33 b(of)g(rules)e(for)h(di\013eren)m +(t)g(c)m(hess)h(v)-5 b(ari-)630 897 y(an)m(ts,)31 b(including)c(man)m +(y)k(shogi)e(v)-5 b(arian)m(ts)31 b(\(historical)e(and)g +(non-historical\).)p eop +%%Page: 43 45 +43 44 bop 150 -116 a Fj(Chapter)30 b(6:)41 b(Ac)m(kno)m(wledgemen)m(ts) +2295 b(43)150 299 y Fh(6)80 b(Ac)l(kno)l(wledgemen)l(ts)275 +533 y Fj(I)30 b(w)m(ould)f(lik)m(e)g(to)j(thank)e(the)g(follo)m(wing)f +(p)s(eople:)225 752 y Fi(\017)60 b Fj(Matthias)35 b(Mutz,)h(who)e +(originally)e(dev)m(elop)s(ed)i(GNU)h(shogi)f(as)h(a)g(spin-o\013)e(of) +i(GNU)g(c)m(hess)g(and)330 862 y(who)30 b(v)m(ery)h(kindly)c(let)k(me)f +(tak)m(e)i(o)m(v)m(er)g(the)e(main)m(tenance)h(of)g(this)e(v)m(ery)i +(in)m(teresting)f(pro)5 b(ject.)225 996 y Fi(\017)60 +b Fj(Ric)m(hard)22 b(Stallman)f(and)h(the)h(F)-8 b(ree)24 +b(Soft)m(w)m(are)f(F)-8 b(oundation,)25 b(for)d(creating)h(an)g +(organization)f(where)330 1106 y(an)m(y)m(one)38 b(can)f(con)m(tribute) +f(soft)m(w)m(are)i(for)e(the)h(common)g(go)s(o)s(d)f(of)h(all,)g(for)f +(making)g(GNU/Lin)m(ux)330 1215 y(p)s(ossible,)22 b(and)h(esp)s +(ecially)e(for)i(writing)f(emacs)i(and)e(gcc,)k(without)d(whic)m(h)e(m) +m(y)j(w)m(orking)e(life)g(w)m(ould)330 1325 y(b)s(e)30 +b(in)m(tolerable.)225 1460 y Fi(\017)60 b Fj(Georges)30 +b(Ho)s(dges,)f(for)f(starting)g(the)g(Shogi)g(Asso)s(ciation)g(in)e +(England,)i(without)f(whic)m(h)g(I)h(w)m(ould)330 1569 +y(probably)i(nev)m(er)h(ha)m(v)m(e)i(heard)e(of)g(shogi,)h(for)f +(supplying)d(shogi)j(equipmen)m(t,)g(for)g(publishing)c(the)330 +1679 y(excellen)m(t)33 b(magazine)h(\\Shogi")f(\(no)m(w)g(sadly)f +(defunct\),)h(for)g(p)s(ersonally)e(answ)m(ering)h(all)f(m)m(y)i(silly) +330 1788 y(questions)c(b)m(y)i(mail,)e(and)h(for)g(b)s(eing)f(the)h(am) +m(bassador)h(of)g(shogi)e(to)j(the)e(W)-8 b(est.)225 +1923 y Fi(\017)60 b Fj(Pieter)30 b(Stouten,)g(for)g(ha)m(ving)g(the)g +(most)h(comprehensiv)m(e)e(shogi)h(site)g(on)g(the)g(W)-8 +b(orld)30 b(Wide)f(W)-8 b(eb)330 2032 y Fg(http://www.halcyon.com/s)o +(tout)o(en/s)o(hog)o(i.ht)o(ml)p Fj(,)16 b(and)k(for)g(main)m(taining)f +(the)i(shogi-l)e(mail-)330 2142 y(ing)32 b(list.)47 b(Go)34 +b(to)g(Pieter's)f(w)m(eb)g(site)f(for)h(more)g(information)f(on)h +(subscribing)c(to)34 b(the)f(list.)47 b(Also)330 2252 +y(thanks)30 b(to)h(ev)m(ery)m(one)h(who)e(con)m(tributes)g(and)g(has)g +(con)m(tributed)f(to)j(that)f(list.)225 2386 y Fi(\017)60 +b Fj(Matt)24 b(Casters,)h(for)e(testing)g(GNU)h(shogi.)38 +b(Matt)24 b(and)e(I)h(will)e(b)s(e)h(w)m(orking)g(together)j(on)e +(impro)m(ving)330 2496 y(the)31 b(solution)e(engine)g(in)g(future)h(v)m +(ersions)g(of)g(this)f(program.)p eop +%%Page: 44 46 +44 45 bop 150 -116 a Fj(44)2734 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Page: 45 47 +45 46 bop 150 -116 a Fj(Chapter)30 b(7:)41 b(Bugs)2848 +b(45)150 299 y Fh(7)80 b(Bugs)275 533 y Fj(The)39 b(motto)i(of)f(GNU)h +(shogi)e(is)g(\\100\045)j(bug-free)d(or)h(y)m(ou)h(don't)f(pa)m(y!")70 +b(:-\))41 b(In)e(the)h(extremely)150 643 y(unlik)m(ely)31 +b(case)k(\(*ahem*\))g(that)f(y)m(ou)g(do)g(\014nd)e(a)i(bug,)g(please)f +(send)g(me)h(\(Mik)m(e)g(V)-8 b(anier\))34 b(an)g(email)e(at)150 +752 y Fg(mvanier@bbb.caltech.edu)p Fj(.)i(Also,)c(feel)g(free)g(to)h +(send)e(me)h(commen)m(ts,)i(complain)m(ts,)d(out-and-out)150 +862 y(ra)m(v)m(es,)45 b(suggestions,)g(plane)40 b(tic)m(k)m(ets)j(to)f +(Ha)m(w)m(aii,)i(and/or)d(large)g(suitcases)h(\014lled)d(with)h(unmark) +m(ed,)150 971 y(un)m(traceable)31 b(h)m(undred-dollar)c(bills.)p +eop +%%Page: 46 48 +46 47 bop 150 -116 a Fj(46)2734 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Page: 47 49 +47 48 bop 150 -116 a Fj(Chapter)30 b(8:)41 b(Index)2821 +b(47)150 299 y Fh(8)80 b(Index)150 623 y Fk(A)150 755 +y Fc(Ac)n(kno)n(wledgemen)n(ts)10 b Fb(.)h(.)i(.)f(.)g(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.) +g(.)36 b Fc(43)150 1021 y Fk(B)150 1154 y Fc(Bo)r(oks)7 +b Fb(.)14 b(.)e(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.) +g(.)g(.)h(.)f(.)g(.)33 b Fc(41)150 1420 y Fk(C)150 1552 +y Fc(Ch)n(u)25 b(Shogi)8 b Fb(.)13 b(.)f(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)33 b Fc(23)150 1818 y +Fk(D)150 1951 y Fc(Dai)26 b(Shogi)18 b Fb(.)13 b(.)f(.)g(.)h(.)f(.)g(.) +h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)44 b Fc(23)150 +2050 y(Dai-dai)26 b(Shogi)9 b Fb(.)j(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.) +g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)34 b Fc(23)150 2150 y(Dra)n(ws)23 +b Fb(.)12 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.) +h(.)f(.)g(.)h(.)47 b Fc(17)150 2250 y(Drops)9 b Fb(.)j(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.) +h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)35 +b Fc(16)150 2516 y Fk(G)150 2648 y Fc(gn)n(ushogi)17 +b Fb(.)c(.)g(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.) +g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f +(.)g(.)43 b Fc(27)150 2748 y(GPL)12 b Fb(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)38 +b Fc(5)150 3014 y Fk(H)150 3146 y Fc(Handicaps)8 b Fb(.)k(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)33 +b Fc(18)150 3412 y Fk(I)150 3545 y Fc(In)n(tro)r(duction)9 +b Fb(.)j(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.) +h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)35 +b Fc(3)150 3811 y Fk(K)150 3943 y Fc(Ky)n(oku)24 b(T)-6 +b(ai)27 b(Shogi)9 b Fb(.)k(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)35 +b Fc(23)150 4209 y Fk(L)150 4342 y Fc(License)25 b Fb(.)12 +b(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.) +g(.)h(.)50 b Fc(5)150 4608 y Fk(M)150 4740 y Fc(Mailing)27 +b(lists)12 b Fb(.)i(.)e(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.) +h(.)37 b Fc(41)150 4840 y(Mak)l(a-dai-dai)26 b(Shogi)21 +b Fb(.)13 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)46 b Fc(23)2025 +623 y Fk(O)2025 771 y Fc(Op)r(ening)25 b(setup)10 b Fb(.)i(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.) +h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)36 b Fc(15)2025 1082 +y Fk(P)2025 1230 y Fc(Piece)26 b(mo)n(v)n(es)16 b Fb(.)c(.)g(.)g(.)h(.) +f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)41 b Fc(14)2025 +1337 y(Piece)26 b(promotion)17 b Fb(.)c(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)43 b Fc(15)2025 1648 y Fk(R)2025 1796 y Fc(References)24 +b Fb(.)12 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.) +49 b Fc(41)2025 1903 y(Rules)17 b Fb(.)12 b(.)g(.)g(.)h(.)f(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.) +h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)42 +b Fc(13)2025 2214 y Fk(S)2025 2362 y Fc(Sample)25 b(game)14 +b Fb(.)e(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.) +g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)40 +b Fc(19)2025 2469 y(Shogi)26 b(v)l(arian)n(ts)17 b Fb(.)c(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.) +g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)43 b Fc(23)2025 2576 +y(Shogi)26 b(vs.)34 b(Chess)8 b Fb(.)14 b(.)e(.)g(.)h(.)f(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)g(.)h(.)34 b Fc(24)2025 2886 y Fk(T)2025 3035 +y Fc(T)-6 b(ai)26 b(Shogi)d Fb(.)13 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.) +g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)49 b Fc(23)2025 3142 +y(T)-6 b(enjiku)25 b(Shogi)f Fb(.)12 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.) +g(.)h(.)f(.)g(.)49 b Fc(23)2025 3249 y(T)-6 b(ori)26 +b(Shogi)8 b Fb(.)13 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h +(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.) +g(.)h(.)f(.)g(.)34 b Fc(23)2025 3559 y Fk(V)2025 3708 +y Fc(V)-6 b(arian)n(ts)23 b Fb(.)13 b(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)49 b Fc(23)2025 4018 +y Fk(W)2025 4167 y Fc(W)-6 b(a)25 b(Shogi)e Fb(.)12 b(.)g(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)48 b +Fc(23)2025 4274 y(W)-6 b(eb)25 b(sites)d Fb(.)12 b(.)h(.)f(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.) +h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)47 b Fc(41)2025 +4381 y(Winning)25 b(the)h(game)17 b Fb(.)12 b(.)g(.)g(.)h(.)f(.)g(.)g +(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.) +g(.)h(.)42 b Fc(17)2025 4691 y Fk(X)2025 4840 y Fc(xshogi)22 +b Fb(.)12 b(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f +(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.) +f(.)g(.)g(.)h(.)47 b Fc(33)p eop +%%Page: 48 50 +48 49 bop 150 -116 a Fj(48)2734 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Page: -1 51 +-1 50 bop 3725 -116 a Fj(i)150 299 y Fh(T)-13 b(able)54 +b(of)g(Con)l(ten)l(ts)150 641 y Fk(GNU)45 b(Shogi)g(\(Japanese)i(c)l +(hess\))12 b Fa(.)19 b(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h +(.)f(.)g(.)h(.)f(.)h(.)56 b Fk(1)150 911 y(1)135 b(In)l(tro)t(duction) +15 b Fa(.)20 b(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h +(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)60 +b Fk(3)150 1181 y(GNU)45 b(GENERAL)g(PUBLIC)g(LICENSE)31 +b Fa(.)19 b(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)75 b Fk(5)449 +1318 y Fj(Pream)m(ble)16 b Fd(.)e(.)h(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)h(.)f(.)g(.)g(.)g(.)g(.)45 b Fj(5)449 1427 y(TERMS)29 +b(AND)j(CONDITIONS)d(F)m(OR)h(COPYING,)h(DISTRIBUTION)631 +1537 y(AND)g(MODIFICA)-8 b(TION)24 b Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fj(6)449 1646 +y(Ho)m(w)31 b(to)g(Apply)e(These)h(T)-8 b(erms)30 b(to)h(Y)-8 +b(our)31 b(New)f(Programs)15 b Fd(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f +(.)g(.)g(.)44 b Fj(11)150 1889 y Fk(2)135 b(Ab)t(out)44 +b(the)h(game)h(of)f(shogi)30 b Fa(.)20 b(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.) +f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)74 b Fk(13)449 2026 +y Fj(2.1)92 b(The)30 b(rules)f(of)h(shogi)21 b Fd(.)15 +b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)51 b Fj(13)748 2135 y(2.1.1)93 b(The)29 b(mo)m(v)m(es)j(of)f +(the)f(pieces)18 b Fd(.)d(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)47 b Fj(14)748 +2245 y(2.1.2)93 b(The)29 b(op)s(ening)g(setup)15 b Fd(.)g(.)g(.)h(.)f +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)45 b Fj(15)748 2355 y(2.1.3)93 +b(Promotion)30 b(of)g(pieces)14 b Fd(.)g(.)h(.)h(.)f(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)43 b Fj(15)748 2464 y(2.1.4)93 b(Drops)9 b Fd(.)15 +b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.) +f(.)g(.)g(.)g(.)g(.)38 b Fj(16)748 2574 y(2.1.5)93 b(Winning)28 +b(the)i(game)18 b Fd(.)f(.)e(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)48 +b Fj(17)748 2683 y(2.1.6)93 b(Dra)m(ws)24 b Fd(.)15 b(.)g(.)g(.)g(.)g +(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 +b Fj(17)748 2793 y(2.1.7)93 b(Handicaps)28 b Fd(.)15 +b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.) +58 b Fj(18)748 2902 y(2.1.8)93 b(Notes)31 b(for)f(c)m(hess)h(pla)m(y)m +(ers)21 b Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)50 b Fj(19)449 +3012 y(2.2)92 b(Sample)29 b(game)g Fd(.)15 b(.)g(.)g(.)g(.)h(.)f(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)57 +b Fj(19)449 3122 y(2.3)92 b(Mating)31 b(problems)18 b +Fd(.)13 b(.)i(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)47 b Fj(22)449 3231 y(2.4)92 b(Shogi)29 +b(v)-5 b(arian)m(ts)10 b Fd(.)15 b(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) +g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)39 +b Fj(23)449 3341 y(2.5)92 b(Di\013erences)31 b(b)s(et)m(w)m(een)g +(shogi)e(and)h(c)m(hess)10 b Fd(.)15 b(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g +(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)39 +b Fj(24)150 3583 y Fk(3)135 b(gn)l(ushogi)33 b Fa(.)20 +b(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f +(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)78 +b Fk(27)150 3853 y(4)135 b(xshogi)10 b Fa(.)20 b(.)g(.)f(.)g(.)h(.)f(.) +h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f +(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)55 b Fk(33)150 +4123 y(5)135 b(References)46 b(and)f(links)29 b Fa(.)20 +b(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h +(.)f(.)h(.)f(.)74 b Fk(41)150 4393 y(6)135 b(Ac)l(kno)l(wledgemen)l(ts) +12 b Fa(.)21 b(.)f(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g +(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)57 b Fk(43)150 4663 +y(7)135 b(Bugs)19 b Fa(.)g(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h +(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.) +g(.)h(.)f(.)h(.)f(.)h(.)f(.)64 b Fk(45)150 4932 y(8)135 +b(Index)30 b Fa(.)19 b(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f +(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.) +h(.)f(.)h(.)f(.)g(.)75 b Fk(47)p eop +%%Page: -2 52 +-2 51 bop 150 -116 a Fj(ii)2772 b(GNU)31 b(Shogi)f(man)m(ual)p +eop +%%Trailer +end +userdict /end-hook known{end-hook}if +%%EOF diff --git a/doc/gnushogi.texinfo b/doc/gnushogi.texinfo new file mode 100644 index 0000000..1fdccf1 --- /dev/null +++ b/doc/gnushogi.texinfo @@ -0,0 +1,2715 @@ +\input texinfo @c -*-texinfo-*- + +@c % ** Start of header. +@setfilename gnushogi.info +@settitle GNU Shogi manual +@c % ** End of header. + +@setchapternewpage odd + +@c ================================== +@c TeX-specific macros +@c ================================== + +@c None yet! + +@c ================================== +@c info-specific macros +@c ================================== + +@c None yet! + +@c ================================== +@c Summary description and copyright. +@c ================================== + +@ifinfo + +This file describes how to use GNU shogi, +a program which plays Shogi (Japanese chess). + +Copyright (C) 1999 Michael C. Vanier and the Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). +@end ignore + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. + +@end ifinfo + +@c ========================================= +@c End of summary description and copyright. +@c ========================================= + + +@c ==================== +@c Title and copyright. +@c ==================== + +@titlepage +@sp 10 +@comment The title is printed in a large font. +@center @titlefont{GNU Shogi (Japanese chess)} +@author Mike Vanier + +@c The following two commands start the copyright page. +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1999 Michael C. Vanier and the Free Software Foundation + +@end titlepage + +@c =========================== +@c End of title and copyright. +@c =========================== + + +@c ========================= +@c Top node and master menu. +@c ========================= + +@node Top, (dir), (dir), (dir) +@top GNU Shogi (Japanese chess) + +@ifinfo +@menu +* Introduction:: What is GNU shogi? +* License:: The GNU General Public License. +* About shogi:: General information, rules, etc. +* gnushogi:: How to play GNU shogi (gnushogi). +* xshogi:: The X interface to GNU shogi. +* References and links:: Where to go for more information. +* Acknowledgements:: +* Bugs:: Where and how to report bugs. +* Index:: +@end menu +@end ifinfo + +@iftex +This document describes GNU shogi, a program which plays Japanese chess +(shogi) against a human opponent. +@end iftex + +@c ================================ +@c End of top node and master menu. +@c ================================ + + +@c ===== +@c Body. +@c ===== + +@node Introduction, License, Top, Top +@chapter Introduction +@cindex Introduction + +GNU shogi is a program that plays shogi, the Japanese version of chess, +against a human (or computer) opponent. This file describes how to use +GNU shogi and also gives background information about the game of shogi. + +This file describes GNU shogi version 1.3. It was written by me, Mike +Vanier, the current maintainer of GNU shogi. My email address is +@email{mvanier@@bbb.caltech.edu}. + + +GNU shogi is actually two programs: + +@sp 1 + +@table @samp + +@item gnushogi +is the text-based program which also contains the game-playing engine. + +@item xshogi +is the X-windows graphical interface to gnushogi. + +@end table + +@sp 1 + +Since xshogi invokes gnushogi, most players will just type ``xshogi'' +and start playing. + +Disclaimer: I use the personal pronouns ``him'', ``his'' etc. to refer +to a shogi player regardless of gender. That's easier than writing +``his or her'' all over the place. I don't mean to infer that women +don't play shogi; in fact shogi is very popular in Japan among women as +well as men. + + + +@node License, About shogi, Introduction, Top +@unnumbered GNU GENERAL PUBLIC LICENSE +@cindex License +@cindex GPL +@center Version 2, June 1991 + +@display +Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. +675 Mass Ave, Cambridge, MA 02139, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@unnumberedsec Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software---to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + +@page +@iftex +@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end iftex +@ifinfo +@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end ifinfo + +@enumerate 0 +@item +This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The ``Program'', below, +refers to any such program or work, and a ``work based on the Program'' +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term ``modification''.) Each licensee is addressed as ``you''. + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +@item +You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +@item +You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + +@enumerate a +@item +You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + +@item +You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any +part thereof, to be licensed as a whole at no charge to all third +parties under the terms of this License. + +@item +If the modified program normally reads commands interactively +when run, you must cause it, when started running for such +interactive use in the most ordinary way, to print or display an +announcement including an appropriate copyright notice and a +notice that there is no warranty (or else, saying that you provide +a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this +License. (Exception: if the Program itself is interactive but +does not normally print such an announcement, your work based on +the Program is not required to print an announcement.) +@end enumerate + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +@item +You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + +@enumerate a +@item +Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections +1 and 2 above on a medium customarily used for software interchange; or, + +@item +Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your +cost of physically performing source distribution, a complete +machine-readable copy of the corresponding source code, to be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +@item +Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is +allowed only for noncommercial distribution and only if you +received the program in object code or executable form with such +an offer, in accord with Subsection b above.) +@end enumerate + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +@item +You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + +@item +You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +@item +Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +@item +If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +@item +If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +@item +The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and ``any +later version'', you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +@item +If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +@page +@iftex +@heading NO WARRANTY +@end iftex +@ifinfo +@center NO WARRANTY +@end ifinfo + +@item +BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +@item +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. +@end enumerate + +@iftex +@heading END OF TERMS AND CONDITIONS +@end iftex +@ifinfo +@center END OF TERMS AND CONDITIONS +@end ifinfo + +@page +@unnumberedsec How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the ``copyright'' line and a pointer to where the full notice is found. + +@smallexample +@var{one line to give the program's name and a brief idea of what it does.} +Copyright (C) 19@var{yy} @var{name of author} + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +@end smallexample + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + +@smallexample +Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details +type `show w'. +This is free software, and you are welcome to redistribute it +under certain conditions; type `show c' for details. +@end smallexample + +The hypothetical commands @samp{show w} and @samp{show c} should show +the appropriate parts of the General Public License. Of course, the +commands you use may be called something other than @samp{show w} and +@samp{show c}; they could even be mouse-clicks or menu items---whatever +suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a ``copyright disclaimer'' for the program, if +necessary. Here is a sample; alter the names: + +@smallexample +Yoyodyne, Inc., hereby disclaims all copyright interest in the program +`Gnomovision' (which makes passes at compilers) written by James Hacker. + +@var{signature of Ty Coon}, 1 April 1989 +Ty Coon, President of Vice +@end smallexample + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + +@node About shogi, gnushogi, License, Top +@chapter About the game of shogi + + +@quotation +``Japanese chess cedes nothing in depth or beauty to the European +game... it is at least as interesting.'' + +--- Alexander Alekhine @* +(quoted in David Pritchard, @cite{The Encyclopedia of Chess Variants}) + +@sp 1 + +``... shogi [is] by far the most complex form of chess that has ever +achieved widespread popularity.'' + +--- R. Wayne Schmittberger, @cite{New Rules for Classic Games} +@end quotation + +@sp 1 + +Shogi is the version of chess played in Japan. It is strikingly +different from standard chess (which I shall refer to henceforth as +``international chess'') and also to all other regional variants, +because captured pieces can re-enter play on the side of the capturer. +This has several interesting effects on the play of the game: + +@sp 1 + +@enumerate +@item +Shogi is much more complex than international chess, at least in +terms of the average number of possible moves per turn (estimated at +about 35 for chess and at about 80 for shogi). + +@item +There are almost no draws (about 1-2% of all games in professional play). + +@item +Exchanges complicate the play rather than simplifying it. + +@item +There are no ``endgames'' in the standard chess sense; all pieces remain +in play throughout the game. Games typically end in a race to +checkmate the other player before being checkmated oneself. + +@item +Ownership of a piece is not indicated by the color of the piece; +instead, pieces are wedge-shaped and point towards the opponent. The +name of the piece is inscribed in Kanji characters on the front of the +piece. + +@item +Most importantly: it's more fun than other forms of chess :-) + +@end enumerate + +@sp 1 + +Shogi is extremely popular in Japan; it has been estimated that 20 +million Japanese can play shogi, of which perhaps 1 million are active +players. It is even more popular there than the game of go, Japan's +other favorite board game. There are a number of professional players +who make a considerable amount of money playing in shogi tournaments, +and the game receives extensive newpaper and television coverage. +Despite this, the game has yet to become popular outside of Japan. Part +of this is because the Kanji characters on the pieces scare away some +people, but mostly it's due, I think, to lack of exposure to the game +and to the difficulty of finding opponents. I hope that GNU shogi will +help introduce shogi to a wider audience. + +@ifinfo +@menu +* The rules of shogi:: +* Sample game:: +* Mating problems:: +* Shogi variants:: +* Differences between shogi and chess:: +@end menu +@end ifinfo + + +@c ------------------------------------------------------- +@c +@c The rules of shogi. +@c +@c ------------------------------------------------------- + +@node The rules of shogi, Sample game, About shogi, About shogi +@section The rules of shogi +@cindex Rules + +Shogi is a two-person abstract strategy board game with full information +(i.e. all pieces and moves are visible to both players at all times). +It is in the chess family, being descended from the same ancestral game +as international chess: the Indian game of Chaturanga. The two players +are referred to as ``Black'' and ``White'', with Black moving first +(unlike in international chess, where White moves first), and with +movement alternating between the two players. Note that ``Black'' and +``White'' are just names; the pieces are not colored. Instead, they are +flat, wedge-shaped pieces which point towards the opponent. The +identity of a given piece is indicated by two Japanese Kanji characters +on each piece. In fact, only the top character is needed to identify +the piece and thus only the top character is used in shogi diagrams. I +will use alphabetical equivalents in the diagrams here; to see what the +Kanji characters look like, start up xshogi (@pxref{xshogi}) and compare +the starting setup there with the starting setup in this file +(@pxref{The opening setup}). + +The object of the game is to capture the opponent's King. The board is +a grid of 9x9 uncolored squares, and pieces are placed on the squares. +Each player begins with 20 pieces, described in the next section. +Capture is by displacement, as in international chess. + +@ifinfo +@menu +* The moves of the pieces:: +* The opening setup:: +* Promotion of pieces:: +* Drops:: +* Winning the game:: +* Draws:: +* Handicaps:: +* Notes for chess players:: +@end menu +@end ifinfo + +@c The moves of the pieces. + +@node The moves of the pieces, The opening setup, The rules of shogi, The rules of shogi +@subsection The moves of the pieces +@cindex Piece moves + +Each player at the beginning of a shogi game has a total of 20 pieces of +eight different types. The moves of the shogi pieces can be divided +into three classes: ``stepping'' pieces, that only move one square at a +time; ``ranging'' pieces that move any number of unobstructed squares in +a line, and ``jumping'' pieces that can jump over obstructing pieces to +reach their destination squares. Most pieces can also promote to +different (usually stronger) pieces under certain circumstances (see the +next section). All pieces capture the same way that they move (even +pawns). The piece moves and promotions are as follows; each piece name +is followed by the standard piece abbreviation: + +@enumerate + +@item +The king (K). The king can move one square in any horizontal, vertical, +or diagonal direction, just like the king in international chess. The +king does not promote. + +@item +The rook (R). The rook can move any number of squares in a horizontal +or vertical direction. The rook is the same as the rook in +international chess (except that it can promote). A rook promotes to a +``dragon king'' or ``dragon'' for short (often just referred to as a +``promoted rook''), which can move as a rook or can move one square in +any diagonal direction. + +@item +The bishop (B). The bishop can move any number of squares in a diagonal +direction. The bishop is the same as the bishop in international chess +(except that it can promote). A bishop promotes to a ``dragon horse'' +or ``horse'' for short (often just referred to as a ``promoted +bishop''), which can move as a bishop or can move one square in any +horizontal or vertical direction. Note: the horse should not be +confused with a knight (see below), as they are two completely different +pieces. + +@item +The gold general (G). A gold general can move one square in any +horizontal or vertical direction, or one square in a forward diagonal +direction. Gold generals do not promote. + +@item +The silver general (S). A silver general can move one square in any +diagonal direction, or one square straight forward. A silver general +promotes to a gold general. + +@item +The knight (N). A knight can move one square straight forward followed +by one square to either forward diagonal, jumping over intervening +pieces if any. In other words, a knight moves like its international +chess counterpart, but forward only. A knight promotes to a gold +general. The knight is the only jumping piece, as in chess. + +@item +The lance (L). A lance can move any number of squares straight forward. +A lance promotes to a gold general. + +@item +The pawn (P). A pawn can move one square straight forward. The pawn +captures the same way that it moves, in contrast to international chess. +There is also no initial two-space move for pawns and no +@emph{en-passant} capture. A pawn promotes to a gold general; a +promoted pawn is usually known as a ``Tokin''. + +@end enumerate + + +@c The opening setup. + +@node The opening setup, Promotion of pieces, The moves of the pieces, The rules of shogi +@subsection The opening setup +@cindex Opening setup + +The opening setup for shogi is as follows: + +@ifinfo + + 9 8 7 6 5 4 3 2 1 ++---------------------------------------------+ @* +| wL | wN | wS | wG | wK | wG | wS | wN | wL | a @* ++---------------------------------------------+ @* +| | wR | | | | | | wB | | b @* ++---------------------------------------------+ @* +| wP | wP | wP | wP | wP | wP | wP | wP | wP | c @* ++---------------------------------------------+ @* +| | | | | | | | | | d @* ++---------------------------------------------+ @* +| | | | | | | | | | e @* ++---------------------------------------------+ @* +| | | | | | | | | | f @* ++---------------------------------------------+ @* +| bP | bP | bP | bP | bP | bP | bP | bP | bP | g @* ++---------------------------------------------+ @* +| | bB | | | | | | bR | | h @* ++---------------------------------------------+ @* +| bL | bN | bS | bG | bK | bG | bS | bN | bL | i @* ++---------------------------------------------+ +@end ifinfo + +@c The following TeX macros are taken with permission from +@c "TeX for the Beginner" by Wynter Snow. + +@tex +\def\startline{\par\nobreak\noindent} + +{\obeylines\obeyspaces% +\gdef\beginVerbatim{\bigbreak% +\begingroup% +\parskip=0pt% +\obeylines\obeyspaces% +\let^^M=\startline% +\tt}} +\gdef\endVerbatim{\endgroup\bigbreak} +\beginVerbatim + + + 9 8 7 6 5 4 3 2 1 ++--------------------------------------------+ +| wL | wN | wS | wG | wK | wG | wS | wN | wL | a ++--------------------------------------------+ +| | wR | | | | | | wB | | b ++--------------------------------------------+ +| wP | wP | wP | wP | wP | wP | wP | wP | wP | c ++--------------------------------------------+ +| | | | | | | | | | d ++--------------------------------------------+ +| | | | | | | | | | e ++--------------------------------------------+ +| | | | | | | | | | f ++--------------------------------------------+ +| bP | bP | bP | bP | bP | bP | bP | bP | bP | g ++--------------------------------------------+ +| | bB | | | | | | bR | | h ++--------------------------------------------+ +| bL | bN | bS | bG | bK | bG | bS | bN | bL | i ++--------------------------------------------+ + +\endVerbatim +@end tex + +@sp 1 + +Here, ``b'' stands for ``black'' and ``w'' stands for ``white'', so +that, for instance, ``bL'' means ``black lance''. The numbers above the +files and the letters to the right of the ranks represent the most +common notation system used for shogi by westerners (the Japanese also +use Arabic numerals for the files but use Japanese numerals for the +ranks). + + +@c Promotion of pieces. + +@node Promotion of pieces, Drops, The opening setup, The rules of shogi +@subsection Promotion of pieces +@cindex Piece promotion + +In sharp contrast to international chess, where only pawns can promote +to higher-ranked pieces, most of the pieces in shogi can promote. The +promoted ranks are discussed in the section on piece moves (@pxref{The +moves of the pieces}) but are repeated here for reference: + +@table @asis + +@item Pawn +promotes to gold general (called a `tokin' in this case only). + +@item Lance +promotes to gold general. + +@item Knight +promotes to gold general. + +@item Silver general +promotes to gold general. + +@item Gold general +does not promote. + +@item Bishop +promotes to ``dragon horse'' or just ``horse'' for short. The horse can +move as a bishop or can move one square in any orthogonal direction. + +@item Rook +promotes to ``dragon king'' or just ``dragon'' for short. The dragon +can move as a rook or can move one square in any diagonal direction. + +@item King +does not promote. + +@end table + +@sp 1 + +The three ranks furthest away from each player constitute his/her +``promotion zone''. A player may, but is not required to, promote a +piece after making a move in which the piece begins and/or ends in the +promotion zone. Thus you can promote a piece when moving the piece into +the promotion zone, out of the promotion zone, or entirely within the +promotion zone. Promotion is mandatory in these cases: + +@sp 1 + +@enumerate + +@item You must promote a pawn or a lance after moving it to the last rank. + +@item You must promote a knight after moving it to either of the last +two ranks. + +@end enumerate + +@sp 1 + +These forced promotions ensure that a piece cannot be moved to a square +from which it would have no further move. + +Pieces ``dropped'' onto the board (@pxref{Drops}) always drop in the +unpromoted state, even if they drop into the promotion zone. + + + +@c Drops. + +@node Drops, Winning the game, Promotion of pieces, The rules of shogi +@subsection Drops +@cindex Drops + +When a player captures a piece, that piece is not removed from play. +Instead, it becomes the property of the capturer and can re-enter play +by being placed on (almost) any vacant square during the player's move. +This is known as a ``drop'' and counts as a full move (in other words, +you can either move a piece on the board or drop a piece onto the board +during your move, but not both). All pieces drop in the unpromoted +state. Pieces may be legally dropped in their promotion zone, but they +do not promote on that turn. + +There are several restrictions on drops: + +@enumerate + +@item A pawn may not be dropped onto a file if there is already an +unpromoted pawn belonging to the same player on that file. It is legal +to drop a pawn on a file which contains a @emph{promoted} pawn belonging +to the same player, however. + +@item A pawn may not be dropped to give immediate checkmate on the +move. A pawn is, however, permitted to be moved on the board to give +immediate checkmate. This is a curious rule, and if anyone knows the +reason for it I would appreciate it if they would contact me and explain +it to me :-) + +@item A pawn or piece may not be dropped onto a square from which they +would have no legal move. This means that pawns and lances may not be +dropped onto the last rank, and the knight may not be dropped onto the +last or second-to-last rank. + +@end enumerate + +It is entirely permissible (and often advisable) to drop a piece or pawn +between one's King and an attacking ranging piece. For this reason, +the final checkmating move is nearly always an attack on the King from +an adjacent square (except for an attack by a Knight). + +Captured pieces are said to be pieces ``in hand''. + +The drop is the primary distinguishing feature of Japanese chess, shared +with no other popular chess-type game. It gives shogi a very aggressive +quality, and dramatically increases the number of possible moves once a +few pieces have been captured. Another interesting feature of shogi is +that exchanges complicate play rather than simplifying it (as in +international chess), because of the drop rule. + + +@c Winning. + +@node Winning the game, Draws, Drops, The rules of shogi +@subsection Winning the game +@cindex Winning the game + +A game of shogi is won by capturing the opponent's king. In general, +this is done by checkmating the king: attacking the king in such a way +that the king cannot be defended no matter what the defending player +moves. Note, though, that there is no rule that requires a player to +defend a king which is being attacked. However, if he does not defend +his king, the opponent is entirely free to capture it on the next move, +thus winning the game. As in international chess, in practice most +games end by resignation when one player realizes that he cannot escape +checkmate. + + +@c Draws. + +@node Draws, Handicaps, Winning the game, The rules of shogi +@subsection Draws +@cindex Draws + +There are very few draws in shogi; only about 1-2% of professional games +end in a draw. One reason for this is that material can never be +depleted as in chess, because captured pieces are constantly re-entering +play as a consequence of the drop rule. In fact, most of the ways a +game can be drawn in chess are not allowed in shogi: + +@sp 1 + +@itemize @bullet + +@item Draws cannot be offered. + +@item There is no fifty-move rule. + +@item A stalemate counts as a win for the stalemater. Stated otherwise: +if you can't move, you lose. + +@item Perpetual check is illegal (see below). + +@end itemize + +@sp 1 + +There are only two legal ways in which a draw can occur: + +@sp 1 + +@enumerate + +@item A position (including the pieces in hand) occurs 4 times with the same +player to move (called ``Sennichite''). However, if this is caused by +consecutive checks (direct attacks on the King, threatening to capture +it on the next move) by one side, the player giving these checks loses +the game. In other words, perpetual check results in a loss for the +attacker who recreates the same position the 4th time. + +@item Both players have moved their King into the the promotion zone (or they +cannot be prevented from doing so) and the Kings cannot be checkmated. +A King who has entered the promotion zone is known as an ``entering +King''; due to the forward orientation of most shogi pieces, it is very +hard to mate such a King. In that case the players may decide to count +their pieces as follows: the King does not count, the Rook and Bishop +count as 5 points, and all other pieces as one point. Promotion is +disregarded. If both players have at least 24 points the game is a draw +(called ``Jishogi''). If a player has less, he loses the game. + +Of course, a player can refuse to count pieces when he still has mating +chances or chances to gain material which would affect the outcome of +the counting. There is no strict rule about what to do if this is not +the case, but nonetheless a player refuses to count up (e.g. because he +does not have enough points for a draw). It has been generally accepted +that in such a case the game ends and the pieces are counted after one +player has managed to get all his pieces protected in the promotion +zone. + +@end enumerate + +@sp 1 + +@c Handicaps. + +@node Handicaps, Notes for chess players, Draws, The rules of shogi +@subsection Handicaps +@cindex Handicaps + +Unlike international chess, shogi has a well-established handicap system +which is used when players of different strengths play against each +other. Handicaps range from small to huge, which makes it possible for +weak players to play against even very strong players and have an even +chance of winning. + +Shogi players are ranked as follows: the weakest rank is around 15 +``kyu'', which represents a beginner. 14 kyu is higher than 15 kyu, 13 +kyu is higher still, and so on until you get to 1 kyu. The next highest +rank is 1 ``dan'', followed by 2 dan, 3 dan and so forth. The highest +amateur rank is 6 dan; professionals go up to 9 dan. However, +professional ranks are not the same as amateur ranks; a professional 1 +dan is @emph{much} stronger than an amateur 1 dan. This system is +similar to that used by go players (and also other Japanese sports such +as karate). + +A handicap consists of the stronger player playing White and removing +one or more pieces from his side of the board at the start of the game. +These pieces are permanently removed from play; they are not in hand. + +The following is a list of the accepted handicaps, from weakest to +strongest. The degree of the handicap, represented by the position in +the list, represents the difference in rank between the two players for +which the handicap is appropriate. These rules are taken from the books +``Shogi for Beginners'' by John Fairbairn and ``The Art of Shogi'' by +Tony Hoskings (@pxref{References and links}) and, I believe, represent +current Japanese practice. + +@sp 1 + +@enumerate + +@item +The stronger player removes his left lance (on 1a). + +@item +The players play a two-game match; in the first game the stronger player +removes his left lance (on 1a), while in the second game he removes his +bishop. + +@item +The stronger player removes his bishop. + +@item +The stronger player removes his rook. + +@item +The stronger player removes his rook and left lance. + +@item +The players play a two-game match; in the first game the stronger player +removes his rook and left lance (on 1a), while in the second game he +removes his rook and bishop. + +@item +The stronger player removes his rook and bishop. This is usually called +a ``two-piece'' handicap. + +@item +The stronger player removes his rook, bishop, and both lances. This is +called a ``four-piece'' handicap. + +@item +The stronger player removes his rook, bishop, both lances, and both +knights. This is called a ``six-piece'' handicap. + +@item +The stronger player removes his rook, bishop, both lances, both knights, +and both silvers. This is called an ``eight-piece'' handicap. + +@end enumerate + +@sp 1 + +Another advantage of playing handicap games is that the handicaps alter +the optimal strategy for both players. For instance, handicaps all have +their own opening lines which may bear little or no resemblance to those +used in non-handicap shogi. This means that when learning handicap +shogi, you are essentially learning completely new games which use the +same equipment! + +The reader may wonder how on earth a player giving an eight-piece +handicap, say, could possibly hope to win. Don't forget, though, that +in shogi the opponent's pieces can be captured and then become part of +one's own army. Thus, if the opponent plays badly enough, the number of +pieces will soon even out. + + +@c Notes for chess players. + +@node Notes for chess players, , Handicaps, The rules of shogi +@subsection Notes for chess players + +Here are a few miscellaneous things that may confuse chess players. +Some of these have been mentioned elsewhere, but they bear repeating. + +@sp 1 + +@enumerate +@item There is no queen. + +@item Pawns capture the same way they move. There is no initial +two-space pawn move and no @emph{en-passant} move. + +@item There is no special castling move. There @emph{are} a large +number of possible defensive formations referred to as ``castles'' +(@pxref{Sample game}) but there is no need for special moves to create +them. + +@item A given piece can only promote to @emph{one} other kind of piece. + +@end enumerate + +@sp 1 + +@c +@c Sample game. +@c + +@node Sample game, Mating problems, The rules of shogi, About shogi +@section Sample game +@cindex Sample game + +@c This will have to be spruced up for the TeX version... + +This game was annotated by Pieter Stouten (@pxref{References and +links}). I have made some minor corrections. Note that captures are +denoted by the ``x'' symbol e.g. Rx3f and drops are denoted by the ``*'' +symbol e.g. R*3f. Check is indicated by a ``+'' after the move, +e.g. R3f+. I recommend you use gnushogi/xshogi to play along with this +game. In xshogi simply hit the ``Force Moves'' button after starting +up, while in gnushogi enter the word ``force'' at the prompt. This will +allow you to enter moves for both sides. + +Note also that the move numbering system used here is the chess-type +system where one move means one move by each player. The Japanese count +one move made by each player as two moves. + +--------------------------------------------------------------------------- + +Below you will find (the English translation of) an annotated game which +was published in the Dutch Shogi magazine ``81'' and in the Dutch +beginners booklet. It has proven to be a very useful game to explain +some basic principles of Shogi. Also, it is a rather straightforward +game compared to professional games where in most cases very diffuse +middle game fights take place. + + Pieter Stouten, 14th May 1990. + +--------------------------------------------------------------------------- + +Black: Michael Trent (1-dan). White: David Murphy (2-dan). + + 1. P2f P3d 2. P2e B3c @* +[ This move is necessary, as otherwise white can exchange pawns: 3. P2d +Px2d 4. Rx2d. He would thus get a pawn in hand and open up his rook +file. ] + + 3. P7f P4d @* +[ White closes the bishop diagonal again. He plans to play ranging rook +(the rook goes to 5b, 4b, 3 or 2b; a defensive strategy) and in that +case he'd better avoid an exchange of bishops. One of the reasons is +that he will have problems developing his pieces without leaving holes +for bishop drops. ] + + 4. S4h R3b 5. P3f S4b 6. K6h K6b @* +[ In general the rook plays an important role in the attacks. It is +wise to move the king away from the area where the initial fights will +be and both players act according to the Shogi proverb ``keep the rook +and king apart''. ] + + 7. K7h K7b 8. P5f P5d 9. G4i-5h G4a-5b @* +[ Both players use their second gold general to build their castle. ] + + 10. S6h @* +[ In itself this move is not bad. However, it will become clear that +black plans a quick attack and in that case it is wiser to omit this +move. ] + + 10... S5c 11. P1f P1d @* +[ The advance of the edge pawns must be timed very well. The remark at +black's tenth move applies here too: this move is good if black wants to +play a slow game, because it eliminates a future B1e. ] + + 12. P4f K8b 13. N3g S7b @* +[ Black develops his knight in order to start an attack over the second, +third and fourth files. White strengthens his king's position and +awaits the attack. He aims at a counterattack as soon as black has +broken through into the white camp. Probably white's breakthrough will +take place later, but he has good compensation in the form of a stronger +castle. This theme occurs very often in static rook versus ranging rook +games. ] + + 14. P4e R4b @* +[ Black starts his attack and white puts up a very passive defence. His +rook has a hard task now to penetrate the black position. Moreover, he +blocks his own bishop. It seems much better to start a counterattack +with 14... P3e, later to be followed by B2b, B5a or Bx4d in order to use +his rook more actively. ] + + 15. Px4d Sx4d 16. P*4e S5c @* +[ 16... Sx4e is more active. A silver general is normally more valuable +than a knight, but white gets two pawns in hand and black none, while +the knight might come in handy for white too. ] + + 17. Bx3c+ Nx3c 18. P2d Px2d @* +[ Black threatens to break through and white has to consider taking the +pawn on 2d or starting a counterattack with Nx4e. If he chooses the +latter, black can play Px2c+ followed by +P3c. The disadvantage is the +black ``tokin'' (=promoted pawn) that white will get in his camp; the +advantage is that it will cost black two more moves to promote his rook. +Because white did not trust that the result after engaging in a +``semeai'' (=mutual attack) with 18...Nx4e would give a positive result, +he captured the pawn on 2d. Making the right decision in moments like +this often makes the difference between a win and a loss: miss one +attacking chance and you will be forced to defend the whole game until +the unavoidable defeat; on the other hand, an unsound attack can destroy +all ``aji'' (=potential, meaning possibilities, threats) without getting +anything in return. ] + + 19. Rx2d Nx4e 20. Nx4e Rx4e 21. R2a+ P*4g @* +[ Now it becomes clear why black's 10. S6h was not good. Had this move +been omitted, then white would not have had the time to play 13... S7b +and after R2a+ the gold on 6a would hang. Thus black would have kept +``sente'' (=initiative). Instead of 21... P*4g, B*6d is a very good +move, because after 22. P*2h black does not have a pawn in hand anymore +and he is being threatened with the annoying 22... N*4f 23. G5g N3h+ +24. S4g +N4h also. Black can also counter 21... B*6d with 22. N*3g. +White would then reply with 22... R4b 23. B*3c P*4g 24. Bx4b+ Sx4b. The +white rook has played its role and instead of spending moves on saving +it white starts to scatter black's defences by successive pawn drops on +the fourth file: 25. Gx4g P*4f 26. G5g N*6e 27. G5h P4g+ 28. Gx4g P*4f. +This analysis was provided by Kato Hifumi, 9-dan professional (the +highest regular grade). Destroying the coherence of the enemy pieces +(their shape) by dropping pawns is one of the most important Shogi +techniques. With the actual move 21... P*4g white missed a good +chance. ] + + 22. Sx4g P*4f 23. B*3g Px4g+ 24. +Rx6a +Px3g @* +[ 23. B*3g seems pointless, but a closer look reveals that it is +actually quite mean. On move 24 white cannot capture black's ``Ryu'' +(=dragon =promoted rook) with his silver: 24... Sx6a 25. N*7d K7b +26. G*8b mate. By attacking the front of the white castle and +threatening to mate him there, black has the chance to break down the +white defences from the side. ] + + 25. +Rx5b S*6b @* +[ Here 25... B*4d would be much better, because it is defensive and +attacking at the same time. After e.g. 26. G*4c Bx9i+ 27. Gx5c black +threatens 28. +Rx7b Kx7b 29. S*6a K8b 30. S*7a Kx7a 31. G*7b mate. +White is one move quicker, however. He has the following beautiful +``tsume'' (mating sequence where every move is check): 27... N*8f 28. Px8f +S*8g 29. Kx8g B*9h 30. K7h Bx8i+ 31. K8g +B8i-8h 32. K9f L*9e mate. +This illustrates the sharpness of Shogi: one move can make the +difference between winning and losing. ] + + 26. P*4f Rx4f @* +[ This move eliminates white's last chances. 26... R4b 27. +Rx4b Sx4b +28. R*4a seems annoying, but after 28... B*3c 29. S7g B*3b white wins +the rook and with his ``tokin'' on 3g there still is some hope. ] + + 27. N*6e +P4g @* +[ White cannot defend anymore, so he starts a desperate attack. Black +does not lose the right track, however. ] + + 28. Nx5c+ +Px5h 29. +Nx6b +Px6h 30. Gx6h N*8f 31. Px8f B*6i 32. Gx6i + R4h+ 33. N*6h +Rx6h 34. Gx6h S*8g 35. Kx8g N*9e 36. K7h Resigns @* +[ White resigns here, because after 36... B*8g 27. K7g his attack has +petered out. ] + +@page + + +@c +@c Mating problems. +@c + +@node Mating problems, Shogi variants, Sample game, About shogi +@section Mating problems + +One good way to improve at shogi is to solve mating problems. There are +several types of these problems, but the most common is called a +``tsume-shogi'' problem, or ``tsume'' problem for short. In a tsume +problem, all pieces that are not on the board are assumed to be in the +opponent's hand (except for your King, which is usually not shown). +Every move you make must be check until the final checkmate. Your +opponent may play any piece on the board or drop any of his pieces in +hand in order to prevent the mate. In a properly constructed tsume +problem, all of your pieces on the board and in hand must be essential +to the solution. One consequence of this is that all of your pieces in +hand must be played during the solution. There should only be one +correct solution for the given number of moves. Tsume problems use +Japanese-style move numbering; thus, a problem where you move (and give +check), your opponent moves, and you move to give checkmate is called a +three-mover. Here is a really trivial three-mover: + +@sp 1 + +@ifinfo + + 3 2 1 @* +----------------+ @* +| | | | a @* +----------------+ @* +| | | wK | b @* +----------------+ @* +| | | | c @* +----------------+ @* +| bN | | | d @* +----------------+ @* +| | | | e @* +----------------+ @* +| | bN | | f @* +----------------+ @* + +@sp 1 + +Black in hand: S, G + +@end ifinfo + + +@tex +\def\startline{\par\nobreak\noindent} + +{\obeylines\obeyspaces% +\gdef\beginVerbatim{\bigbreak% +\begingroup% +\parskip=0pt% +\obeylines\obeyspaces% +\let^^M=\startline% +\tt}} +\gdef\endVerbatim{\endgroup\bigbreak} +\beginVerbatim + + 3 2 1 +----------------+ + | | | | a +----------------+ + | | | wK | b +----------------+ + | | | | c +----------------+ + | bN | | | d +----------------+ + | | | | e +----------------+ + | | bN | | f +----------------+ + +Black in hand: S, G + +\endVerbatim +@end tex + +@sp 1 + +Here, Black plays G*2b, White plays K1c, and Black plays S*1d mate. +More typical tsume problems range from 5 moves to arbitrarily high +numbers of moves, and they can be quite brain-busting. Tsume problems +may seem artificial, but in the closing stages of the game where both +players have a lot of pieces in hand, it is often necessary to give +check at every move, or else your opponent will start a counterattack +and will mate you before you mate him. A tsume problem is a worst-case +scenario for the attacker: you have to mate your opponent even though he +has every piece not on the board in hand, which means you have to +develop sharp attacking skills. Many more tsume problems can be found +on the internet; I particularly recommend Patrick Davin's ``Shogi +Nexus'' (@pxref{References and links}). + +@page + +@c +@c Shogi variants. +@c + +@node Shogi variants, Differences between shogi and chess, Mating problems, About shogi +@section Shogi variants +@cindex Shogi variants +@cindex Variants +@cindex Tori Shogi +@cindex Wa Shogi +@cindex Chu Shogi +@cindex Dai Shogi +@cindex Tenjiku Shogi +@cindex Dai-dai Shogi +@cindex Maka-dai-dai Shogi +@cindex Tai Shogi +@cindex Kyoku Tai Shogi + +Several historical variants of shogi exist. Most of these were invented +before modern shogi (in some cases hundreds of years before), are much +larger than modern shogi and are not played with drops. Thus, in many +ways they are really more like giant chess games than like modern shogi. +The only one of these games to have survived in Japan is Chu (middle) +shogi, which is still played a little bit. Thanks to the efforts of +George Hodges and John Fairbairn of the Shogi Association (two British +shogi enthusiasts), these games were resurrected and rules and sets for +them can still be purchased from George Hodges (@pxref{References and +links}). I hope to eventually extend GNU shogi so that it can play at +least some of these games. There are also several non-historical +variants of shogi; I don't know much about them but you can find +information about them on the internet (@pxref{References and links}). + +The historical variants include: + +@sp 1 + +@enumerate + +@item +Tori (bird) shogi, played on a 7x7 board with 32 pieces in all; this is +the only variant that is known to have been played with drops. + +@item +Wa shogi, played on an 11x11 board with 54 pieces. This game can be +played with or without drops but the historical evidence favors the view +that it was played without drops. However, most people who have tried +it claim it is a much better game with drops, being even more intricate +than standard shogi. + +@item +Chu (middle) shogi, played on a 12x12 board with 92 pieces. This was +(and is) by far the most popular of the variants, and has 21 different +kinds of pieces in the starting line-up alone (along with several others +that appear upon promotion). Unlike modern shogi, there are a +tremendous number of ranging pieces and the game is definitely not +played with drops. There is also an amazing piece called the Lion which +has a double king move and can capture two pieces at once! Chu shogi +has a small but fanatical following, some of whom consider it better +than modern shogi. + +@item +Dai (great) shogi, played on a 15x15 board with 130 pieces. Other than +the larger board, this game is very similar to Chu shogi. + +@item +Tenjiku (exotic) shogi, played on a 16x16 board with 176 pieces. This +game is possibly the most complex tactical game in existence. There are +many astoundingly powerful pieces, including one (the Fire Demon) that +can capture up to eight opposing pieces in a single move! Despite the +size of the game, checkmates can occur very suddenly (and often very +early on) if one player makes a wrong move. Tenjiku also has a small +but fanatical following, one of whom (Colin Adams) has written a book on +the game which is available for download at +@uref{http://www.colina.demon.co.uk/tenjiku.html}. + +@item +Dai-dai (great-great) shogi, played on a 17x17 board with 192 pieces. +The opening setup alone has 64 different kinds of pieces! This game and +the larger ones that follow sound pretty outlandish, but they have +actually been played; a game of Dai-dai can supposedly be played in +about 12 hours. + +@item +Maka-dai-dai (great-great-great) shogi, played on a 19x19 board with 192 +pieces. For those for whom Dai-dai shogi is just too small :-) + +@item +Tai (grand) shogi, played on a 25x25 board with 377 pieces! Until +recently, this was thought to be the biggest chess game ever devised, +but now there is... + +@item +Kyoku tai (extremely grand?) shogi, played on a 36x36 board with 402 +pieces. The rules for this have just been unearthed in an old Japanese +book. Hopefully someone will soon organize a postal Kyoku tai shogi +championship; maybe their distant ancestors could finish it :-) + +It is thought that the really huge games (Dai-dai and up) were never +really played to any significant extent (gee, wonder why?) and were +devised merely so that the creators could have the fun of inventing +enormous games, amazing their friends and confounding their enemies. +However, the games up to Tenjiku shogi at least appear to be quite +playable, assuming one has the time. + +@end enumerate + +@sp 1 + +@c +@c Differences between shogi and chess. +@c + +@node Differences between shogi and chess, , Shogi variants, About shogi +@section Differences between shogi and chess +@cindex Shogi vs. Chess + +Some differences between shogi and international chess have been +mentioned elsewhere in this document; I summarize them here for people +who are interested in game comparisons. I won't try to deal with the +thorny question of which game is ``better'' although my bias may have +already come through :-) In fact, the drop rule makes the two games so +different in character that arguing over which game is better is like +comparing apples to oranges (you'd be better off comparing chess to Chu +shogi (@pxref{Shogi variants}). However, I believe that if you are a +chess fan you'll really like shogi as well, and shogi is also popular +with many people who don't particularly like chess. + +Here are the significant differences between chess and shogi: + +@sp 1 + +@enumerate + +@item +In shogi, captured pieces become the property of the capturer and can +re-enter play by being dropped onto almost any vacant square. In chess, +captured pieces are out of the game. Thus, in shogi, piece exchanges +complicate the play significantly while in chess they simplify it. + +@item +The shogi board is 9x9; the chess board is 8x8. + +@item +Shogi has five pieces with no counterpart in chess: the gold and silver +generals, the lance, the promoted rook and the promoted bishop. Chess +has one piece with no counterpart in shogi: the queen. The knight's +move in shogi is much more restrictive than in chess. Pieces in shogi +generally have a much smaller range of movement than in chess (unless +they are in hand). + +@item +In shogi, all pieces except the gold general and the king can promote, +but only to one kind of piece. Promotion is easier in shogi because the +promotion zone is closer to the starting position of the pieces +(especially pawns). In chess, only the pawn can promote, but it can +promote to any other piece except the king. + +@item +In shogi, pawns capture the same way they move. There is no initial +two-space pawn move and hence no @emph{en-passant} captures. In chess, +pawns capture diagonally which means that opposing pawns can block each +other. + +@item +In shogi, you only have one rook and one bishop. Note that the bishop +is not restricted to only one ``color'' square (squares in shogi aren't +colored, but never mind) because promoted bishops can also move one +square orthogonally. + +@item +There is no special castling move in shogi. The term ``castle'' is +used in shogi to denote a defensive formation consisting of (usually) +three generals which protect the king. There are many such castles +(about 40 or so have names). @xref{Sample game}. + +@item +Draws are much rarer in shogi than in chess. Perpetual check is not +allowed. Stalemate is a virtual impossibility, and is a loss for the +stalematee. + +@item +Since pieces are never out of play in shogi, chess-type endgames +involving only a few pieces do not occur. + +@item +Shogi games are generally longer than chess games (about 60-70 moves is +typical). + +@item +Shogi has a well-developed handicap system which is in general use; +chess does not. + +@end enumerate + +@sp 1 + +The effects of all these differences on play include (in my opinion): + +@sp 1 + +@enumerate + +@item +Piece/pawn structures in chess are more rigid than in shogi. Pawns +block each other and pawns, once advanced, cannot ever retreat. In +shogi, you can repair the hole caused by a pawn advance by exchanging +the pawn and dropping it back where you want it. Thus shogi is more +fluid than chess and less ``structural''. + +@item +Counterattack is MUCH more common in shogi than in chess. Games +typically end in mutual mating attacks, where each player is trying to +checkmate the other player before being checkmated himself. This makes +tempo incredibly important and also makes sacrificial play quite common. + +@item +Attacks involving only ranging pieces are more a feature of chess than +of shogi. A shogi attack typically uses a ranging piece or pieces to +support an attack by short-range pieces (especially generals). It is +very rare to mate a king with a non-adjacent ranging piece in shogi +since the player whose king is threatened can almost always interpose by +dropping a piece. + +@end enumerate + +@sp 1 + + +@c -------------------- +@c gnushogi. +@c -------------------- + +@node gnushogi, xshogi, About shogi, Top +@chapter gnushogi +@cindex gnushogi + +This section describes how to run the ``gnushogi'' program. + +@sp 1 + +SYNOPSIS + +@sp 1 + +gnushogi [ [[-]a] [-b bookfile] [-B binbookfile] [-C] [-h langfile] +[-L langfile] [-r length] [-R] [-s pathname] [-l pathname] [-S binbooksize] +[-t] [-c size] [-T size] [-v] [-x] [-X] arg1 arg2 ] + +@sp 1 + +DESCRIPTION + +@sp 1 + +GNU shogi (gnushogi) plays a game of japanese chess (shogi) against the +user or it plays against itself. + +At startup gnushogi reads the binbook file if it is present. It then +looks for a book file. If it is present it adds its contents to the +binbook data. If the binbook file is writable a new combined binbook +file is written. + +Gnushogi is a modified version of the gnuchess program. It has a simple +alphanumeric board display, or it can be used with the xshogi program +under X windows. The program gets its opening moves from the file +gnushogi.bbk which is located in a directory specified in the Makefile. +To invoke the program type: + +@sp 1 + +@table @samp + +@item gnushogi -C +simple curses based version + +@item gnushogi -X (or just gnushogi) +xshogi compatible version + +@item gnushogi -R +raw test display version +@end table + +@sp 1 + +TIME CONTROLS + +@sp 1 + +If one argument is given, it is the search time per move in +[minutes:]seconds. So gnushogi 30 will generate one move every 30 +seconds, while gnushogi 5:00 will generate one move every 5 minutes. + +If two or more arguments are given, they will be used to set tournament +time controls with the first argument of each pair being the number of +moves and the second being the total clock time in minutes[:seconds]. +Thus, entering gnushogi 60 5 will set the clocks for 5 minutes (300 +seconds) for the first 60 moves, and gnushogi 30 3:30 will allow 3 +minutes and 30 seconds for 30 moves. + +gnushogi 30 5 1 :30 will allow 5 minutes for the first 30 moves and 30 +seconds for each move after that. Up to 4 pairs of controls may be +specified. + +If no argument is given the program will prompt the user for level of +play. + +For use with xshogi see the documentation on that program. +@xref{xshogi}. + +@sp 1 + +@page + +BOOK + +@sp 1 + +The book gnushogi.tbk consists of a sequence of openings. An opening +begins with a line starting with a # (the rest of the line is a +comment). Following this is a series of moves in algebraic notation +alternating black and white separated by white space. A move may have a +? after it indicating this move should never be made in this position. +Moves are stored as position:move so transpositions between openings can +take place. + +@sp 1 + +HASHFILE + +@sp 1 + +The hashfile if created should be on the order of 4 megabytes; you can +create such a hashfile by typing ``gnushogi -c 22'' (see below). This +file contains positions and moves learned from previous games. If a +hashfile is used the computer makes use of the experience it gained in +past games. Tests run so far show that it plays no worse with the +hashfile than without, but it is not clear yet whether it provides a +real advantage. + +@sp 1 + +LEGAL MOVES + +@sp 1 + +Note: Piece letters are determined by the language file. What is +specified here is the default (English). + +Once gnushogi is invoked, the program will display the board and prompt +the user for a move. To enter a move, use the notation 7g7f where the +first letter-number pair indicates the origin square and the second +letter-number pair indicates the destination square. An alternative is +to use the notation P7f where the first letter indicates the piece type +(P,L,N,S,G,B,R,K). To promote append a + the type of the new piece to +the move, as in 2d2c+ or P2c+. Note that you must use capital letters +for the pieces by default. + +@sp 1 + +COMMAND-LINE OPTIONS + +@sp 1 + +@table @samp + +@item -a +Do not search on opponent's time. + +@item a +Do search on opponent's time. + +@item -b @var{bookfile} +Use bookfile for opening book. + +@item -B @var{binbookfile} +Use binbookfile for binary opening book. + +@item -c @var{size} +Create a new HASHFILE. File size is 2^size entries of approximately 65+? +bytes. + +@item -C +Use curses-based display mode. + +@item -h +Do not use hashfile. + +@item h +Do use hashfile. + +@item -l @var{pathname} +Pathname of the loadfile used with get or xget. + +@item -L @var{lang} +Use language lang from the file gnushogi.lang. If -L is not specified +it uses the first language in the file. + +@item -P @var{plylevels} +Number of plys to include in the binbookfile. For generating a +binbookfile. + +@item -r @var{length} +Rehash @emph{length} times in searching entries for position in +transposition table. + +@item -R +Use raw text display mode. This can be used for dumb terminals or for +systems that don't have curses. + +@item -s @var{pathname} +Pathname of the save file to use with the save command. + +@item -S @var{size} +Size of binbookfile for memory based books. For creating a binbookfile. + +@item -t +Show statistics for HASHFILE. + +@item -T @var{size} +Set the transposition table size to 2^size entries. + +@item -v +Show version and patchlevel. + +@item -x @var{value} +Use value as the evaluation window xwndw. + +@item -X +Use xshogi display mode (the default). + +@end table + +@sp 1 + +COMMANDS + +@sp 1 + +In addition to legal moves, the following commands can be entered at the +gnushogi prompt. Note: command names are determined by the language +file and may vary with the implementation. The default language is +English. + +@table @samp + +@item alg +allow algebraic input (not implemented). + +@item Awindow +change Alpha window (default score + 90). + +@item Bwindow +change Beta window (default score - 90). + +@item beep +toggles beeping after each move (default: on). + +@item bd +updates the current board position on the display. + +@item book +turns off use of the opening library. + +@item both +causes the computer to play both sides of a shogi game. + +@item black +causes the computer to take the white pieces, if the computer is to move +first. + +@item bsave +saves a game to disk as a book textfile. The program will prompt the +user for a file name. + +@item gamein +toggles game mode time control. Assumes the time specified for time +control is the time for a complete game. Input with the level command +should be the game time and the expected number of moves in a game. go +command must be given. + +@item coords +show coordinates on the display (visual only). + +@item contempt +allows the value of @emph{contempt} to be modified. + +@item debug +asks for a piece as color piece, as wb or bn, and shows its calculated +value on each square. + +@item debuglevel +sets level of debugging output if compiled with debug options. + +@item depth +allows the user to change the search depth of the program. The maximum +depth is 29 ply. Normally the depth is set to 29 and the computer +terminates its search based on elapsed time rather than depth. If depth +is set to (say) 4 ply, the program will search until all moves have been +examined to a depth of 4 ply (with extensions up to 11 additional ply +for sequences of checks and captures). If you set a maximum time per +move and also use the depth command, the search will stop at the +specified time or the specified depth, whichever comes first. + +@item easy +toggles easy mode (thinking on opponents time) on and off. The default +is easy mode ON. If easy mode is disabled, the keyboard is polled for +input every so often and when input is seen the search is terminated. It +may also be terminated with a sigint. + +@item edit +allows the user to set up a board position. +@itemize @minus + +@item # +clear the board. + +@item c +toggle piece color. + +@item . +command will exit setup mode. + +@item p3b +place a pawn on 3b + +@item p3b+ +place a promoted pawn on 3b + +@item p* +place a pawn in hand (among the captured pieces) + +@end itemize + +Pieces are entered by typing a letter (p,l,n,s,g,b,r,k) for +the piece followed by the coordinate. Here, letter case is ignored. + +The usual warning about the language file applies. + +@item exit +exits gnushogi. + +@item first +tells the computer to move first. Computer begins searching for a move. +(same as ``go''). + +@item force +allows the user to enter moves for both sides. To get the program to +play after a sequence of moves has been entered use the ``black'' or +``white'' commands. + +@item get +retrieves a game from disk. The program will prompt the user for a file +name. + +@item go +tells the computer to move first. Computer begins searching for a move. +(same as ``first''). + +@item hash +use/don't use hashfile. + +@item hashdepth +allows the user to change the minimum depth for using the hashfile and +the number of moves from the beginning of the game to use it. + +@item help +displays a short description of the commands and the current status of +options. + +@item hint +causes the program to supply the user with its predicted move. + +@item level +allows the user to set time controls such as 60 moves in 5 minutes etc. +In tournament mode, the program will vary the time it takes for each +move depending on the situation. If easy mode is disabled (using the +``easy'' command), the program will often respond with its move +immediately, saving time on its clock for use later on. + +@item list +writes the game moves and some statistics on search depth, nodes, and +time to the file ``shogi.lst''. + +@item material +toggle material flag - draws on no pawns and both sides < rook. + +@item new +starts a new game. + +@item p +evaluates the board and shows the point score for each piece. The total +score for a position is the sum of these individual piece scores. + +@item post +causes the program to display the principal variation and the score +during the search. A score of 100 is equivalent to a 1 pawn advantage +for the computer. + +@item quit +exits the game. + +@item random +causes the program to randomize its move selection slightly. + +@item rcptr +set recapture mode. + +@item remove +backout the last level for both sides. Equal to 2 undo's. + +@item reverse +causes the board display to be reversed. That is, the black pieces will +now appear at the top of the board. + +@item rv +reverse board display. + +@item save +saves a game to disk. The program will prompt the user for a file name. + +@item switch +causes the program to switch places with the opponent and begin +searching. + +@item test +performs some speed tests for MoveList and CaptureList generation, and +ScorePosition position scoring for the current board. + +@item time +set computer's time remaining, intended for synchronizing clocks among +multiple players. + +@item tsume +toggle tsume mode. In tsume mode, not all possible moves will be +generated. If a king is in check, only moves that get the king out of +check are generated. If the king is not in check, only moves that give +check to the opponent's king are generated. + +@item undo +undoes the last move whether it was the computer's or the human's. You +may also type ``remove''. This is equivalent to two ``undo'''s +(e.g. retract one move for each side). + +@item white +causes the computer to take the black pieces, if the computer is to move +first the go command must be given. + +@item xget +read an xshogi position file. + +@item xsave +save as an xshogi position file. + +@item xwndw +change X window. The window around alpha/beta used to determine whether +the position should be scored or just estimated. Note: this has +@emph{nothing} to do with xshogi or X windows; the terms are completely +separate. + +@end table + +@sp 1 + + +@c -------------------- +@c xshogi. +@c -------------------- + +@node xshogi, References and links, gnushogi, Top +@chapter xshogi +@cindex xshogi + +This section describes how to run the ``xshogi'' program. + +@sp 1 + +SYNOPSIS + +@sp 1 + +xshogi [ options ] + +@sp 1 + +DESCRIPTION + +@sp 1 + +xshogi provides an X11/Xt/Athena Widgets user interface for gnushogi. +With xshogi you can play gnushogi, set up arbitrary positions, force +variations, or watch xshogi manage a game between two shogi programs. +Furthermore, it can be used as an interface between two players on +different displays. + +xshogi can also be used as a shogi board to play out games. It will +read through a game file or allow a player to play through a variation +manually (force mode). This is useful for keeping track of email postal +games or browsing games off the net. + +After starting xshogi, you can make moves by pressing mouse button 1 +while the cursor is over a square with your piece on it and dragging the +mouse to another square. If the move is illegal, gnushogi will not +allow it. xshogi will then retract the move. + +@sp 1 + +COMMAND-LINE OPTIONS + +@sp 1 + +The following command line options also correspond to X resources that +you can set in your .Xdefaults file. + +@sp 1 + +@table @samp + +@item [standard Xt options] +xshogi accepts standard Xt options like -display, -geometry, and +-iconic. + +@item -tc or -timeControl minutes[:seconds] +Amount of time for a set of moves determined by movesPerSession. If +this number of moves is played within the time control period, xshogi +resets the time clocks. Default: 5 minutes. + +@item -mps or -movesPerSession moves +Number of moves in a time control period. Default: 40 moves. + +@item -st or -searchTime minutes[:seconds] +Tell gnushogi to spend at most the given amount of time searching for +each of its moves. Without this option, gnushogi chooses its search +time based on the number of moves and amount of time remaining until the +next time control. Setting this option also sets -clockMode to False. + +@item -sd or -searchDepth number +Tell gnushogi to look ahead at most the given number of moves when +searching for a move to make. Without this option, gnushogi chooses +its search depth based on the number of moves and amount of time +remaining until the next time control. Setting this option also sets +-clockMode to False. + +@item -clock or -clockMode (True | False) +Determines whether or not to use the clock. If clockMode is False, the +clock does not run, but the side that is to play next is still +highlighted. + +@item -td or -timeDelay seconds +Time delay between moves during ``Load Game''. This doesn't have to be +a round number. Try -td 0.4. Default: 1 second. + +@item -nsp or -noShogiProgram (True | False) +If this option is True, xshogi acts as a passive shogi board; it does +not try to start a shogi program, not even to check whether moves made +in Force mode are legal. It also sets -clockMode to False. Default: +False. + +@item -fsp or -firstShogiProgram program +Name of first shogi program. In matches between two machines, this +program plays white. Default: ``gnushogi''. + +@item -ssp or -secondShogiProgram program +Name of second shogi program, if needed. In matches between two +machines, this program plays black; otherwise it is not started. +Default: ``gnushogi''. + +@item -fh or -firstHost host +Name of host the first shogi program plays on. Default: ``localhost''. + +@item -sh or -secondHost host +Name of host the second shogi program plays on. Default: ``localhost''. + +@item -rsh or -remoteShell shell_name +Some systems do not use rsh as the remote shell. This option allows a +user to name the remote shell command. This should be done in the +resource file. + +@item -mm or -matchMode (False | Init | Position | Opening) +Automatically run a game between firstShogiProgram and +secondShogiProgram. If matchMode is set to Init, xshogi will start the +game with the initial shogi position. If matchMode is set to Position, +xshogi will start the game with the position specified by the +loadPositionFile resource. If matchMode is set to Opening, xshogi will +play out the opening moves specified by the -loadGameFile resource. If +the -saveGameFile resource is set, a move record for the match will be +saved in the specified file. Default: ``False''. + +@item -lgf or -loadGameFile file +Name of file to read a game record from. Game files are found in the +directory named by the SHOGIDIR environment variable. If this variable +is not set, the current directory is used unless the file name starts +with a /. + +@item -lpf or -loadPositionFile file +Name of file to read a game position from. Position files are found in +the directory named by the SHOGIDIR environment variable. If this +variable is not set, the current directory is used unless the file name +starts with a /. + +@item -sgf or -saveGameFile file +Name of file to save a game record to. Game files are saved in the +directory named by the SHOGIDIR environment variable. If this variable +is not set, the current directory is used unless the file name starts +with a /. + +@item -spf or -savePositionFile file +Name of file to save a game position to. Position files are saved in +the directory named by the SHOGIDIR environment variable. If this +variable is not set, the current directory is used unless the file name +starts with a /. + +@item -coords or -showCoords (True | False) +If this option is True, xshogi displays algebraic coordinates along the +board's left and bottom edges. The default is False. The coordFont +resource specifies what font to use. + +@item -mono or -monoMode (True | False) +Determines whether xshogi displays its pieces and squares with two +colors or four. You shouldn't have to specify monochrome. xshogi will +determine if this is necessary. + +@item -wpc or -blackPieceColor color +Color specification for black pieces suitable for XParseColor(3X11). +Default: #FFFFCC. These colors look good on a DEC workstation. If you +need different colors, try using the xcolors application. Source for +xcolors can be found in the X11 contrib directory. + +@item -bpc or -whitePieceColor color +Same for white pieces. Default: #202020. + +@item -lsc or -lightSquareColor color +Same for light squares. Default: #C8C365. + +@item -dsc or -darkSquareColor color +Same for dark squares. Default: #77A26D. + +@item -wps or -westernPieceSet (True | False) +Choose the Western style piece set. + +@item -npb or -normalPawnBitmap file +@item -nnb or -normalKnightBitmap file +@item -nbb or -normalBishopBitmap file +@item -nrb or -normalRookBitmap file +@item -nkb or -normalKingBitmap file +Names of the bitmap files for the bitmap piece icons. + +@item -rpb or -reversePawnBitmap file +@item -rnb or -reverseKnightBitmap file +@item -rbb or -reverseBishopBitmap file +@item -rrb or -reverseRookBitmap file +@item -rkb or -reverseKingBitmap file +Names of the bitmap files for the outline piece icons. + +@item -debug or -debugMode (True | False) +Turns on debugging printout. + +@end table + +@sp 1 + +@page + +OTHER X RESOURCES + +@sp 1 + +@table @samp + +@item initString +The actual string that is sent to initialize the shogi program can be +set from .Xdefaults. It can't be set from the command line because of +syntax problems. The default value is ``new\nbeep\nrandom\neasy\n''. +The ``new'' and ``beep'' commands are required. You can remove the +``random'' command if you like; including it causes gnushogi to +randomize its move selection slightly so that it doesn't play the same +moves in every game. Even without ``random'', gnushogi randomizes its +choice of moves from its opening book. You can also remove ``easy'' if +you like; including it toggles easy mode off, causing gnushogi to think +on your time. That is, if ``easy'' is included in the initString, GNU +Shogi thinks on your time; if not, it does not. (Yes, this does seem +backwards, doesn't it.) You can also try adding other commands to the +initString; see the gnushogi documentation (@pxref{gnushogi}) for +details. + +@item blackString and whiteString +These resources control what is sent when the Machine Black and Machine +White buttons are selected. This is mostly for compatibility with +obsolete versions of gnushogi. + +Alternate bitmaps for piece icons can be specified either by choosing +one of the built-in sets or with the file name resources described +above. There are three built-in sets of piece bitmaps available, large +(the default), medium, or small. It is easiest to select the set you +prefer in the .Xdefaults file: + + XShogi*boardSize: Medium + +The font used for button labels and comments can be changed in the +.Xdefaults file. You may want to choose a smaller font if you are using +the small pieces: + + XShogi*font: helvetica_oblique12 + +The font used for coordinates (when the showCoords option is True) can +be set similarly: + + XShogi*coordFont: helvetica_10 + +If you are using a grayscale monitor, try setting the colors to: + + XShogi*blackPieceColor: gray100 @* + XShogi*whitePieceColor: gray0 @* + XShogi*lightSquareColor: gray60 @* + XShogi*darkSquareColor: gray40 + +@end table + +@sp 1 + +COMMAND BUTTONS AND KEYS + +@sp 1 + +@table @samp + +@item Quit +Quits xshogi. Q or q is a keyboard equivalent. + +@item Reset +Resets xshogi to the beginning of a shogi game. It also deselects any +game or position files. + +@item Flip View +inverts the view of the shogi board. + +@item Hint +displays a move hint from gnushogi. + +@item Load Game +plays a game from a record file. If no file is specified a popup dialog +asks for a filename. Game files are found in the directory named by the +SHOGIDIR environment variable. If this variable is not declared then +the current directory is used unless the file name starts with a /. G +or g is a keyboard equivalent. The game file parser will accept almost +any file that contains moves in algebraic notation. If the first line +begins with `#', it is assumed to be a title and is displayed. Text +enclosed in parentheses or square brackets is assumed to be commentary +and is displayed in a pop-up window. Any other text in the file is +ignored. + +@item Load Position +sets up a position from a position file. If no file is specified a +popup dialog asks for a filename. Position files are found in the +directory named by the SHOGIDIR environment variable. If this variable +is not declared then the current directory is used unless the file name +starts with a /. Position files must be in the format that the Save +Position command writes. + +@item Save Game +saves a game to a record file. If no file is specified a popup dialog +asks for a filename. If the filename exists, the user is asked whether +the current game record is be appended to this file or if the file +should be replaced. Game files are saved in the directory named by the +SHOGIDIR environment variable. If this variable is not declared then +the current directory is used unless the file name starts with a /. +Game files are human-readable, and can also be read back by the Load +Game command. Furthermore, they are accepted as gnushogi text bookfiles. + +@item Save Position +saves a position to a position file. If no file is specified a popup +dialog asks for a filename. Position files are saved in the directory +named by the SHOGIDIR environment variable. If this variable is not +declared then the current directory is used unless the file name starts +with a /. Position files are human-readable, and can also be read back +by the Load Position command. + +@item Machine White +forces gnushogi to play white. + +@item Machine Black +forces gnushogi to play black. + +@item Force Moves +forces a series of moves. That is, gnushogi stops playing and xshogi +allows you to make moves for both white and black. + +@item Two Machines +plays a game between two computer programs. + +@item Forward +moves forward through a series of remembered moves. F or f is a +keyboard equivalent. + +@item Backward +moves backward through a series of remembered moves. As a side effect, +puts xshogi into Force Moves mode. B or b is a keyboard equivalent. + +@item Pause +pauses the clocks or (in Load Game mode) pauses the game being loaded. +Press Pause again to continue. P or p is a keyboard equivalent. + +@item Edit Position +lets you set up an arbitrary board position. Use mouse button 1 to drag +pieces to new squares, or to delete a piece by dragging it off the board +or dragging an empty square on top of it. To drop a new piece on a +square, press mouse button 2 or 3 over the square. This brings up a +menu of black pieces (button 2) or white pieces (button 3). Additional +menu choices let you empty the square or clear the board. You can set +the side to play next by clicking on the Black or White indicator at the +top of the screen. + +@item Challenge +allows to make a two display game between two human players. Enter the +display you want to connect to. If you are allowed to connect, a new +board is displayed at the remote display. Challenge mode can only be +stopped by pressing ``quit''. + +@item Select Level +allows to reset the clocks for both players. Enter the number of moves +and the number of minutes in which the moves should be done. + +@item Move NOW +force computer to stop thinking and to make the current best move. + +@item Iconify I, i, C or c +iconifies xshogi. + +@end table + +@sp 1 + +LIMITATIONS + +@sp 1 + +If you press the Pause button during GNU Shogi's turn, +xshogi will stop the clocks, but gnushogi will still make a +move. + +After a mate or draw when playing against gnushogi, if you +back up with the Backward button, the clocks are reset +(because gnushogi has exited and must be restarted). + +The game parser recognizes only algebraic notation. + +@sp 1 + +AUTHORS + +@sp 1 + +Original authors of XBoard: Chris Sears and Dan Sears. + +Enhancements for XBoard (Version 2.0): Tim Mann. + +Conversion to XShogi (Version 1.1): Matthias Mutz. + +Current maintainer: Mike Vanier. + +@sp 1 + +COPYRIGHT INFORMATION + +@sp 1 + +XShogi borrows its piece bitmaps from CRANES Shogi. + +Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. +Enhancements Copyright 1992 Free Software Foundation, Inc. Enhancements +Copyright 1993 Matthias Mutz. Further enhancements copyright 1999 by +Michael Vanier and the Free Software Foundation, Inc. + +The following terms apply to Digital Equipment Corporation's copyright +interest in XBoard: + +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +The following terms apply to the enhanced version of XShogi distributed +by the Free Software Foundation: + +This file is part of XSHOGI. + +XSHOGI is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY. No author or distributor accepts responsibility to anyone +for the consequences of using it or for whether it serves any particular +purpose or works at all, unless he says so in writing. Refer to the +XSHOGI General Public License for full details. + +Everyone is granted permission to copy, modify and redistribute XSHOGI, +but only under the conditions described in the XSHOGI General Public +License. A copy of this license is supposed to have been given to you +along with XSHOGI so you can know your rights and responsibilities. It +should be in a file named COPYING. Among other things, the copyright +notice and this notice must be preserved on all copies. + + +@c --------------------- +@c References and links. +@c --------------------- + +@node References and links, Acknowledgements, xshogi, Top +@chapter References and links +@cindex References +@cindex Books +@cindex Mailing lists +@cindex Web sites + + +There are very few English-language books for people learning shogi. +The two I recommend are: + +@sp 1 + +@enumerate + +@item +@cite{Shogi for Beginners, 2nd. Edition}, by John Fairbairn. This is a +superb beginner's book in every way, covering all phases of the game. +It was out of print for a long time, but has now been reprinted and is +available either from Kiseido (@uref{http://www.labnet.or.jp/~kiseido}) +or from George Hodges (see below). + +@item +@cite{The Art of Shogi}, by Tony Hoskings. This is one step up from the +Fairbairn book. It covers a lot of ground, and is especially noteworthy +for its detailed treatment of opening lines. You can order this book +from Amazon.com's UK branch (@uref{http://www.amazon.co.uk}). + +@end enumerate + +@sp 1 + +Another book you may find is @cite{Shogi: Japan's Game of Strategy} by +Trevor Leggett. This book is very elementary and is somewhat outdated, +having been published first in 1966. However, it does feature a paper +shogi board and punch-out pieces, so if you want a really cheap shogi +set you might pick this book up. It is still in print. + +Two books that are no longer in print but are definitely worth getting +if you find them are @cite{Guide to Shogi Openings} and @cite{Better +Moves for Better Shogi}, both by Aono Teriuchi. They are published in a +bilingual edition (English/Japanese) and are the only books on shogi in +English written by a Japanese professional shogi player. John Fairbairn +did the translation from Japanese to English. + +Shogi sets are available from: + +@sp 1 + +@quotation +George F. Hodges @* +P.O. Box 77 @* +Bromley, Kent @* +United Kingdom BR1 2WT +@end quotation + +@sp 1 + +George also sells equipment for all the historical shogi variants +(@pxref{Shogi variants}) (except for Kyoku tai shogi) and also sells +back issues of the magazine ``Shogi'' which he published for 70 issues +in the late 70's to late 80's. This magazine is STRONGLY recommended; +it contains more information about shogi in English than you will ever +find anywhere else. + +Here are some useful URLs: + +@sp 1 + +@table @asis + +@item Pieter Stouten's shogi page: @uref{http://www.halcyon.com/stouten/shogi.html} +This is the main shogi-related site on the internet, with links to +almost all the other sites. + +@item Roger Hare's shogi page: @uref{http://www.ed.ac.uk/~rjhare/shogi} +This has lots of information, including full rules to most of the shogi +variants. + +@item Patrick Davin's Shogi Nexus: @uref{http://www.vega.or.jp/~patrick/shogi/} +There's lots of cool stuff on this site; my favorite is the extensive +collection of Tsume-shogi (mating) problems, both for beginners and +more advanced players. + +@item Steve Evans' shogi page: @uref{http://www.netspace.net.au/~trout/index.html} +Steve has written a program that plays almost all of the shogi variants, +unfortunately it only runs on Windows :-( + +@item Hans Bodlaender's chess variant pages: @uref{http://www.cs.ruu.nl/~hansb/d.chessvar} +This page has an almost unimaginable variety of rules for different +chess variants, including many shogi variants (historical and non-historical). + +@end table + +@sp 1 + +@c ----------------- +@c Acknowledgements. +@c ----------------- + +@node Acknowledgements, Bugs, References and links, Top +@chapter Acknowledgements +@cindex Acknowledgements + +I would like to thank the following people: + +@sp 1 + +@itemize @bullet + +@item +Matthias Mutz, who originally developed GNU shogi as a spin-off of GNU +chess and who very kindly let me take over the maintenance of this very +interesting project. + +@item +Richard Stallman and the Free Software Foundation, for creating an +organization where anyone can contribute software for the common good of +all, for making GNU/Linux possible, and especially for writing emacs and +gcc, without which my working life would be intolerable. + +@item +Georges Hodges, for starting the Shogi Association in England, without +which I would probably never have heard of shogi, for supplying shogi +equipment, for publishing the excellent magazine ``Shogi'' (now sadly +defunct), for personally answering all my silly questions by mail, and +for being the ambassador of shogi to the West. + +@item +Pieter Stouten, for having the most comprehensive shogi site on the +World Wide Web @uref{http://www.halcyon.com/stouten/shogi.html}, and for +maintaining the shogi-l mailing list. Go to Pieter's web site for more +information on subscribing to the list. Also thanks to everyone who +contributes and has contributed to that list. + +@item +Matt Casters, for testing GNU shogi. Matt and I will be working +together on improving the solution engine in future versions of this +program. + +@end itemize + +@sp 1 + +@c ----- +@c Bugs. +@c ----- + +@node Bugs, Index, Acknowledgements, Top +@chapter Bugs + +The motto of GNU shogi is ``100% bug-free or you don't pay!'' :-) In the +extremely unlikely case (*ahem*) that you do find a bug, please send me +(Mike Vanier) an email at @email{mvanier@@bbb.caltech.edu}. Also, feel +free to send me comments, complaints, out-and-out raves, suggestions, +plane tickets to Hawaii, and/or large suitcases filled with unmarked, +untraceable hundred-dollar bills. + + +@c ============ +@c End of body. +@c ============ + + + +@c ==== +@c End. +@c ==== + +@node Index, , Bugs, Top +@chapter Index + +@printindex cp + +@contents + +@bye + + diff --git a/doc/gnushogi_1.html b/doc/gnushogi_1.html new file mode 100644 index 0000000..2b15dd5 --- /dev/null +++ b/doc/gnushogi_1.html @@ -0,0 +1,61 @@ + + + + +GNU Shogi manual - Introduction + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Introduction

+

+ + + +

+GNU shogi is a program that plays shogi, the Japanese version of chess, +against a human (or computer) opponent. This file describes how to use +GNU shogi and also gives background information about the game of shogi. + + +

+This file describes GNU shogi version 1.3. It was written by me, Mike +Vanier, the current maintainer of GNU shogi. My email address is +mvanier@bbb.caltech.edu. + + +

+GNU shogi is actually two programs: + + +

+ +
`gnushogi' +
+is the text-based program which also contains the game-playing engine. + +
`xshogi' +
+is the X-windows graphical interface to gnushogi. + +
+ +

+Since xshogi invokes gnushogi, most players will just type "xshogi" +and start playing. + + +

+Disclaimer: I use the personal pronouns "him", "his" etc. to refer +to a shogi player regardless of gender. That's easier than writing +"his or her" all over the place. I don't mean to infer that women +don't play shogi; in fact shogi is very popular in Japan among women as +well as men. + + +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_10.html b/doc/gnushogi_10.html new file mode 100644 index 0000000..ddb906b --- /dev/null +++ b/doc/gnushogi_10.html @@ -0,0 +1,80 @@ + + + + +GNU Shogi manual - Draws + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Draws

+

+ + + +

+There are very few draws in shogi; only about 1-2% of professional games +end in a draw. One reason for this is that material can never be +depleted as in chess, because captured pieces are constantly re-entering +play as a consequence of the drop rule. In fact, most of the ways a +game can be drawn in chess are not allowed in shogi: + + + +

    + +
  • Draws cannot be offered. + +
  • There is no fifty-move rule. + +
  • A stalemate counts as a win for the stalemater. Stated otherwise: + +if you can't move, you lose. + +
  • Perpetual check is illegal (see below). + +
+ +

+There are only two legal ways in which a draw can occur: + + + +

    + +
  1. A position (including the pieces in hand) occurs 4 times with the same + +player to move (called "Sennichite"). However, if this is caused by +consecutive checks (direct attacks on the King, threatening to capture +it on the next move) by one side, the player giving these checks loses +the game. In other words, perpetual check results in a loss for the +attacker who recreates the same position the 4th time. + +
  2. Both players have moved their King into the the promotion zone (or they + +cannot be prevented from doing so) and the Kings cannot be checkmated. +A King who has entered the promotion zone is known as an "entering +King"; due to the forward orientation of most shogi pieces, it is very +hard to mate such a King. In that case the players may decide to count +their pieces as follows: the King does not count, the Rook and Bishop +count as 5 points, and all other pieces as one point. Promotion is +disregarded. If both players have at least 24 points the game is a draw +(called "Jishogi"). If a player has less, he loses the game. + +Of course, a player can refuse to count pieces when he still has mating +chances or chances to gain material which would affect the outcome of +the counting. There is no strict rule about what to do if this is not +the case, but nonetheless a player refuses to count up (e.g. because he +does not have enough points for a draw). It has been generally accepted +that in such a case the game ends and the pieces are counted after one +player has managed to get all his pieces protected in the promotion +zone. + +
+ +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_11.html b/doc/gnushogi_11.html new file mode 100644 index 0000000..7b8cb17 --- /dev/null +++ b/doc/gnushogi_11.html @@ -0,0 +1,126 @@ + + + + +GNU Shogi manual - Handicaps + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Handicaps

+

+ + + +

+Unlike international chess, shogi has a well-established handicap system +which is used when players of different strengths play against each +other. Handicaps range from small to huge, which makes it possible for +weak players to play against even very strong players and have an even +chance of winning. + + +

+Shogi players are ranked as follows: the weakest rank is around 15 +"kyu", which represents a beginner. 14 kyu is higher than 15 kyu, 13 +kyu is higher still, and so on until you get to 1 kyu. The next highest +rank is 1 "dan", followed by 2 dan, 3 dan and so forth. The highest +amateur rank is 6 dan; professionals go up to 9 dan. However, +professional ranks are not the same as amateur ranks; a professional 1 +dan is much stronger than an amateur 1 dan. This system is +similar to that used by go players (and also other Japanese sports such +as karate). + + +

+A handicap consists of the stronger player playing White and removing +one or more pieces from his side of the board at the start of the game. +These pieces are permanently removed from play; they are not in hand. + + +

+The following is a list of the accepted handicaps, from weakest to +strongest. The degree of the handicap, represented by the position in +the list, represents the difference in rank between the two players for +which the handicap is appropriate. These rules are taken from the books +"Shogi for Beginners" by John Fairbairn and "The Art of Shogi" by +Tony Hoskings (see section References and links) and, I believe, represent +current Japanese practice. + + + +

    + +
  1. + +The stronger player removes his left lance (on 1a). + +
  2. + +The players play a two-game match; in the first game the stronger player +removes his left lance (on 1a), while in the second game he removes his +bishop. + +
  3. + +The stronger player removes his bishop. + +
  4. + +The stronger player removes his rook. + +
  5. + +The stronger player removes his rook and left lance. + +
  6. + +The players play a two-game match; in the first game the stronger player +removes his rook and left lance (on 1a), while in the second game he +removes his rook and bishop. + +
  7. + +The stronger player removes his rook and bishop. This is usually called +a "two-piece" handicap. + +
  8. + +The stronger player removes his rook, bishop, and both lances. This is +called a "four-piece" handicap. + +
  9. + +The stronger player removes his rook, bishop, both lances, and both +knights. This is called a "six-piece" handicap. + +
  10. + +The stronger player removes his rook, bishop, both lances, both knights, +and both silvers. This is called an "eight-piece" handicap. + +
+ +

+Another advantage of playing handicap games is that the handicaps alter +the optimal strategy for both players. For instance, handicaps all have +their own opening lines which may bear little or no resemblance to those +used in non-handicap shogi. This means that when learning handicap +shogi, you are essentially learning completely new games which use the +same equipment! + + +

+The reader may wonder how on earth a player giving an eight-piece +handicap, say, could possibly hope to win. Don't forget, though, that +in shogi the opponent's pieces can be captured and then become part of +one's own army. Thus, if the opponent plays badly enough, the number of +pieces will soon even out. + + +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_12.html b/doc/gnushogi_12.html new file mode 100644 index 0000000..b5370f4 --- /dev/null +++ b/doc/gnushogi_12.html @@ -0,0 +1,40 @@ + + + + +GNU Shogi manual - Notes for chess players + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Notes for chess players

+ +

+Here are a few miscellaneous things that may confuse chess players. +Some of these have been mentioned elsewhere, but they bear repeating. + + + +

    +
  1. There is no queen. + +
  2. Pawns capture the same way they move. There is no initial + +two-space pawn move and no en-passant move. + +
  3. There is no special castling move. There are a large + +number of possible defensive formations referred to as "castles" +(see section Sample game) but there is no need for special moves to create +them. + +
  4. A given piece can only promote to one other kind of piece. + +
+ +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_13.html b/doc/gnushogi_13.html new file mode 100644 index 0000000..4e6c703 --- /dev/null +++ b/doc/gnushogi_13.html @@ -0,0 +1,210 @@ + + + + +GNU Shogi manual - Sample game + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Sample game

+

+ + + +

+This game was annotated by Pieter Stouten (see section References and links). I have made some minor corrections. Note that captures are +denoted by the "x" symbol e.g. Rx3f and drops are denoted by the "*" +symbol e.g. R*3f. Check is indicated by a "+" after the move, +e.g. R3f+. I recommend you use gnushogi/xshogi to play along with this +game. In xshogi simply hit the "Force Moves" button after starting +up, while in gnushogi enter the word "force" at the prompt. This will +allow you to enter moves for both sides. + + +

+Note also that the move numbering system used here is the chess-type +system where one move means one move by each player. The Japanese count +one move made by each player as two moves. + + +

+--------------------------------------------------------------------------- + + +

+Below you will find (the English translation of) an annotated game which +was published in the Dutch Shogi magazine "81" and in the Dutch +beginners booklet. It has proven to be a very useful game to explain +some basic principles of Shogi. Also, it is a rather straightforward +game compared to professional games where in most cases very diffuse +middle game fights take place. + + +

+ Pieter Stouten, 14th May 1990. + + +

+--------------------------------------------------------------------------- + + +

+Black: Michael Trent (1-dan). White: David Murphy (2-dan). + + +

+ 1. P2f P3d 2. P2e B3c
+[ This move is necessary, as otherwise white can exchange pawns: 3. P2d +Px2d 4. Rx2d. He would thus get a pawn in hand and open up his rook +file. ] + + +

+ 3. P7f P4d
+[ White closes the bishop diagonal again. He plans to play ranging rook +(the rook goes to 5b, 4b, 3 or 2b; a defensive strategy) and in that +case he'd better avoid an exchange of bishops. One of the reasons is +that he will have problems developing his pieces without leaving holes +for bishop drops. ] + + +

+ 4. S4h R3b 5. P3f S4b 6. K6h K6b
+[ In general the rook plays an important role in the attacks. It is +wise to move the king away from the area where the initial fights will +be and both players act according to the Shogi proverb "keep the rook +and king apart". ] + + +

+ 7. K7h K7b 8. P5f P5d 9. G4i-5h G4a-5b
+[ Both players use their second gold general to build their castle. ] + + +

+ 10. S6h
+[ In itself this move is not bad. However, it will become clear that +black plans a quick attack and in that case it is wiser to omit this +move. ] + + +

+ 10... S5c 11. P1f P1d
+[ The advance of the edge pawns must be timed very well. The remark at +black's tenth move applies here too: this move is good if black wants to +play a slow game, because it eliminates a future B1e. ] + + +

+ 12. P4f K8b 13. N3g S7b
+[ Black develops his knight in order to start an attack over the second, +third and fourth files. White strengthens his king's position and +awaits the attack. He aims at a counterattack as soon as black has +broken through into the white camp. Probably white's breakthrough will +take place later, but he has good compensation in the form of a stronger +castle. This theme occurs very often in static rook versus ranging rook +games. ] + + +

+ 14. P4e R4b
+[ Black starts his attack and white puts up a very passive defence. His +rook has a hard task now to penetrate the black position. Moreover, he +blocks his own bishop. It seems much better to start a counterattack +with 14... P3e, later to be followed by B2b, B5a or Bx4d in order to use +his rook more actively. ] + + +

+ 15. Px4d Sx4d 16. P*4e S5c
+[ 16... Sx4e is more active. A silver general is normally more valuable +than a knight, but white gets two pawns in hand and black none, while +the knight might come in handy for white too. ] + + +

+ 17. Bx3c+ Nx3c 18. P2d Px2d
+[ Black threatens to break through and white has to consider taking the +pawn on 2d or starting a counterattack with Nx4e. If he chooses the +latter, black can play Px2c+ followed by +P3c. The disadvantage is the +black "tokin" (=promoted pawn) that white will get in his camp; the +advantage is that it will cost black two more moves to promote his rook. +Because white did not trust that the result after engaging in a +"semeai" (=mutual attack) with 18...Nx4e would give a positive result, +he captured the pawn on 2d. Making the right decision in moments like +this often makes the difference between a win and a loss: miss one +attacking chance and you will be forced to defend the whole game until +the unavoidable defeat; on the other hand, an unsound attack can destroy +all "aji" (=potential, meaning possibilities, threats) without getting +anything in return. ] + + +

+ 19. Rx2d Nx4e 20. Nx4e Rx4e 21. R2a+ P*4g
+[ Now it becomes clear why black's 10. S6h was not good. Had this move +been omitted, then white would not have had the time to play 13... S7b +and after R2a+ the gold on 6a would hang. Thus black would have kept +"sente" (=initiative). Instead of 21... P*4g, B*6d is a very good +move, because after 22. P*2h black does not have a pawn in hand anymore +and he is being threatened with the annoying 22... N*4f 23. G5g N3h+ +24. S4g +N4h also. Black can also counter 21... B*6d with 22. N*3g. +White would then reply with 22... R4b 23. B*3c P*4g 24. Bx4b+ Sx4b. The +white rook has played its role and instead of spending moves on saving +it white starts to scatter black's defences by successive pawn drops on +the fourth file: 25. Gx4g P*4f 26. G5g N*6e 27. G5h P4g+ 28. Gx4g P*4f. +This analysis was provided by Kato Hifumi, 9-dan professional (the +highest regular grade). Destroying the coherence of the enemy pieces +(their shape) by dropping pawns is one of the most important Shogi +techniques. With the actual move 21... P*4g white missed a good +chance. ] + + +

+ 22. Sx4g P*4f 23. B*3g Px4g+ 24. +Rx6a +Px3g
+[ 23. B*3g seems pointless, but a closer look reveals that it is +actually quite mean. On move 24 white cannot capture black's "Ryu" +(=dragon =promoted rook) with his silver: 24... Sx6a 25. N*7d K7b +26. G*8b mate. By attacking the front of the white castle and +threatening to mate him there, black has the chance to break down the +white defences from the side. ] + + +

+ 25. +Rx5b S*6b
+[ Here 25... B*4d would be much better, because it is defensive and +attacking at the same time. After e.g. 26. G*4c Bx9i+ 27. Gx5c black +threatens 28. +Rx7b Kx7b 29. S*6a K8b 30. S*7a Kx7a 31. G*7b mate. +White is one move quicker, however. He has the following beautiful +"tsume" (mating sequence where every move is check): 27... N*8f 28. Px8f +S*8g 29. Kx8g B*9h 30. K7h Bx8i+ 31. K8g +B8i-8h 32. K9f L*9e mate. +This illustrates the sharpness of Shogi: one move can make the +difference between winning and losing. ] + + +

+ 26. P*4f Rx4f
+[ This move eliminates white's last chances. 26... R4b 27. +Rx4b Sx4b +28. R*4a seems annoying, but after 28... B*3c 29. S7g B*3b white wins +the rook and with his "tokin" on 3g there still is some hope. ] + + +

+ 27. N*6e +P4g
+[ White cannot defend anymore, so he starts a desperate attack. Black +does not lose the right track, however. ] + + +

+ 28. Nx5c+ +Px5h 29. +Nx6b +Px6h 30. Gx6h N*8f 31. Px8f B*6i 32. Gx6i + R4h+ 33. N*6h +Rx6h 34. Gx6h S*8g 35. Kx8g N*9e 36. K7h Resigns
+[ White resigns here, because after 36... B*8g 27. K7g his attack has +petered out. ] + + +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_14.html b/doc/gnushogi_14.html new file mode 100644 index 0000000..7ee806c --- /dev/null +++ b/doc/gnushogi_14.html @@ -0,0 +1,72 @@ + + + + +GNU Shogi manual - Mating problems + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Mating problems

+ +

+One good way to improve at shogi is to solve mating problems. There are +several types of these problems, but the most common is called a +"tsume-shogi" problem, or "tsume" problem for short. In a tsume +problem, all pieces that are not on the board are assumed to be in the +opponent's hand (except for your King, which is usually not shown). +Every move you make must be check until the final checkmate. Your +opponent may play any piece on the board or drop any of his pieces in +hand in order to prevent the mate. In a properly constructed tsume +problem, all of your pieces on the board and in hand must be essential +to the solution. One consequence of this is that all of your pieces in +hand must be played during the solution. There should only be one +correct solution for the given number of moves. Tsume problems use +Japanese-style move numbering; thus, a problem where you move (and give +check), your opponent moves, and you move to give checkmate is called a + +three-mover. Here is a really trivial three-mover: +

+

+
+   3    2    1            
+----------------+         
+ |    |    |    |  a         
+----------------+           
+ |    |    | wK |  b         
+----------------+           
+ |    |    |    |  c       
+----------------+         
+ | bN |    |    |  d       
+----------------+         
+ |    |    |    |  e       
+----------------+         
+ |    | bN |    |  f       
+----------------+
+
+Black in hand: S, G
+
+
+ + +

+Here, Black plays G*2b, White plays K1c, and Black plays S*1d mate. +More typical tsume problems range from 5 moves to arbitrarily high +numbers of moves, and they can be quite brain-busting. Tsume problems +may seem artificial, but in the closing stages of the game where both +players have a lot of pieces in hand, it is often necessary to give +check at every move, or else your opponent will start a counterattack +and will mate you before you mate him. A tsume problem is a worst-case +scenario for the attacker: you have to mate your opponent even though he +has every piece not on the board in hand, which means you have to +develop sharp attacking skills. Many more tsume problems can be found +on the internet; I particularly recommend Patrick Davin's "Shogi +Nexus" (see section References and links). + + +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_15.html b/doc/gnushogi_15.html new file mode 100644 index 0000000..63f7e24 --- /dev/null +++ b/doc/gnushogi_15.html @@ -0,0 +1,129 @@ + + + + +GNU Shogi manual - Shogi variants + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Shogi variants

+

+ + + + + + + + + + + + + +

+Several historical variants of shogi exist. Most of these were invented +before modern shogi (in some cases hundreds of years before), are much +larger than modern shogi and are not played with drops. Thus, in many +ways they are really more like giant chess games than like modern shogi. +The only one of these games to have survived in Japan is Chu (middle) +shogi, which is still played a little bit. Thanks to the efforts of +George Hodges and John Fairbairn of the Shogi Association (two British +shogi enthusiasts), these games were resurrected and rules and sets for +them can still be purchased from George Hodges (see section References and links). I hope to eventually extend GNU shogi so that it can play at +least some of these games. There are also several non-historical +variants of shogi; I don't know much about them but you can find +information about them on the internet (see section References and links). + + +

+The historical variants include: + + + +

    + +
  1. + +Tori (bird) shogi, played on a 7x7 board with 32 pieces in all; this is +the only variant that is known to have been played with drops. + +
  2. + +Wa shogi, played on an 11x11 board with 54 pieces. This game can be +played with or without drops but the historical evidence favors the view +that it was played without drops. However, most people who have tried +it claim it is a much better game with drops, being even more intricate +than standard shogi. + +
  3. + +Chu (middle) shogi, played on a 12x12 board with 92 pieces. This was +(and is) by far the most popular of the variants, and has 21 different +kinds of pieces in the starting line-up alone (along with several others +that appear upon promotion). Unlike modern shogi, there are a +tremendous number of ranging pieces and the game is definitely not +played with drops. There is also an amazing piece called the Lion which +has a double king move and can capture two pieces at once! Chu shogi +has a small but fanatical following, some of whom consider it better +than modern shogi. + +
  4. + +Dai (great) shogi, played on a 15x15 board with 130 pieces. Other than +the larger board, this game is very similar to Chu shogi. + +
  5. + +Tenjiku (exotic) shogi, played on a 16x16 board with 176 pieces. This +game is possibly the most complex tactical game in existence. There are +many astoundingly powerful pieces, including one (the Fire Demon) that +can capture up to eight opposing pieces in a single move! Despite the +size of the game, checkmates can occur very suddenly (and often very +early on) if one player makes a wrong move. Tenjiku also has a small +but fanatical following, one of whom (Colin Adams) has written a book on +the game which is available for download at +http://www.colina.demon.co.uk/tenjiku.html. + +
  6. + +Dai-dai (great-great) shogi, played on a 17x17 board with 192 pieces. +The opening setup alone has 64 different kinds of pieces! This game and +the larger ones that follow sound pretty outlandish, but they have +actually been played; a game of Dai-dai can supposedly be played in +about 12 hours. + +
  7. + +Maka-dai-dai (great-great-great) shogi, played on a 19x19 board with 192 +pieces. For those for whom Dai-dai shogi is just too small :-) + +
  8. + +Tai (grand) shogi, played on a 25x25 board with 377 pieces! Until +recently, this was thought to be the biggest chess game ever devised, +but now there is... + +
  9. + +Kyoku tai (extremely grand?) shogi, played on a 36x36 board with 402 +pieces. The rules for this have just been unearthed in an old Japanese +book. Hopefully someone will soon organize a postal Kyoku tai shogi +championship; maybe their distant ancestors could finish it :-) + +It is thought that the really huge games (Dai-dai and up) were never +really played to any significant extent (gee, wonder why?) and were +devised merely so that the creators could have the fun of inventing +enormous games, amazing their friends and confounding their enemies. +However, the games up to Tenjiku shogi at least appear to be quite +playable, assuming one has the time. + +
+ +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_16.html b/doc/gnushogi_16.html new file mode 100644 index 0000000..ca5716f --- /dev/null +++ b/doc/gnushogi_16.html @@ -0,0 +1,145 @@ + + + + +GNU Shogi manual - Differences between shogi and chess + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Differences between shogi and chess

+

+ + + +

+Some differences between shogi and international chess have been +mentioned elsewhere in this document; I summarize them here for people +who are interested in game comparisons. I won't try to deal with the +thorny question of which game is "better" although my bias may have +already come through :-) In fact, the drop rule makes the two games so +different in character that arguing over which game is better is like +comparing apples to oranges (you'd be better off comparing chess to Chu +shogi (see section Shogi variants). However, I believe that if you are a +chess fan you'll really like shogi as well, and shogi is also popular +with many people who don't particularly like chess. + + +

+Here are the significant differences between chess and shogi: + + + +

    + +
  1. + +In shogi, captured pieces become the property of the capturer and can +re-enter play by being dropped onto almost any vacant square. In chess, +captured pieces are out of the game. Thus, in shogi, piece exchanges +complicate the play significantly while in chess they simplify it. + +
  2. + +The shogi board is 9x9; the chess board is 8x8. + +
  3. + +Shogi has five pieces with no counterpart in chess: the gold and silver +generals, the lance, the promoted rook and the promoted bishop. Chess +has one piece with no counterpart in shogi: the queen. The knight's +move in shogi is much more restrictive than in chess. Pieces in shogi +generally have a much smaller range of movement than in chess (unless +they are in hand). + +
  4. + +In shogi, all pieces except the gold general and the king can promote, +but only to one kind of piece. Promotion is easier in shogi because the +promotion zone is closer to the starting position of the pieces +(especially pawns). In chess, only the pawn can promote, but it can +promote to any other piece except the king. + +
  5. + +In shogi, pawns capture the same way they move. There is no initial +two-space pawn move and hence no en-passant captures. In chess, +pawns capture diagonally which means that opposing pawns can block each +other. + +
  6. + +In shogi, you only have one rook and one bishop. Note that the bishop +is not restricted to only one "color" square (squares in shogi aren't +colored, but never mind) because promoted bishops can also move one +square orthogonally. + +
  7. + +There is no special castling move in shogi. The term "castle" is +used in shogi to denote a defensive formation consisting of (usually) +three generals which protect the king. There are many such castles +(about 40 or so have names). See section Sample game. + +
  8. + +Draws are much rarer in shogi than in chess. Perpetual check is not +allowed. Stalemate is a virtual impossibility, and is a loss for the +stalematee. + +
  9. + +Since pieces are never out of play in shogi, chess-type endgames +involving only a few pieces do not occur. + +
  10. + +Shogi games are generally longer than chess games (about 60-70 moves is +typical). + +
  11. + +Shogi has a well-developed handicap system which is in general use; +chess does not. + +
+ +

+The effects of all these differences on play include (in my opinion): + + + +

    + +
  1. + +Piece/pawn structures in chess are more rigid than in shogi. Pawns +block each other and pawns, once advanced, cannot ever retreat. In +shogi, you can repair the hole caused by a pawn advance by exchanging +the pawn and dropping it back where you want it. Thus shogi is more +fluid than chess and less "structural". + +
  2. + +Counterattack is MUCH more common in shogi than in chess. Games +typically end in mutual mating attacks, where each player is trying to +checkmate the other player before being checkmated himself. This makes +tempo incredibly important and also makes sacrificial play quite common. + +
  3. + +Attacks involving only ranging pieces are more a feature of chess than +of shogi. A shogi attack typically uses a ranging piece or pieces to +support an attack by short-range pieces (especially generals). It is +very rare to mate a king with a non-adjacent ranging piece in shogi +since the player whose king is threatened can almost always interpose by +dropping a piece. + +
+ +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_17.html b/doc/gnushogi_17.html new file mode 100644 index 0000000..ce3a0f5 --- /dev/null +++ b/doc/gnushogi_17.html @@ -0,0 +1,534 @@ + + + + +GNU Shogi manual - gnushogi + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

gnushogi

+

+ + + +

+This section describes how to run the "gnushogi" program. + + +

+SYNOPSIS + + + +

+gnushogi [ [[-]a] [-b bookfile] [-B binbookfile] [-C] [-h langfile] +[-L langfile] [-r length] [-R] [-s pathname] [-l pathname] [-S binbooksize] +[-t] [-c size] [-T size] [-v] [-x] [-X] arg1 arg2 ] + + +

+DESCRIPTION + + +

+GNU shogi (gnushogi) plays a game of japanese chess (shogi) against the +user or it plays against itself. + + +

+At startup gnushogi reads the binbook file if it is present. It then +looks for a book file. If it is present it adds its contents to the +binbook data. If the binbook file is writable a new combined binbook +file is written. + + +

+Gnushogi is a modified version of the gnuchess program. It has a simple +alphanumeric board display, or it can be used with the xshogi program +under X windows. The program gets its opening moves from the file +gnushogi.bbk which is located in a directory specified in the Makefile. +To invoke the program type: + + +

+ +
`gnushogi -C' +
+simple curses based version + +
`gnushogi -X (or just gnushogi)' +
+xshogi compatible version + +
`gnushogi -R' +
+raw test display version +
+ +

+TIME CONTROLS + + +

+If one argument is given, it is the search time per move in +[minutes:]seconds. So gnushogi 30 will generate one move every 30 +seconds, while gnushogi 5:00 will generate one move every 5 minutes. + + +

+If two or more arguments are given, they will be used to set tournament +time controls with the first argument of each pair being the number of +moves and the second being the total clock time in minutes[:seconds]. +Thus, entering gnushogi 60 5 will set the clocks for 5 minutes (300 +seconds) for the first 60 moves, and gnushogi 30 3:30 will allow 3 +minutes and 30 seconds for 30 moves. + + +

+gnushogi 30 5 1 :30 will allow 5 minutes for the first 30 moves and 30 +seconds for each move after that. Up to 4 pairs of controls may be +specified. + + +

+If no argument is given the program will prompt the user for level of +play. + + +

+For use with xshogi see the documentation on that program. +See section xshogi. + + +

+BOOK + + +

+The book gnushogi.tbk consists of a sequence of openings. An opening +begins with a line starting with a # (the rest of the line is a +comment). Following this is a series of moves in algebraic notation +alternating black and white separated by white space. A move may have a +? after it indicating this move should never be made in this position. +Moves are stored as position:move so transpositions between openings can +take place. + + +

+HASHFILE + + +

+The hashfile if created should be on the order of 4 megabytes; you can +create such a hashfile by typing "gnushogi -c 22" (see below). This +file contains positions and moves learned from previous games. If a +hashfile is used the computer makes use of the experience it gained in +past games. Tests run so far show that it plays no worse with the +hashfile than without, but it is not clear yet whether it provides a +real advantage. + + +

+LEGAL MOVES + + +

+Note: Piece letters are determined by the language file. What is +specified here is the default (English). + + +

+Once gnushogi is invoked, the program will display the board and prompt +the user for a move. To enter a move, use the notation 7g7f where the +first letter-number pair indicates the origin square and the second +letter-number pair indicates the destination square. An alternative is +to use the notation P7f where the first letter indicates the piece type +(P,L,N,S,G,B,R,K). To promote append a + the type of the new piece to +the move, as in 2d2c+ or P2c+. Note that you must use capital letters +for the pieces by default. + + +

+COMMAND-LINE OPTIONS + + +

+ +
`-a' +
+Do not search on opponent's time. + +
`a' +
+Do search on opponent's time. + +
`-b bookfile' +
+Use bookfile for opening book. + +
`-B binbookfile' +
+Use binbookfile for binary opening book. + +
`-c size' +
+Create a new HASHFILE. File size is 2^size entries of approximately 65+? +bytes. + +
`-C' +
+Use curses-based display mode. + +
`-h' +
+Do not use hashfile. + +
`h' +
+Do use hashfile. + +
`-l pathname' +
+Pathname of the loadfile used with get or xget. + +
`-L lang' +
+Use language lang from the file gnushogi.lang. If -L is not specified +it uses the first language in the file. + +
`-P plylevels' +
+Number of plys to include in the binbookfile. For generating a +binbookfile. + +
`-r length' +
+Rehash length times in searching entries for position in +transposition table. + +
`-R' +
+Use raw text display mode. This can be used for dumb terminals or for +systems that don't have curses. + +
`-s pathname' +
+Pathname of the save file to use with the save command. + +
`-S size' +
+Size of binbookfile for memory based books. For creating a binbookfile. + +
`-t' +
+Show statistics for HASHFILE. + +
`-T size' +
+Set the transposition table size to 2^size entries. + +
`-v' +
+Show version and patchlevel. + +
`-x value' +
+Use value as the evaluation window xwndw. + +
`-X' +
+Use xshogi display mode (the default). + +
+ +

+COMMANDS + + +

+In addition to legal moves, the following commands can be entered at the +gnushogi prompt. Note: command names are determined by the language +file and may vary with the implementation. The default language is +English. + + +

+ +
`alg' +
+allow algebraic input (not implemented). + +
`Awindow' +
+change Alpha window (default score + 90). + +
`Bwindow' +
+change Beta window (default score - 90). + +
`beep' +
+toggles beeping after each move (default: on). + +
`bd' +
+updates the current board position on the display. + +
`book' +
+turns off use of the opening library. + +
`both' +
+causes the computer to play both sides of a shogi game. + +
`black' +
+causes the computer to take the white pieces, if the computer is to move +first. + +
`bsave' +
+saves a game to disk as a book textfile. The program will prompt the +user for a file name. + +
`gamein' +
+toggles game mode time control. Assumes the time specified for time +control is the time for a complete game. Input with the level command +should be the game time and the expected number of moves in a game. go +command must be given. + +
`coords' +
+show coordinates on the display (visual only). + +
`contempt' +
+allows the value of contempt to be modified. + +
`debug' +
+asks for a piece as color piece, as wb or bn, and shows its calculated +value on each square. + +
`debuglevel' +
+sets level of debugging output if compiled with debug options. + +
`depth' +
+allows the user to change the search depth of the program. The maximum +depth is 29 ply. Normally the depth is set to 29 and the computer +terminates its search based on elapsed time rather than depth. If depth +is set to (say) 4 ply, the program will search until all moves have been +examined to a depth of 4 ply (with extensions up to 11 additional ply +for sequences of checks and captures). If you set a maximum time per +move and also use the depth command, the search will stop at the +specified time or the specified depth, whichever comes first. + +
`easy' +
+toggles easy mode (thinking on opponents time) on and off. The default +is easy mode ON. If easy mode is disabled, the keyboard is polled for +input every so often and when input is seen the search is terminated. It +may also be terminated with a sigint. + +
`edit' +
+allows the user to set up a board position. + +
    + +
  • # + +clear the board. + +
  • c + +toggle piece color. + +
  • . + +command will exit setup mode. + +
  • p3b + +place a pawn on 3b + +
  • p3b+ + +place a promoted pawn on 3b + +
  • p* + +place a pawn in hand (among the captured pieces) + +
+ +Pieces are entered by typing a letter (p,l,n,s,g,b,r,k) for +the piece followed by the coordinate. Here, letter case is ignored. + +The usual warning about the language file applies. + +
`exit' +
+exits gnushogi. + +
`first' +
+tells the computer to move first. Computer begins searching for a move. +(same as "go"). + +
`force' +
+allows the user to enter moves for both sides. To get the program to +play after a sequence of moves has been entered use the "black" or +"white" commands. + +
`get' +
+retrieves a game from disk. The program will prompt the user for a file +name. + +
`go' +
+tells the computer to move first. Computer begins searching for a move. +(same as "first"). + +
`hash' +
+use/don't use hashfile. + +
`hashdepth' +
+allows the user to change the minimum depth for using the hashfile and +the number of moves from the beginning of the game to use it. + +
`help' +
+displays a short description of the commands and the current status of +options. + +
`hint' +
+causes the program to supply the user with its predicted move. + +
`level' +
+allows the user to set time controls such as 60 moves in 5 minutes etc. +In tournament mode, the program will vary the time it takes for each +move depending on the situation. If easy mode is disabled (using the +"easy" command), the program will often respond with its move +immediately, saving time on its clock for use later on. + +
`list' +
+writes the game moves and some statistics on search depth, nodes, and +time to the file "shogi.lst". + +
`material' +
+toggle material flag - draws on no pawns and both sides < rook. + +
`new' +
+starts a new game. + +
`p' +
+evaluates the board and shows the point score for each piece. The total +score for a position is the sum of these individual piece scores. + +
`post' +
+causes the program to display the principal variation and the score +during the search. A score of 100 is equivalent to a 1 pawn advantage +for the computer. + +
`quit' +
+exits the game. + +
`random' +
+causes the program to randomize its move selection slightly. + +
`rcptr' +
+set recapture mode. + +
`remove' +
+backout the last level for both sides. Equal to 2 undo's. + +
`reverse' +
+causes the board display to be reversed. That is, the black pieces will +now appear at the top of the board. + +
`rv' +
+reverse board display. + +
`save' +
+saves a game to disk. The program will prompt the user for a file name. + +
`switch' +
+causes the program to switch places with the opponent and begin +searching. + +
`test' +
+performs some speed tests for MoveList and CaptureList generation, and +ScorePosition position scoring for the current board. + +
`time' +
+set computer's time remaining, intended for synchronizing clocks among +multiple players. + +
`tsume' +
+toggle tsume mode. In tsume mode, not all possible moves will be +generated. If a king is in check, only moves that get the king out of +check are generated. If the king is not in check, only moves that give +check to the opponent's king are generated. + +
`undo' +
+undoes the last move whether it was the computer's or the human's. You +may also type "remove". This is equivalent to two "undo"'s +(e.g. retract one move for each side). + +
`white' +
+causes the computer to take the black pieces, if the computer is to move +first the go command must be given. + +
`xget' +
+read an xshogi position file. + +
`xsave' +
+save as an xshogi position file. + +
`xwndw' +
+change X window. The window around alpha/beta used to determine whether +the position should be scored or just estimated. Note: this has +nothing to do with xshogi or X windows; the terms are completely +separate. + +
+ +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_18.html b/doc/gnushogi_18.html new file mode 100644 index 0000000..e6ea7c9 --- /dev/null +++ b/doc/gnushogi_18.html @@ -0,0 +1,543 @@ + + + + +GNU Shogi manual - xshogi + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

xshogi

+

+ + + +

+This section describes how to run the "xshogi" program. + + +

+SYNOPSIS + + +

+xshogi [ options ] + + +

+DESCRIPTION + + +

+xshogi provides an X11/Xt/Athena Widgets user interface for gnushogi. +With xshogi you can play gnushogi, set up arbitrary positions, force +variations, or watch xshogi manage a game between two shogi programs. +Furthermore, it can be used as an interface between two players on +different displays. + + +

+xshogi can also be used as a shogi board to play out games. It will +read through a game file or allow a player to play through a variation +manually (force mode). This is useful for keeping track of email postal +games or browsing games off the net. + + +

+After starting xshogi, you can make moves by pressing mouse button 1 +while the cursor is over a square with your piece on it and dragging the +mouse to another square. If the move is illegal, gnushogi will not +allow it. xshogi will then retract the move. + + +

+COMMAND-LINE OPTIONS + + +

+The following command line options also correspond to X resources that +you can set in your .Xdefaults file. + + +

+ +
`[standard Xt options]' +
+xshogi accepts standard Xt options like -display, -geometry, and +-iconic. + +
`-tc or -timeControl minutes[:seconds]' +
+Amount of time for a set of moves determined by movesPerSession. If +this number of moves is played within the time control period, xshogi +resets the time clocks. Default: 5 minutes. + +
`-mps or -movesPerSession moves' +
+Number of moves in a time control period. Default: 40 moves. + +
`-st or -searchTime minutes[:seconds]' +
+Tell gnushogi to spend at most the given amount of time searching for +each of its moves. Without this option, gnushogi chooses its search +time based on the number of moves and amount of time remaining until the +next time control. Setting this option also sets -clockMode to False. + +
`-sd or -searchDepth number' +
+Tell gnushogi to look ahead at most the given number of moves when +searching for a move to make. Without this option, gnushogi chooses +its search depth based on the number of moves and amount of time +remaining until the next time control. Setting this option also sets +-clockMode to False. + +
`-clock or -clockMode (True | False)' +
+Determines whether or not to use the clock. If clockMode is False, the +clock does not run, but the side that is to play next is still +highlighted. + +
`-td or -timeDelay seconds' +
+Time delay between moves during "Load Game". This doesn't have to be +a round number. Try -td 0.4. Default: 1 second. + +
`-nsp or -noShogiProgram (True | False)' +
+If this option is True, xshogi acts as a passive shogi board; it does +not try to start a shogi program, not even to check whether moves made +in Force mode are legal. It also sets -clockMode to False. Default: +False. + +
`-fsp or -firstShogiProgram program' +
+Name of first shogi program. In matches between two machines, this +program plays white. Default: "gnushogi". + +
`-ssp or -secondShogiProgram program' +
+Name of second shogi program, if needed. In matches between two +machines, this program plays black; otherwise it is not started. +Default: "gnushogi". + +
`-fh or -firstHost host' +
+Name of host the first shogi program plays on. Default: "localhost". + +
`-sh or -secondHost host' +
+Name of host the second shogi program plays on. Default: "localhost". + +
`-rsh or -remoteShell shell_name' +
+Some systems do not use rsh as the remote shell. This option allows a +user to name the remote shell command. This should be done in the +resource file. + +
`-mm or -matchMode (False | Init | Position | Opening)' +
+Automatically run a game between firstShogiProgram and +secondShogiProgram. If matchMode is set to Init, xshogi will start the +game with the initial shogi position. If matchMode is set to Position, +xshogi will start the game with the position specified by the +loadPositionFile resource. If matchMode is set to Opening, xshogi will +play out the opening moves specified by the -loadGameFile resource. If +the -saveGameFile resource is set, a move record for the match will be +saved in the specified file. Default: "False". + +
`-lgf or -loadGameFile file' +
+Name of file to read a game record from. Game files are found in the +directory named by the SHOGIDIR environment variable. If this variable +is not set, the current directory is used unless the file name starts +with a /. + +
`-lpf or -loadPositionFile file' +
+Name of file to read a game position from. Position files are found in +the directory named by the SHOGIDIR environment variable. If this +variable is not set, the current directory is used unless the file name +starts with a /. + +
`-sgf or -saveGameFile file' +
+Name of file to save a game record to. Game files are saved in the +directory named by the SHOGIDIR environment variable. If this variable +is not set, the current directory is used unless the file name starts +with a /. + +
`-spf or -savePositionFile file' +
+Name of file to save a game position to. Position files are saved in +the directory named by the SHOGIDIR environment variable. If this +variable is not set, the current directory is used unless the file name +starts with a /. + +
`-coords or -showCoords (True | False)' +
+If this option is True, xshogi displays algebraic coordinates along the +board's left and bottom edges. The default is False. The coordFont +resource specifies what font to use. + +
`-mono or -monoMode (True | False)' +
+Determines whether xshogi displays its pieces and squares with two +colors or four. You shouldn't have to specify monochrome. xshogi will +determine if this is necessary. + +
`-wpc or -blackPieceColor color' +
+Color specification for black pieces suitable for XParseColor(3X11). +Default: #FFFFCC. These colors look good on a DEC workstation. If you +need different colors, try using the xcolors application. Source for +xcolors can be found in the X11 contrib directory. + +
`-bpc or -whitePieceColor color' +
+Same for white pieces. Default: #202020. + +
`-lsc or -lightSquareColor color' +
+Same for light squares. Default: #C8C365. + +
`-dsc or -darkSquareColor color' +
+Same for dark squares. Default: #77A26D. + +
`-wps or -westernPieceSet (True | False)' +
+Choose the Western style piece set. + +
`-npb or -normalPawnBitmap file' +
+
`-nnb or -normalKnightBitmap file' +
+
`-nbb or -normalBishopBitmap file' +
+
`-nrb or -normalRookBitmap file' +
+
`-nkb or -normalKingBitmap file' +
+Names of the bitmap files for the bitmap piece icons. + +
`-rpb or -reversePawnBitmap file' +
+
`-rnb or -reverseKnightBitmap file' +
+
`-rbb or -reverseBishopBitmap file' +
+
`-rrb or -reverseRookBitmap file' +
+
`-rkb or -reverseKingBitmap file' +
+Names of the bitmap files for the outline piece icons. + +
`-debug or -debugMode (True | False)' +
+Turns on debugging printout. + +
+ +

+OTHER X RESOURCES + + +

+ +
`initString' +
+The actual string that is sent to initialize the shogi program can be +set from .Xdefaults. It can't be set from the command line because of +syntax problems. The default value is "new\nbeep\nrandom\neasy\n". +The "new" and "beep" commands are required. You can remove the +"random" command if you like; including it causes gnushogi to +randomize its move selection slightly so that it doesn't play the same +moves in every game. Even without "random", gnushogi randomizes its +choice of moves from its opening book. You can also remove "easy" if +you like; including it toggles easy mode off, causing gnushogi to think +on your time. That is, if "easy" is included in the initString, GNU +Shogi thinks on your time; if not, it does not. (Yes, this does seem +backwards, doesn't it.) You can also try adding other commands to the +initString; see the gnushogi documentation (see section gnushogi) for +details. + +
`blackString and whiteString' +
+These resources control what is sent when the Machine Black and Machine +White buttons are selected. This is mostly for compatibility with +obsolete versions of gnushogi. + +Alternate bitmaps for piece icons can be specified either by choosing +one of the built-in sets or with the file name resources described +above. There are three built-in sets of piece bitmaps available, large +(the default), medium, or small. It is easiest to select the set you +prefer in the .Xdefaults file: + + XShogi*boardSize: Medium + +The font used for button labels and comments can be changed in the +.Xdefaults file. You may want to choose a smaller font if you are using +the small pieces: + + XShogi*font: helvetica_oblique12 + +The font used for coordinates (when the showCoords option is True) can +be set similarly: + + XShogi*coordFont: helvetica_10 + +If you are using a grayscale monitor, try setting the colors to: + + XShogi*blackPieceColor: gray100
+ XShogi*whitePieceColor: gray0
+ XShogi*lightSquareColor: gray60
+ XShogi*darkSquareColor: gray40 + +
+ +

+COMMAND BUTTONS AND KEYS + + +

+ +
`Quit' +
+Quits xshogi. Q or q is a keyboard equivalent. + +
`Reset' +
+Resets xshogi to the beginning of a shogi game. It also deselects any +game or position files. + +
`Flip View' +
+inverts the view of the shogi board. + +
`Hint' +
+displays a move hint from gnushogi. + +
`Load Game' +
+plays a game from a record file. If no file is specified a popup dialog +asks for a filename. Game files are found in the directory named by the +SHOGIDIR environment variable. If this variable is not declared then +the current directory is used unless the file name starts with a /. G +or g is a keyboard equivalent. The game file parser will accept almost +any file that contains moves in algebraic notation. If the first line +begins with `#', it is assumed to be a title and is displayed. Text +enclosed in parentheses or square brackets is assumed to be commentary +and is displayed in a pop-up window. Any other text in the file is +ignored. + +
`Load Position' +
+sets up a position from a position file. If no file is specified a +popup dialog asks for a filename. Position files are found in the +directory named by the SHOGIDIR environment variable. If this variable +is not declared then the current directory is used unless the file name +starts with a /. Position files must be in the format that the Save +Position command writes. + +
`Save Game' +
+saves a game to a record file. If no file is specified a popup dialog +asks for a filename. If the filename exists, the user is asked whether +the current game record is be appended to this file or if the file +should be replaced. Game files are saved in the directory named by the +SHOGIDIR environment variable. If this variable is not declared then +the current directory is used unless the file name starts with a /. +Game files are human-readable, and can also be read back by the Load +Game command. Furthermore, they are accepted as gnushogi text bookfiles. + +
`Save Position' +
+saves a position to a position file. If no file is specified a popup +dialog asks for a filename. Position files are saved in the directory +named by the SHOGIDIR environment variable. If this variable is not +declared then the current directory is used unless the file name starts +with a /. Position files are human-readable, and can also be read back +by the Load Position command. + +
`Machine White' +
+forces gnushogi to play white. + +
`Machine Black' +
+forces gnushogi to play black. + +
`Force Moves' +
+forces a series of moves. That is, gnushogi stops playing and xshogi +allows you to make moves for both white and black. + +
`Two Machines' +
+plays a game between two computer programs. + +
`Forward' +
+moves forward through a series of remembered moves. F or f is a +keyboard equivalent. + +
`Backward' +
+moves backward through a series of remembered moves. As a side effect, +puts xshogi into Force Moves mode. B or b is a keyboard equivalent. + +
`Pause' +
+pauses the clocks or (in Load Game mode) pauses the game being loaded. +Press Pause again to continue. P or p is a keyboard equivalent. + +
`Edit Position' +
+lets you set up an arbitrary board position. Use mouse button 1 to drag +pieces to new squares, or to delete a piece by dragging it off the board +or dragging an empty square on top of it. To drop a new piece on a +square, press mouse button 2 or 3 over the square. This brings up a +menu of black pieces (button 2) or white pieces (button 3). Additional +menu choices let you empty the square or clear the board. You can set +the side to play next by clicking on the Black or White indicator at the +top of the screen. + +
`Challenge' +
+allows to make a two display game between two human players. Enter the +display you want to connect to. If you are allowed to connect, a new +board is displayed at the remote display. Challenge mode can only be +stopped by pressing "quit". + +
`Select Level' +
+allows to reset the clocks for both players. Enter the number of moves +and the number of minutes in which the moves should be done. + +
`Move NOW' +
+force computer to stop thinking and to make the current best move. + +
`Iconify I, i, C or c' +
+iconifies xshogi. + +
+ +

+LIMITATIONS + + +

+If you press the Pause button during GNU Shogi's turn, +xshogi will stop the clocks, but gnushogi will still make a +move. + + +

+After a mate or draw when playing against gnushogi, if you +back up with the Backward button, the clocks are reset +(because gnushogi has exited and must be restarted). + + +

+The game parser recognizes only algebraic notation. + + +

+AUTHORS + + +

+Original authors of XBoard: Chris Sears and Dan Sears. + + +

+Enhancements for XBoard (Version 2.0): Tim Mann. + + +

+Conversion to XShogi (Version 1.1): Matthias Mutz. + + +

+Current maintainer: Mike Vanier. + + +

+COPYRIGHT INFORMATION + + +

+XShogi borrows its piece bitmaps from CRANES Shogi. + + +

+Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. +Enhancements Copyright 1992 Free Software Foundation, Inc. Enhancements +Copyright 1993 Matthias Mutz. Further enhancements copyright 1999 by +Michael Vanier and the Free Software Foundation, Inc. + + +

+The following terms apply to Digital Equipment Corporation's copyright +interest in XBoard: + + +

+All Rights Reserved + + +

+Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + + +

+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + + +

+The following terms apply to the enhanced version of XShogi distributed +by the Free Software Foundation: + + +

+This file is part of XSHOGI. + + +

+XSHOGI is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY. No author or distributor accepts responsibility to anyone +for the consequences of using it or for whether it serves any particular +purpose or works at all, unless he says so in writing. Refer to the +XSHOGI General Public License for full details. + + +

+Everyone is granted permission to copy, modify and redistribute XSHOGI, +but only under the conditions described in the XSHOGI General Public +License. A copy of this license is supposed to have been given to you +along with XSHOGI so you can know your rights and responsibilities. It +should be in a file named COPYING. Among other things, the copyright +notice and this notice must be preserved on all copies. + + +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_19.html b/doc/gnushogi_19.html new file mode 100644 index 0000000..e6e2f82 --- /dev/null +++ b/doc/gnushogi_19.html @@ -0,0 +1,121 @@ + + + + +GNU Shogi manual - References and links + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

References and links

+

+ + + + + + +

+There are very few English-language books for people learning shogi. +The two I recommend are: + + + +

    + +
  1. + +Shogi for Beginners, 2nd. Edition, by John Fairbairn. This is a +superb beginner's book in every way, covering all phases of the game. +It was out of print for a long time, but has now been reprinted and is +available either from Kiseido (http://www.labnet.or.jp/~kiseido) +or from George Hodges (see below). + +
  2. + +The Art of Shogi, by Tony Hoskings. This is one step up from the +Fairbairn book. It covers a lot of ground, and is especially noteworthy +for its detailed treatment of opening lines. You can order this book +from Amazon.com's UK branch (http://www.amazon.co.uk). + +
+ +

+Another book you may find is Shogi: Japan's Game of Strategy by +Trevor Leggett. This book is very elementary and is somewhat outdated, +having been published first in 1966. However, it does feature a paper +shogi board and punch-out pieces, so if you want a really cheap shogi +set you might pick this book up. It is still in print. + + +

+Two books that are no longer in print but are definitely worth getting +if you find them are Guide to Shogi Openings and Better +Moves for Better Shogi, both by Aono Teriuchi. They are published in a +bilingual edition (English/Japanese) and are the only books on shogi in +English written by a Japanese professional shogi player. John Fairbairn +did the translation from Japanese to English. + + +

+Shogi sets are available from: + + + +

+

+George F. Hodges
+P.O. Box 77
+Bromley, Kent
+United Kingdom BR1 2WT +

+ +

+George also sells equipment for all the historical shogi variants +(see section Shogi variants) (except for Kyoku tai shogi) and also sells +back issues of the magazine "Shogi" which he published for 70 issues +in the late 70's to late 80's. This magazine is STRONGLY recommended; +it contains more information about shogi in English than you will ever +find anywhere else. + + +

+Here are some useful URLs: + + +

+ +
Pieter Stouten's shogi page: http://www.halcyon.com/stouten/shogi.html +
+This is the main shogi-related site on the internet, with links to +almost all the other sites. + +
Roger Hare's shogi page: http://www.ed.ac.uk/~rjhare/shogi +
+This has lots of information, including full rules to most of the shogi +variants. + +
Patrick Davin's Shogi Nexus: http://www.vega.or.jp/~patrick/shogi/ +
+There's lots of cool stuff on this site; my favorite is the extensive +collection of Tsume-shogi (mating) problems, both for beginners and +more advanced players. + +
Steve Evans' shogi page: http://www.netspace.net.au/~trout/index.html +
+Steve has written a program that plays almost all of the shogi variants, +unfortunately it only runs on Windows :-( + +
Hans Bodlaender's chess variant pages: http://www.cs.ruu.nl/~hansb/d.chessvar +
+This page has an almost unimaginable variety of rules for different +chess variants, including many shogi variants (historical and non-historical). + +
+ +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_2.html b/doc/gnushogi_2.html new file mode 100644 index 0000000..cc42638 --- /dev/null +++ b/doc/gnushogi_2.html @@ -0,0 +1,461 @@ + + + + +GNU Shogi manual - License + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

GNU GENERAL PUBLIC LICENSE

+

+ + +

+ Version 2, June 1991 +
+ + + +
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+675 Mass Ave, Cambridge, MA 02139, USA
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+ + + +

Preamble

+ +

+ The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + +

+ When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + +

+ To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + +

+ For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + +

+ We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + +

+ Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + +

+ Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + +

+ The precise terms and conditions for copying, distribution and +modification follow. + + + + +

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

+ + +
    +
  1. + +This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +
  2. + +You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +
  3. + +You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + +
      +
    1. + +You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + +
    2. + +You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any +part thereof, to be licensed as a whole at no charge to all third +parties under the terms of this License. + +
    3. + +If the modified program normally reads commands interactively +when run, you must cause it, when started running for such +interactive use in the most ordinary way, to print or display an +announcement including an appropriate copyright notice and a +notice that there is no warranty (or else, saying that you provide +a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this +License. (Exception: if the Program itself is interactive but +does not normally print such an announcement, your work based on +the Program is not required to print an announcement.) +
    + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +
  4. + +You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + +
      +
    1. + +Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections +1 and 2 above on a medium customarily used for software interchange; or, + +
    2. + +Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your +cost of physically performing source distribution, a complete +machine-readable copy of the corresponding source code, to be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +
    3. + +Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is +allowed only for noncommercial distribution and only if you +received the program in object code or executable form with such +an offer, in accord with Subsection b above.) +
    + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +
  5. + +You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + +
  6. + +You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +
  7. + +Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +
  8. + +If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +
  9. + +If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +
  10. + +The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +
  11. + +If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + + +

    NO WARRANTY + +

  12. + +BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +
  13. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. +
+ + +

END OF TERMS AND CONDITIONS

+ + + +

How to Apply These Terms to Your New Programs

+ +

+ If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + +

+ To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + +

+one line to give the program's name and a brief idea of what it does.
+Copyright (C) 19yy  name of author
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ +

+Also add information on how to contact you by electronic and paper mail. + + +

+If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + + +

+Gnomovision version 69, Copyright (C) 19yy name of author
+Gnomovision comes with ABSOLUTELY NO WARRANTY; for details 
+type `show w'.
+This is free software, and you are welcome to redistribute it
+under certain conditions; type `show c' for details.
+
+ +

+The hypothetical commands `show w' and `show c' should show +the appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and +`show c'; they could even be mouse-clicks or menu items--whatever +suits your program. + + +

+You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + + +

+Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+`Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+signature of Ty Coon, 1 April 1989
+Ty Coon, President of Vice
+
+ +

+This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_20.html b/doc/gnushogi_20.html new file mode 100644 index 0000000..618bc00 --- /dev/null +++ b/doc/gnushogi_20.html @@ -0,0 +1,64 @@ + + + + +GNU Shogi manual - Acknowledgements + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Acknowledgements

+

+ + + +

+I would like to thank the following people: + + + +

    + +
  • + +Matthias Mutz, who originally developed GNU shogi as a spin-off of GNU +chess and who very kindly let me take over the maintenance of this very +interesting project. + +
  • + +Richard Stallman and the Free Software Foundation, for creating an +organization where anyone can contribute software for the common good of +all, for making GNU/Linux possible, and especially for writing emacs and +gcc, without which my working life would be intolerable. + +
  • + +Georges Hodges, for starting the Shogi Association in England, without +which I would probably never have heard of shogi, for supplying shogi +equipment, for publishing the excellent magazine "Shogi" (now sadly +defunct), for personally answering all my silly questions by mail, and +for being the ambassador of shogi to the West. + +
  • + +Pieter Stouten, for having the most comprehensive shogi site on the +World Wide Web http://www.halcyon.com/stouten/shogi.html, and for +maintaining the shogi-l mailing list. Go to Pieter's web site for more +information on subscribing to the list. Also thanks to everyone who +contributes and has contributed to that list. + +
  • + +Matt Casters, for testing GNU shogi. Matt and I will be working +together on improving the solution engine in future versions of this +program. + +
+ +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_21.html b/doc/gnushogi_21.html new file mode 100644 index 0000000..12157db --- /dev/null +++ b/doc/gnushogi_21.html @@ -0,0 +1,26 @@ + + + + +GNU Shogi manual - Bugs + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Bugs

+ +

+The motto of GNU shogi is "100% bug-free or you don't pay!" :-) In the +extremely unlikely case (*ahem*) that you do find a bug, please send me +(Mike Vanier) an email at mvanier@bbb.caltech.edu. Also, feel +free to send me comments, complaints, out-and-out raves, suggestions, +plane tickets to Hawaii, and/or large suitcases filled with unmarked, +untraceable hundred-dollar bills. + + +


+ [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_22.html b/doc/gnushogi_22.html new file mode 100644 index 0000000..8654b9a --- /dev/null +++ b/doc/gnushogi_22.html @@ -0,0 +1,142 @@ + + + + +GNU Shogi manual - Index + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


+ + +

Index

+ +

+Jump to: +a +- +b +- +c +- +d +- +g +- +h +- +i +- +k +- +l +- +m +- +o +- +p +- +r +- +s +- +t +- +v +- +w +- +x +

+

a

+ +
  • Acknowledgements +
  • +

    b

    + +
  • Books +
  • +

    c

    + +
  • Chu Shogi +
  • +

    d

    + +
  • Dai Shogi +
  • Dai-dai Shogi +
  • Draws +
  • Drops +
  • +

    g

    + +
  • gnushogi +
  • GPL +
  • +

    h

    + +
  • Handicaps +
  • +

    i

    + +
  • Introduction +
  • +

    k

    + +
  • Kyoku Tai Shogi +
  • +

    l

    + +
  • License +
  • +

    m

    + +
  • Mailing lists +
  • Maka-dai-dai Shogi +
  • +

    o

    + +
  • Opening setup +
  • +

    p

    + +
  • Piece moves +
  • Piece promotion +
  • +

    r

    + +
  • References +
  • Rules +
  • +

    s

    + +
  • Sample game +
  • Shogi variants +
  • Shogi vs. Chess +
  • +

    t

    + +
  • Tai Shogi +
  • Tenjiku Shogi +
  • Tori Shogi +
  • +

    v

    + +
  • Variants +
  • +

    w

    + +
  • Wa Shogi +
  • Web sites +
  • Winning the game +
  • +

    x

    + +
  • xshogi +
  • + + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_3.html b/doc/gnushogi_3.html new file mode 100644 index 0000000..a70fa51 --- /dev/null +++ b/doc/gnushogi_3.html @@ -0,0 +1,98 @@ + + + + +GNU Shogi manual - About shogi + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


    + + +

    About the game of shogi

    +

    + + + + +

    +

    +"Japanese chess cedes nothing in depth or beauty to the European +game... it is at least as interesting." + + +

    +--- Alexander Alekhine
    +(quoted in David Pritchard, The Encyclopedia of Chess Variants) + + +

    +"... shogi [is] by far the most complex form of chess that has ever +achieved widespread popularity." + + +

    +--- R. Wayne Schmittberger, New Rules for Classic Games +

    + +

    +Shogi is the version of chess played in Japan. It is strikingly +different from standard chess (which I shall refer to henceforth as +"international chess") and also to all other regional variants, +because captured pieces can re-enter play on the side of the capturer. +This has several interesting effects on the play of the game: + + + +

      +
    1. + +Shogi is much more complex than international chess, at least in +terms of the average number of possible moves per turn (estimated at +about 35 for chess and at about 80 for shogi). + +
    2. + +There are almost no draws (about 1-2% of all games in professional play). + +
    3. + +Exchanges complicate the play rather than simplifying it. + +
    4. + +There are no "endgames" in the standard chess sense; all pieces remain +in play throughout the game. Games typically end in a race to +checkmate the other player before being checkmated oneself. + +
    5. + +Ownership of a piece is not indicated by the color of the piece; +instead, pieces are wedge-shaped and point towards the opponent. The +name of the piece is inscribed in Kanji characters on the front of the +piece. + +
    6. + +Most importantly: it's more fun than other forms of chess :-) + +
    + +

    +Shogi is extremely popular in Japan; it has been estimated that 20 +million Japanese can play shogi, of which perhaps 1 million are active +players. It is even more popular there than the game of go, Japan's +other favorite board game. There are a number of professional players +who make a considerable amount of money playing in shogi tournaments, +and the game receives extensive newpaper and television coverage. +Despite this, the game has yet to become popular outside of Japan. Part +of this is because the Kanji characters on the pieces scare away some +people, but mostly it's due, I think, to lack of exposure to the game +and to the difficulty of finding opponents. I hope that GNU shogi will +help introduce shogi to a wider audience. + + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_4.html b/doc/gnushogi_4.html new file mode 100644 index 0000000..4f4f45e --- /dev/null +++ b/doc/gnushogi_4.html @@ -0,0 +1,46 @@ + + + + +GNU Shogi manual - The rules of shogi + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


    + + +

    The rules of shogi

    +

    + + + +

    +Shogi is a two-person abstract strategy board game with full information +(i.e. all pieces and moves are visible to both players at all times). +It is in the chess family, being descended from the same ancestral game +as international chess: the Indian game of Chaturanga. The two players +are referred to as "Black" and "White", with Black moving first +(unlike in international chess, where White moves first), and with +movement alternating between the two players. Note that "Black" and +"White" are just names; the pieces are not colored. Instead, they are +flat, wedge-shaped pieces which point towards the opponent. The +identity of a given piece is indicated by two Japanese Kanji characters +on each piece. In fact, only the top character is needed to identify +the piece and thus only the top character is used in shogi diagrams. I +will use alphabetical equivalents in the diagrams here; to see what the +Kanji characters look like, start up xshogi (see section xshogi) and compare +the starting setup there with the starting setup in this file +(see section The opening setup). + + +

    +The object of the game is to capture the opponent's King. The board is +a grid of 9x9 uncolored squares, and pieces are placed on the squares. +Each player begins with 20 pieces, described in the next section. +Capture is by displacement, as in international chess. + + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_5.html b/doc/gnushogi_5.html new file mode 100644 index 0000000..6de8e61 --- /dev/null +++ b/doc/gnushogi_5.html @@ -0,0 +1,97 @@ + + + + +GNU Shogi manual - The moves of the pieces + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


    + + +

    The moves of the pieces

    +

    + + + +

    +Each player at the beginning of a shogi game has a total of 20 pieces of +eight different types. The moves of the shogi pieces can be divided +into three classes: "stepping" pieces, that only move one square at a +time; "ranging" pieces that move any number of unobstructed squares in +a line, and "jumping" pieces that can jump over obstructing pieces to +reach their destination squares. Most pieces can also promote to +different (usually stronger) pieces under certain circumstances (see the +next section). All pieces capture the same way that they move (even +pawns). The piece moves and promotions are as follows; each piece name +is followed by the standard piece abbreviation: + + + +

      + +
    1. + +The king (K). The king can move one square in any horizontal, vertical, +or diagonal direction, just like the king in international chess. The +king does not promote. + +
    2. + +The rook (R). The rook can move any number of squares in a horizontal +or vertical direction. The rook is the same as the rook in +international chess (except that it can promote). A rook promotes to a +"dragon king" or "dragon" for short (often just referred to as a +"promoted rook"), which can move as a rook or can move one square in +any diagonal direction. + +
    3. + +The bishop (B). The bishop can move any number of squares in a diagonal +direction. The bishop is the same as the bishop in international chess +(except that it can promote). A bishop promotes to a "dragon horse" +or "horse" for short (often just referred to as a "promoted +bishop"), which can move as a bishop or can move one square in any +horizontal or vertical direction. Note: the horse should not be +confused with a knight (see below), as they are two completely different +pieces. + +
    4. + +The gold general (G). A gold general can move one square in any +horizontal or vertical direction, or one square in a forward diagonal +direction. Gold generals do not promote. + +
    5. + +The silver general (S). A silver general can move one square in any +diagonal direction, or one square straight forward. A silver general +promotes to a gold general. + +
    6. + +The knight (N). A knight can move one square straight forward followed +by one square to either forward diagonal, jumping over intervening +pieces if any. In other words, a knight moves like its international +chess counterpart, but forward only. A knight promotes to a gold +general. The knight is the only jumping piece, as in chess. + +
    7. + +The lance (L). A lance can move any number of squares straight forward. +A lance promotes to a gold general. + +
    8. + +The pawn (P). A pawn can move one square straight forward. The pawn +captures the same way that it moves, in contrast to international chess. +There is also no initial two-space move for pawns and no +en-passant capture. A pawn promotes to a gold general; a +promoted pawn is usually known as a "Tokin". + +
    + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_6.html b/doc/gnushogi_6.html new file mode 100644 index 0000000..1027529 --- /dev/null +++ b/doc/gnushogi_6.html @@ -0,0 +1,57 @@ + + + + +GNU Shogi manual - The opening setup + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


    + + +

    The opening setup

    +

    + + + +

    + +The opening setup for shogi is as follows: +

    +

    +   9    8    7    6    5    4    3    2    1
    ++--------------------------------------------+     
    +| wL | wN | wS | wG | wK | wG | wS | wN | wL |  a     
    ++--------------------------------------------+       
    +|    | wR |    |    |    |    |    | wB |    |  b     
    ++--------------------------------------------+       
    +| wP | wP | wP | wP | wP | wP | wP | wP | wP |  c   
    ++--------------------------------------------+     
    +|    |    |    |    |    |    |    |    |    |  d   
    ++--------------------------------------------+     
    +|    |    |    |    |    |    |    |    |    |  e   
    ++--------------------------------------------+     
    +|    |    |    |    |    |    |    |    |    |  f   
    ++--------------------------------------------+     
    +| bP | bP | bP | bP | bP | bP | bP | bP | bP |  g   
    ++--------------------------------------------+       
    +|    | bB |    |    |    |    |    | bR |    |  h   
    ++--------------------------------------------+       
    +| bL | bN | bS | bG | bK | bG | bS | bN | bL |  i    
    ++--------------------------------------------+
    +
    + + +

    +Here, "b" stands for "black" and "w" stands for "white", so +that, for instance, "bL" means "black lance". The numbers above the +files and the letters to the right of the ranks represent the most +common notation system used for shogi by westerners (the Japanese also +use Arabic numerals for the files but use Japanese numerals for the +ranks). + + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_7.html b/doc/gnushogi_7.html new file mode 100644 index 0000000..fa7a28e --- /dev/null +++ b/doc/gnushogi_7.html @@ -0,0 +1,94 @@ + + + + +GNU Shogi manual - Promotion of pieces + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


    + + +

    Promotion of pieces

    +

    + + + +

    +In sharp contrast to international chess, where only pawns can promote +to higher-ranked pieces, most of the pieces in shogi can promote. The +promoted ranks are discussed in the section on piece moves (see section The moves of the pieces) but are repeated here for reference: + + +

    + +
    Pawn +
    +promotes to gold general (called a `tokin' in this case only). + +
    Lance +
    +promotes to gold general. + +
    Knight +
    +promotes to gold general. + +
    Silver general +
    +promotes to gold general. + +
    Gold general +
    +does not promote. + +
    Bishop +
    +promotes to "dragon horse" or just "horse" for short. The horse can +move as a bishop or can move one square in any orthogonal direction. + +
    Rook +
    +promotes to "dragon king" or just "dragon" for short. The dragon +can move as a rook or can move one square in any diagonal direction. + +
    King +
    +does not promote. + +
    + +

    +The three ranks furthest away from each player constitute his/her +"promotion zone". A player may, but is not required to, promote a +piece after making a move in which the piece begins and/or ends in the +promotion zone. Thus you can promote a piece when moving the piece into +the promotion zone, out of the promotion zone, or entirely within the +promotion zone. Promotion is mandatory in these cases: + + + +

      + +
    1. You must promote a pawn or a lance after moving it to the last rank. + +
    2. You must promote a knight after moving it to either of the last + +two ranks. + +
    + +

    +These forced promotions ensure that a piece cannot be moved to a square +from which it would have no further move. + + +

    +Pieces "dropped" onto the board (see section Drops) always drop in the +unpromoted state, even if they drop into the promotion zone. + + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_8.html b/doc/gnushogi_8.html new file mode 100644 index 0000000..ba24091 --- /dev/null +++ b/doc/gnushogi_8.html @@ -0,0 +1,79 @@ + + + + +GNU Shogi manual - Drops + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


    + + +

    Drops

    +

    + + + +

    +When a player captures a piece, that piece is not removed from play. +Instead, it becomes the property of the capturer and can re-enter play +by being placed on (almost) any vacant square during the player's move. +This is known as a "drop" and counts as a full move (in other words, +you can either move a piece on the board or drop a piece onto the board +during your move, but not both). All pieces drop in the unpromoted +state. Pieces may be legally dropped in their promotion zone, but they +do not promote on that turn. + + +

    +There are several restrictions on drops: + + + +

      + +
    1. A pawn may not be dropped onto a file if there is already an + +unpromoted pawn belonging to the same player on that file. It is legal +to drop a pawn on a file which contains a promoted pawn belonging +to the same player, however. + +
    2. A pawn may not be dropped to give immediate checkmate on the + +move. A pawn is, however, permitted to be moved on the board to give +immediate checkmate. This is a curious rule, and if anyone knows the +reason for it I would appreciate it if they would contact me and explain +it to me :-) + +
    3. A pawn or piece may not be dropped onto a square from which they + +would have no legal move. This means that pawns and lances may not be +dropped onto the last rank, and the knight may not be dropped onto the +last or second-to-last rank. + +
    + +

    +It is entirely permissible (and often advisable) to drop a piece or pawn +between one's King and an attacking ranging piece. For this reason, +the final checkmating move is nearly always an attack on the King from +an adjacent square (except for an attack by a Knight). + + +

    +Captured pieces are said to be pieces "in hand". + + +

    +The drop is the primary distinguishing feature of Japanese chess, shared +with no other popular chess-type game. It gives shogi a very aggressive +quality, and dramatically increases the number of possible moves once a +few pieces have been captured. Another interesting feature of shogi is +that exchanges complicate play rather than simplifying it (as in +international chess), because of the drop rule. + + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_9.html b/doc/gnushogi_9.html new file mode 100644 index 0000000..ad6ecb6 --- /dev/null +++ b/doc/gnushogi_9.html @@ -0,0 +1,32 @@ + + + + +GNU Shogi manual - Winning the game + + + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


    + + +

    Winning the game

    +

    + + + +

    +A game of shogi is won by capturing the opponent's king. In general, +this is done by checkmating the king: attacking the king in such a way +that the king cannot be defended no matter what the defending player +moves. Note, though, that there is no rule that requires a player to +defend a king which is being attacked. However, if he does not defend +his king, the opponent is entirely free to capture it on the next move, +thus winning the game. As in international chess, in practice most +games end by resignation when one player realizes that he cannot escape +checkmate. + + +


    + [Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]   + + + diff --git a/doc/gnushogi_stoc.html b/doc/gnushogi_stoc.html new file mode 100644 index 0000000..9be1680 --- /dev/null +++ b/doc/gnushogi_stoc.html @@ -0,0 +1,37 @@ + + + + +GNU Shogi manual - Short Table of Contents + + +

    GNU Shogi manual

    +
    Mike Vanier
    +

    +


    +

    +


    +This document was generated on June 29, 1999 using +texi2html 1.57. + + + diff --git a/doc/gnushogi_toc.html b/doc/gnushogi_toc.html new file mode 100644 index 0000000..57e3731 --- /dev/null +++ b/doc/gnushogi_toc.html @@ -0,0 +1,50 @@ + + + + +GNU Shogi manual - Table of Contents + + +

    GNU Shogi manual

    +
    Mike Vanier
    +

    +


    +

    +


    +This document was generated on June 29, 1999 using +texi2html 1.57. + + + diff --git a/doc/listserv.ref b/doc/listserv.ref index 2bd676e..d27c1d6 100644 --- a/doc/listserv.ref +++ b/doc/listserv.ref @@ -1,8 +1,13 @@ +NOTE: this file may be seriously outdated. I haven't had time to go over +it yet. Let me know if there are problems. + +-- Mike (mvanier@bbb.caltech.edu) + + + This is a message from Pieter Stouten, one of the owners of a listserver for the game of Shogi. - - -------------------------------------------------------------------------------------------- +------------------------------------------------------------------------ H O W T O D E A L W I T H T E C H N I O N @@ -13,12 +18,13 @@ explanation about how it all works. This file will also automatically be sent to all new subscribers to the list. One thing that must be clear is the fundamental difference between - the List Server or - +the List Server +or and - the Shogi Discussion List or . +the Shogi Discussion List or +. LISTSERV diff --git a/doc/make_fig1 b/doc/make_fig1 new file mode 100755 index 0000000..cd92ef9 --- /dev/null +++ b/doc/make_fig1 @@ -0,0 +1,55 @@ +#! /usr/bin/env python + +import sys, re + +key = "The opening setup for shogi is as follows:" + +replace = """ +The opening setup for shogi is as follows: +

    +

    +   9    8    7    6    5    4    3    2    1
    ++--------------------------------------------+     
    +| wL | wN | wS | wG | wK | wG | wS | wN | wL |  a     
    ++--------------------------------------------+       
    +|    | wR |    |    |    |    |    | wB |    |  b     
    ++--------------------------------------------+       
    +| wP | wP | wP | wP | wP | wP | wP | wP | wP |  c   
    ++--------------------------------------------+     
    +|    |    |    |    |    |    |    |    |    |  d   
    ++--------------------------------------------+     
    +|    |    |    |    |    |    |    |    |    |  e   
    ++--------------------------------------------+     
    +|    |    |    |    |    |    |    |    |    |  f   
    ++--------------------------------------------+     
    +| bP | bP | bP | bP | bP | bP | bP | bP | bP |  g   
    ++--------------------------------------------+       
    +|    | bB |    |    |    |    |    | bR |    |  h   
    ++--------------------------------------------+       
    +| bL | bN | bS | bG | bK | bG | bS | bN | bL |  i    
    ++--------------------------------------------+
    +
    +""" + +# +# Insert the first figure directly into the html file. +# + +done = 0 + +while 1: + line = sys.stdin.readline() + if not line: + break + + if not done: + match = re.match(key, line) + if match: + print replace, + done = 1 + else: + print line, + else: + print line, + + diff --git a/doc/make_fig2 b/doc/make_fig2 new file mode 100755 index 0000000..94e867c --- /dev/null +++ b/doc/make_fig2 @@ -0,0 +1,53 @@ +#! /usr/bin/env python + +import sys, re + +key = "three-mover. Here is a really trivial three-mover:" + +replace = """ +three-mover. Here is a really trivial three-mover: +

    +

    +
    +   3    2    1            
    +----------------+         
    + |    |    |    |  a         
    +----------------+           
    + |    |    | wK |  b         
    +----------------+           
    + |    |    |    |  c       
    +----------------+         
    + | bN |    |    |  d       
    +----------------+         
    + |    |    |    |  e       
    +----------------+         
    + |    | bN |    |  f       
    +----------------+
    +
    +Black in hand: S, G
    +
    +
    +""" + +# +# Insert the figure directly into the html file. +# + +done = 0 + +while 1: + line = sys.stdin.readline() + if not line: + break + + if not done: + match = re.match(key, line) + if match: + print replace, + done = 1 + else: + print line, + else: + print line, + + diff --git a/doc/shogi.rules b/doc/shogi.rules index f98231c..b8e9652 100644 --- a/doc/shogi.rules +++ b/doc/shogi.rules @@ -1,26 +1,22 @@ - - -These are the rules of Shogi, as distributed by the Shogi-l listserver. - - ------------------------------------------------------------------------------------------- - - S H O G I R U L E S ==================== +These are the rules of Shogi (Japanese chess), as distributed by the +Shogi-l listserver. I have edited it slightly for clarity. + +-- Mike -Shogi is a Japanese board game played by two players. -The object of the game is to capture the opponent's King. -Shogi is played on a nine-by-nine board. The vertical rows are called files, -the horizontal ones ranks or just rows. Each player has twenty pieces: -one King, two Gold Generals, two Silver Generals, two kNights, -two Lances, one Rook, one Bishop and nine Pawns. -The player moving up the board and making the first move is referred to as -black and his opponent white, although in Shogi sets all pieces have the -same colour. They are differentiated only in direction: pieces pointing -away from a player are his. The pieces lie flat on the board and have -their Japanese name written on them. + +Shogi is a Japanese board game played by two players. The object of the +game is to capture the opponent's King. Shogi is played on a nine-by-nine +board. The vertical rows are called files, the horizontal ones ranks or +just rows. Each player has twenty pieces: one King, two Gold Generals, two +Silver Generals, two kNights, two Lances, one Rook, one Bishop and nine +Pawns. The player moving up the board and making the first move is +referred to as black and his opponent white, although in Shogi sets all +pieces have the same colour. They are differentiated only in direction: +pieces pointing away from a player are his. The pieces lie flat on the +board and have their Japanese name written on them. THE MOVES @@ -40,11 +36,14 @@ Pawn: one step forward Apart from the King and the Gold General all pieces can promote. After promotion their moves are as follows: + + Promoted Silver, promoted kNight, promoted Lance and promoted Pawn all move as a Gold. + + The promoted Rook in addition to the moves of the unpromoted Rook can move one step in the diagonal directions. It either moves like a Rook or like a King. + + The promoted Bishop in addition to the moves of the unpromoted Bishop can move one step horizontally or vertically. It either moves like a Bishop or like a King. @@ -72,17 +71,19 @@ opponent's piece is captured. All pieces capture in the same way that they move. Captured pieces become part of the capturer's force. In a later move, instead of moving a piece on the board, a player may put a piece that he has captured from his opponent back onto the board, in an empty square. -This is called dropping a piece. Pieces are always dropped unpromoted: if -a promoted piece is captured, it reverts to its unpromoted rank. -Pieces may be dropped on any empty square on the board with only three -restrictions: +This is called dropping a piece. Pieces are always dropped unpromoted: if a +promoted piece is captured, it reverts to its unpromoted rank. Pieces may +be dropped on any empty square on the board with only three restrictions: + 1) After dropping a piece it must be able to make a legal move. This applies to Pawns, Knights or Lances. They may not be dropped onto a square from which they will never be able to move. + 2) Attacking the King by dropping a Pawn on the square in front of him is not allowed if the King cannot prevent being captured on the following move. To use the Chess expression: checkmating the King with a Pawn drop is prohibited. + 3) A pawn may only be dropped on a file (vertical row) if there is no other unpromoted pawn of the same player on that file. @@ -91,19 +92,22 @@ DRAWS ----- The game of Shogi has very few draws (roughly 1 percent), mainly because of -the possibility to drop pieces. Draws cannot be offered and can arise from -two situations: +the ability to drop pieces. Draws cannot be offered and can arise from two +situations: + 1) A position (including the pieces in hand) occurs 4 times with the same player to move ("Sennichite"). However, if this is caused by consecutive checks (direct attacks on the King, threatening to capture it on the next move) by one side, the player giving these checks loses the game. + 2) Both players have moved their King into the the promotion zone (or they cannot be prevented to do so) and the Kings cannot be checkmated. In - that case the players may decide to count their pieces where the King does - not count, the Rook and Bishop count as 5 points, and all other pieces as - one point. Promotion is disregarded. If both players have at least 24 - points the game is a draw ("Jishogi"). If a player has less, he loses the - game. + that case the players may decide to count their pieces where the King + does not count, the Rook and Bishop count as 5 points, and all other + pieces as one point. Promotion is disregarded. If both players have at + least 24 points the game is a draw ("Jishogi"). If a player has less, + he loses the game. + Of course, a player can refuse to count pieces when he still has mating chances or chances to gain material which would affect the outcome of the counting. There is no strict rule about what to do if this is not the case, diff --git a/doc/texinfo.tex b/doc/texinfo.tex new file mode 100644 index 0000000..7421f88 --- /dev/null +++ b/doc/texinfo.tex @@ -0,0 +1,5868 @@ +% texinfo.tex -- TeX macros to handle Texinfo files. +% +% Load plain if necessary, i.e., if running under initex. +\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi +% +\def\texinfoversion{1999-05-25.6}% +% +% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 +% Free Software Foundation, Inc. +% +% This texinfo.tex file is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License as +% published by the Free Software Foundation; either version 2, or (at +% your option) any later version. +% +% This texinfo.tex file is distributed in the hope that it will be +% useful, but WITHOUT ANY WARRANTY; without even the implied warranty +% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +% General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this texinfo.tex file; see the file COPYING. If not, write +% to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +% Boston, MA 02111-1307, USA. +% +% In other words, you are welcome to use, share and improve this program. +% You are forbidden to forbid anyone else to use, share and improve +% what you give them. Help stamp out software-hoarding! +% +% Please try the latest version of texinfo.tex before submitting bug +% reports; you can get the latest version from: +% ftp://ftp.gnu.org/pub/gnu/texinfo.tex +% (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) +% ftp://tug.org/tex/texinfo.tex +% ftp://ctan.org/macros/texinfo/texinfo.tex +% (and all CTAN mirrors, finger ctan@ctan.org for a list). +% /home/gd/gnu/doc/texinfo.tex on the GNU machines. +% The texinfo.tex in any given Texinfo distribution could well be out +% of date, so if that's what you're using, please check. +% There is a small home page for Texinfo at http://texinfo.org/. +% +% Send bug reports to bug-texinfo@gnu.org. Please include including a +% complete document in each bug report with which we can reproduce the +% problem. Patches are, of course, greatly appreciated. +% +% To process a Texinfo manual with TeX, it's most reliable to use the +% texi2dvi shell script that comes with the distribution. For a simple +% manual foo.texi, however, you can get away with this: +% tex foo.texi +% texindex foo.?? +% tex foo.texi +% tex foo.texi +% dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps. +% The extra runs of TeX get the cross-reference information correct. +% Sometimes one run after texindex suffices, and sometimes you need more +% than two; texi2dvi does it as many times as necessary. +% +% It is possible to adapt texinfo.tex for other languages. You can get +% the existing language-specific files from ftp://ftp.gnu.org/gnu/texinfo/. + +\message{Loading texinfo [version \texinfoversion]:} + +% If in a .fmt file, print the version number +% and turn on active characters that we couldn't do earlier because +% they might have appeared in the input file name. +\everyjob{\message{[Texinfo version \texinfoversion]}% + \catcode`+=\active \catcode`\_=\active} + +% Save some parts of plain tex whose names we will redefine. +\let\ptexb=\b +\let\ptexbullet=\bullet +\let\ptexc=\c +\let\ptexcomma=\, +\let\ptexdot=\. +\let\ptexdots=\dots +\let\ptexend=\end +\let\ptexequiv=\equiv +\let\ptexexclam=\! +\let\ptexi=\i +\let\ptexlbrace=\{ +\let\ptexrbrace=\} +\let\ptexstar=\* +\let\ptext=\t + +% We never want plain's outer \+ definition in Texinfo. +% For @tex, we can use \tabalign. +\let\+ = \relax + +% Get ready for pdf. +\newif\ifpdf +\ifx\pdfoutput\undefined\else + \input pdfcolor + \pdfoutput=1 + \pdftrue +\fi + +\message{Basics,} +\chardef\other=12 + +% If this character appears in an error message or help string, it +% starts a new line in the output. +\newlinechar = `^^J + +% Set up fixed words for English if not already set. +\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi +\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi +\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi +\ifx\putwordin\undefined \gdef\putwordin{in}\fi +\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi +\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi +\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi +\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi +\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi +\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi +\ifx\putwordof\undefined \gdef\putwordof{of}\fi +\ifx\putwordon\undefined \gdef\putwordon{on}\fi +\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi +\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi +\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi +\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi +\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi +\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi +\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi +% +\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi +\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi +\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi +\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi +\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi +\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi +\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi +\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi +\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi +\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi +\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi +\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi +% +\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi +\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi +\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi +\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi +\ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi +\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi +\ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi + +% Ignore a token. +% +\def\gobble#1{} + +\hyphenation{ap-pen-dix} +\hyphenation{mini-buf-fer mini-buf-fers} +\hyphenation{eshell} +\hyphenation{white-space} + +% Margin to add to right of even pages, to left of odd pages. +\newdimen \bindingoffset +\newdimen \normaloffset +\newdimen\pagewidth \newdimen\pageheight + +% Sometimes it is convenient to have everything in the transcript file +% and nothing on the terminal. We don't just call \tracingall here, +% since that produces some useless output on the terminal. +% +\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% +\ifx\eTeXversion\undefined +\def\loggingall{\tracingcommands2 \tracingstats2 + \tracingpages1 \tracingoutput1 \tracinglostchars1 + \tracingmacros2 \tracingparagraphs1 \tracingrestores1 + \showboxbreadth\maxdimen\showboxdepth\maxdimen +}% +\else +\def\loggingall{\tracingcommands3 \tracingstats2 + \tracingpages1 \tracingoutput1 \tracinglostchars1 + \tracingmacros2 \tracingparagraphs1 \tracingrestores1 + \tracingscantokens1 \tracingassigns1 \tracingifs1 + \tracinggroups1 \tracingnesting2 + \showboxbreadth\maxdimen\showboxdepth\maxdimen +}% +\fi + +% For @cropmarks command. +% Do @cropmarks to get crop marks. +% +\newif\ifcropmarks +\let\cropmarks = \cropmarkstrue +% +% Dimensions to add cropmarks at corners. +% Added by P. A. MacKay, 12 Nov. 1986 +% +\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines +\newdimen\cornerlong \cornerlong=1pc +\newdimen\cornerthick \cornerthick=.3pt +\newdimen\topandbottommargin \topandbottommargin=.75in + +% Main output routine. +\chardef\PAGE = 255 +\output = {\onepageout{\pagecontents\PAGE}} + +\newbox\headlinebox +\newbox\footlinebox + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions, but you have to call it yourself. +\def\onepageout#1{% + \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi + % + \ifodd\pageno \advance\hoffset by \bindingoffset + \else \advance\hoffset by -\bindingoffset\fi + % + % Do this outside of the \shipout so @code etc. will be expanded in + % the headline as they should be, not taken literally (outputting ''code). + \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% + \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% + % + {% + % Have to do this stuff outside the \shipout because we want it to + % take effect in \write's, yet the group defined by the \vbox ends + % before the \shipout runs. + % + \escapechar = `\\ % use backslash in output files. + \indexdummies % don't expand commands in the output. + \normalturnoffactive % \ in index entries must not stay \, e.g., if + % the page break happens to be in the middle of an example. + \shipout\vbox{% + \ifcropmarks \vbox to \outervsize\bgroup + \hsize = \outerhsize + \vskip-\topandbottommargin + \vtop to0pt{% + \line{\ewtop\hfil\ewtop}% + \nointerlineskip + \line{% + \vbox{\moveleft\cornerthick\nstop}% + \hfill + \vbox{\moveright\cornerthick\nstop}% + }% + \vss}% + \vskip\topandbottommargin + \line\bgroup + \hfil % center the page within the outer (page) hsize. + \ifodd\pageno\hskip\bindingoffset\fi + \vbox\bgroup + \fi + % + \unvbox\headlinebox + \pagebody{#1}% + \ifdim\ht\footlinebox > 0pt + % Only leave this space if the footline is nonempty. + % (We lessened \vsize for it in \oddfootingxxx.) + % The \baselineskip=24pt in plain's \makefootline has no effect. + \vskip 2\baselineskip + \unvbox\footlinebox + \fi + % + \ifpdf\pdfmkdest{\the\pageno}\fi + % + \ifcropmarks + \egroup % end of \vbox\bgroup + \hfil\egroup % end of (centering) \line\bgroup + \vskip\topandbottommargin plus1fill minus1fill + \boxmaxdepth = \cornerthick + \vbox to0pt{\vss + \line{% + \vbox{\moveleft\cornerthick\nsbot}% + \hfill + \vbox{\moveright\cornerthick\nsbot}% + }% + \nointerlineskip + \line{\ewbot\hfil\ewbot}% + }% + \egroup % \vbox from first cropmarks clause + \fi + }% end of \shipout\vbox + }% end of group with \turnoffactive + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi +} + +\newinsert\margin \dimen\margin=\maxdimen + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi +% marginal hacks, juha@viisa.uucp (Juha Takala) +\ifvoid\margin\else % marginal info is present + \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi +\dimen@=\dp#1 \unvbox#1 +\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi +\ifr@ggedbottom \kern-\dimen@ \vfil \fi} +} + +% Here are the rules for the cropmarks. Note that they are +% offset so that the space between them is truly \outerhsize or \outervsize +% (P. A. MacKay, 12 November, 1986) +% +\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} +\def\nstop{\vbox + {\hrule height\cornerthick depth\cornerlong width\cornerthick}} +\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} +\def\nsbot{\vbox + {\hrule height\cornerlong depth\cornerthick width\cornerthick}} + +% Parse an argument, then pass it to #1. The argument is the rest of +% the input line (except we remove a trailing comment). #1 should be a +% macro which expects an ordinary undelimited TeX argument. +% +\def\parsearg#1{% + \let\next = #1% + \begingroup + \obeylines + \futurelet\temp\parseargx +} + +% If the next token is an obeyed space (from an @example environment or +% the like), remove it and recurse. Otherwise, we're done. +\def\parseargx{% + % \obeyedspace is defined far below, after the definition of \sepspaces. + \ifx\obeyedspace\temp + \expandafter\parseargdiscardspace + \else + \expandafter\parseargline + \fi +} + +% Remove a single space (as the delimiter token to the macro call). +{\obeyspaces % + \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} + +{\obeylines % + \gdef\parseargline#1^^M{% + \endgroup % End of the group started in \parsearg. + % + % First remove any @c comment, then any @comment. + % Result of each macro is put in \toks0. + \argremovec #1\c\relax % + \expandafter\argremovecomment \the\toks0 \comment\relax % + % + % Call the caller's macro, saved as \next in \parsearg. + \expandafter\next\expandafter{\the\toks0}% + }% +} + +% Since all \c{,omment} does is throw away the argument, we can let TeX +% do that for us. The \relax here is matched by the \relax in the call +% in \parseargline; it could be more or less anything, its purpose is +% just to delimit the argument to the \c. +\def\argremovec#1\c#2\relax{\toks0 = {#1}} +\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} + +% \argremovec{,omment} might leave us with trailing spaces, though; e.g., +% @end itemize @c foo +% will have two active spaces as part of the argument with the +% `itemize'. Here we remove all active spaces from #1, and assign the +% result to \toks0. +% +% This loses if there are any *other* active characters besides spaces +% in the argument -- _ ^ +, for example -- since they get expanded. +% Fortunately, Texinfo does not define any such commands. (If it ever +% does, the catcode of the characters in questionwill have to be changed +% here.) But this means we cannot call \removeactivespaces as part of +% \argremovec{,omment}, since @c uses \parsearg, and thus the argument +% that \parsearg gets might well have any character at all in it. +% +\def\removeactivespaces#1{% + \begingroup + \ignoreactivespaces + \edef\temp{#1}% + \global\toks0 = \expandafter{\temp}% + \endgroup +} + +% Change the active space to expand to nothing. +% +\begingroup + \obeyspaces + \gdef\ignoreactivespaces{\obeyspaces\let =\empty} +\endgroup + + +\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} + +%% These are used to keep @begin/@end levels from running away +%% Call \inENV within environments (after a \begingroup) +\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} +\def\ENVcheck{% +\ifENV\errmessage{Still within an environment; press RETURN to continue} +\endgroup\fi} % This is not perfect, but it should reduce lossage + +% @begin foo is the same as @foo, for now. +\newhelp\EMsimple{Press RETURN to continue.} + +\outer\def\begin{\parsearg\beginxxx} + +\def\beginxxx #1{% +\expandafter\ifx\csname #1\endcsname\relax +{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else +\csname #1\endcsname\fi} + +% @end foo executes the definition of \Efoo. +% +\def\end{\parsearg\endxxx} +\def\endxxx #1{% + \removeactivespaces{#1}% + \edef\endthing{\the\toks0}% + % + \expandafter\ifx\csname E\endthing\endcsname\relax + \expandafter\ifx\csname \endthing\endcsname\relax + % There's no \foo, i.e., no ``environment'' foo. + \errhelp = \EMsimple + \errmessage{Undefined command `@end \endthing'}% + \else + \unmatchedenderror\endthing + \fi + \else + % Everything's ok; the right environment has been started. + \csname E\endthing\endcsname + \fi +} + +% There is an environment #1, but it hasn't been started. Give an error. +% +\def\unmatchedenderror#1{% + \errhelp = \EMsimple + \errmessage{This `@end #1' doesn't have a matching `@#1'}% +} + +% Define the control sequence \E#1 to give an unmatched @end error. +% +\def\defineunmatchedend#1{% + \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% +} + + +% Single-spacing is done by various environments (specifically, in +% \nonfillstart and \quotations). +\newskip\singlespaceskip \singlespaceskip = 12.5pt +\def\singlespace{% + % Why was this kern here? It messes up equalizing space above and below + % environments. --karl, 6may93 + %{\advance \baselineskip by -\singlespaceskip + %\kern \baselineskip}% + \setleading \singlespaceskip +} + +%% Simple single-character @ commands + +% @@ prints an @ +% Kludge this until the fonts are right (grr). +\def\@{{\tt\char64}} + +% This is turned off because it was never documented +% and you can use @w{...} around a quote to suppress ligatures. +%% Define @` and @' to be the same as ` and ' +%% but suppressing ligatures. +%\def\`{{`}} +%\def\'{{'}} + +% Used to generate quoted braces. +\def\mylbrace {{\tt\char123}} +\def\myrbrace {{\tt\char125}} +\let\{=\mylbrace +\let\}=\myrbrace +\begingroup + % Definitions to produce actual \{ & \} command in an index. + \catcode`\{ = 12 \catcode`\} = 12 + \catcode`\[ = 1 \catcode`\] = 2 + \catcode`\@ = 0 \catcode`\\ = 12 + @gdef@lbracecmd[\{]% + @gdef@rbracecmd[\}]% +@endgroup + +% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent +% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H. +\let\, = \c +\let\dotaccent = \. +\def\ringaccent#1{{\accent23 #1}} +\let\tieaccent = \t +\let\ubaraccent = \b +\let\udotaccent = \d + +% Other special characters: @questiondown @exclamdown +% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss. +\def\questiondown{?`} +\def\exclamdown{!`} + +% Dotless i and dotless j, used for accents. +\def\imacro{i} +\def\jmacro{j} +\def\dotless#1{% + \def\temp{#1}% + \ifx\temp\imacro \ptexi + \else\ifx\temp\jmacro \j + \else \errmessage{@dotless can be used only with i or j}% + \fi\fi +} + +% Be sure we're in horizontal mode when doing a tie, since we make space +% equivalent to this in @example-like environments. Otherwise, a space +% at the beginning of a line will start with \penalty -- and +% since \penalty is valid in vertical mode, we'd end up putting the +% penalty on the vertical list instead of in the new paragraph. +{\catcode`@ = 11 + % Avoid using \@M directly, because that causes trouble + % if the definition is written into an index file. + \global\let\tiepenalty = \@M + \gdef\tie{\leavevmode\penalty\tiepenalty\ } +} + +% @: forces normal size whitespace following. +\def\:{\spacefactor=1000 } + +% @* forces a line break. +\def\*{\hfil\break\hbox{}\ignorespaces} + +% @. is an end-of-sentence period. +\def\.{.\spacefactor=3000 } + +% @! is an end-of-sentence bang. +\def\!{!\spacefactor=3000 } + +% @? is an end-of-sentence query. +\def\?{?\spacefactor=3000 } + +% @w prevents a word break. Without the \leavevmode, @w at the +% beginning of a paragraph, when TeX is still in vertical mode, would +% produce a whole line of output instead of starting the paragraph. +\def\w#1{\leavevmode\hbox{#1}} + +% @group ... @end group forces ... to be all on one page, by enclosing +% it in a TeX vbox. We use \vtop instead of \vbox to construct the box +% to keep its height that of a normal line. According to the rules for +% \topskip (p.114 of the TeXbook), the glue inserted is +% max (\topskip - \ht (first item), 0). If that height is large, +% therefore, no glue is inserted, and the space between the headline and +% the text is small, which looks bad. +% +\def\group{\begingroup + \ifnum\catcode13=\active \else + \errhelp = \groupinvalidhelp + \errmessage{@group invalid in context where filling is enabled}% + \fi + % + % The \vtop we start below produces a box with normal height and large + % depth; thus, TeX puts \baselineskip glue before it, and (when the + % next line of text is done) \lineskip glue after it. (See p.82 of + % the TeXbook.) Thus, space below is not quite equal to space + % above. But it's pretty close. + \def\Egroup{% + \egroup % End the \vtop. + \endgroup % End the \group. + }% + % + \vtop\bgroup + % We have to put a strut on the last line in case the @group is in + % the midst of an example, rather than completely enclosing it. + % Otherwise, the interline space between the last line of the group + % and the first line afterwards is too small. But we can't put the + % strut in \Egroup, since there it would be on a line by itself. + % Hence this just inserts a strut at the beginning of each line. + \everypar = {\strut}% + % + % Since we have a strut on every line, we don't need any of TeX's + % normal interline spacing. + \offinterlineskip + % + % OK, but now we have to do something about blank + % lines in the input in @example-like environments, which normally + % just turn into \lisppar, which will insert no space now that we've + % turned off the interline space. Simplest is to make them be an + % empty paragraph. + \ifx\par\lisppar + \edef\par{\leavevmode \par}% + % + % Reset ^^M's definition to new definition of \par. + \obeylines + \fi + % + % Do @comment since we are called inside an environment such as + % @example, where each end-of-line in the input causes an + % end-of-line in the output. We don't want the end-of-line after + % the `@group' to put extra space in the output. Since @group + % should appear on a line by itself (according to the Texinfo + % manual), we don't worry about eating any user text. + \comment +} +% +% TeX puts in an \escapechar (i.e., `@') at the beginning of the help +% message, so this ends up printing `@group can only ...'. +% +\newhelp\groupinvalidhelp{% +group can only be used in environments such as @example,^^J% +where each line of input produces a line of output.} + +% @need space-in-mils +% forces a page break if there is not space-in-mils remaining. + +\newdimen\mil \mil=0.001in + +\def\need{\parsearg\needx} + +% Old definition--didn't work. +%\def\needx #1{\par % +%% This method tries to make TeX break the page naturally +%% if the depth of the box does not fit. +%{\baselineskip=0pt% +%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak +%\prevdepth=-1000pt +%}} + +\def\needx#1{% + % Go into vertical mode, so we don't make a big box in the middle of a + % paragraph. + \par + % + % Don't add any leading before our big empty box, but allow a page + % break, since the best break might be right here. + \allowbreak + \nointerlineskip + \vtop to #1\mil{\vfil}% + % + % TeX does not even consider page breaks if a penalty added to the + % main vertical list is 10000 or more. But in order to see if the + % empty box we just added fits on the page, we must make it consider + % page breaks. On the other hand, we don't want to actually break the + % page after the empty box. So we use a penalty of 9999. + % + % There is an extremely small chance that TeX will actually break the + % page at this \penalty, if there are no other feasible breakpoints in + % sight. (If the user is using lots of big @group commands, which + % almost-but-not-quite fill up a page, TeX will have a hard time doing + % good page breaking, for example.) However, I could not construct an + % example where a page broke at this \penalty; if it happens in a real + % document, then we can reconsider our strategy. + \penalty9999 + % + % Back up by the size of the box, whether we did a page break or not. + \kern -#1\mil + % + % Do not allow a page break right after this kern. + \nobreak +} + +% @br forces paragraph break + +\let\br = \par + +% @dots{} output an ellipsis using the current font. +% We do .5em per period so that it has the same spacing in a typewriter +% font as three actual period characters. +% +\def\dots{% + \leavevmode + \hbox to 1.5em{% + \hskip 0pt plus 0.25fil minus 0.25fil + .\hss.\hss.% + \hskip 0pt plus 0.5fil minus 0.5fil + }% +} + +% @enddots{} is an end-of-sentence ellipsis. +% +\def\enddots{% + \leavevmode + \hbox to 2em{% + \hskip 0pt plus 0.25fil minus 0.25fil + .\hss.\hss.\hss.% + \hskip 0pt plus 0.5fil minus 0.5fil + }% + \spacefactor=3000 +} + + +% @page forces the start of a new page +% +\def\page{\par\vfill\supereject} + +% @exdent text.... +% outputs text on separate line in roman font, starting at standard page margin + +% This records the amount of indent in the innermost environment. +% That's how much \exdent should take out. +\newskip\exdentamount + +% This defn is used inside fill environments such as @defun. +\def\exdent{\parsearg\exdentyyy} +\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} + +% This defn is used inside nofill environments such as @example. +\def\nofillexdent{\parsearg\nofillexdentyyy} +\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount +\leftline{\hskip\leftskip{\rm#1}}}} + +% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph. + +\def\inmargin#1{% +\strut\vadjust{\nobreak\kern-\strutdepth + \vtop to \strutdepth{\baselineskip\strutdepth\vss + \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}} +\newskip\inmarginspacing \inmarginspacing=1cm +\def\strutdepth{\dp\strutbox} + +%\hbox{{\rm#1}}\hfil\break}} + +% @include file insert text of that file as input. +% Allow normal characters that we make active in the argument (a file name). +\def\include{\begingroup + \catcode`\\=12 + \catcode`~=12 + \catcode`^=12 + \catcode`_=12 + \catcode`|=12 + \catcode`<=12 + \catcode`>=12 + \catcode`+=12 + \parsearg\includezzz} +% Restore active chars for included file. +\def\includezzz#1{\endgroup\begingroup + % Read the included file in a group so nested @include's work. + \def\thisfile{#1}% + \input\thisfile +\endgroup} + +\def\thisfile{} + +% @center line outputs that line, centered + +\def\center{\parsearg\centerzzz} +\def\centerzzz #1{{\advance\hsize by -\leftskip +\advance\hsize by -\rightskip +\centerline{#1}}} + +% @sp n outputs n lines of vertical space + +\def\sp{\parsearg\spxxx} +\def\spxxx #1{\vskip #1\baselineskip} + +% @comment ...line which is ignored... +% @c is the same as @comment +% @ignore ... @end ignore is another way to write a comment + +\def\comment{\begingroup \catcode`\^^M=\other% +\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% +\commentxxx} +{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} + +\let\c=\comment + +% @paragraphindent NCHARS +% We'll use ems for NCHARS, close enough. +% We cannot implement @paragraphindent asis, though. +% +\def\asisword{asis} % no translation, these are keywords +\def\noneword{none} +% +\def\paragraphindent{\parsearg\doparagraphindent} +\def\doparagraphindent#1{% + \def\temp{#1}% + \ifx\temp\asisword + \else + \ifx\temp\noneword + \defaultparindent = 0pt + \else + \defaultparindent = #1em + \fi + \fi + \parindent = \defaultparindent +} + +% @exampleindent NCHARS +% We'll use ems for NCHARS like @paragraphindent. +% It seems @exampleindent asis isn't necessary, but +% I preserve it to make it similar to @paragraphindent. +\def\exampleindent{\parsearg\doexampleindent} +\def\doexampleindent#1{% + \def\temp{#1}% + \ifx\temp\asisword + \else + \ifx\temp\noneword + \lispnarrowing = 0pt + \else + \lispnarrowing = #1em + \fi + \fi +} + +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math means output in math mode. +% We don't use $'s directly in the definition of \math because control +% sequences like \math are expanded when the toc file is written. Then, +% we read the toc file back, the $'s will be normal characters (as they +% should be, according to the definition of Texinfo). So we must use a +% control sequence to switch into and out of math mode. +% +% This isn't quite enough for @math to work properly in indices, but it +% seems unlikely it will ever be needed there. +% +\let\implicitmath = $ +\def\math#1{\implicitmath #1\implicitmath} + +% @bullet and @minus need the same treatment as @math, just above. +\def\bullet{\implicitmath\ptexbullet\implicitmath} +\def\minus{\implicitmath-\implicitmath} + +% @refill is a no-op. +\let\refill=\relax + +% If working on a large document in chapters, it is convenient to +% be able to disable indexing, cross-referencing, and contents, for test runs. +% This is done with @novalidate (before @setfilename). +% +\newif\iflinks \linkstrue % by default we want the aux files. +\let\novalidate = \linksfalse + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \iflinks + \readauxfile + \fi % \openindices needs to do some work in any case. + \openindices + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \global\let\setfilename=\comment % Ignore extra @setfilename cmds. + % + % If texinfo.cnf is present on the system, read it. + % Useful for site-wide @afourpaper, etc. + % Just to be on the safe side, close the input stream before the \input. + \openin 1 texinfo.cnf + \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi + \closein1 + \temp + % + \comment % Ignore the actual filename. +} + +% Called from \setfilename. +% +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} + +% @bye. +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + + +\message{pdf,} +% adobe `portable' document format + +\newcount\tempnum +\newcount\lnkcount +\newtoks\filename +\newcount\filenamelength +\newcount\pgn + +\ifpdf +\def\pdfmkdest#1{\pdfdest name{#1@} xyz} +\def\pdfmkpgn#1{#1@} + +% Adding outlines to PDF; macros for calculating structure of outlines +% come from Petr Olsak +\def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% + \else \csname#1\endcsname \fi} +\def\advancenumber#1{\tempnum=\expnumber{#1}\relax + \advance\tempnum by1 + \expandafter\xdef\csname#1\endcsname{\the\tempnum}} +\def\pdfmakeoutlines{{% + \openin 1 \jobname.toc + \ifeof 1\else\bgroup + \closein 1 + \def\code##1{##1} + \def\file##1{##1} + \def\TeX##1{TeX} + \def\tt{} + \def\char{char} + \def\samp##1{##1} + \def\kbd##1{##1} + \def\key##1{##1} + \def\rawbackslashxx{\string\\} + \def\chapentry ##1##2##3{} + \def\unnumbchapentry ##1##2{} + \def\secentry ##1##2##3##4{\advancenumber{chap##2}} + \def\unnumbsecentry ##1##2{} + \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}} + \def\unnumbsubsecentry ##1##2{} + \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}} + \def\unnumbsubsubsecentry ##1##2{} + \input \jobname.toc + \def\chapentry ##1##2##3{% + \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}} + \def\unnumbchapentry ##1##2{% + \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} + \def\secentry ##1##2##3##4{% + \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}} + \def\unnumbsecentry ##1##2{% + \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} + \def\subsecentry ##1##2##3##4##5{% + \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}} + \def\unnumbsubsecentry ##1##2{% + \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} + \def\subsubsecentry ##1##2##3##4##5##6{% + \pdfoutline goto name{\pdfmkpgn{##6}}{##1}} + \def\unnumbsubsubsecentry ##1##2{% + \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} + \input \jobname.toc + \egroup\fi +}} +\pdfmakeoutlines + +\def\makelinks #1,{% + \def\params{#1}\def\E{END}% + \ifx\params\E + \let\nextmakelinks=\relax + \else + \let\nextmakelinks=\makelinks + \ifnum\lnkcount>0,\fi + \picknum{#1}% + \Blue\pdfannotlink attr{/Border [0 0 0]} + goto name{\pdfmkpgn{\the\pgn}}% + #1% + \advance\lnkcount by 1% + \Black\pdfendlink + \fi + \nextmakelinks +} + +\def\picknum#1{\expandafter\pn#1} +\def\pn#1{% + \def\p{#1}% + \ifx\p\lbrace + \let\nextpn=\ppn + \else + \let\nextpn=\ppnn + \def\first{#1} + \fi + \nextpn +} +\def\ppn#1{\pgn=#1\gobble} +\def\ppnn{\pgn=\first} +\def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,} + +\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} +\def\skipspaces#1{\def\PP{#1}\def\D{|}% + \ifx\PP\D\let\nextsp\relax + \else\let\nextsp\skipspaces + \ifx\p\space\else\addtokens{\filename}{\PP}% + \advance\filenamelength by 1 + \fi + \fi + \nextsp} +\def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} + +\def\pdflink#1{% + \leavevmode\Red + \begingroup + \normalturnoffactive\def\@{@}% + \pdfannotlink + attr{/Border [0 0 0]}% + user{/Subtype /Link /A << /S /URI /URI (#1) >>}% + \endgroup +} + +\else +\let\pdflink = \gobble +\fi % end \ifpdf + +\message{fonts,} +% Font-change commands. + +% Texinfo sort of supports the sans serif font style, which plain TeX does not. +% So we set up a \sf analogous to plain's \rm, etc. +\newfam\sffam +\def\sf{\fam=\sffam \tensf} +\let\li = \sf % Sometimes we call it \li, not \sf. + +% We don't need math for this one. +\def\ttsl{\tenttsl} + +% Use Computer Modern fonts at \magstephalf (11pt). +\newcount\mainmagstep +\mainmagstep=\magstephalf + +% Set the font macro #1 to the font named #2, adding on the +% specified font prefix (normally `cm'). +% #3 is the font's design size, #4 is a scale factor +\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} + +% Use cm as the default font prefix. +% To specify the font prefix, you must define \fontprefix +% before you read in texinfo.tex. +\ifx\fontprefix\undefined +\def\fontprefix{cm} +\fi +% Support font families that don't use the same naming scheme as CM. +\def\rmshape{r} +\def\rmbshape{bx} %where the normal face is bold +\def\bfshape{b} +\def\bxshape{bx} +\def\ttshape{tt} +\def\ttbshape{tt} +\def\ttslshape{sltt} +\def\itshape{ti} +\def\itbshape{bxti} +\def\slshape{sl} +\def\slbshape{bxsl} +\def\sfshape{ss} +\def\sfbshape{ss} +\def\scshape{csc} +\def\scbshape{csc} + +\ifx\bigger\relax +\let\mainmagstep=\magstep1 +\setfont\textrm\rmshape{12}{1000} +\setfont\texttt\ttshape{12}{1000} +\else +\setfont\textrm\rmshape{10}{\mainmagstep} +\setfont\texttt\ttshape{10}{\mainmagstep} +\fi +% Instead of cmb10, you many want to use cmbx10. +% cmbx10 is a prettier font on its own, but cmb10 +% looks better when embedded in a line with cmr10. +\setfont\textbf\bfshape{10}{\mainmagstep} +\setfont\textit\itshape{10}{\mainmagstep} +\setfont\textsl\slshape{10}{\mainmagstep} +\setfont\textsf\sfshape{10}{\mainmagstep} +\setfont\textsc\scshape{10}{\mainmagstep} +\setfont\textttsl\ttslshape{10}{\mainmagstep} +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep + +% A few fonts for @defun, etc. +\setfont\defbf\bxshape{10}{\magstep1} %was 1314 +\setfont\deftt\ttshape{10}{\magstep1} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} + +% Fonts for indices and small examples (9pt). +% We actually use the slanted font rather than the italic, +% because texinfo normally uses the slanted fonts for that. +% Do not make many font distinctions in general in the index, since they +% aren't very useful. +\setfont\ninett\ttshape{9}{1000} +\setfont\ninettsl\ttslshape{10}{900} +\setfont\indrm\rmshape{9}{1000} +\setfont\indit\itshape{9}{1000} +\setfont\indsl\slshape{9}{1000} +\let\indtt=\ninett +\let\indttsl=\ninettsl +\let\indsf=\indrm +\let\indbf=\indrm +\setfont\indsc\scshape{10}{900} +\font\indi=cmmi9 +\font\indsy=cmsy9 + +% Fonts for title page: +\setfont\titlerm\rmbshape{12}{\magstep3} +\setfont\titleit\itbshape{10}{\magstep4} +\setfont\titlesl\slbshape{10}{\magstep4} +\setfont\titlett\ttbshape{12}{\magstep3} +\setfont\titlettsl\ttslshape{10}{\magstep4} +\setfont\titlesf\sfbshape{17}{\magstep1} +\let\titlebf=\titlerm +\setfont\titlesc\scbshape{10}{\magstep4} +\font\titlei=cmmi12 scaled \magstep3 +\font\titlesy=cmsy10 scaled \magstep4 +\def\authorrm{\secrm} + +% Chapter (and unnumbered) fonts (17.28pt). +\setfont\chaprm\rmbshape{12}{\magstep2} +\setfont\chapit\itbshape{10}{\magstep3} +\setfont\chapsl\slbshape{10}{\magstep3} +\setfont\chaptt\ttbshape{12}{\magstep2} +\setfont\chapttsl\ttslshape{10}{\magstep3} +\setfont\chapsf\sfbshape{17}{1000} +\let\chapbf=\chaprm +\setfont\chapsc\scbshape{10}{\magstep3} +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 + +% Section fonts (14.4pt). +\setfont\secrm\rmbshape{12}{\magstep1} +\setfont\secit\itbshape{10}{\magstep2} +\setfont\secsl\slbshape{10}{\magstep2} +\setfont\sectt\ttbshape{12}{\magstep1} +\setfont\secttsl\ttslshape{10}{\magstep2} +\setfont\secsf\sfbshape{12}{\magstep1} +\let\secbf\secrm +\setfont\secsc\scbshape{10}{\magstep2} +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 + +% \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad. +% \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded. +% \setfont\ssecsl\slshape{10}{\magstep1} +% \setfont\ssectt\ttshape{10}{\magstep1} +% \setfont\ssecsf\sfshape{10}{\magstep1} + +%\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx. +%\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than +%\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1. +%\setfont\ssectt\ttshape{10}{1315} +%\setfont\ssecsf\sfshape{10}{1315} + +%\let\ssecbf=\ssecrm + +% Subsection fonts (13.15pt). +\setfont\ssecrm\rmbshape{12}{\magstephalf} +\setfont\ssecit\itbshape{10}{1315} +\setfont\ssecsl\slbshape{10}{1315} +\setfont\ssectt\ttbshape{12}{\magstephalf} +\setfont\ssecttsl\ttslshape{10}{1315} +\setfont\ssecsf\sfbshape{12}{\magstephalf} +\let\ssecbf\ssecrm +\setfont\ssecsc\scbshape{10}{\magstep1} +\font\sseci=cmmi12 scaled \magstephalf +\font\ssecsy=cmsy10 scaled 1315 +% The smallcaps and symbol fonts should actually be scaled \magstep1.5, +% but that is not a standard magnification. + +% In order for the font changes to affect most math symbols and letters, +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts, we +% don't bother to reset \scriptfont and \scriptscriptfont (which would +% also require loading a lot more fonts). +% +\def\resetmathfonts{% + \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy + \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf + \textfont\ttfam = \tentt \textfont\sffam = \tensf +} + + +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this so that font changes will continue to work +% in math mode, where it is the current \fam that is relevant in most +% cases, not the current font. Plain TeX does \def\bf{\fam=\bffam +% \tenbf}, for example. By redefining \tenbf, we obviate the need to +% redefine \bf itself. +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl + \resetmathfonts} +\def\titlefonts{% + \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl + \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc + \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy + \let\tenttsl=\titlettsl + \resetmathfonts \setleading{25pt}} +\def\titlefont#1{{\titlefonts\rm #1}} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl + \resetmathfonts \setleading{19pt}} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl + \resetmathfonts \setleading{16pt}} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl + \resetmathfonts \setleading{15pt}} +\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? +\def\indexfonts{% + \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl + \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc + \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl + \resetmathfonts \setleading{12pt}} + +% Set up the default fonts, so we can use them for creating boxes. +% +\textfonts + +% Define these so they can be easily changed for other fonts. +\def\angleleft{$\langle$} +\def\angleright{$\rangle$} + +% Count depth in font-changes, for error checks +\newcount\fontdepth \fontdepth=0 + +% Fonts for short table of contents. +\setfont\shortcontrm\rmshape{12}{1000} +\setfont\shortcontbf\bxshape{12}{1000} +\setfont\shortcontsl\slshape{12}{1000} + +%% Add scribe-like font environments, plus @l for inline lisp (usually sans +%% serif) and @ii for TeX italic + +% \smartitalic{ARG} outputs arg in italics, followed by an italic correction +% unless the following character is such as not to need one. +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} +\def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx} +\def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx} + +\let\i=\smartitalic +\let\var=\smartslanted +\let\dfn=\smartslanted +\let\emph=\smartitalic +\let\cite=\smartslanted + +\def\b#1{{\bf #1}} +\let\strong=\b + +% We can't just use \exhyphenpenalty, because that only has effect at +% the end of a paragraph. Restore normal hyphenation at the end of the +% group within which \nohyphenation is presumably called. +% +\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} +\def\restorehyphenation{\hyphenchar\font = `- } + +\def\t#1{% + {\tt \rawbackslash \frenchspacing #1}% + \null +} +\let\ttfont=\t +\def\samp#1{`\tclose{#1}'\null} +\setfont\smallrm\rmshape{8}{1000} +\font\smallsy=cmsy9 +\def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{% + \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% + \vbox{\hrule\kern-0.4pt + \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% + \kern-0.4pt\hrule}% + \kern-.06em\raise0.4pt\hbox{\angleright}}}} +% The old definition, with no lozenge: +%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +% @file, @option are the same as @samp. +\let\file=\samp +\let\option=\samp + +% @code is a modification of @t, +% which makes spaces the same size as normal in the surrounding text. +\def\tclose#1{% + {% + % Change normal interword space to be same as for the current font. + \spaceskip = \fontdimen2\font + % + % Switch to typewriter. + \tt + % + % But `\ ' produces the large typewriter interword space. + \def\ {{\spaceskip = 0pt{} }}% + % + % Turn off hyphenation. + \nohyphenation + % + \rawbackslash + \frenchspacing + #1% + }% + \null +} + +% We *must* turn on hyphenation at `-' and `_' in \code. +% Otherwise, it is too hard to avoid overfull hboxes +% in the Emacs manual, the Library manual, etc. + +% Unfortunately, TeX uses one parameter (\hyphenchar) to control +% both hyphenation at - and hyphenation within words. +% We must therefore turn them both off (\tclose does that) +% and arrange explicitly to hyphenate at a dash. +% -- rms. +{ + \catcode`\-=\active + \catcode`\_=\active + % + \global\def\code{\begingroup + \catcode`\-=\active \let-\codedash + \catcode`\_=\active \let_\codeunder + \codex + } + % + % If we end up with any active - characters when handling the index, + % just treat them as a normal -. + \global\def\indexbreaks{\catcode`\-=\active \let-\realdash} +} + +\def\realdash{-} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}} +\def\codex #1{\tclose{#1}\endgroup} + +%\let\exp=\tclose %Was temporary + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. + +% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), +% `example' (@kbd uses ttsl only inside of @example and friends), +% or `code' (@kbd uses normal tty font always). +\def\kbdinputstyle{\parsearg\kbdinputstylexxx} +\def\kbdinputstylexxx#1{% + \def\arg{#1}% + \ifx\arg\worddistinct + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% + \else\ifx\arg\wordexample + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% + \else\ifx\arg\wordcode + \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% + \fi\fi\fi +} +\def\worddistinct{distinct} +\def\wordexample{example} +\def\wordcode{code} + +% Default is kbdinputdistinct. (Too much of a hassle to call the macro, +% the catcodes are wrong for parsearg to work.) +\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl} + +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else{\tclose{\kbdfont\look}}\fi +\else{\tclose{\kbdfont\look}}\fi} + +% For @url, @env, @command quotes seem unnecessary, so use \code. +\let\url=\code +\let\env=\code +\let\command=\code + +% @uref (abbreviation for `urlref') takes an optional (comma-separated) +% second argument specifying the text to display and an optional third +% arg as text to display instead of (rather than in addition to) the url +% itself. First (mandatory) arg is the url. Perhaps eventually put in +% a hypertex \special here. +% +\def\uref#1{\douref #1,,,\finish} +\def\douref#1,#2,#3,#4\finish{% + \pdflink{#1}% + \setbox0 = \hbox{\ignorespaces #3}% + \ifdim\wd0 > 0pt + \unhbox0 % third arg given, show only that + \else + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \ifpdf + \unhbox0 % PDF: 2nd arg given, show only it + \else + \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url + \fi + \else + \code{#1}% only url given, so show it + \fi + \fi + % + \ifpdf + \Black\pdfendlink + \fi +} + +% rms does not like angle brackets --karl, 17may97. +% So now @email is just like @uref, unless we are pdf. +% +%\def\email#1{\angleleft{\tt #1}\angleright} +\ifpdf + \def\email#1{\doemail#1,,\finish} + \def\doemail#1,#2,#3\finish{% + \pdflink{mailto:#1}% + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi + \Black\pdfendlink + } +\else + \let\email=\uref +\fi + +% Check if we are currently using a typewriter font. Since all the +% Computer Modern typewriter fonts have zero interword stretch (and +% shrink), and it is reasonable to expect all typewriter fonts to have +% this property, we can check that font parameter. +% +\def\ifmonospace{\ifdim\fontdimen3\font=0pt } + +% Typeset a dimension, e.g., `in' or `pt'. The only reason for the +% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. +% +\def\dmn#1{\thinspace #1} + +\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} + +% @l was never documented to mean ``switch to the Lisp font'', +% and it is not used as such in any manual I can find. We need it for +% Polish suppressed-l. --karl, 22sep96. +%\def\l#1{{\li #1}\null} + +% Explicit font changes: @r, @sc, undocumented @ii. +\def\r#1{{\rm #1}} % roman font +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + +% @acronym downcases the argument and prints in smallcaps. +\def\acronym#1{{\smallcaps \lowercase{#1}}} + +% @pounds{} is a sterling sign. +\def\pounds{{\it\$}} + + +\message{page headings,} + +\newskip\titlepagetopglue \titlepagetopglue = 1.5in +\newskip\titlepagebottomglue \titlepagebottomglue = 2pc + +% First the title page. Must do @settitle before @titlepage. +\newif\ifseenauthor +\newif\iffinishedtitlepage + +% Do an implicit @contents or @shortcontents after @end titlepage if the +% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. +% +\newif\ifsetcontentsaftertitlepage + \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue +\newif\ifsetshortcontentsaftertitlepage + \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue + +\def\shorttitlepage{\parsearg\shorttitlepagezzz} +\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} + +\def\titlepage{\begingroup \parindent=0pt \textfonts + \let\subtitlerm=\tenrm + \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% + % + \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% + % + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % + % Now you can print the title using @title. + \def\title{\parsearg\titlezzz}% + \def\titlezzz##1{\leftline{\titlefonts\rm ##1} + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Now you can put text using @subtitle. + \def\subtitle{\parsearg\subtitlezzz}% + \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% + % + % @author should come last, but may come many times. + \def\author{\parsearg\authorzzz}% + \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi + {\authorfont \leftline{##1}}}% + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + \oldpage + \let\page = \oldpage + \hbox{}}% +% \def\page{\oldpage \hbox{}} +} + +\def\Etitlepage{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + % + % If they want short, they certainly want long too. + \ifsetshortcontentsaftertitlepage + \shortcontents + \contents + \global\let\shortcontents = \relax + \global\let\contents = \relax + \fi + % + \ifsetcontentsaftertitlepage + \contents + \global\let\contents = \relax + \global\let\shortcontents = \relax + \fi + % + \HEADINGSon +} + +\def\finishtitlepage{% + \vskip4pt \hrule height 2pt width \hsize + \vskip\titlepagebottomglue + \finishedtitlepagetrue +} + +%%% Set up page headings and footings. + +\let\thispage=\folio + +\newtoks\evenheadline % headline on even pages +\newtoks\oddheadline % headline on odd pages +\newtoks\evenfootline % footline on even pages +\newtoks\oddfootline % footline on odd pages + +% Now make Tex use those variables +\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline + \else \the\evenheadline \fi}} +\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline + \else \the\evenfootline \fi}\HEADINGShook} +\let\HEADINGShook=\relax + +% Commands to set those variables. +% For example, this is what @headings on does +% @evenheading @thistitle|@thispage|@thischapter +% @oddheading @thischapter|@thispage|@thistitle +% @evenfooting @thisfile|| +% @oddfooting ||@thisfile + +\def\evenheading{\parsearg\evenheadingxxx} +\def\oddheading{\parsearg\oddheadingxxx} +\def\everyheading{\parsearg\everyheadingxxx} + +\def\evenfooting{\parsearg\evenfootingxxx} +\def\oddfooting{\parsearg\oddfootingxxx} +\def\everyfooting{\parsearg\everyfootingxxx} + +{\catcode`\@=0 % + +\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} +\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} +\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}% + +\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} +\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} +\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% + \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% + % + % Leave some space for the footline. Hopefully ok to assume + % @evenfooting will not be used by itself. + \global\advance\pageheight by -\baselineskip + \global\advance\vsize by -\baselineskip +} + +\gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} +% +}% unbind the catcode of @. + +% @headings double turns headings on for double-sided printing. +% @headings single turns headings on for single-sided printing. +% @headings off turns them off. +% @headings on same as @headings double, retained for compatibility. +% @headings after turns on double-sided headings after this page. +% @headings doubleafter turns on double-sided headings after this page. +% @headings singleafter turns on single-sided headings after this page. +% By default, they are off at the start of a document, +% and turned `on' after @end titlepage. + +\def\headings #1 {\csname HEADINGS#1\endcsname} + +\def\HEADINGSoff{ +\global\evenheadline={\hfil} \global\evenfootline={\hfil} +\global\oddheadline={\hfil} \global\oddfootline={\hfil}} +\HEADINGSoff +% When we turn headings on, set the page number to 1. +% For double-sided printing, put current file name in lower left corner, +% chapter name on inside top of right hand pages, document +% title on inside top of left hand pages, and page numbers on outside top +% edge of all pages. +\def\HEADINGSdouble{ +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} +\let\contentsalignmacro = \chappager + +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{ +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} +\def\HEADINGSon{\HEADINGSdouble} + +\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} +\let\HEADINGSdoubleafter=\HEADINGSafter +\def\HEADINGSdoublex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} + +\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} +\def\HEADINGSsinglex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} + +% Subroutines used in generating headings +% Produces Day Month Year style of output. +\def\today{% + \number\day\space + \ifcase\month + \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr + \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug + \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec + \fi + \space\number\year} + +% @settitle line... specifies the title of the document, for headings. +% It generates no output of its own. +\def\thistitle{\putwordNoTitle} +\def\settitle{\parsearg\settitlezzz} +\def\settitlezzz #1{\gdef\thistitle{#1}} + + +\message{tables,} +% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). + +% default indentation of table text +\newdimen\tableindent \tableindent=.8in +% default indentation of @itemize and @enumerate text +\newdimen\itemindent \itemindent=.3in +% margin between end of table item and start of table text. +\newdimen\itemmargin \itemmargin=.1in + +% used internally for \itemindent minus \itemmargin +\newdimen\itemmax + +% Note @table, @vtable, and @vtable define @item, @itemx, etc., with +% these defs. +% They also define \itemindex +% to index the item name in whatever manner is desired (perhaps none). + +\newif\ifitemxneedsnegativevskip + +\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} + +\def\internalBitem{\smallbreak \parsearg\itemzzz} +\def\internalBitemx{\itemxpar \parsearg\itemzzz} + +\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} +\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} + +\def\internalBkitem{\smallbreak \parsearg\kitemzzz} +\def\internalBkitemx{\itemxpar \parsearg\kitemzzz} + +\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% + \itemzzz {#1}} + +\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% + \itemzzz {#1}} + +\def\itemzzz #1{\begingroup % + \advance\hsize by -\rightskip + \advance\hsize by -\tableindent + \setbox0=\hbox{\itemfont{#1}}% + \itemindex{#1}% + \nobreak % This prevents a break before @itemx. + % + % If the item text does not fit in the space we have, put it on a line + % by itself, and do not allow a page break either before or after that + % line. We do not start a paragraph here because then if the next + % command is, e.g., @kindex, the whatsit would get put into the + % horizontal list on a line by itself, resulting in extra blank space. + \ifdim \wd0>\itemmax + % + % Make this a paragraph so we get the \parskip glue and wrapping, + % but leave it ragged-right. + \begingroup + \advance\leftskip by-\tableindent + \advance\hsize by\tableindent + \advance\rightskip by0pt plus1fil + \leavevmode\unhbox0\par + \endgroup + % + % We're going to be starting a paragraph, but we don't want the + % \parskip glue -- logically it's part of the @item we just started. + \nobreak \vskip-\parskip + % + % Stop a page break at the \parskip glue coming up. Unfortunately + % we can't prevent a possible page break at the following + % \baselineskip glue. + \nobreak + \endgroup + \itemxneedsnegativevskipfalse + \else + % The item text fits into the space. Start a paragraph, so that the + % following text (if any) will end up on the same line. + \noindent + % Do this with kerns and \unhbox so that if there is a footnote in + % the item text, it can migrate to the main vertical list and + % eventually be printed. + \nobreak\kern-\tableindent + \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 + \unhbox0 + \nobreak\kern\dimen0 + \endgroup + \itemxneedsnegativevskiptrue + \fi +} + +\def\item{\errmessage{@item while not in a table}} +\def\itemx{\errmessage{@itemx while not in a table}} +\def\kitem{\errmessage{@kitem while not in a table}} +\def\kitemx{\errmessage{@kitemx while not in a table}} +\def\xitem{\errmessage{@xitem while not in a table}} +\def\xitemx{\errmessage{@xitemx while not in a table}} + +% Contains a kludge to get @end[description] to work. +\def\description{\tablez{\dontindex}{1}{}{}{}{}} + +% @table, @ftable, @vtable. +\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} +{\obeylines\obeyspaces% +\gdef\tablex #1^^M{% +\tabley\dontindex#1 \endtabley}} + +\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} +{\obeylines\obeyspaces% +\gdef\ftablex #1^^M{% +\tabley\fnitemindex#1 \endtabley +\def\Eftable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} +{\obeylines\obeyspaces% +\gdef\vtablex #1^^M{% +\tabley\vritemindex#1 \endtabley +\def\Evtable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\dontindex #1{} +\def\fnitemindex #1{\doind {fn}{\code{#1}}}% +\def\vritemindex #1{\doind {vr}{\code{#1}}}% + +{\obeyspaces % +\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% +\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} + +\def\tablez #1#2#3#4#5#6{% +\aboveenvbreak % +\begingroup % +\def\Edescription{\Etable}% Necessary kludge. +\let\itemindex=#1% +\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % +\ifnum 0#4>0 \tableindent=#4\mil \fi % +\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % +\def\itemfont{#2}% +\itemmax=\tableindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \tableindent % +\exdentamount=\tableindent +\parindent = 0pt +\parskip = \smallskipamount +\ifdim \parskip=0pt \parskip=2pt \fi% +\def\Etable{\endgraf\afterenvbreak\endgroup}% +\let\item = \internalBitem % +\let\itemx = \internalBitemx % +\let\kitem = \internalBkitem % +\let\kitemx = \internalBkitemx % +\let\xitem = \internalBxitem % +\let\xitemx = \internalBxitemx % +} + +% This is the counter used by @enumerate, which is really @itemize + +\newcount \itemno + +\def\itemize{\parsearg\itemizezzz} + +\def\itemizezzz #1{% + \begingroup % ended by the @end itemize + \itemizey {#1}{\Eitemize} +} + +\def\itemizey #1#2{% +\aboveenvbreak % +\itemmax=\itemindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \itemindent % +\exdentamount=\itemindent +\parindent = 0pt % +\parskip = \smallskipamount % +\ifdim \parskip=0pt \parskip=2pt \fi% +\def#2{\endgraf\afterenvbreak\endgroup}% +\def\itemcontents{#1}% +\let\item=\itemizeitem} + +% Set sfcode to normal for the chars that usually have another value. +% These are `.?!:;,' +\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 + \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } + +% \splitoff TOKENS\endmark defines \first to be the first token in +% TOKENS, and \rest to be the remainder. +% +\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% + +% Allow an optional argument of an uppercase letter, lowercase letter, +% or number, to specify the first label in the enumerated list. No +% argument is the same as `1'. +% +\def\enumerate{\parsearg\enumeratezzz} +\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} +\def\enumeratey #1 #2\endenumeratey{% + \begingroup % ended by the @end enumerate + % + % If we were given no argument, pretend we were given `1'. + \def\thearg{#1}% + \ifx\thearg\empty \def\thearg{1}\fi + % + % Detect if the argument is a single token. If so, it might be a + % letter. Otherwise, the only valid thing it can be is a number. + % (We will always have one token, because of the test we just made. + % This is a good thing, since \splitoff doesn't work given nothing at + % all -- the first parameter is undelimited.) + \expandafter\splitoff\thearg\endmark + \ifx\rest\empty + % Only one token in the argument. It could still be anything. + % A ``lowercase letter'' is one whose \lccode is nonzero. + % An ``uppercase letter'' is one whose \lccode is both nonzero, and + % not equal to itself. + % Otherwise, we assume it's a number. + % + % We need the \relax at the end of the \ifnum lines to stop TeX from + % continuing to look for a . + % + \ifnum\lccode\expandafter`\thearg=0\relax + \numericenumerate % a number (we hope) + \else + % It's a letter. + \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax + \lowercaseenumerate % lowercase letter + \else + \uppercaseenumerate % uppercase letter + \fi + \fi + \else + % Multiple tokens in the argument. We hope it's a number. + \numericenumerate + \fi +} + +% An @enumerate whose labels are integers. The starting integer is +% given in \thearg. +% +\def\numericenumerate{% + \itemno = \thearg + \startenumeration{\the\itemno}% +} + +% The starting (lowercase) letter is in \thearg. +\def\lowercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more lowercase letters in @enumerate; get a bigger + alphabet}% + \fi + \char\lccode\itemno + }% +} + +% The starting (uppercase) letter is in \thearg. +\def\uppercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more uppercase letters in @enumerate; get a bigger + alphabet} + \fi + \char\uccode\itemno + }% +} + +% Call itemizey, adding a period to the first argument and supplying the +% common last two arguments. Also subtract one from the initial value in +% \itemno, since @item increments \itemno. +% +\def\startenumeration#1{% + \advance\itemno by -1 + \itemizey{#1.}\Eenumerate\flushcr +} + +% @alphaenumerate and @capsenumerate are abbreviations for giving an arg +% to @enumerate. +% +\def\alphaenumerate{\enumerate{a}} +\def\capsenumerate{\enumerate{A}} +\def\Ealphaenumerate{\Eenumerate} +\def\Ecapsenumerate{\Eenumerate} + +% Definition of @item while inside @itemize. + +\def\itemizeitem{% +\advance\itemno by 1 +{\let\par=\endgraf \smallbreak}% +\ifhmode \errmessage{In hmode at itemizeitem}\fi +{\parskip=0in \hskip 0pt +\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% +\vadjust{\penalty 1200}}% +\flushcr} + +% @multitable macros +% Amy Hendrickson, 8/18/94, 3/6/96 +% +% @multitable ... @end multitable will make as many columns as desired. +% Contents of each column will wrap at width given in preamble. Width +% can be specified either with sample text given in a template line, +% or in percent of \hsize, the current width of text on page. + +% Table can continue over pages but will only break between lines. + +% To make preamble: +% +% Either define widths of columns in terms of percent of \hsize: +% @multitable @columnfractions .25 .3 .45 +% @item ... +% +% Numbers following @columnfractions are the percent of the total +% current hsize to be used for each column. You may use as many +% columns as desired. + + +% Or use a template: +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item ... +% using the widest term desired in each column. +% +% For those who want to use more than one line's worth of words in +% the preamble, break the line within one argument and it +% will parse correctly, i.e., +% +% @multitable {Column 1 template} {Column 2 template} {Column 3 +% template} +% Not: +% @multitable {Column 1 template} {Column 2 template} +% {Column 3 template} + +% Each new table line starts with @item, each subsequent new column +% starts with @tab. Empty columns may be produced by supplying @tab's +% with nothing between them for as many times as empty columns are needed, +% ie, @tab@tab@tab will produce two empty columns. + +% @item, @tab, @multitable or @end multitable do not need to be on their +% own lines, but it will not hurt if they are. + +% Sample multitable: + +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item first col stuff @tab second col stuff @tab third col +% @item +% first col stuff +% @tab +% second col stuff +% @tab +% third col +% @item first col stuff @tab second col stuff +% @tab Many paragraphs of text may be used in any column. +% +% They will wrap at the width determined by the template. +% @item@tab@tab This will be in third column. +% @end multitable + +% Default dimensions may be reset by user. +% @multitableparskip is vertical space between paragraphs in table. +% @multitableparindent is paragraph indent in table. +% @multitablecolmargin is horizontal space to be left between columns. +% @multitablelinespace is space to leave between table items, baseline +% to baseline. +% 0pt means it depends on current normal line spacing. +% +\newskip\multitableparskip +\newskip\multitableparindent +\newdimen\multitablecolspace +\newskip\multitablelinespace +\multitableparskip=0pt +\multitableparindent=6pt +\multitablecolspace=12pt +\multitablelinespace=0pt + +% Macros used to set up halign preamble: +% +\let\endsetuptable\relax +\def\xendsetuptable{\endsetuptable} +\let\columnfractions\relax +\def\xcolumnfractions{\columnfractions} +\newif\ifsetpercent + +% #1 is the part of the @columnfraction before the decimal point, which +% is presumably either 0 or the empty string (but we don't check, we +% just throw it away). #2 is the decimal part, which we use as the +% percent of \hsize for this column. +\def\pickupwholefraction#1.#2 {% + \global\advance\colcount by 1 + \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}% + \setuptable +} + +\newcount\colcount +\def\setuptable#1{% + \def\firstarg{#1}% + \ifx\firstarg\xendsetuptable + \let\go = \relax + \else + \ifx\firstarg\xcolumnfractions + \global\setpercenttrue + \else + \ifsetpercent + \let\go\pickupwholefraction + \else + \global\advance\colcount by 1 + \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator; + % typically that is always in the input, anyway. + \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% + \fi + \fi + \ifx\go\pickupwholefraction + % Put the argument back for the \pickupwholefraction call, so + % we'll always have a period there to be parsed. + \def\go{\pickupwholefraction#1}% + \else + \let\go = \setuptable + \fi% + \fi + \go +} + +% This used to have \hskip1sp. But then the space in a template line is +% not enough. That is bad. So let's go back to just & until we +% encounter the problem it was intended to solve again. +% --karl, nathan@acm.org, 20apr99. +\def\tab{&} + +% @multitable ... @end multitable definitions: +% +\def\multitable{\parsearg\dotable} +\def\dotable#1{\bgroup + \vskip\parskip + \let\item\crcr + \tolerance=9500 + \hbadness=9500 + \setmultitablespacing + \parskip=\multitableparskip + \parindent=\multitableparindent + \overfullrule=0pt + \global\colcount=0 + \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}% + % + % To parse everything between @multitable and @item: + \setuptable#1 \endsetuptable + % + % \everycr will reset column counter, \colcount, at the end of + % each line. Every column entry will cause \colcount to advance by one. + % The table preamble + % looks at the current \colcount to find the correct column width. + \everycr{\noalign{% + % + % \filbreak%% keeps underfull box messages off when table breaks over pages. + % Maybe so, but it also creates really weird page breaks when the table + % breaks over pages. Wouldn't \vfil be better? Wait until the problem + % manifests itself, so it can be fixed for real --karl. + \global\colcount=0\relax}}% + % + % This preamble sets up a generic column definition, which will + % be used as many times as user calls for columns. + % \vtop will set a single line and will also let text wrap and + % continue for many paragraphs if desired. + \halign\bgroup&\global\advance\colcount by 1\relax + \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname + % + % In order to keep entries from bumping into each other + % we will add a \leftskip of \multitablecolspace to all columns after + % the first one. + % + % If a template has been used, we will add \multitablecolspace + % to the width of each template entry. + % + % If the user has set preamble in terms of percent of \hsize we will + % use that dimension as the width of the column, and the \leftskip + % will keep entries from bumping into each other. Table will start at + % left margin and final column will justify at right margin. + % + % Make sure we don't inherit \rightskip from the outer environment. + \rightskip=0pt + \ifnum\colcount=1 + % The first column will be indented with the surrounding text. + \advance\hsize by\leftskip + \else + \ifsetpercent \else + % If user has not set preamble in terms of percent of \hsize + % we will advance \hsize by \multitablecolspace. + \advance\hsize by \multitablecolspace + \fi + % In either case we will make \leftskip=\multitablecolspace: + \leftskip=\multitablecolspace + \fi + % Ignoring space at the beginning and end avoids an occasional spurious + % blank line, when TeX decides to break the line at the space before the + % box from the multistrut, so the strut ends up on a line by itself. + % For example: + % @multitable @columnfractions .11 .89 + % @item @code{#} + % @tab Legal holiday which is valid in major parts of the whole country. + % Is automatically provided with highlighting sequences respectively marking + % characters. + \noindent\ignorespaces##\unskip\multistrut}\cr +} + +\def\setmultitablespacing{% test to see if user has set \multitablelinespace. +% If so, do nothing. If not, give it an appropriate dimension based on +% current baselineskip. +\ifdim\multitablelinespace=0pt +%% strut to put in table in case some entry doesn't have descenders, +%% to keep lines equally spaced +\let\multistrut = \strut +%% Test to see if parskip is larger than space between lines of +%% table. If not, do nothing. +%% If so, set to same dimension as multitablelinespace. +\else +\gdef\multistrut{\vrule height\multitablelinespace depth\dp0 +width0pt\relax} \fi +\ifdim\multitableparskip>\multitablelinespace +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. +\fi% +\ifdim\multitableparskip=0pt +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. +\fi} + + +\message{conditionals,} +% Prevent errors for section commands. +% Used in @ignore and in failing conditionals. +\def\ignoresections{% + \let\chapter=\relax + \let\unnumbered=\relax + \let\top=\relax + \let\unnumberedsec=\relax + \let\unnumberedsection=\relax + \let\unnumberedsubsec=\relax + \let\unnumberedsubsection=\relax + \let\unnumberedsubsubsec=\relax + \let\unnumberedsubsubsection=\relax + \let\section=\relax + \let\subsec=\relax + \let\subsubsec=\relax + \let\subsection=\relax + \let\subsubsection=\relax + \let\appendix=\relax + \let\appendixsec=\relax + \let\appendixsection=\relax + \let\appendixsubsec=\relax + \let\appendixsubsection=\relax + \let\appendixsubsubsec=\relax + \let\appendixsubsubsection=\relax + \let\contents=\relax + \let\smallbook=\relax + \let\titlepage=\relax +} + +% Used in nested conditionals, where we have to parse the Texinfo source +% and so want to turn off most commands, in case they are used +% incorrectly. +% +\def\ignoremorecommands{% + \let\defcodeindex = \relax + \let\defcv = \relax + \let\deffn = \relax + \let\deffnx = \relax + \let\defindex = \relax + \let\defivar = \relax + \let\defmac = \relax + \let\defmethod = \relax + \let\defop = \relax + \let\defopt = \relax + \let\defspec = \relax + \let\deftp = \relax + \let\deftypefn = \relax + \let\deftypefun = \relax + \let\deftypeivar = \relax + \let\deftypevar = \relax + \let\deftypevr = \relax + \let\defun = \relax + \let\defvar = \relax + \let\defvr = \relax + \let\ref = \relax + \let\xref = \relax + \let\printindex = \relax + \let\pxref = \relax + \let\settitle = \relax + \let\setchapternewpage = \relax + \let\setchapterstyle = \relax + \let\everyheading = \relax + \let\evenheading = \relax + \let\oddheading = \relax + \let\everyfooting = \relax + \let\evenfooting = \relax + \let\oddfooting = \relax + \let\headings = \relax + \let\include = \relax + \let\lowersections = \relax + \let\down = \relax + \let\raisesections = \relax + \let\up = \relax + \let\set = \relax + \let\clear = \relax + \let\item = \relax +} + +% Ignore @ignore ... @end ignore. +% +\def\ignore{\doignore{ignore}} + +% Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text. +% +\def\ifinfo{\doignore{ifinfo}} +\def\ifhtml{\doignore{ifhtml}} +\def\ifnottex{\doignore{ifnottex}} +\def\html{\doignore{html}} +\def\menu{\doignore{menu}} +\def\direntry{\doignore{direntry}} + +% @dircategory CATEGORY -- specify a category of the dir file +% which this file should belong to. Ignore this in TeX. +\let\dircategory = \comment + +% Ignore text until a line `@end #1'. +% +\def\doignore#1{\begingroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define a command to swallow text until we reach `@end #1'. + % This @ is a catcode 12 token (that is the normal catcode of @ in + % this texinfo.tex file). We change the catcode of @ below to match. + \long\def\doignoretext##1@end #1{\enddoignore}% + % + % Make sure that spaces turn into tokens that match what \doignoretext wants. + \catcode32 = 10 + % + % Ignore braces, too, so mismatched braces don't cause trouble. + \catcode`\{ = 9 + \catcode`\} = 9 + % + % We must not have @c interpreted as a control sequence. + \catcode`\@ = 12 + % + % Make the letter c a comment character so that the rest of the line + % will be ignored. This way, the document can have (for example) + % @c @end ifinfo + % and the @end ifinfo will be properly ignored. + % (We've just changed @ to catcode 12.) + \catcode`\c = 14 + % + % And now expand that command. + \doignoretext +} + +% What we do to finish off ignored text. +% +\def\enddoignore{\endgroup\ignorespaces}% + +\newif\ifwarnedobs\warnedobsfalse +\def\obstexwarn{% + \ifwarnedobs\relax\else + % We need to warn folks that they may have trouble with TeX 3.0. + % This uses \immediate\write16 rather than \message to get newlines. + \immediate\write16{} + \immediate\write16{WARNING: for users of Unix TeX 3.0!} + \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} + \immediate\write16{If you are running another version of TeX, relax.} + \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} + \immediate\write16{ Then upgrade your TeX installation if you can.} + \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)} + \immediate\write16{If you are stuck with version 3.0, run the} + \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} + \immediate\write16{ to use a workaround.} + \immediate\write16{} + \global\warnedobstrue + \fi +} + +% **In TeX 3.0, setting text in \nullfont hangs tex. For a +% workaround (which requires the file ``dummy.tfm'' to be installed), +% uncomment the following line: +%%%%%\font\nullfont=dummy\let\obstexwarn=\relax + +% Ignore text, except that we keep track of conditional commands for +% purposes of nesting, up to an `@end #1' command. +% +\def\nestedignore#1{% + \obstexwarn + % We must actually expand the ignored text to look for the @end + % command, so that nested ignore constructs work. Thus, we put the + % text into a \vbox and then do nothing with the result. To minimize + % the change of memory overflow, we follow the approach outlined on + % page 401 of the TeXbook: make the current font be a dummy font. + % + \setbox0 = \vbox\bgroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define `@end #1' to end the box, which will in turn undefine the + % @end command again. + \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% + % + % We are going to be parsing Texinfo commands. Most cause no + % trouble when they are used incorrectly, but some commands do + % complicated argument parsing or otherwise get confused, so we + % undefine them. + % + % We can't do anything about stray @-signs, unfortunately; + % they'll produce `undefined control sequence' errors. + \ignoremorecommands + % + % Set the current font to be \nullfont, a TeX primitive, and define + % all the font commands to also use \nullfont. We don't use + % dummy.tfm, as suggested in the TeXbook, because not all sites + % might have that installed. Therefore, math mode will still + % produce output, but that should be an extremely small amount of + % stuff compared to the main input. + % + \nullfont + \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont + \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont + \let\tensf = \nullfont + % Similarly for index fonts (mostly for their use in + % smallexample) + \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont + \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont + \let\indsf = \nullfont + % + % Don't complain when characters are missing from the fonts. + \tracinglostchars = 0 + % + % Don't bother to do space factor calculations. + \frenchspacing + % + % Don't report underfull hboxes. + \hbadness = 10000 + % + % Do minimal line-breaking. + \pretolerance = 10000 + % + % Do not execute instructions in @tex + \def\tex{\doignore{tex}}% + % Do not execute macro definitions. + % `c' is a comment character, so the word `macro' will get cut off. + \def\macro{\doignore{ma}}% +} + +% @set VAR sets the variable VAR to an empty value. +% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. +% +% Since we want to separate VAR from REST-OF-LINE (which might be +% empty), we can't just use \parsearg; we have to insert a space of our +% own to delimit the rest of the line, and then take it out again if we +% didn't need it. Make sure the catcode of space is correct to avoid +% losing inside @example, for instance. +% +\def\set{\begingroup\catcode` =10 + \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. + \parsearg\setxxx} +\def\setxxx#1{\setyyy#1 \endsetyyy} +\def\setyyy#1 #2\endsetyyy{% + \def\temp{#2}% + \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty + \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. + \fi + \endgroup +} +% Can't use \xdef to pre-expand #2 and save some time, since \temp or +% \next or other control sequences that we've defined might get us into +% an infinite loop. Consider `@set foo @cite{bar}'. +\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} + +% @clear VAR clears (i.e., unsets) the variable VAR. +% +\def\clear{\parsearg\clearxxx} +\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} + +% @value{foo} gets the text saved in variable foo. +{ + \catcode`\_ = \active + % + % We might end up with active _ or - characters in the argument if + % we're called from @code, as @code{@value{foo-bar_}}. So \let any + % such active characters to their normal equivalents. + \gdef\value{\begingroup + \catcode`\-=12 \catcode`\_=12 + \indexbreaks \let_\normalunderscore + \valuexxx} +} +\def\valuexxx#1{\expandablevalue{#1}\endgroup} + +% We have this subroutine so that we can handle at least some @value's +% properly in indexes (we \let\value to this in \indexdummies). Ones +% whose names contain - or _ still won't work, but we can't do anything +% about that. The command has to be fully expandable, since the result +% winds up in the index file. This means that if the variable's value +% contains other Texinfo commands, it's almost certain it will fail +% (although perhaps we could fix that with sufficient work to do a +% one-level expansion on the result, instead of complete). +% +\def\expandablevalue#1{% + \expandafter\ifx\csname SET#1\endcsname\relax + {[No value for ``#1'']}% + \else + \csname SET#1\endcsname + \fi +} + +% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined +% with @set. +% +\def\ifset{\parsearg\ifsetxxx} +\def\ifsetxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifsetfail + \else + \expandafter\ifsetsucceed + \fi +} +\def\ifsetsucceed{\conditionalsucceed{ifset}} +\def\ifsetfail{\nestedignore{ifset}} +\defineunmatchedend{ifset} + +% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been +% defined with @set, or has been undefined with @clear. +% +\def\ifclear{\parsearg\ifclearxxx} +\def\ifclearxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifclearsucceed + \else + \expandafter\ifclearfail + \fi +} +\def\ifclearsucceed{\conditionalsucceed{ifclear}} +\def\ifclearfail{\nestedignore{ifclear}} +\defineunmatchedend{ifclear} + +% @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text +% following, through the first @end iftex (etc.). Make `@end iftex' +% (etc.) valid only after an @iftex. +% +\def\iftex{\conditionalsucceed{iftex}} +\def\ifnothtml{\conditionalsucceed{ifnothtml}} +\def\ifnotinfo{\conditionalsucceed{ifnotinfo}} +\defineunmatchedend{iftex} +\defineunmatchedend{ifnothtml} +\defineunmatchedend{ifnotinfo} + +% We can't just want to start a group at @iftex (for example) and end it +% at @end iftex, since then @set commands inside the conditional have no +% effect (they'd get reverted at the end of the group). So we must +% define \Eiftex to redefine itself to be its previous value. (We can't +% just define it to fail again with an ``unmatched end'' error, since +% the @ifset might be nested.) +% +\def\conditionalsucceed#1{% + \edef\temp{% + % Remember the current value of \E#1. + \let\nece{prevE#1} = \nece{E#1}% + % + % At the `@end #1', redefine \E#1 to be its previous value. + \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% + }% + \temp +} + +% We need to expand lots of \csname's, but we don't want to expand the +% control sequences after we've constructed them. +% +\def\nece#1{\expandafter\noexpand\csname#1\endcsname} + +% @defininfoenclose. +\let\definfoenclose=\comment + + +\message{indexing,} +% Index generation facilities + +% Define \newwrite to be identical to plain tex's \newwrite +% except not \outer, so it can be used within \newindex. +{\catcode`\@=11 +\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} + +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. +% The name of an index should be no more than 2 characters long +% for the sake of vms. +% +\def\newindex#1{% + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 % Open the file + \fi + \expandafter\xdef\csname#1index\endcsname{% % Define @#1index + \noexpand\doindex{#1}} +} + +% @defindex foo == \newindex{foo} + +\def\defindex{\parsearg\newindex} + +% Define @defcodeindex, like @defindex except put all entries in @code. + +\def\newcodeindex#1{% + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 + \fi + \expandafter\xdef\csname#1index\endcsname{% + \noexpand\docodeindex{#1}} +} + +\def\defcodeindex{\parsearg\newcodeindex} + +% @synindex foo bar makes index foo feed into index bar. +% Do this instead of @defindex foo if you don't want it as a separate index. +% The \closeout helps reduce unnecessary open files; the limit on the +% Acorn RISC OS is a mere 16 files. +\def\synindex#1 #2 {% + \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname + \expandafter\closeout\csname#1indfile\endcsname + \expandafter\let\csname#1indfile\endcsname=\synindexfoo + \expandafter\xdef\csname#1index\endcsname{% define \xxxindex + \noexpand\doindex{#2}}% +} + +% @syncodeindex foo bar similar, but put all entries made for index foo +% inside @code. +\def\syncodeindex#1 #2 {% + \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname + \expandafter\closeout\csname#1indfile\endcsname + \expandafter\let\csname#1indfile\endcsname=\synindexfoo + \expandafter\xdef\csname#1index\endcsname{% define \xxxindex + \noexpand\docodeindex{#2}}% +} + +% Define \doindex, the driver for all \fooindex macros. +% Argument #1 is generated by the calling \fooindex macro, +% and it is "foo", the name of the index. + +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} + +% like the previous two, but they put @code around the argument. +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} + +\def\indexdummies{% +\def\ { }% +% Take care of the plain tex accent commands. +\def\"{\realbackslash "}% +\def\`{\realbackslash `}% +\def\'{\realbackslash '}% +\def\^{\realbackslash ^}% +\def\~{\realbackslash ~}% +\def\={\realbackslash =}% +\def\b{\realbackslash b}% +\def\c{\realbackslash c}% +\def\d{\realbackslash d}% +\def\u{\realbackslash u}% +\def\v{\realbackslash v}% +\def\H{\realbackslash H}% +% Take care of the plain tex special European modified letters. +\def\oe{\realbackslash oe}% +\def\ae{\realbackslash ae}% +\def\aa{\realbackslash aa}% +\def\OE{\realbackslash OE}% +\def\AE{\realbackslash AE}% +\def\AA{\realbackslash AA}% +\def\o{\realbackslash o}% +\def\O{\realbackslash O}% +\def\l{\realbackslash l}% +\def\L{\realbackslash L}% +\def\ss{\realbackslash ss}% +% Take care of texinfo commands likely to appear in an index entry. +% (Must be a way to avoid doing expansion at all, and thus not have to +% laboriously list every single command here.) +\def\@{@}% will be @@ when we switch to @ as escape char. +% Need these in case \tex is in effect and \{ is a \delimiter again. +% But can't use \lbracecmd and \rbracecmd because texindex assumes +% braces and backslashes are used only as delimiters. +\let\{ = \mylbrace +\let\} = \myrbrace +\def\_{{\realbackslash _}}% +\def\w{\realbackslash w }% +\def\bf{\realbackslash bf }% +%\def\rm{\realbackslash rm }% +\def\sl{\realbackslash sl }% +\def\sf{\realbackslash sf}% +\def\tt{\realbackslash tt}% +\def\gtr{\realbackslash gtr}% +\def\less{\realbackslash less}% +\def\hat{\realbackslash hat}% +\def\TeX{\realbackslash TeX}% +\def\dots{\realbackslash dots }% +\def\result{\realbackslash result}% +\def\equiv{\realbackslash equiv}% +\def\expansion{\realbackslash expansion}% +\def\print{\realbackslash print}% +\def\error{\realbackslash error}% +\def\point{\realbackslash point}% +\def\copyright{\realbackslash copyright}% +\def\tclose##1{\realbackslash tclose {##1}}% +\def\code##1{\realbackslash code {##1}}% +\def\uref##1{\realbackslash uref {##1}}% +\def\url##1{\realbackslash url {##1}}% +\def\env##1{\realbackslash env {##1}}% +\def\command##1{\realbackslash command {##1}}% +\def\option##1{\realbackslash option {##1}}% +\def\dotless##1{\realbackslash dotless {##1}}% +\def\samp##1{\realbackslash samp {##1}}% +\def\,##1{\realbackslash ,{##1}}% +\def\t##1{\realbackslash t {##1}}% +\def\r##1{\realbackslash r {##1}}% +\def\i##1{\realbackslash i {##1}}% +\def\b##1{\realbackslash b {##1}}% +\def\sc##1{\realbackslash sc {##1}}% +\def\cite##1{\realbackslash cite {##1}}% +\def\key##1{\realbackslash key {##1}}% +\def\file##1{\realbackslash file {##1}}% +\def\var##1{\realbackslash var {##1}}% +\def\kbd##1{\realbackslash kbd {##1}}% +\def\dfn##1{\realbackslash dfn {##1}}% +\def\emph##1{\realbackslash emph {##1}}% +\def\acronym##1{\realbackslash acronym {##1}}% +% +% Handle some cases of @value -- where the variable name does not +% contain - or _, and the value does not contain any +% (non-fully-expandable) commands. +\let\value = \expandablevalue +% +\unsepspaces +% Turn off macro expansion +\turnoffmacros +} + +% If an index command is used in an @example environment, any spaces +% therein should become regular spaces in the raw index file, not the +% expansion of \tie (\\leavevmode \penalty \@M \ ). +{\obeyspaces + \gdef\unsepspaces{\obeyspaces\let =\space}} + +% \indexnofonts no-ops all font-change commands. +% This is used when outputting the strings to sort the index by. +\def\indexdummyfont#1{#1} +\def\indexdummytex{TeX} +\def\indexdummydots{...} + +\def\indexnofonts{% +% Just ignore accents. +\let\,=\indexdummyfont +\let\"=\indexdummyfont +\let\`=\indexdummyfont +\let\'=\indexdummyfont +\let\^=\indexdummyfont +\let\~=\indexdummyfont +\let\==\indexdummyfont +\let\b=\indexdummyfont +\let\c=\indexdummyfont +\let\d=\indexdummyfont +\let\u=\indexdummyfont +\let\v=\indexdummyfont +\let\H=\indexdummyfont +\let\dotless=\indexdummyfont +% Take care of the plain tex special European modified letters. +\def\oe{oe}% +\def\ae{ae}% +\def\aa{aa}% +\def\OE{OE}% +\def\AE{AE}% +\def\AA{AA}% +\def\o{o}% +\def\O{O}% +\def\l{l}% +\def\L{L}% +\def\ss{ss}% +\let\w=\indexdummyfont +\let\t=\indexdummyfont +\let\r=\indexdummyfont +\let\i=\indexdummyfont +\let\b=\indexdummyfont +\let\emph=\indexdummyfont +\let\strong=\indexdummyfont +\let\cite=\indexdummyfont +\let\sc=\indexdummyfont +%Don't no-op \tt, since it isn't a user-level command +% and is used in the definitions of the active chars like <, >, |... +%\let\tt=\indexdummyfont +\let\tclose=\indexdummyfont +\let\code=\indexdummyfont +\let\url=\indexdummyfont +\let\uref=\indexdummyfont +\let\env=\indexdummyfont +\let\command=\indexdummyfont +\let\option=\indexdummyfont +\let\file=\indexdummyfont +\let\samp=\indexdummyfont +\let\kbd=\indexdummyfont +\let\key=\indexdummyfont +\let\var=\indexdummyfont +\let\TeX=\indexdummytex +\let\dots=\indexdummydots +\def\@{@}% +} + +% To define \realbackslash, we must make \ not be an escape. +% We must first make another character (@) an escape +% so we do not become unable to do a definition. + +{\catcode`\@=0 \catcode`\\=\other + @gdef@realbackslash{\}} + +\let\indexbackslash=0 %overridden during \printindex. +\let\SETmarginindex=\relax % put index entries in margin (undocumented)? + +% For \ifx comparisons. +\def\emptymacro{\empty} + +% Most index entries go through here, but \dosubind is the general case. +% +\def\doind#1#2{\dosubind{#1}{#2}\empty} + +% Workhorse for all \fooindexes. +% #1 is name of index, #2 is stuff to put there, #3 is subentry -- +% \empty if called from \doind, as we usually are. The main exception +% is with defuns, which call us directly. +% +\def\dosubind#1#2#3{% + % Put the index entry in the margin if desired. + \ifx\SETmarginindex\relax\else + \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% + \fi + {% + \count255=\lastpenalty + {% + \indexdummies % Must do this here, since \bf, etc expand at this stage + \escapechar=`\\ + {% + \let\folio = 0% We will expand all macros now EXCEPT \folio. + \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now + % so it will be output as is; and it will print as backslash. + % + \def\thirdarg{#3}% + % + % If third arg is present, precede it with space in sort key. + \ifx\thirdarg\emptymacro + \let\subentry = \empty + \else + \def\subentry{ #3}% + \fi + % + % First process the index entry with all font commands turned + % off to get the string to sort by. + {\indexnofonts \xdef\indexsorttmp{#2\subentry}}% + % + % Now the real index entry with the fonts. + \toks0 = {#2}% + % + % If third (subentry) arg is present, add it to the index + % string. And include a space. + \ifx\thirdarg\emptymacro \else + \toks0 = \expandafter{\the\toks0 \space #3}% + \fi + % + % Set up the complete index entry, with both the sort key + % and the original text, including any font commands. We write + % three arguments to \entry to the .?? file, texindex reduces to + % two when writing the .??s sorted result. + \edef\temp{% + \write\csname#1indfile\endcsname{% + \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% + }% + % + % If a skip is the last thing on the list now, preserve it + % by backing up by \lastskip, doing the \write, then inserting + % the skip again. Otherwise, the whatsit generated by the + % \write will make \lastskip zero. The result is that sequences + % like this: + % @end defun + % @tindex whatever + % @defun ... + % will have extra space inserted, because the \medbreak in the + % start of the @defun won't see the skip inserted by the @end of + % the previous defun. + % + % But don't do any of this if we're not in vertical mode. We + % don't want to do a \vskip and prematurely end a paragraph. + % + % Avoid page breaks due to these extra skips, too. + % + \iflinks + \ifvmode + \skip0 = \lastskip + \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi + \fi + % + \temp % do the write + % + % + \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi + \fi + }% + }% + \penalty\count255 + }% +} + +% The index entry written in the file actually looks like +% \entry {sortstring}{page}{topic} +% or +% \entry {sortstring}{page}{topic}{subtopic} +% The texindex program reads in these files and writes files +% containing these kinds of lines: +% \initial {c} +% before the first topic whose initial is c +% \entry {topic}{pagelist} +% for a topic that is used without subtopics +% \primary {topic} +% for the beginning of a topic that is used with subtopics +% \secondary {subtopic}{pagelist} +% for each subtopic. + +% Define the user-accessible indexing commands +% @findex, @vindex, @kindex, @cindex. + +\def\findex {\fnindex} +\def\kindex {\kyindex} +\def\cindex {\cpindex} +\def\vindex {\vrindex} +\def\tindex {\tpindex} +\def\pindex {\pgindex} + +\def\cindexsub {\begingroup\obeylines\cindexsub} +{\obeylines % +\gdef\cindexsub "#1" #2^^M{\endgroup % +\dosubind{cp}{#2}{#1}}} + +% Define the macros used in formatting output of the sorted index material. + +% @printindex causes a particular index (the ??s file) to get printed. +% It does not print any chapter heading (usually an @unnumbered). +% +\def\printindex{\parsearg\doprintindex} +\def\doprintindex#1{\begingroup + \dobreak \chapheadingskip{10000}% + % + \indexfonts \rm + \tolerance = 9500 + \indexbreaks + % + % See if the index file exists and is nonempty. + % Change catcode of @ here so that if the index file contains + % \initial {@} + % as its first line, TeX doesn't complain about mismatched braces + % (because it thinks @} is a control sequence). + \catcode`\@ = 11 + \openin 1 \jobname.#1s + \ifeof 1 + % \enddoublecolumns gets confused if there is no text in the index, + % and it loses the chapter title and the aux file entries for the + % index. The easiest way to prevent this problem is to make sure + % there is some text. + \putwordIndexNonexistent + \else + % + % If the index file exists but is empty, then \openin leaves \ifeof + % false. We have to make TeX try to read something from the file, so + % it can discover if there is anything in it. + \read 1 to \temp + \ifeof 1 + \putwordIndexIsEmpty + \else + % Index files are almost Texinfo source, but we use \ as the escape + % character. It would be better to use @, but that's too big a change + % to make right now. + \def\indexbackslash{\rawbackslashxx}% + \catcode`\\ = 0 + \escapechar = `\\ + \begindoublecolumns + \input \jobname.#1s + \enddoublecolumns + \fi + \fi + \closein 1 +\endgroup} + +% These macros are used by the sorted index file itself. +% Change them to control the appearance of the index. + +\def\initial#1{{% + % Some minor font changes for the special characters. + \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt + % + % Remove any glue we may have, we'll be inserting our own. + \removelastskip + % + % We like breaks before the index initials, so insert a bonus. + \penalty -300 + % + % Typeset the initial. Making this add up to a whole number of + % baselineskips increases the chance of the dots lining up from column + % to column. It still won't often be perfect, because of the stretch + % we need before each entry, but it's better. + % + % No shrink because it confuses \balancecolumns. + \vskip 1.67\baselineskip plus .5\baselineskip + \leftline{\secbf #1}% + \vskip .33\baselineskip plus .1\baselineskip + % + % Do our best not to break after the initial. + \nobreak +}} + +% This typesets a paragraph consisting of #1, dot leaders, and then #2 +% flush to the right margin. It is used for index and table of contents +% entries. The paragraph is indented by \leftskip. +% +\def\entry#1#2{\begingroup + % + % Start a new paragraph if necessary, so our assignments below can't + % affect previous text. + \par + % + % Do not fill out the last line with white space. + \parfillskip = 0in + % + % No extra space above this paragraph. + \parskip = 0in + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent = 2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % A bit of stretch before each entry for the benefit of balancing columns. + \vskip 0pt plus1pt + % + % Start a ``paragraph'' for the index entry so the line breaking + % parameters we've set above will have an effect. + \noindent + % + % Insert the text of the index entry. TeX will do line-breaking on it. + #1% + % The following is kludged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \def\tempa{{\rm }}% + \def\tempb{#2}% + \edef\tempc{\tempa}% + \edef\tempd{\tempb}% + \ifx\tempc\tempd\ \else% + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. + \ #2% The page number ends the paragraph. + \fi% + \par +\endgroup} + +% Like \dotfill except takes at least 1 em. +\def\indexdotfill{\cleaders + \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} + +\def\primary #1{\line{#1\hfil}} + +\newskip\secondaryindent \secondaryindent=0.5cm + +\def\secondary #1#2{ +{\parfillskip=0in \parskip=0in +\hangindent =1in \hangafter=1 +\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par +}} + +% Define two-column mode, which we use to typeset indexes. +% Adapted from the TeXbook, page 416, which is to say, +% the manmac.tex format used to print the TeXbook itself. +\catcode`\@=11 + +\newbox\partialpage +\newdimen\doublecolumnhsize + +\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns + % Grab any single-column material above us. + \output = {% + % + % Here is a possibility not foreseen in manmac: if we accumulate a + % whole lot of material, we might end up calling this \output + % routine twice in a row (see the doublecol-lose test, which is + % essentially a couple of indexes with @setchapternewpage off). In + % that case we just ship out what is in \partialpage with the normal + % output routine. Generally, \partialpage will be empty when this + % runs and this will be a no-op. See the indexspread.tex test case. + \ifvoid\partialpage \else + \onepageout{\pagecontents\partialpage}% + \fi + % + \global\setbox\partialpage = \vbox{% + % Unvbox the main output page. + \unvbox\PAGE + \kern-\topskip \kern\baselineskip + }% + }% + \eject % run that output routine to set \partialpage + % + % Use the double-column output routine for subsequent pages. + \output = {\doublecolumnout}% + % + % Change the page size parameters. We could do this once outside this + % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 + % format, but then we repeat the same computation. Repeating a couple + % of assignments once per index is clearly meaningless for the + % execution time, so we may as well do it in one place. + % + % First we halve the line length, less a little for the gutter between + % the columns. We compute the gutter based on the line length, so it + % changes automatically with the paper format. The magic constant + % below is chosen so that the gutter has the same value (well, +-<1pt) + % as it did when we hard-coded it. + % + % We put the result in a separate register, \doublecolumhsize, so we + % can restore it in \pagesofar, after \hsize itself has (potentially) + % been clobbered. + % + \doublecolumnhsize = \hsize + \advance\doublecolumnhsize by -.04154\hsize + \divide\doublecolumnhsize by 2 + \hsize = \doublecolumnhsize + % + % Double the \vsize as well. (We don't need a separate register here, + % since nobody clobbers \vsize.) + \advance\vsize by -\ht\partialpage + \vsize = 2\vsize +} + +% The double-column output routine for all double-column pages except +% the last. +% +\def\doublecolumnout{% + \splittopskip=\topskip \splitmaxdepth=\maxdepth + % Get the available space for the double columns -- the normal + % (undoubled) page height minus any material left over from the + % previous page. + \dimen@ = \vsize + \divide\dimen@ by 2 + % + % box0 will be the left-hand column, box2 the right. + \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ + \onepageout\pagesofar + \unvbox255 + \penalty\outputpenalty +} +\def\pagesofar{% + % Re-output the contents of the output page -- any previous material, + % followed by the two boxes we just split, in box0 and box2. + \unvbox\partialpage + % + \hsize = \doublecolumnhsize + \wd0=\hsize \wd2=\hsize + \hbox to\pagewidth{\box0\hfil\box2}% +} +\def\enddoublecolumns{% + \output = {% + % Split the last of the double-column material. Leave it on the + % current page, no automatic page break. + \balancecolumns + % + % If we end up splitting too much material for the current page, + % though, there will be another page break right after this \output + % invocation ends. Having called \balancecolumns once, we do not + % want to call it again. Therefore, reset \output to its normal + % definition right away. (We hope \balancecolumns will never be + % called on to balance too much material, but if it is, this makes + % the output somewhat more palatable.) + \global\output = {\onepageout{\pagecontents\PAGE}}% + }% + \eject + \endgroup % started in \begindoublecolumns + % + % \pagegoal was set to the doubled \vsize above, since we restarted + % the current page. We're now back to normal single-column + % typesetting, so reset \pagegoal to the normal \vsize (after the + % \endgroup where \vsize got restored). + \pagegoal = \vsize +} +\def\balancecolumns{% + % Called at the end of the double column material. + \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. + \dimen@ = \ht0 + \advance\dimen@ by \topskip + \advance\dimen@ by-\baselineskip + \divide\dimen@ by 2 % target to split to + %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% + \splittopskip = \topskip + % Loop until we get a decent breakpoint. + {% + \vbadness = 10000 + \loop + \global\setbox3 = \copy0 + \global\setbox1 = \vsplit3 to \dimen@ + \ifdim\ht3>\dimen@ + \global\advance\dimen@ by 1pt + \repeat + }% + %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% + \setbox0=\vbox to\dimen@{\unvbox1}% + \setbox2=\vbox to\dimen@{\unvbox3}% + % + \pagesofar +} +\catcode`\@ = \other + + +\message{sectioning,} +% Chapters, sections, etc. + +\newcount\chapno +\newcount\secno \secno=0 +\newcount\subsecno \subsecno=0 +\newcount\subsubsecno \subsubsecno=0 + +% This counter is funny since it counts through charcodes of letters A, B, ... +% The \the is necessary, despite appearances, because \appendixletter is +% expanded while writing the .toc file. \char\appendixno is not +% expandable, thus it is written literally, thus all appendixes come out +% with the same letter (or @) in the toc without it. +\newcount\appendixno \appendixno = `\@ +\def\appendixletter{\char\the\appendixno} + +% Each @chapter defines this as the name of the chapter. +% page headings and footings can use it. @section does likewise. +\def\thischapter{} +\def\thissection{} + +\newcount\absseclevel % used to calculate proper heading level +\newcount\secbase\secbase=0 % @raise/lowersections modify this count + +% @raisesections: treat @section as chapter, @subsection as section, etc. +\def\raisesections{\global\advance\secbase by -1} +\let\up=\raisesections % original BFox name + +% @lowersections: treat @chapter as section, @section as subsection, etc. +\def\lowersections{\global\advance\secbase by 1} +\let\down=\lowersections % original BFox name + +% Choose a numbered-heading macro +% #1 is heading level if unmodified by @raisesections or @lowersections +% #2 is text for heading +\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \chapterzzz{#2} +\or + \seczzz{#2} +\or + \numberedsubseczzz{#2} +\or + \numberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \chapterzzz{#2} + \else + \numberedsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses appendix heading levels +\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \appendixzzz{#2} +\or + \appendixsectionzzz{#2} +\or + \appendixsubseczzz{#2} +\or + \appendixsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \appendixzzz{#2} + \else + \appendixsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses numberless heading levels +\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \unnumberedzzz{#2} +\or + \unnumberedseczzz{#2} +\or + \unnumberedsubseczzz{#2} +\or + \unnumberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \unnumberedzzz{#2} + \else + \unnumberedsubsubseczzz{#2} + \fi +\fi +} + +% @chapter, @appendix, @unnumbered. +\def\thischaptername{No Chapter Title} +\outer\def\chapter{\parsearg\chapteryyy} +\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz +\def\chapterzzz #1{% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}% +\chapmacro {#1}{\the\chapno}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +% We don't substitute the actual chapter name into \thischapter +% because we don't want its macros evaluated now. +\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% + {\the\chapno}}}% +\temp +\donoderef +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec +} + +\outer\def\appendix{\parsearg\appendixyyy} +\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz +\def\appendixzzz #1{% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \appendixno by 1 +\message{\putwordAppendix\space \appendixletter}% +\chapmacro {#1}{\putwordAppendix{} \appendixletter}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% + {\putwordAppendix{} \appendixletter}}}% +\temp +\appendixnoderef +\global\let\section = \appendixsec +\global\let\subsection = \appendixsubsec +\global\let\subsubsection = \appendixsubsubsec +} + +% @centerchap is like @unnumbered, but the heading is centered. +\outer\def\centerchap{\parsearg\centerchapyyy} +\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} + +% @top is like @unnumbered. +\outer\def\top{\parsearg\unnumberedyyy} + +\outer\def\unnumbered{\parsearg\unnumberedyyy} +\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz +\def\unnumberedzzz #1{% +\secno=0 \subsecno=0 \subsubsecno=0 +% +% This used to be simply \message{#1}, but TeX fully expands the +% argument to \message. Therefore, if #1 contained @-commands, TeX +% expanded them. For example, in `@unnumbered The @cite{Book}', TeX +% expanded @cite (which turns out to cause errors because \cite is meant +% to be executed, not expanded). +% +% Anyway, we don't want the fully-expanded definition of @cite to appear +% as a result of the \message, we just want `@cite' itself. We use +% \the to achieve this: TeX expands \the only once, +% simply yielding the contents of . (We also do this for +% the toc entries.) +\toks0 = {#1}\message{(\the\toks0)}% +% +\unnumbchapmacro {#1}% +\gdef\thischapter{#1}\gdef\thissection{#1}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}% +\temp +\unnumbnoderef +\global\let\section = \unnumberedsec +\global\let\subsection = \unnumberedsubsec +\global\let\subsubsection = \unnumberedsubsubsec +} + +% Sections. +\outer\def\numberedsec{\parsearg\secyyy} +\def\secyyy #1{\numhead1{#1}} % normally calls seczzz +\def\seczzz #1{% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% + {\the\chapno}{\the\secno}}}% +\temp +\donoderef +\nobreak +} + +\outer\def\appendixsection{\parsearg\appendixsecyyy} +\outer\def\appendixsec{\parsearg\appendixsecyyy} +\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz +\def\appendixsectionzzz #1{% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% + {\appendixletter}{\the\secno}}}% +\temp +\appendixnoderef +\nobreak +} + +\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} +\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz +\def\unnumberedseczzz #1{% +\plainsecheading {#1}\gdef\thissection{#1}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}% +\temp +\unnumbnoderef +\nobreak +} + +% Subsections. +\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} +\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz +\def\numberedsubseczzz #1{% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% + {\the\chapno}{\the\secno}{\the\subsecno}}}% +\temp +\donoderef +\nobreak +} + +\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} +\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz +\def\appendixsubseczzz #1{% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% + {\appendixletter}{\the\secno}{\the\subsecno}}}% +\temp +\appendixnoderef +\nobreak +} + +\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} +\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz +\def\unnumberedsubseczzz #1{% +\plainsubsecheading {#1}\gdef\thissection{#1}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry% + {\the\toks0}}}% +\temp +\unnumbnoderef +\nobreak +} + +% Subsubsections. +\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} +\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz +\def\numberedsubsubseczzz #1{% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% +\temp +\donoderef +\nobreak +} + +\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} +\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz +\def\appendixsubsubseczzz #1{% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% + {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% +\temp +\appendixnoderef +\nobreak +} + +\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} +\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz +\def\unnumberedsubsubseczzz #1{% +\plainsubsubsecheading {#1}\gdef\thissection{#1}% +\toks0 = {#1}% +\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry% + {\the\toks0}}}% +\temp +\unnumbnoderef +\nobreak +} + +% These are variants which are not "outer", so they can appear in @ifinfo. +% Actually, they should now be obsolete; ordinary section commands should work. +\def\infotop{\parsearg\unnumberedzzz} +\def\infounnumbered{\parsearg\unnumberedzzz} +\def\infounnumberedsec{\parsearg\unnumberedseczzz} +\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} +\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} + +\def\infoappendix{\parsearg\appendixzzz} +\def\infoappendixsec{\parsearg\appendixseczzz} +\def\infoappendixsubsec{\parsearg\appendixsubseczzz} +\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} + +\def\infochapter{\parsearg\chapterzzz} +\def\infosection{\parsearg\sectionzzz} +\def\infosubsection{\parsearg\subsectionzzz} +\def\infosubsubsection{\parsearg\subsubsectionzzz} + +% These macros control what the section commands do, according +% to what kind of chapter we are in (ordinary, appendix, or unnumbered). +% Define them by default for a numbered chapter. +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec + +% Define @majorheading, @heading and @subheading + +% NOTE on use of \vbox for chapter headings, section headings, and such: +% 1) We use \vbox rather than the earlier \line to permit +% overlong headings to fold. +% 2) \hyphenpenalty is set to 10000 because hyphenation in a +% heading is obnoxious; this forbids it. +% 3) Likewise, headings look best if no \parindent is used, and +% if justification is not attempted. Hence \raggedright. + + +\def\majorheading{\parsearg\majorheadingzzz} +\def\majorheadingzzz #1{% +{\advance\chapheadingskip by 10pt \chapbreak }% +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\chapheading{\parsearg\chapheadingzzz} +\def\chapheadingzzz #1{\chapbreak % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +% @heading, @subheading, @subsubheading. +\def\heading{\parsearg\plainsecheading} +\def\subheading{\parsearg\plainsubsecheading} +\def\subsubheading{\parsearg\plainsubsubsecheading} + +% These macros generate a chapter, section, etc. heading only +% (including whitespace, linebreaking, etc. around it), +% given all the information in convenient, parsed form. + +%%% Args are the skip and penalty (usually negative) +\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} + +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} + +%%% Define plain chapter starts, and page on/off switching for it +% Parameter controlling skip before chapter headings (if needed) + +\newskip\chapheadingskip + +\def\chapbreak{\dobreak \chapheadingskip {-4000}} +\def\chappager{\par\vfill\supereject} +\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} + +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} + +\def\CHAPPAGoff{% +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{% +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{ +\global\let\contentsalignmacro = \chapoddpage +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +\def\CHAPFplain{ +\global\let\chapmacro=\chfplain +\global\let\unnumbchapmacro=\unnchfplain +\global\let\centerchapmacro=\centerchfplain} + +% Plain chapter opening. +% #1 is the text, #2 the chapter number or empty if unnumbered. +\def\chfplain#1#2{% + \pchapsepmacro + {% + \chapfonts \rm + \def\chapnum{#2}% + \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright + \hangindent = \wd0 \centerparametersmaybe + \unhbox0 #1\par}% + }% + \nobreak\bigskip % no page break after a chapter title + \nobreak +} + +% Plain opening for unnumbered. +\def\unnchfplain#1{\chfplain{#1}{}} + +% @centerchap -- centered and unnumbered. +\let\centerparametersmaybe = \relax +\def\centerchfplain#1{{% + \def\centerparametersmaybe{% + \advance\rightskip by 3\rightskip + \leftskip = \rightskip + \parfillskip = 0pt + }% + \chfplain{#1}{}% +}} + +\CHAPFplain % The default + +\def\unnchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\nobreak +} + +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} + +\def\centerchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt + \hfill {\rm #1}\hfill}}\bigskip \par\nobreak +} + +\def\CHAPFopen{ +\global\let\chapmacro=\chfopen +\global\let\unnumbchapmacro=\unnchfopen +\global\let\centerchapmacro=\centerchfopen} + + +% Section titles. +\newskip\secheadingskip +\def\secheadingbreak{\dobreak \secheadingskip {-1000}} +\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} +\def\plainsecheading#1{\sectionheading{sec}{}{#1}} + +% Subsection titles. +\newskip \subsecheadingskip +\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} +\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} +\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} + +% Subsubsection titles. +\let\subsubsecheadingskip = \subsecheadingskip +\let\subsubsecheadingbreak = \subsecheadingbreak +\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} +\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} + + +% Print any size section title. +% +% #1 is the section type (sec/subsec/subsubsec), #2 is the section +% number (maybe empty), #3 the text. +\def\sectionheading#1#2#3{% + {% + \expandafter\advance\csname #1headingskip\endcsname by \parskip + \csname #1headingbreak\endcsname + }% + {% + % Switch to the right set of fonts. + \csname #1fonts\endcsname \rm + % + % Only insert the separating space if we have a section number. + \def\secnum{#2}% + \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% + % + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright + \hangindent = \wd0 % zero if no section number + \unhbox0 #3}% + }% + \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak +} + + +\message{toc,} +% Table of contents. +\newwrite\tocfile + +% Write an entry to the toc file, opening it if necessary. +% Called from @chapter, etc. We supply {\folio} at the end of the +% argument, which will end up as the last argument to the \...entry macro. +% +% We open the .toc file here instead of at @setfilename or any other +% given time so that @contents can be put in the document anywhere. +% +\newif\iftocfileopened +\def\writetocentry#1{% + \iftocfileopened\else + \immediate\openout\tocfile = \jobname.toc + \global\tocfileopenedtrue + \fi + \iflinks \write\tocfile{#1{\folio}}\fi +} + +\newskip\contentsrightmargin \contentsrightmargin=1in +\newcount\savepageno +\newcount\lastnegativepageno \lastnegativepageno = -1 + +% Finish up the main text and prepare to read what we've written +% to \tocfile. +% +\def\startcontents#1{% + % If @setchapternewpage on, and @headings double, the contents should + % start on an odd page, unlike chapters. Thus, we maintain + % \contentsalignmacro in parallel with \pagealignmacro. + % From: Torbjorn Granlund + \contentsalignmacro + \immediate\closeout\tocfile + % + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \unnumbchapmacro{#1}\def\thischapter{}% + \savepageno = \pageno + \begingroup % Set up to handle contents files properly. + \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 + % We can't do this, because then an actual ^ in a section + % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. + %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. + % + % Roman numerals for page numbers. + \ifnum \pageno>0 \pageno = \lastnegativepageno \fi +} + + +% Normal (long) toc. +\def\contents{% + \startcontents{\putwordTOC}% + \openin 1 \jobname.toc + \ifeof 1 \else + \closein 1 + \input \jobname.toc + \fi + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \endgroup + \lastnegativepageno = \pageno + \pageno = \savepageno +} + +% And just the chapters. +\def\summarycontents{% + \startcontents{\putwordShortTOC}% + % + \let\chapentry = \shortchapentry + \let\unnumbchapentry = \shortunnumberedentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl + \rm + \hyphenpenalty = 10000 + \advance\baselineskip by 1pt % Open it up a little. + \def\secentry ##1##2##3##4{} + \def\unnumbsecentry ##1##2{} + \def\subsecentry ##1##2##3##4##5{} + \def\unnumbsubsecentry ##1##2{} + \def\subsubsecentry ##1##2##3##4##5##6{} + \def\unnumbsubsubsecentry ##1##2{} + \openin 1 \jobname.toc + \ifeof 1 \else + \closein 1 + \input \jobname.toc + \fi + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \endgroup + \lastnegativepageno = \pageno + \pageno = \savepageno +} +\let\shortcontents = \summarycontents + +\ifpdf + \pdfcatalog{/PageMode /UseOutlines}% +\fi + +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Chapter-level things, for both the long and short contents. +\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} + +% See comments in \dochapentry re vbox and related settings +\def\shortchapentry#1#2#3{% + \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% +} + +% Typeset the label for a chapter or appendix for the short contents. +% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. +% We could simplify the code here by writing out an \appendixentry +% command in the toc file for appendices, instead of using \chapentry +% for both, but it doesn't seem worth it. +\setbox0 = \hbox{\shortcontrm \putwordAppendix } +\newdimen\shortappendixwidth \shortappendixwidth = \wd0 + +\def\shortchaplabel#1{% + % We typeset #1 in a box of constant width, regardless of the text of + % #1, so the chapter titles will come out aligned. + \setbox0 = \hbox{#1}% + \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi + % + % This space should be plenty, since a single number is .5em, and the + % widest letter (M) is 1em, at least in the Computer Modern fonts. + % (This space doesn't include the extra space that gets added after + % the label; that gets put in by \shortchapentry above.) + \advance\dimen0 by 1.1em + \hbox to \dimen0{#1\hfil}% +} + +\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} +\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} + +% Sections. +\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} +\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} + +% Subsections. +\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} +\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} + +% And subsubsections. +\def\subsubsecentry#1#2#3#4#5#6{% + \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} +\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} + +% This parameter controls the indentation of the various levels. +\newdimen\tocindent \tocindent = 3pc + +% Now for the actual typesetting. In all these, #1 is the text and #2 is the +% page number. +% +% If the toc has to be broken over pages, we want it to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip + \begingroup + \chapentryfonts + \tocentry{#1}{\dopageno{#2}}% + \endgroup + \nobreak\vskip .25\baselineskip plus.1\baselineskip +} + +\def\dosecentry#1#2{\begingroup + \secentryfonts \leftskip=\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsecentry#1#2{\begingroup + \subsecentryfonts \leftskip=2\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsubsecentry#1#2{\begingroup + \subsubsecentryfonts \leftskip=3\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +% Final typesetting of a toc entry; we use the same \entry macro as for +% the index entries, but we want to suppress hyphenation here. (We +% can't do that in the \entry macro, since index entries might consist +% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) +\def\tocentry#1#2{\begingroup + \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks + % Do not use \turnoffactive in these arguments. Since the toc is + % typeset in cmr, so characters such as _ would come out wrong; we + % have to do the usual translation tricks. + \entry{#1}{#2}% +\endgroup} + +% Space between chapter (or whatever) number and the title. +\def\labelspace{\hskip1em \relax} + +\def\dopageno#1{{\rm #1}} +\def\doshortpageno#1{{\rm #1}} + +\def\chapentryfonts{\secfonts \rm} +\def\secentryfonts{\textfonts} +\let\subsecentryfonts = \textfonts +\let\subsubsecentryfonts = \textfonts + + +\message{environments,} +% @foo ... @end foo. + +% Since these characters are used in examples, it should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% Furthermore, these definitions must come after we define our fonts. +\newbox\dblarrowbox \newbox\longdblarrowbox +\newbox\pushcharbox \newbox\bullbox +\newbox\equivbox \newbox\errorbox + +%{\tentt +%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} +%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} +%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} +%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} +% Adapted from the manmac format (p.420 of TeXbook) +%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex +% depth .1ex\hfil} +%} + +% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. +\def\point{$\star$} +\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} +\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% Adapted from the TeXbook's \boxit. +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} + +\global\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{ + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} + +% The @error{} command. +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @tex ... @end tex escapes into raw Tex temporarily. +% One exception: @ is still an escape character, so that @end tex works. +% But \@ or @@ will get a plain tex @ character. + +\def\tex{\begingroup + \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 + \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 + \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie + \catcode `\%=14 + \catcode 43=12 % plus + \catcode`\"=12 + \catcode`\==12 + \catcode`\|=12 + \catcode`\<=12 + \catcode`\>=12 + \escapechar=`\\ + % + \let\b=\ptexb + \let\bullet=\ptexbullet + \let\c=\ptexc + \let\,=\ptexcomma + \let\.=\ptexdot + \let\dots=\ptexdots + \let\equiv=\ptexequiv + \let\!=\ptexexclam + \let\i=\ptexi + \let\{=\ptexlbrace + \let\+=\tabalign + \let\}=\ptexrbrace + \let\*=\ptexstar + \let\t=\ptext + % + \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% + \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% + \def\@{@}% +\let\Etex=\endgroup} + +% Define @lisp ... @endlisp. +% @lisp does a \begingroup so it can rebind things, +% including the definition of @endlisp (which normally is erroneous). + +% Amount to narrow the margins by for @lisp. +\newskip\lispnarrowing \lispnarrowing=0.4in + +% This is the definition that ^^M gets inside @lisp, @example, and other +% such environments. \null is better than a space, since it doesn't +% have any width. +\def\lisppar{\null\endgraf} + +% Make each space character in the input produce a normal interword +% space in the output. Don't allow a line break at this space, as this +% is used only in environments like @example, where each line of input +% should produce a line of output anyway. +% +{\obeyspaces % +\gdef\sepspaces{\obeyspaces\let =\tie}} + +% Define \obeyedspace to be our active space, whatever it is. This is +% for use in \parsearg. +{\sepspaces% +\global\let\obeyedspace= } + +% This space is always present above and below environments. +\newskip\envskipamount \envskipamount = 0pt + +% Make spacing and below environment symmetrical. We use \parskip here +% to help in doing that, since in @example-like environments \parskip +% is reset to zero; thus the \afterenvbreak inserts no space -- but the +% start of the next paragraph will insert \parskip +% +\def\aboveenvbreak{{\advance\envskipamount by \parskip +\endgraf \ifdim\lastskip<\envskipamount +\removelastskip \penalty-50 \vskip\envskipamount \fi}} + +\let\afterenvbreak = \aboveenvbreak + +% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. +\let\nonarrowing=\relax + +% @cartouche ... @end cartouche: draw rectangle w/rounded corners around +% environment contents. +\font\circle=lcircle10 +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip +\circthick=\fontdimen8\circle +% +\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth +\def\ctr{{\hskip 6pt\circle\char'010}} +\def\cbl{{\circle\char'012\hskip -6pt}} +\def\cbr{{\hskip 6pt\circle\char'011}} +\def\carttop{\hbox to \cartouter{\hskip\lskip + \ctl\leaders\hrule height\circthick\hfil\ctr + \hskip\rskip}} +\def\cartbot{\hbox to \cartouter{\hskip\lskip + \cbl\leaders\hrule height\circthick\hfil\cbr + \hskip\rskip}} +% +\newskip\lskip\newskip\rskip + +\long\def\cartouche{% +\begingroup + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt %we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18.4pt % allow for 3pt kerns on either +% side, and for 6pt waste from +% each corner char, and rule thickness + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing=\comment + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \hsize=\cartinner + \kern3pt + \begingroup + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip +\def\Ecartouche{% + \endgroup + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup +\endgroup +}} + + +% This macro is called at the beginning of all the @example variants, +% inside a group. +\def\nonfillstart{% + \aboveenvbreak + \inENV % This group ends at the end of the body + \hfuzz = 12pt % Don't be fussy + \sepspaces % Make spaces be word-separators rather than space tokens. + \singlespace + \let\par = \lisppar % don't ignore blank lines + \obeylines % each line of input is a line of output + \parskip = 0pt + \parindent = 0pt + \emergencystretch = 0pt % don't try to avoid overfull boxes + % @cartouche defines \nonarrowing to inhibit narrowing + % at next level down. + \ifx\nonarrowing\relax + \advance \leftskip by \lispnarrowing + \exdentamount=\lispnarrowing + \let\exdent=\nofillexdent + \let\nonarrowing=\relax + \fi +} + +% Define the \E... control sequence only if we are inside the particular +% environment, so the error checking in \end will work. +% +% To end an @example-like environment, we first end the paragraph (via +% \afterenvbreak's vertical glue), and then the group. That way we keep +% the zero \parskip that the environments set -- \parskip glue will be +% inserted at the beginning of the next paragraph in the document, after +% the environment. +% +\def\nonfillfinish{\afterenvbreak\endgroup} + +% @lisp: indented, narrowed, typewriter font. +\def\lisp{\begingroup + \nonfillstart + \let\Elisp = \nonfillfinish + \tt + \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. + \gobble % eat return +} + +% @example: Same as @lisp. +\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} + +% @small... is usually equivalent to the non-small (@smallbook +% redefines). We must call \example (or whatever) last in the +% definition, since it reads the return following the @example (or +% whatever) command. +% +% This actually allows (for example) @end display inside an +% @smalldisplay. Too bad, but makeinfo will catch the error anyway. +% +\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display} +\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp} +\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format} +\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp} + +% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts. +% Originally contributed by Pavel@xerox. +\def\smalllispx{\begingroup + \def\Esmalllisp{\nonfillfinish\endgroup}% + \def\Esmallexample{\nonfillfinish\endgroup}% + \indexfonts + \lisp +} + +% @display: same as @lisp except keep current font. +% +\def\display{\begingroup + \nonfillstart + \let\Edisplay = \nonfillfinish + \gobble +} + +% @smalldisplay (when @smallbook): @display plus smaller fonts. +% +\def\smalldisplayx{\begingroup + \def\Esmalldisplay{\nonfillfinish\endgroup}% + \indexfonts \rm + \display +} + +% @format: same as @display except don't narrow margins. +% +\def\format{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eformat = \nonfillfinish + \gobble +} + +% @smallformat (when @smallbook): @format plus smaller fonts. +% +\def\smallformatx{\begingroup + \def\Esmallformat{\nonfillfinish\endgroup}% + \indexfonts \rm + \format +} + +% @flushleft (same as @format). +% +\def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} + +% @flushright. +% +\def\flushright{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eflushright = \nonfillfinish + \advance\leftskip by 0pt plus 1fill + \gobble +} + +% @quotation does normal linebreaking (hence we can't use \nonfillstart) +% and narrows the margins. +% +\def\quotation{% + \begingroup\inENV %This group ends at the end of the @quotation body + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \singlespace + \parindent=0pt + % We have retained a nonzero parskip for the environment, since we're + % doing normal filling. So to avoid extra space below the environment... + \def\Equotation{\parskip = 0pt \nonfillfinish}% + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \advance\rightskip by \lispnarrowing + \exdentamount = \lispnarrowing + \let\nonarrowing = \relax + \fi +} + + +\message{defuns,} +% @defun etc. + +% Allow user to change definition object font (\df) internally +\def\setdeffont #1 {\csname DEF#1\endcsname} + +\newskip\defbodyindent \defbodyindent=.4in +\newskip\defargsindent \defargsindent=50pt +\newskip\deftypemargin \deftypemargin=12pt +\newskip\deflastargmargin \deflastargmargin=18pt + +\newcount\parencount +% define \functionparens, which makes ( and ) and & do special things. +% \functionparens affects the group it is contained in. +\def\activeparens{% +\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active +\catcode`\[=\active \catcode`\]=\active} + +% Make control sequences which act like normal parenthesis chars. +\let\lparen = ( \let\rparen = ) + +{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) + +% Be sure that we always have a definition for `(', etc. For example, +% if the fn name has parens in it, \boldbrax will not be in effect yet, +% so TeX would otherwise complain about undefined control sequence. +\global\let(=\lparen \global\let)=\rparen +\global\let[=\lbrack \global\let]=\rbrack + +\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } +\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} +% This is used to turn on special parens +% but make & act ordinary (given that it's active). +\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} + +% Definitions of (, ) and & used in args for functions. +% This is the definition of ( outside of all parentheses. +\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested + \global\advance\parencount by 1 +} +% +% This is the definition of ( when already inside a level of parens. +\gdef\opnested{\char`\(\global\advance\parencount by 1 } +% +\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. + % also in that case restore the outer-level definition of (. + \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi + \global\advance \parencount by -1 } +% If we encounter &foo, then turn on ()-hacking afterwards +\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } +% +\gdef\normalparens{\boldbrax\let&=\ampnr} +} % End of definition inside \activeparens +%% These parens (in \boldbrax) actually are a little bolder than the +%% contained text. This is especially needed for [ and ] +\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 } +\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } +\let\ampnr = \& +\def\lbrb{{\bf\char`\[}} +\def\rbrb{{\bf\char`\]}} + +% Active &'s sneak into the index arguments, so make sure it's defined. +{ + \catcode`& = 13 + \global\let& = \ampnr +} + +% First, defname, which formats the header line itself. +% #1 should be the function name. +% #2 should be the type of definition, such as "Function". + +\def\defname #1#2{% +% Get the values of \leftskip and \rightskip as they were +% outside the @def... +\dimen2=\leftskip +\advance\dimen2 by -\defbodyindent +\noindent +\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% +\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line +\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations +\parshape 2 0in \dimen0 \defargsindent \dimen1 +% Now output arg 2 ("Function" or some such) +% ending at \deftypemargin from the right margin, +% but stuck inside a box of width 0 so it does not interfere with linebreaking +{% Adjust \hsize to exclude the ambient margins, +% so that \rightline will obey them. +\advance \hsize by -\dimen2 +\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}% +% Make all lines underfull and no complaints: +\tolerance=10000 \hbadness=10000 +\advance\leftskip by -\defbodyindent +\exdentamount=\defbodyindent +{\df #1}\enskip % Generate function name +} + +% Actually process the body of a definition +% #1 should be the terminating control sequence, such as \Edefun. +% #2 should be the "another name" control sequence, such as \defunx. +% #3 should be the control sequence that actually processes the header, +% such as \defunheader. + +\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % 61 is `=' +\obeylines\activeparens\spacesplit#3} + +% #1 is the \E... control sequence to end the definition (which we define). +% #2 is the \...x control sequence for consecutive fns (which we define). +% #3 is the control sequence to call to resume processing. +% #4, delimited by the space, is the class name. +% +\def\defmethparsebody#1#2#3#4 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% +\parindent=0in +\advance\leftskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} + +% @deftypemethod has an extra argument that nothing else does. Sigh. +% #1 is the \E... control sequence to end the definition (which we define). +% #2 is the \...x control sequence for consecutive fns (which we define). +% #3 is the control sequence to call to resume processing. +% #4, delimited by the space, is the class name. +% #5 is the method's return type. +% +\def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}} + +\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} + +% These parsing functions are similar to the preceding ones +% except that they do not make parens into active characters. +% These are used for "variables" since they have no arguments. + +\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % +\obeylines\spacesplit#3} + +% This is used for \def{tp,vr}parsebody. It could probably be used for +% some of the others, too, with some judicious conditionals. +% +\def\parsebodycommon#1#2#3{% + \begingroup\inENV % + \medbreak % + % Define the end token that this defining construct specifies + % so that it will exit this group. + \def#1{\endgraf\endgroup\medbreak}% + \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% + \parindent=0in + \advance\leftskip by \defbodyindent + \exdentamount=\defbodyindent + \begingroup\obeylines +} + +\def\defvrparsebody#1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{#3{#4}}% +} + +% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the +% type is just `struct', because we lose the braces in `{struct +% termios}' when \spacesplit reads its undelimited argument. Sigh. +% \let\deftpparsebody=\defvrparsebody +% +% So, to get around this, we put \empty in with the type name. That +% way, TeX won't find exactly `{...}' as an undelimited argument, and +% won't strip off the braces. +% +\def\deftpparsebody #1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{\parsetpheaderline{#3{#4}}}\empty +} + +% Fine, but then we have to eventually remove the \empty *and* the +% braces (if any). That's what this does. +% +\def\removeemptybraces\empty#1\relax{#1} + +% After \spacesplit has done its work, this is called -- #1 is the final +% thing to call, #2 the type name (which starts with \empty), and #3 +% (which might be empty) the arguments. +% +\def\parsetpheaderline#1#2#3{% + #1{\removeemptybraces#2\relax}{#3}% +}% + +\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\spacesplit{#3{#5}}} + +% Split up #2 at the first space token. +% call #1 with two arguments: +% the first is all of #2 before the space token, +% the second is all of #2 after that space token. +% If #2 contains no space token, all of it is passed as the first arg +% and the second is passed as empty. + +{\obeylines +\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% +\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% +\ifx\relax #3% +#1{#2}{}\else #1{#2}{#3#4}\fi}} + +% So much for the things common to all kinds of definitions. + +% Define @defun. + +% First, define the processing that is wanted for arguments of \defun +% Use this to expand the args and terminate the paragraph they make up + +\def\defunargs#1{\functionparens \sl +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +% Set the font temporarily and use \font in case \setfont made \tensl a macro. +{\tensl\hyphenchar\font=0}% +#1% +{\tensl\hyphenchar\font=45}% +\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\nobreak\vskip -\parskip\nobreak +} + +\def\deftypefunargs #1{% +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +% Use \boldbraxnoamp, not \functionparens, so that & is not special. +\boldbraxnoamp +\tclose{#1}% avoid \code because of side effects on active chars +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\nobreak\vskip -\parskip\nobreak +} + +% Do complete processing of one @defun or @defunx line already parsed. + +% @deffn Command forward-char nchars + +\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} + +\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% +\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defun == @deffn Function + +\def\defun{\defparsebody\Edefun\defunx\defunheader} + +\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{\putwordDeffunc}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefun int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} + +% #1 is the data type. #2 is the name and args. +\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} +% #1 is the data type, #2 the name, #3 the args. +\def\deftypefunheaderx #1#2 #3\relax{% +\doind {fn}{\code{#2}}% Make entry in function index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypefun}% +\deftypefunargs {#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} + +% \defheaderxcond#1\relax$$$ +% puts #1 in @code, followed by a space, but does nothing if #1 is null. +\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} + +% #1 is the classification. #2 is the data type. #3 is the name and args. +\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} +% #1 is the classification, #2 the data type, #3 the name, #4 the args. +\def\deftypefnheaderx #1#2#3 #4\relax{% +\doind {fn}{\code{#3}}% Make entry in function index +\begingroup +\normalparens % notably, turn off `&' magic, which prevents +% at least some C++ text from working +\defname {\defheaderxcond#2\relax$$$#3}{#1}% +\deftypefunargs {#4}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defmac == @deffn Macro + +\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} + +\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{\putwordDefmac}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defspec == @deffn Special Form + +\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} + +\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{\putwordDefspec}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defop CATEGORY CLASS OPERATION ARG... +% +\def\defop #1 {\def\defoptype{#1}% +\defopparsebody\Edefop\defopx\defopheader\defoptype} +% +\def\defopheader #1#2#3{% +\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index +\begingroup\defname {#2}{\defoptype\ \putwordon\ #1}% +\defunargs {#3}\endgroup % +} + +% @deftypemethod CLASS RETURN-TYPE METHOD ARG... +% +\def\deftypemethod{% + \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} +% +% #1 is the class name, #2 the data type, #3 the method name, #4 the args. +\def\deftypemethodheader#1#2#3#4{% + \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index + \begingroup + \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}% + \deftypefunargs{#4}% + \endgroup +} + +% @deftypeivar CLASS TYPE VARNAME +% +\def\deftypeivar{% + \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader} +% +% #1 is the class name, #2 the data type, #3 the variable name. +\def\deftypeivarheader#1#2#3{% + \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index + \begingroup + \defname{#3}{\putwordInstanceVariableof\ \code{#1}}% + \defvarargs{#3}% + \endgroup +} + +% @defmethod == @defop Method +% +\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} +% +% #1 is the class name, #2 the method name, #3 the args. +\def\defmethodheader#1#2#3{% + \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index + \begingroup + \defname{#2}{\putwordMethodon\ \code{#1}}% + \defunargs{#3}% + \endgroup +} + +% @defcv {Class Option} foo-class foo-flag + +\def\defcv #1 {\def\defcvtype{#1}% +\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} + +\def\defcvarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index +\begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}% +\defvarargs {#3}\endgroup % +} + +% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME +% +\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} +% +\def\defivarheader#1#2#3{% + \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index + \begingroup + \defname{#2}{\putwordInstanceVariableof\ #1}% + \defvarargs{#3}% + \endgroup +} + +% @defvar +% First, define the processing that is wanted for arguments of @defvar. +% This is actually simple: just print them in roman. +% This must expand the args and terminate the paragraph they make up +\def\defvarargs #1{\normalparens #1% +\interlinepenalty=10000 +\endgraf\nobreak\vskip -\parskip\nobreak} + +% @defvr Counter foo-count + +\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} + +\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% +\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} + +% @defvar == @defvr Variable + +\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} + +\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{\putwordDefvar}% +\defvarargs {#2}\endgroup % +} + +% @defopt == @defvr {User Option} + +\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} + +\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{\putwordDefopt}% +\defvarargs {#2}\endgroup % +} + +% @deftypevar int foobar + +\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} + +% #1 is the data type. #2 is the name, perhaps followed by text that +% is actually part of the data type, which should not be put into the index. +\def\deftypevarheader #1#2{% +\dovarind#2 \relax% Make entry in variables index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypevar}% +\interlinepenalty=10000 +\endgraf\nobreak\vskip -\parskip\nobreak +\endgroup} +\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} + +% @deftypevr {Global Flag} int enable + +\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} + +\def\deftypevrheader #1#2#3{\dovarind#3 \relax% +\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} +\interlinepenalty=10000 +\endgraf\nobreak\vskip -\parskip\nobreak +\endgroup} + +% Now define @deftp +% Args are printed in bold, a slight difference from @defvar. + +\def\deftpargs #1{\bf \defvarargs{#1}} + +% @deftp Class window height width ... + +\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} + +\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% +\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} + +% These definitions are used if you use @defunx (etc.) +% anywhere other than immediately after a @defun or @defunx. +% +\def\defcvx#1 {\errmessage{@defcvx in invalid context}} +\def\deffnx#1 {\errmessage{@deffnx in invalid context}} +\def\defivarx#1 {\errmessage{@defivarx in invalid context}} +\def\defmacx#1 {\errmessage{@defmacx in invalid context}} +\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}} +\def\defoptx #1 {\errmessage{@defoptx in invalid context}} +\def\defopx#1 {\errmessage{@defopx in invalid context}} +\def\defspecx#1 {\errmessage{@defspecx in invalid context}} +\def\deftpx#1 {\errmessage{@deftpx in invalid context}} +\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}} +\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}} +\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}} +\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}} +\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}} +\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}} +\def\defunx#1 {\errmessage{@defunx in invalid context}} +\def\defvarx#1 {\errmessage{@defvarx in invalid context}} +\def\defvrx#1 {\errmessage{@defvrx in invalid context}} + + +\message{macros,} +% @macro. + +% To do this right we need a feature of e-TeX, \scantokens, +% which we arrange to emulate with a temporary file in ordinary TeX. +\ifx\eTeXversion\undefined + \newwrite\macscribble + \def\scanmacro#1{% + \begingroup \newlinechar`\^^M + % Undo catcode changes of \startcontents and \doprintindex + \catcode`\@=0 \catcode`\\=12 \escapechar=`\@ + % Append \endinput to make sure that TeX does not see the ending newline. + \toks0={#1\endinput}% + \immediate\openout\macscribble=\jobname.tmp + \immediate\write\macscribble{\the\toks0}% + \immediate\closeout\macscribble + \let\xeatspaces\eatspaces + \input \jobname.tmp + \endgroup +} +\else +\def\scanmacro#1{% +\begingroup \newlinechar`\^^M +% Undo catcode changes of \startcontents and \doprintindex +\catcode`\@=0 \catcode`\\=12 \escapechar=`\@ +\let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup} +\fi + +\newcount\paramno % Count of parameters +\newtoks\macname % Macro name +\newif\ifrecursive % Is it recursive? +\def\macrolist{} % List of all defined macros in the form + % \do\macro1\do\macro2... + +% Utility routines. +% Thisdoes \let #1 = #2, except with \csnames. +\def\cslet#1#2{% +\expandafter\expandafter +\expandafter\let +\expandafter\expandafter +\csname#1\endcsname +\csname#2\endcsname} + +% Trim leading and trailing spaces off a string. +% Concepts from aro-bend problem 15 (see CTAN). +{\catcode`\@=11 +\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} +\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} +\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} +\def\unbrace#1{#1} +\unbrace{\gdef\trim@@@ #1 } #2@{#1} +} + +% Trim a single trailing ^^M off a string. +{\catcode`\^^M=12\catcode`\Q=3% +\gdef\eatcr #1{\eatcra #1Q^^MQ}% +\gdef\eatcra#1^^MQ{\eatcrb#1Q}% +\gdef\eatcrb#1Q#2Q{#1}% +} + +% Macro bodies are absorbed as an argument in a context where +% all characters are catcode 10, 11 or 12, except \ which is active +% (as in normal texinfo). It is necessary to change the definition of \. + +% It's necessary to have hard CRs when the macro is executed. This is +% done by making ^^M (\endlinechar) catcode 12 when reading the macro +% body, and then making it the \newlinechar in \scanmacro. + +\def\macrobodyctxt{% + \catcode`\~=12 + \catcode`\^=12 + \catcode`\_=12 + \catcode`\|=12 + \catcode`\<=12 + \catcode`\>=12 + \catcode`\+=12 + \catcode`\{=12 + \catcode`\}=12 + \catcode`\@=12 + \catcode`\^^M=12 + \usembodybackslash} + +\def\macroargctxt{% + \catcode`\~=12 + \catcode`\^=12 + \catcode`\_=12 + \catcode`\|=12 + \catcode`\<=12 + \catcode`\>=12 + \catcode`\+=12 + \catcode`\@=12 + \catcode`\\=12} + +% \mbodybackslash is the definition of \ in @macro bodies. +% It maps \foo\ => \csname macarg.foo\endcsname => #N +% where N is the macro parameter number. +% We define \csname macarg.\endcsname to be \realbackslash, so +% \\ in macro replacement text gets you a backslash. + +{\catcode`@=0 @catcode`@\=@active + @gdef@usembodybackslash{@let\=@mbodybackslash} + @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} +} +\expandafter\def\csname macarg.\endcsname{\realbackslash} + +\def\macro{\recursivefalse\parsearg\macroxxx} +\def\rmacro{\recursivetrue\parsearg\macroxxx} + +\def\macroxxx#1{% + \getargs{#1}% now \macname is the macname and \argl the arglist + \ifx\argl\empty % no arguments + \paramno=0% + \else + \expandafter\parsemargdef \argl;% + \fi + \if1\csname ismacro.\the\macname\endcsname + \message{Warning: redefining \the\macname}% + \else + \expandafter\ifx\csname \the\macname\endcsname \relax + \else \errmessage{The name \the\macname\space is reserved}\fi + \global\cslet{macsave.\the\macname}{\the\macname}% + \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% + % Add the macroname to \macrolist + \toks0 = \expandafter{\macrolist\do}% + \xdef\macrolist{\the\toks0 + \expandafter\noexpand\csname\the\macname\endcsname}% + \fi + \begingroup \macrobodyctxt + \ifrecursive \expandafter\parsermacbody + \else \expandafter\parsemacbody + \fi} + +\def\unmacro{\parsearg\unmacroxxx} +\def\unmacroxxx#1{% + \if1\csname ismacro.#1\endcsname + \global\cslet{#1}{macsave.#1}% + \global\expandafter\let \csname ismacro.#1\endcsname=0% + % Remove the macro name from \macrolist + \begingroup + \edef\tempa{\expandafter\noexpand\csname#1\endcsname}% + \def\do##1{% + \def\tempb{##1}% + \ifx\tempa\tempb + % remove this + \else + \toks0 = \expandafter{\newmacrolist\do}% + \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}% + \fi}% + \def\newmacrolist{}% + % Execute macro list to define \newmacrolist + \macrolist + \global\let\macrolist\newmacrolist + \endgroup + \else + \errmessage{Macro #1 not defined}% + \fi +} + +% This makes use of the obscure feature that if the last token of a +% is #, then the preceding argument is delimited by +% an opening brace, and that opening brace is not consumed. +\def\getargs#1{\getargsxxx#1{}} +\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} +\def\getmacname #1 #2\relax{\macname={#1}} +\def\getmacargs#1{\def\argl{#1}} + +% Parse the optional {params} list. Set up \paramno and \paramlist +% so \defmacro knows what to do. Define \macarg.blah for each blah +% in the params list, to be ##N where N is the position in that list. +% That gets used by \mbodybackslash (above). + +% We need to get `macro parameter char #' into several definitions. +% The technique used is stolen from LaTeX: let \hash be something +% unexpandable, insert that wherever you need a #, and then redefine +% it to # just before using the token list produced. +% +% The same technique is used to protect \eatspaces till just before +% the macro is used. + +\def\parsemargdef#1;{\paramno=0\def\paramlist{}% + \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} +\def\parsemargdefxxx#1,{% + \if#1;\let\next=\relax + \else \let\next=\parsemargdefxxx + \advance\paramno by 1% + \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname + {\xeatspaces{\hash\the\paramno}}% + \edef\paramlist{\paramlist\hash\the\paramno,}% + \fi\next} + +% These two commands read recursive and nonrecursive macro bodies. +% (They're different since rec and nonrec macros end differently.) + +\long\def\parsemacbody#1@end macro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% +\long\def\parsermacbody#1@end rmacro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% + +% This defines the macro itself. There are six cases: recursive and +% nonrecursive macros of zero, one, and many arguments. +% Much magic with \expandafter here. +% \xdef is used so that macro definitions will survive the file +% they're defined in; @include reads the file inside a group. +\def\defmacro{% + \let\hash=##% convert placeholders to macro parameter chars + \ifrecursive + \ifcase\paramno + % 0 + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\scanmacro{\temp}}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup\noexpand\scanmacro{\temp}}% + \else % many + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{\egroup\noexpand\scanmacro{\temp}}% + \fi + \else + \ifcase\paramno + % 0 + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \else % many + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \expandafter\noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \fi + \fi} + +\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} + +% \braceorline decides whether the next nonwhitespace character is a +% {. If so it reads up to the closing }, if not, it reads the whole +% line. Whatever was read is then fed to the next control sequence +% as an argument (by \parsebrace or \parsearg) +\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} +\def\braceorlinexxx{% + \ifx\nchar\bgroup\else + \expandafter\parsearg + \fi \next} + +% We mant to disable all macros during \shipout so that they are not +% expanded by \write. +\def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}% + \edef\next{\macrolist}\expandafter\endgroup\next} + + +% @alias. +\def\alias#1=#2{\gdef#1{#2}} + + +\message{cross references,} +% @xref etc. + +\newwrite\auxfile + +\newif\ifhavexrefs % True if xref values are known. +\newif\ifwarnedxrefs % True if we warned once that they aren't known. + +% @inforef is relatively simple. +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, + node \samp{\ignorespaces#1{}}} + +% @node's job is to define \lastnode. +\def\node{\ENVcheck\parsearg\nodezzz} +\def\nodezzz#1{\nodexxx [#1,]} +\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} +\let\nwnode=\node +\let\lastnode=\relax + +% The sectioning commands (@chapter, etc.) call these. +\def\donoderef{% + \ifx\lastnode\relax\else + \expandafter\expandafter\expandafter\setref{\lastnode}% + {Ysectionnumberandtype}% + \global\let\lastnode=\relax + \fi +} +\def\unnumbnoderef{% + \ifx\lastnode\relax\else + \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}% + \global\let\lastnode=\relax + \fi +} +\def\appendixnoderef{% + \ifx\lastnode\relax\else + \expandafter\expandafter\expandafter\setref{\lastnode}% + {Yappendixletterandtype}% + \global\let\lastnode=\relax + \fi +} + + +% @anchor{NAME} -- define xref target at arbitrary point. +% +{ \catcode`\@ = 11 +% From latex.ltx, to make @anchor truely invisible. +\newdimen\@savsk +\newcount\@savsf +\gdef\@bsphack{\relax + \ifhmode \@savsk\lastskip \@savsf\spacefactor \fi +} +\gdef\@esphack{\relax + \ifhmode \spacefactor\@savsf + \ifdim\@savsk>\z@ \ignorespaces \fi + \fi +} +\gdef\anchor#1{\@bsphack \setref{#1}{Ynothing}\@esphack} +} + +% \setref{NAME}{SNT} defines a cross-reference point NAME, namely +% NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have +% to set \indexdummies so commands such as @code in a section title +% aren't expanded. It would be nicer not to expand the titles in the +% first place, but there's so many layers that that is hard to do. +% +\def\setref#1#2{{% + \indexdummies + \ifpdf \pdfmkdest{#1}\fi + \dosetq{#1-title}{Ytitle}% + \dosetq{#1-pg}{Ypagenumber}% + \dosetq{#1-snt}{#2}% +}} + +% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is +% the node name, #2 the name of the Info cross-reference, #3 the printed +% node name, #4 the name of the Info file, #5 the name of the printed +% manual. All but the node name can be omitted. +% +\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} +\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup + \def\printedmanual{\ignorespaces #5}% + \def\printednodename{\ignorespaces #3}% + \setbox1=\hbox{\printedmanual}% + \setbox0=\hbox{\printednodename}% + \ifdim \wd0 = 0pt + % No printed node name was explicitly given. + \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax + % Use the node name inside the square brackets. + \def\printednodename{\ignorespaces #1}% + \else + % Use the actual chapter/section title appear inside + % the square brackets. Use the real section title if we have it. + \ifdim \wd1 > 0pt + % It is in another manual, so we don't have it. + \def\printednodename{\ignorespaces #1}% + \else + \ifhavexrefs + % We know the real title if we have the xref values. + \def\printednodename{\refx{#1-title}{}}% + \else + % Otherwise just copy the Info node name. + \def\printednodename{\ignorespaces #1}% + \fi% + \fi + \fi + \fi + % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifpdf + \leavevmode + \getfilename{#4}% + \ifnum\filenamelength>0 + \pdfannotlink attr{/Border [0 0 0]}% + goto file{\the\filename.pdf} name{#1@}% + \else + \pdfannotlink attr{/Border [0 0 0]}% + goto name{#1@}% + \fi + \BlueGreen + \fi + % + \ifdim \wd1 > 0pt + \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}% + \else + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\normalturnoffactive + % Only output a following space if the -snt ref is nonempty; for + % @unnumbered and @anchor, it won't be. + \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% + \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi + }% + % [mynode], + [\printednodename],\space + % page 3 + \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + \fi + \ifpdf \Black\pdfendlink \fi +\endgroup} + +% \dosetq is the interface for calls from other macros + +% Use \normalturnoffactive so that punctuation chars such as underscore +% and backslash work in node names. (\turnoffactive doesn't do \.) +\def\dosetq#1#2{% + {\let\folio=0% + \normalturnoffactive + \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}% + \iflinks + \next + \fi + }% +} + +% \internalsetq {foo}{page} expands into +% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} +% When the aux file is read, ' is the escape character + +\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} + +% Things to be expanded by \internalsetq + +\def\Ypagenumber{\folio} + +\def\Ytitle{\thissection} + +\def\Ynothing{} + +\def\Ysectionnumberandtype{% +\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % +\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\def\Yappendixletterandtype{% +\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% +\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\gdef\xreftie{'tie} + +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Non-3.0. +\else + \def\linenumber{\the\inputlineno:\space} +\fi + +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. + +\def\refx#1#2{% + \expandafter\ifx\csname X#1\endcsname\relax + % If not defined, say something at least. + \angleleft un\-de\-fined\angleright + \iflinks + \ifhavexrefs + \message{\linenumber Undefined cross reference `#1'.}% + \else + \ifwarnedxrefs\else + \global\warnedxrefstrue + \message{Cross reference values unknown; you must run TeX again.}% + \fi + \fi + \fi + \else + % It's defined, so just use it. + \csname X#1\endcsname + \fi + #2% Output the suffix in any case. +} + +% This is the macro invoked by entries in the aux file. +% +\def\xrdef#1{\begingroup + % Reenable \ as an escape while reading the second argument. + \catcode`\\ = 0 + \afterassignment\endgroup + \expandafter\gdef\csname X#1\endcsname +} + +% Read the last existing aux file, if any. No error if none exists. +\def\readauxfile{\begingroup + \catcode`\^^@=\other + \catcode`\^^A=\other + \catcode`\^^B=\other + \catcode`\^^C=\other + \catcode`\^^D=\other + \catcode`\^^E=\other + \catcode`\^^F=\other + \catcode`\^^G=\other + \catcode`\^^H=\other + \catcode`\^^K=\other + \catcode`\^^L=\other + \catcode`\^^N=\other + \catcode`\^^P=\other + \catcode`\^^Q=\other + \catcode`\^^R=\other + \catcode`\^^S=\other + \catcode`\^^T=\other + \catcode`\^^U=\other + \catcode`\^^V=\other + \catcode`\^^W=\other + \catcode`\^^X=\other + \catcode`\^^Z=\other + \catcode`\^^[=\other + \catcode`\^^\=\other + \catcode`\^^]=\other + \catcode`\^^^=\other + \catcode`\^^_=\other + \catcode`\@=\other + \catcode`\^=\other + % It was suggested to define this as 7, which would allow ^^e4 etc. + % in xref tags, i.e., node names. But since ^^e4 notation isn't + % supported in the main text, it doesn't seem desirable. Furthermore, + % that is not enough: for node names that actually contain a ^ + % character, we would end up writing a line like this: 'xrdef {'hat + % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first + % argument, and \hat is not an expandable control sequence. It could + % all be worked out, but why? Either we support ^^ or we don't. + % + % The other change necessary for this was to define \auxhat: + % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter + % and then to call \auxhat in \setq. + % + \catcode`\~=\other + \catcode`\[=\other + \catcode`\]=\other + \catcode`\"=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\$=\other + \catcode`\#=\other + \catcode`\&=\other + \catcode`+=\other % avoid \+ for paranoia even though we've turned it off + % Make the characters 128-255 be printing characters + {% + \count 1=128 + \def\loop{% + \catcode\count 1=\other + \advance\count 1 by 1 + \ifnum \count 1<256 \loop \fi + }% + }% + % The aux file uses ' as the escape (for now). + % Turn off \ as an escape so we do not lose on + % entries which were dumped with control sequences in their names. + % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ + % Reference to such entries still does not work the way one would wish, + % but at least they do not bomb out when the aux file is read in. + \catcode`\{=1 + \catcode`\}=2 + \catcode`\%=\other + \catcode`\'=0 + \catcode`\\=\other + % + \openin 1 \jobname.aux + \ifeof 1 \else + \closein 1 + \input \jobname.aux + \global\havexrefstrue + \global\warnedobstrue + \fi + % Open the new aux file. TeX will close it automatically at exit. + \openout\auxfile=\jobname.aux +\endgroup} + + +% Footnotes. + +\newcount \footnoteno + +% The trailing space in the following definition for supereject is +% vital for proper filling; pages come out unaligned when you do a +% pagealignmacro call if that space before the closing brace is +% removed. (Generally, numeric constants should always be followed by a +% space to prevent strange expansion errors.) +\def\supereject{\par\penalty -20000\footnoteno =0 } + +% @footnotestyle is meaningful for info output only. +\let\footnotestyle=\comment + +\let\ptexfootnote=\footnote + +{\catcode `\@=11 +% +% Auto-number footnotes. Otherwise like plain. +\gdef\footnote{% + \global\advance\footnoteno by \@ne + \edef\thisfootno{$^{\the\footnoteno}$}% + % + % In case the footnote comes at the end of a sentence, preserve the + % extra spacing after we do the footnote number. + \let\@sf\empty + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi + % + % Remove inadvertent blank space before typesetting the footnote number. + \unskip + \thisfootno\@sf + \footnotezzz +}% + +% Don't bother with the trickery in plain.tex to not require the +% footnote text as a parameter. Our footnotes don't need to be so general. +% +% Oh yes, they do; otherwise, @ifset and anything else that uses +% \parseargline fail inside footnotes because the tokens are fixed when +% the footnote is read. --karl, 16nov96. +% +\long\gdef\footnotezzz{\insert\footins\bgroup + % We want to typeset this text as a normal paragraph, even if the + % footnote reference occurs in (for example) a display environment. + % So reset some parameters. + \interlinepenalty\interfootnotelinepenalty + \splittopskip\ht\strutbox % top baseline for broken footnotes + \splitmaxdepth\dp\strutbox + \floatingpenalty\@MM + \leftskip\z@skip + \rightskip\z@skip + \spaceskip\z@skip + \xspaceskip\z@skip + \parindent\defaultparindent + % + % Hang the footnote text off the number. + \hang + \textindent{\thisfootno}% + % + % Don't crash into the line above the footnote text. Since this + % expands into a box, it must come within the paragraph, lest it + % provide a place where TeX can split the footnote. + \footstrut + \futurelet\next\fo@t +} +\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t + \else\let\next\f@t\fi \next} +\def\f@@t{\bgroup\aftergroup\@foot\let\next} +\def\f@t#1{#1\@foot} +\def\@foot{\strut\egroup} + +}%end \catcode `\@=11 + +% Set the baselineskip to #1, and the lineskip and strut size +% correspondingly. There is no deep meaning behind these magic numbers +% used as factors; they just match (closely enough) what Knuth defined. +% +\def\lineskipfactor{.08333} +\def\strutheightpercent{.70833} +\def\strutdepthpercent {.29167} +% +\def\setleading#1{% + \normalbaselineskip = #1\relax + \normallineskip = \lineskipfactor\normalbaselineskip + \normalbaselines + \setbox\strutbox =\hbox{% + \vrule width0pt height\strutheightpercent\baselineskip + depth \strutdepthpercent \baselineskip + }% +} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt} + +% @image. We use the macros from epsf.tex to support this. +% If epsf.tex is not installed and @image is used, we complain. +% +% Check for and read epsf.tex up front. If we read it only at @image +% time, we might be inside a group, and then its definitions would get +% undone and the next image would fail. +\openin 1 = epsf.tex +\ifeof 1 \else + \closein 1 + % Do not bother showing banner with post-v2.7 epsf.tex (available in + % doc/epsf.tex until it shows up on ctan). + \def\epsfannounce{\toks0 = }% + \input epsf.tex +\fi +% +% We will only complain once about lack of epsf.tex. +\newif\ifwarnednoepsf +\newhelp\noepsfhelp{epsf.tex must be installed for images to + work. It is also included in the Texinfo distribution, or you can get + it from ftp://tug.org/tex/epsf.tex.} +% +\def\image#1{% + \ifx\epsfbox\undefined + \ifwarnednoepsf \else + \errhelp = \noepsfhelp + \errmessage{epsf.tex not found, images will be ignored}% + \global\warnednoepsftrue + \fi + \else + \imagexxx #1,,,\finish + \fi +} +% +% Arguments to @image: +% #1 is (mandatory) image filename; we tack on .eps extension. +% #2 is (optional) width, #3 is (optional) height. +% #4 is just the usual extra ignored arg for parsing this stuff. +\def\imagexxx#1,#2,#3,#4\finish{% + \ifx\pdfoutput\undefined + % \epsfbox itself resets \epsf?size at each figure. + \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi + \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi + \begingroup + \catcode`\^^M = 5 % in case we're inside an example + % If the image is by itself, center it. + \ifvmode + \nobreak\bigskip + % Usually we'll have text after the image which will insert + % \parskip glue, so insert it here too to equalize the space + % above and below. + \nobreak\vskip\parskip + \nobreak + \centerline{\epsfbox{#1.eps}}% + \bigbreak + \else + % In the middle of a paragraph, no extra space. + \epsfbox{#1.eps}% + \fi + \endgroup + \else + \centerline{\pdfimage #1.pdf}% + \fi +} + + +\message{localization,} +% and i18n. + +% @documentlanguage is usually given very early, just after +% @setfilename. If done too late, it may not override everything +% properly. Single argument is the language abbreviation. +% It would be nice if we could set up a hyphenation file here. +% +\def\documentlanguage{\parsearg\dodocumentlanguage} +\def\dodocumentlanguage#1{% + \tex % read txi-??.tex file in plain TeX. + % Read the file if it exists. + \openin 1 txi-#1.tex + \ifeof1 + \errhelp = \nolanghelp + \errmessage{Cannot read language file txi-#1.tex}% + \let\temp = \relax + \else + \def\temp{\input txi-#1.tex }% + \fi + \temp + \endgroup +} +\newhelp\nolanghelp{The given language definition file cannot be found or +is empty. Maybe you need to install it? In the current directory +should work if nowhere else does.} + + +% @documentencoding should change something in TeX eventually, most +% likely, but for now just recognize it. +\let\documentencoding = \comment + + +% Page size parameters. +% +\newdimen\defaultparindent \defaultparindent = 15pt + +\chapheadingskip = 15pt plus 4pt minus 2pt +\secheadingskip = 12pt plus 3pt minus 2pt +\subsecheadingskip = 9pt plus 2pt minus 2pt + +% Prevent underfull vbox error messages. +\vbadness = 10000 + +% Don't be so finicky about underfull hboxes, either. +\hbadness = 2000 + +% Following George Bush, just get rid of widows and orphans. +\widowpenalty=10000 +\clubpenalty=10000 + +% Use TeX 3.0's \emergencystretch to help line breaking, but if we're +% using an old version of TeX, don't do anything. We want the amount of +% stretch added to depend on the line length, hence the dependence on +% \hsize. We call this whenever the paper size is set. +% +\def\setemergencystretch{% + \ifx\emergencystretch\thisisundefined + % Allow us to assign to \emergencystretch anyway. + \def\emergencystretch{\dimen0}% + \else + \emergencystretch = .15\hsize + \fi +} + +% Parameters in order: 1) textheight; 2) textwidth; 3) voffset; +% 4) hoffset; 5) binding offset; 6) topskip. Then whoever calls us can +% set \parskip and call \setleading for \baselineskip. +% +\def\internalpagesizes#1#2#3#4#5#6{% + \voffset = #3\relax + \topskip = #6\relax + \splittopskip = \topskip + % + \vsize = #1\relax + \advance\vsize by \topskip + \outervsize = \vsize + \advance\outervsize by 2\topandbottommargin + \pageheight = \vsize + % + \hsize = #2\relax + \outerhsize = \hsize + \advance\outerhsize by 0.5in + \pagewidth = \hsize + % + \normaloffset = #4\relax + \bindingoffset = #5\relax + % + \parindent = \defaultparindent + \setemergencystretch +} + +% @letterpaper (the default). +\def\letterpaper{{\globaldefs = 1 + \parskip = 3pt plus 2pt minus 1pt + \setleading{13.2pt}% + % + % If page is nothing but text, make it come out even. + \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}% +}} + +% Use @smallbook to reset parameters for 7x9.5 (or so) format. +\def\smallbook{{\globaldefs = 1 + \parskip = 2pt plus 1pt + \setleading{12pt}% + % + \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}% + % + \lispnarrowing = 0.3in + \tolerance = 700 + \hfuzz = 1pt + \contentsrightmargin = 0pt + \deftypemargin = 0pt + \defbodyindent = .5cm + % + \let\smalldisplay = \smalldisplayx + \let\smallexample = \smalllispx + \let\smallformat = \smallformatx + \let\smalllisp = \smalllispx +}} + +% Use @afourpaper to print on European A4 paper. +\def\afourpaper{{\globaldefs = 1 + \setleading{12pt}% + \parskip = 3pt plus 2pt minus 1pt + % + \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}% + % + \tolerance = 700 + \hfuzz = 1pt +}} + +% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin +% 29mm, hence bottom margin 28mm, nominal side margin 3cm. +\def\afourlatex{{\globaldefs = 1 + \setleading{13.6pt}% + % + \afourpaper + \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}% + % + \globaldefs = 0 +}} + +% Use @afourwide to print on European A4 paper in wide format. +\def\afourwide{% + \afourpaper + \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}% + % + \globaldefs = 0 +} + +% @pagesizes TEXTHEIGHT[,TEXTWIDTH] +% Perhaps we should allow setting the margins, \topskip, \parskip, +% and/or leading, also. Or perhaps we should compute them somehow. +% +\def\pagesizes{\parsearg\pagesizesxxx} +\def\pagesizesxxx#1{\pagesizesyyy #1,,\finish} +\def\pagesizesyyy#1,#2,#3\finish{{% + \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi + \globaldefs = 1 + % + \parskip = 3pt plus 2pt minus 1pt + \setleading{13.2pt}% + % + \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}% +}} + +% Set default to letter. +% +\letterpaper + + +\message{and turning on texinfo input format.} + +% Define macros to output various characters with catcode for normal text. +\catcode`\"=\other +\catcode`\~=\other +\catcode`\^=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode`\+=\other +\catcode`\$=\other +\def\normaldoublequote{"} +\def\normaltilde{~} +\def\normalcaret{^} +\def\normalunderscore{_} +\def\normalverticalbar{|} +\def\normalless{<} +\def\normalgreater{>} +\def\normalplus{+} +\def\normaldollar{$} + +% This macro is used to make a character print one way in ttfont +% where it can probably just be output, and another way in other fonts, +% where something hairier probably needs to be done. +% +% #1 is what to print if we are indeed using \tt; #2 is what to print +% otherwise. Since all the Computer Modern typewriter fonts have zero +% interword stretch (and shrink), and it is reasonable to expect all +% typewriter fonts to have this, we can check that font parameter. +% +\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} + +% Same as above, but check for italic font. Actually this also catches +% non-italic slanted fonts since it is impossible to distinguish them from +% italic fonts. But since this is only used by $ and it uses \sl anyway +% this is not a problem. +\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} + +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). +% Most of these we simply print from the \tt font, but for some, we can +% use math or other variants that look better in normal text. + +\catcode`\"=\active +\def\activedoublequote{{\tt\char34}} +\let"=\activedoublequote +\catcode`\~=\active +\def~{{\tt\char126}} +\chardef\hat=`\^ +\catcode`\^=\active +\def^{{\tt \hat}} + +\catcode`\_=\active +\def_{\ifusingtt\normalunderscore\_} +% Subroutine for the previous macro. +\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}} + +\catcode`\|=\active +\def|{{\tt\char124}} +\chardef \less=`\< +\catcode`\<=\active +\def<{{\tt \less}} +\chardef \gtr=`\> +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +\catcode`\$=\active +\def${\ifusingit{{\sl\$}}\normaldollar} +%\catcode 27=\active +%\def^^[{$\diamondsuit$} + +% Set up an active definition for =, but don't enable it most of the time. +{\catcode`\==\active +\global\def={{\tt \char 61}}} + +\catcode`+=\active +\catcode`\_=\active + +% If a .fmt file is being used, characters that might appear in a file +% name cannot be active until we have parsed the command line. +% So turn them off again, and have \everyjob (or @setfilename) turn them on. +% \otherifyactive is called near the end of this file. +\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} + +\catcode`\@=0 + +% \rawbackslashxx output one backslash character in current font +\global\chardef\rawbackslashxx=`\\ +%{\catcode`\\=\other +%@gdef@rawbackslashxx{\}} + +% \rawbackslash redefines \ as input to do \rawbackslashxx. +{\catcode`\\=\active +@gdef@rawbackslash{@let\=@rawbackslashxx }} + +% \normalbackslash outputs one backslash in fixed width font. +\def\normalbackslash{{\tt\rawbackslashxx}} + +% \catcode 17=0 % Define control-q +\catcode`\\=\active + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +@def@turnoffactive{@let"=@normaldoublequote +@let\=@realbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus +@let$=@normaldollar} + +@def@normalturnoffactive{@let"=@normaldoublequote +@let\=@normalbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus +@let$=@normaldollar} + +% Make _ and + \other characters, temporarily. +% This is canceled by @fixbackslash. +@otherifyactive + +% If a .fmt file is being used, we don't want the `\input texinfo' to show up. +% That is what \eatinput is for; after that, the `\' should revert to printing +% a backslash. +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput + +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\{ in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% Also back turn on active characters that might appear in the input +% file name, in case not using a pre-dumped format. +% +@gdef@fixbackslash{% + @ifx\@eatinput @let\ = @normalbackslash @fi + @catcode`+=@active + @catcode`@_=@active +} + +% Say @foo, not \foo, in error messages. +@escapechar = `@@ + +% These look ok in all fonts, so just make them not special. +@catcode`@& = @other +@catcode`@# = @other +@catcode`@% = @other + +@c Set initial fonts. +@textfonts +@rm + + +@c Local variables: +@c eval: (add-hook 'write-file-hooks 'time-stamp) +@c page-delimiter: "^\\\\message" +@c time-stamp-start: "def\\\\texinfoversion{" +@c time-stamp-format: "%:y-%02m-%02d.%H" +@c time-stamp-end: "}" +@c End: diff --git a/doc/tutorial1.gam b/doc/tutorial1.gam index e77309e..6642ca7 100644 --- a/doc/tutorial1.gam +++ b/doc/tutorial1.gam @@ -18,11 +18,11 @@ 3.P7f P4d [ White closes the bishop diagonal again. He plans to play ranging rook (the rook goes to 5, 4, 3 of 2b; a defensive strategy) and in that case - he*d better avoid an exchange of bishops. One of the reasons is that he + he'd better avoid an exchange of bishops. One of the reasons is that he will have problems developing his pieces without leaving holes for bishop drops. ] 4.S4h R3b 5.P3f S4b 6.K6h K6b -[ In general the rook play an important role in the attacks. It is wise +[ In general the rook plays an important role in the attacks. It is wise to move the king away from the area where the initial fights will be and both players act according to the Shogi proverb "keep the rook and king apart". ] @@ -34,13 +34,13 @@ move. ] 10... S5c 11.P1f P1d [ The advance of the edge pawns must be timed very well. The remark at - blacks tenth move applies here too: this move is good if black wants to - play a slow game, because it eleminates a future B1e. ] + black's tenth move applies here too: this move is good if black wants to + play a slow game, because it eliminates a future B1e. ] 12. P4f K8b 13.N3g S7b [ Black develops his knight in order to start an attack over the second, - third and fourth files. White strengthens his kings position and awaits + third and fourth files. White strengthens his king's position and awaits the attack. He aims at a counter attack as soon as black has broken - through into the white camp. Probably white*s breakthrough will take + through into the white camp. Probably white's breakthrough will take place later, but he has good compensation in the form of a stronger castle. This theme occurs very often in static rook versus ranging rook games. ] @@ -60,8 +60,8 @@ latter, black can play Px2c+ followed by +P3c. The disadvantage is the black "tokin" (=promoted pawn) that white will get in his camp; the advantage is that it will cost black two more moves to promote his - rook. Because white did not trust the result after engaging in a - "semeai" (=mutual attack) with 18... N4e would to give a positive + rook. Because white did not trust that the result after engaging in a + "semeai" (=mutual attack) with 18...N4e would to give a positive result, he captured the pawn on 2d. Making the right decision in moments like this often makes the difference between a win and a loss: miss one attacking chance and you will be forced to defend the whole @@ -69,7 +69,7 @@ can destroy all "aji" (=potential, meaning possibilities, threats) without getting anything in return. ] 19.Rx2d Nx4e 20.Nx4e Rx4e 21.R2a+ P*4g -[ Now it becomes clear why black*s 10.S6h was not good. Had this move +[ Now it becomes clear why black's 10.S6h was not good. Had this move been omitted, then white would not have had the time to play 13... S7b and after R2a+ the gold on 6a would hang. Thus black would have kept "sente" (=initiative). Instead of 21... P*4g B*6d is a very good move, @@ -101,11 +101,11 @@ illustrates the sharpness of Shogi: one move can make the difference between winning and losing. ] 26.P*4f Rx4f -[ This move eliminates white*s last chances. 26... R4b 27.+Rx4b Sx4b +[ This move eliminates white's last chances. 26... R4b 27.+Rx4b Sx4b 28.R*4a seems annoying, but after 28... B*3c 29.S7g B*3b white wins the rook and with his "tokin" on 3g there still is some hope. ] 27.N*6e +P4g -[ White cannot defend anymore, so he starts a desparate attack. Black +[ White cannot defend anymore, so he starts a desperate attack. Black does not lose the right track, however. ] 28.Nx5c+ +Px5h 29.+Nx6b +Px6h 30.Gx6h N*8f 31.Px8f B*6i 32.Gx6i R4h+ 33.N*6h +Rx6h 34.Gx6h S*8g 35.Kx8g N*9e 36.K7h Resigns diff --git a/doc/xshogi.6 b/doc/xshogi.6 new file mode 100644 index 0000000..1dfc857 --- /dev/null +++ b/doc/xshogi.6 @@ -0,0 +1,616 @@ +.TH xshogi 6 "Jan 29, 1993" "X Version 11" +.SH NAME +xshogi \- Xt/Athena user interface for gnushogi +.SH SYNOPSIS +.B xshogi [ options ] +.SH DESCRIPTION +.IR xshogi +provides an X11/Xt/Athena Widgets user interface for gnushogi. +With +.IR xshogi +you can play gnushogi, +set up arbitrary positions, +force variations, or watch +.IR xshogi +manage a game between two shogi programs. +Furthermore, it can be used as an interface between two players on +different displays. +.LP +.IR xshogi +can also be used as a shogi board to play out games. +It will read through a game file or allow a player to play +through a variation manually (force mode). +This is useful for keeping track of email postal games or browsing games +off the net. +.LP +After starting +.IR xshogi , +you can make moves by pressing mouse button 1 +while the cursor is over a square with your piece on it +and dragging the mouse to another square. +If the move is illegal, gnushogi will not allow it. +.IR xshogi +will then retract the move. + +.SH RULES +Shogi is a Japanese board game played by two players. +The object of the game is to capture the opponent's King. +Shogi is played on a nine-by-nine board. The vertical rows are called files, +the horizontal ones ranks or just rows. Each player has twenty pieces: +one King, two Gold Generals, two Silver Generals, two kNights, +two Lances, one Rook, one Bishop and nine Pawns. +The player moving up the board and making the first move is referred to as +black and his opponent white, although in Shogi sets all pieces have the +same colour. They are differentiated only in direction: pieces pointing +away from a player are his. The pieces lie flat on the board and have +their Japanese name written on them. + +.SS Moves +.TP 8 +.B King +one step in any direction per move +.TP 8 +.B "Gold General" +one step per move any way except diagonally backward (as a king but not diagonally backward) +.TP 8 +.B "Silver General" +one step per move forwards or diagonally (as a king but not sideways or vertically backward) +.TP 8 +.B Knight +one step to left or right, and two steps forward (the only piece which may jump over other pieces) +.TP 8 +.B Rook +moves vertically or horizontally any distance +.TP 8 +.B Bishop +moves diagonally any distance +.TP 8 +.B Lance +moves forward any distance +.TP 8 +.B Pawn +one step forward + +.SS Promotion +The three rows furthest away from a player are called the promotion zone. Apart +from the King and the Gold, any piece can be promoted to a more powerful piece +when it makes a move completely or partly in the promotion zone. So, when a +piece moves into, out of or fully inside the promotion zone it may be promoted +upon completion of its move. Promotion is optional, provided that the piece +still can make a legal move in case it is not promoted: if a Pawn or a Lance +move to the last row, or a Knight moves to either of the last two rows, it must +be promoted. In Shogi sets promoting a piece is done by turning this piece +upside down. Its promoted name is written on its other side. + +Apart from the King and the Gold General all pieces can promote. +After promotion their moves are as follows: +.TP 8 +.B + +Promoted Silver, promoted kNight, promoted Lance and promoted Pawn all +move as a Gold. +.TP 8 +.B + +The promoted Rook in addition to the moves of the unpromoted Rook can +move one step in the diagonal directions. It either moves like a Rook +or like a King. +.TP 8 +.B + +The promoted Bishop in addition to the moves of the unpromoted Bishop +can move one step horizontally or vertically. It either moves like a +Bishop or like a King. + +.SS Capturing and dropping pieces + +When one piece moves onto the same square as an opponent's piece, the +opponent's piece is captured. All pieces capture in the same way that they +move. Captured pieces become part of the capturer's force. In a later move, +instead of moving a piece on the board, a player may put a piece that he +has captured from his opponent back onto the board, in an empty square. +This is called dropping a piece. Pieces are always dropped unpromoted: if +a promoted piece is captured, it reverts to its unpromoted rank. +Pieces may be dropped on any empty square on the board with only three +restrictions: +.TP 8 +.B 1) +After dropping a piece it must be able to make a legal move. This applies +to Pawns, Knights or Lances. They may not be dropped onto a square from +which they will never be able to move. +.TP 8 +.B 2) +Attacking the King by dropping a Pawn on the square in front of him is not +allowed if the King cannot prevent being captured on the following move. +To use the Chess expression: checkmating the King with a Pawn drop is +prohibited. +.TP 8 +.B 3) +A pawn may only be dropped on a file (vertical row) if there is no other +unpromoted pawn of the same player on that file. + +.SS Draws + +The game of Shogi has very few draws (roughly 1 percent), mainly because of +the possibility to drop pieces. Draws cannot be offered and can arise from +two situations: +.TP 8 +.B 1) +A position (including the pieces in hand) occurs 4 times with the same +player to move ("Sennichite"). However, if this is caused by consecutive +checks (direct attacks on the King, threatening to capture it on the next +move) by one side, the player giving these checks loses the game. +.TP 8 +.B 2) +Both players have moved their King into the the promotion zone (or they +cannot be prevented to do so) and the Kings cannot be checkmated. In +that case the players may decide to count their pieces where the King does +not count, the Rook and Bishop count as 5 points, and all other pieces as +one point. Promotion is disregarded. If both players have at least 24 +points the game is a draw ("Jishogi"). If a player has less, he loses the +game. +.PP +Of course, a player can refuse to count pieces when he still has mating +chances or chances to gain material which would affect the outcome of the +counting. There is no strict rule about what to do if this is not the case, +but nonetheless a player refuses to count up (e.g. because he does not have +enough points for a draw). It has been generally accepted that in such a +case the game ends and the pieces are counted after one player has managed +to get all his pieces protected in the promotion zone. + +.SH OPTIONS +The following command line options also correspond to X resources +that you can set in your +.IR \&.Xdefaults +file. +.TP 8 +.B standard Xt options +.IR xshogi +accepts standard Xt options like -display, -geometry, and -iconic. +.TP 8 +.B -tc or -timeControl minutes[:seconds] +Amount of time for a set of moves determined by +.IR movesPerSession . +If this number of moves is played within the time control period, +.IR xshogi +resets the time clocks. +Default: 5 minutes. +.TP 8 +.B -mps or -movesPerSession moves +Number of moves in a time control period. +Default: 40 moves. +.TP 8 +.B -st or -searchTime minutes[:seconds] +Tell gnushogi to spend at most the given amount of time searching +for each of its moves. Without this option, gnushogi chooses +its search time based on the number of moves and amount of time +remaining until the next time control. +Setting this option also sets -clockMode to False. +.TP 8 +.B -sd or -searchDepth number +Tell gnushogi to look ahead at most the given number of moves when searching +for a move to make. Without this option, gnushogi chooses +its search depth based on the number of moves and amount of time +remaining until the next time control. +Setting this option also sets -clockMode to False. +.TP 8 +.B -clock or -clockMode "(True | False)" +Determines whether or not to use the clock. +If clockMode is False, the clock does not run, but the +side that is to play next is still highlighted. +.TP 8 +.B -td or -timeDelay seconds +Time delay between moves during "Load Game". +This doesn't have to be round numbers. +Try -td 0.4. Default: 1 second. +.TP 8 +.B -nsp or -noShogiProgram "(True | False)" +If this option is True, +.IR xshogi +acts as a passive shogiboard; it does not +try to start a shogi program, not even to check whether +moves made in Force mode are legal. +It also sets -clockMode to False. +Default: False. +.TP 8 +.B -fsp or -firstShogiProgram program +Name of first shogi program. +In matches between two machines, this program plays white. +Default: "gnushogi". +.TP 8 +.B -ssp or -secondShogiProgram program +Name of second shogi program, if needed. +In matches between two machines, this program plays black; otherwise +it is not started. +Default: "gnushogi". +.TP 8 +.B -fh or -firstHost host +Name of host the first shogi program plays on. +Default: "localhost". +.TP 8 +.B -sh or -secondHost host +Name of host the second shogi program plays on. +Default: "localhost". +.TP 8 +.B -rsh or -remoteShell shell_name +Some systems do not use rsh as the remote shell. +This option allows a user to name the remote shell command. +This should be done in the resource file. +.TP 8 +.B -mm or -matchMode "(False | Init | Position | Opening)" +Automatically run a game between +.IR firstShogiProgram +and +.IR secondShogiProgram . +If +.IR matchMode +is set to +.IR Init , +.IR xshogi +will start the game with the initial shogi position. +If +.IR matchMode +is set to +.IR Position , +.IR xshogi +will start the game with the position specified by the +.IR loadPositionFile +resource. +If +.IR matchMode +is set to +.IR Opening , +.IR xshogi +will play out the opening moves specified by the +.IR -loadGameFile +resource. +If the +.IR -saveGameFile +resource is set, a move record for the match will +be saved in the specified file. +Default: "False". +.TP 8 +.B -lgf or -loadGameFile file +Name of file to read a game record from. +Game files are found in the directory named by the SHOGIDIR environment +variable. If this variable is not set, the current directory is used +unless the file name starts with a /. +.TP 8 +.B -lpf or -loadPositionFile file +Name of file to read a game position from. +Position files are found in the directory named by the SHOGIDIR environment +variable. If this variable is not set, the current directory is used +unless the file name starts with a /. +.TP 8 +.B -sgf or -saveGameFile file +Name of file to save a game record to. +Game files are saved in the directory named by the SHOGIDIR environment +variable. If this variable is not set, the current directory is used +unless the file name starts with a /. +.TP 8 +.B -spf or -savePositionFile file +Name of file to save a game position to. +Position files are saved in the directory named by the SHOGIDIR environment +variable. If this variable is not set, the current directory is used +unless the file name starts with a /. +.TP 8 +.B -coords or -showCoords "(True | False)" +If this option is True, +.IR xshogi +displays algebraic coordinates along the board's left and bottom edges. +The default is False. The +.IR coordFont +resource specifies what font to use. +.TP 8 +.B -mono or -monoMode "(True | False)" +Determines whether +.IR xshogi +displays its pieces and squares with two colors or four. +You shouldn't have to specify monochrome. +.IR xshogi +will determine if this is necessary. +.TP 8 +.B -wpc or -blackPieceColor color +Color specification for black pieces +suitable for +.IR XParseColor (3X11). +Default: #FFFFCC. +These colors look good on a DEC workstation. +If you need different colors, try using the +.IR xcolors +application. Source for +.IR xcolors +can be found in the X11/R4 contrib directory. +.TP 8 +.B -bpc or -whitePieceColor color +Same for white pieces. +Default: #202020. +.TP 8 +.B -lsc or -lightSquareColor color +Same for light squares. +Default: #C8C365. +.TP 8 +.B -dsc or -darkSquareColor color +Same for dark squares. +Default: #77A26D. +.TP 8 +.B -wps or -westernPieceSet (True | False) +Choose the Western style piece set. +.TP 8 +.B -npb or -normalPawnBitmap file +.PD 0 +.TP 8 +.B -nnb or -normalKnightBitmap file +.TP 8 +.B -nbb or -normalBishopBitmap file +.TP 8 +.B -nrb or -normalRookBitmap file +.TP 8 +.B -nkb or -normalKingBitmap file +Names of the bitmap files for the bitmap piece icons. +.PD + +.PD 0 +.TP 8 +.B -rpb or -reversePawnBitmap file +.TP 8 +.B -rnb or -reverseKnightBitmap file +.TP 8 +.B -rbb or -reverseBishopBitmap file +.TP 8 +.B -rrb or -reverseRookBitmap file +.TP 8 +.B -rkb or -reverseKingBitmap file +Names of the bitmap files for the outline piece icons. +.PD +.TP 8 +.B -debug or -debugMode "(True | False)" +Turns on debugging printout. +.SH RESOURCES +.TP 8 +.B initString +The actual string that is sent to initialize the shogi program can be +set from .Xdefaults. It can't be set from the command line because of +syntax problems. The default value is "new\\nbeep\\nrandom\\neasy\\n". +The "new" and "beep" commands are required. +You can remove the "random" command if you +like; including it causes gnushogi to randomize its move selection slightly so +that it doesn't play the same moves in every game. +Even without "random", gnushogi +randomizes its choice of moves from its opening book. +You can also remove "easy" if you like; including it toggles easy mode +.IR off , +causing gnushogi to think on your time. +That is, if "easy" is included in the initString, gnushogi thinks +on your time; if not, it does not. (Yes, this does seem backwards, doesn't +it.) +You can also try adding other commands to the initString; see the gnushogi +documentation for details. +.TP 8 +.B blackString and whiteString +These resources control what is sent when the Machine Black and Machine White +buttons are selected. This is mostly for compatibility with obsolete versions +of gnushogi. +.LP +Alternate bitmaps for piece icons can be specified +either by choosing one of the built-in sets or with +the file name resources described above. +There are three built-in sets of piece bitmaps available, +large (the default), medium, or small. +It is easiest to select the set you prefer in the .Xdefaults file: +.sp 1 +.br +XShogi*boardSize: Medium +.LP +The font used for button labels and comments can be changed in +the .Xdefaults file. You may want to choose a smaller +font if you are using the small pieces: +.sp 1 +.br +XShogi*font: helvetica_oblique12 +.LP +The font used for coordinates (when the +.IR showCoords +option is True) can be set similarly: +.sp 1 +.br +XShogi*coordFont: helvetica_10 +.LP +If you are using a grayscale monitor, try setting the colors to: +.sp 1 +.br +XShogi*blackPieceColor: gray100 +.br +XShogi*whitePieceColor: gray0 +.br +XShogi*lightSquareColor: gray60 +.br +XShogi*darkSquareColor: gray40 +.SH COMMAND BUTTONS AND KEYS +.TP 8 +.B Quit +Quits +.IR xshogi . +Q or q is a keyboard equivalent. +.TP 8 +.B Reset +Resets +.IR xshogi +to the beginning of a shogi game. +It also deselects any game or position files. +.TP 8 +.B Flip View +inverts the view of the shogi board. +.TP 8 +.B Hint +displays a move hint from gnushogi. +.TP 8 +.B Load Game +plays a game from a record file. +If no file is specified a popup dialog asks for a filename. +Game files are found in the directory named by the SHOGIDIR environment +variable. If this variable is not declared then the current directory is used +unless the file name starts with a /. +G or g is a keyboard equivalent. +The game file parser will accept almost any file that contains +moves in algebraic notation. +If the first line begins with `#', it +is assumed to be a title and is displayed. +Text enclosed in parentheses or square brackets is assumed to be +commentary and is displayed in a pop-up window. +Any other text in the file is ignored. +.TP 8 +.B Load Position +sets up a position from a position file. +If no file is specified a popup dialog asks for a filename. +Position files are found in the directory named by the SHOGIDIR environment +variable. If this variable is not declared then the current directory is used +unless the file name starts with a /. +Position files must be in the format that the Save Position command +writes. +.TP 8 +.B Save Game +saves a game to a record file. +If no file is specified a popup dialog asks for a filename. +If the filename exists, the user is asked whether the current game record +is be appended to this file or if the file should be replaced. +Game files are saved in the directory named by the SHOGIDIR environment +variable. If this variable is not declared then the current directory is used +unless the file name starts with a /. +Game files are human-readable, and can also be read back by +the Load Game command. Furthermore, they are accepted as gnushogi text bookfiles. +.TP 8 +.B Save Position +saves a position to a position file. +If no file is specified a popup dialog asks for a filename. +Position files are saved in the directory named by the SHOGIDIR environment +variable. If this variable is not declared then the current directory is used +unless the file name starts with a /. +Position files are human-readable, and can also be read back by +the Load Position command. +.TP 8 +.B Machine White +forces gnushogi to play white. +.TP 8 +.B Machine Black +forces gnushogi to play black. +.TP 8 +.B Force Moves +forces a series of moves. That is, gnushogi stops playing +and xshogi allows you to make moves for both white and black. +.TP 8 +.B Two Machines +plays a game between two computer programs. +.TP 8 +.B Forward +moves forward through a series of remembered moves. +F or f is a keyboard equivalent. +.TP 8 +.B Backward +moves backward through a series of remembered moves. +As a side effect, puts xshogi into Force Moves mode. +B or b is a keyboard equivalent. +.TP 8 +.B Pause +pauses the clocks or (in Load Game mode) pauses the game being loaded. +Press Pause again to continue. +P or p is a keyboard equivalent. +.TP 8 +.B Edit Position +lets you set up an arbitrary board position. +Use mouse button 1 to drag pieces to new squares, or to +delete a piece by dragging it off the board or dragging an empty square +on top of it. To drop a new piece on a square, press mouse button 2 or 3 +over the square. This brings up a menu of black pieces (button 2) or white +pieces (button 3). Additional menu choices let you empty the square or +clear the board. You can set the side to play next +by clicking on the Black or White indicator at the top of the screen. +.TP 8 +.B Challenge +allows to make a two display game between two human players. +Enter the display you want to connect to. If you are allowed to +connect, a new board is displayed at the remote display. +Challenge mode can only be stopped by pressing "quit". +.TP 8 +.B Select Level +allows to reset the clocks for both players. +Enter the number of moves and the number of minutes in which the +moves should be done. +.TP 8 +.B Move NOW +force computer to stop thinking and to make the current best move. +.TP 8 +.B Iconify +I, i, C or c iconifies +.IR xshogi . +.SH SEE ALSO +.IR gnushogi (6) +.SH LIMITATIONS +If you press the Pause button during gnushogi's turn, +.IR xshogi +will stop the clocks, +but gnushogi will still make a move. +.LP +After a mate or draw when playing against gnushogi, if you back up with +the Backward button, the clocks are reset (because +gnushogi has exited and must +be restarted). +.LP +Some +.IR xshogi +functions may not work with versions of gnushogi earlier +than 1.1, patchlevel 02. +.LP +The game parser recognizes only algebraic notation. +.SH AUTHORS +Original authors of XBoard: Chris Sears and Dan Sears. +.LP +Enhancements for XBoard (Version 2.0): Tim Mann. +.LP +Conversion to XShogi (Version 1.1): Matthias Mutz. +.SH COPYRIGHT +XShogi borrows its piece bitmaps from CRANES Shogi. +.LP +Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. +Enhancements Copyright 1992 Free Software Foundation, Inc. +Enhancements Copyright 1993 Matthias Mutz +.LP +The following terms apply to Digital Equipment Corporation's copyright +interest in XBoard: +.LP +.RS +All Rights Reserved +.LP +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. +.LP +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. +.RE +.LP +The following terms apply to the enhanced version of XShogi distributed +by the Free Software Foundation: +.LP +.RS +This file is part of XSHOGI. +.LP +XSHOGI is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY. No author or distributor accepts responsibility to anyone for +the consequences of using it or for whether it serves any particular +purpose or works at all, unless he says so in writing. Refer to the XSHOGI +General Public License for full details. +.LP +Everyone is granted permission to copy, modify and redistribute XSHOGI, but +only under the conditions described in the XSHOGI General Public License. A +copy of this license is supposed to have been given to you along with +XSHOGI so you can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice and this +notice must be preserved on all copies. +.RE diff --git a/gnushogi/Makefile.in b/gnushogi/Makefile.in new file mode 100644 index 0000000..55b7aea --- /dev/null +++ b/gnushogi/Makefile.in @@ -0,0 +1,284 @@ +# +# Makefile for GNU Shogi +# +# Copyright (c) 1993, 1994 Matthias Mutz +# Copyright (c) 1998, 1999 Michael Vanier and the Free Software Foundation +# +# GNU Shogi is based on GNU Chess +# Copyright (c) 1992 Free Software Foundation +# +# This file is part of GNU Shogi. +# +# GNU Shogi is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either ../version 1, or (at your option) +# any later ../version. +# +# GNU Shogi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Shogi; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# + +# +# gnushogi is GNU shogi, for raw text, curses, or x output. +# pat2inc converts pattern textfile to "pattern.inc" include file. +# sizetest shows the memory usage of the main data structures. +# + +SHELL = /bin/sh +VERS = 1.3 +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +ROOT = .. + + +# Installation directory. +prefix = @prefix@ + +# Where the binaries live. +BINDIR = $(prefix)/bin + +# Where the language description, the book, and the +# persistent hashtable live. +LIBDIR = $(prefix)/lib/gnushogi + +# Where the man page goes. +MANDIR = $(prefix)/man/man6 + +# Where the info file goes. +INFODIR = $(prefix)/info + +# For _pow external +LIBS = -lm + +# Display routines. +LCURSES = -lcurses -ltermcap + + +# +# C compiler and compiler options. +# + +CC = @CC@ +CWARNINGS = @WARNINGS@ +CEXTRAFLAGS = @CEXTRAFLAGS@ +CFLAGS = @CFLAGS@ $(CEXTRAFLAGS) $(CWARNINGS) -I.. + + +# The hashfile is a record of positions seen. It is used by +# GNU Shogi to avoid making the same mistakes, a form of learning. + +HASH = -DHASHFILE=\"$(LIBDIR)/gnushogi.hsh\" + + +# The "book" is a record of the first few moves, for playing good +# moves easily and quickly, saving time, and irritating the human +# opponent. + +TEXTBOOK = -DBOOK=\"$(LIBDIR)/gnushogi.tbk\" +BINBOOK = -DBINBOOK=\"$(LIBDIR)/gnushogi.bbk\" + + +# The language file describes capabilities of the program. It may +# be useful for customizing gnushogi for non-English-speaking players. + +LANGF = -DLANGFILE=\"../misc/gnushogi.lng\" + + +# The pattern file contains various opening patterns. The program tries to +# obtain such a pattern in the opening stage. Sequences of opening +# patterns may be described in order to support the correct order of moves. + +PATTERN = -DPATTERNFILE=\"../misc/gnushogi.pat\" + + +all: + @echo No target specified. + + +# +# Source files. +# + +COMMONFILES = \ + attacks.o \ + book.o \ + commondsp.o \ + cursesdsp.o \ + dspwrappers.o \ + eval.o \ + genmove.o \ + globals.o \ + init.o \ + pattern.o \ + rawdsp.o \ + search.o \ + sysdeps.o \ + tcontrl.o \ + util.o + +GNUSHOGI_FILES = $(COMMONFILES) main.o + + +PAT2INCFILES = $(COMMONFILES) makepattern.o pat2inc.o + + +# +# Primary targets. +# + +gnushogi: + $(CC) $(CFLAGS) -o gnushogi $(GNUSHOGI_FILES) $(LCURSES) $(LIBS) + +pat2inc: + $(CC) $(CFLAGS) -o pat2inc $(PAT2INCFILES) $(LCURSES) $(LIBS) + +sizetest: + $(CC) $(CFLAGS) -o sizetest sizetest.o $(LIBS) + + +# +# Object files. +# + +# Common files. + +attacks.o: + $(CC) $(CFLAGS) -c attacks.c + +book.o: + $(CC) $(CFLAGS) $(TEXTBOOK) $(BINBOOK) -c book.c + +commondsp.o: + $(CC) $(CFLAGS) -c commondsp.c + +cursesdsp.o: + $(CC) $(CFLAGS) -c cursesdsp.c + +dspwrappers.o: + $(CC) $(CFLAGS) -c dspwrappers.c + +genmove.o: + $(CC) $(CFLAGS) -c genmove.c + +globals.o: + $(CC) $(CFLAGS) -c globals.c + +eval.o: + $(CC) $(CFLAGS) -c eval.c + +init.o: + $(CC) $(CFLAGS) $(LANGF) -c init.c + +main.o: + $(CC) $(CFLAGS) $(BINBOOK) -c main.c + +# To create "pattern.inc" with "pat2inc", the external +# pattern textfile must be used. + +makepattern.o: + $(CC) $(CFLAGS) $(PATTERN) -c makepattern.c + +pattern.o: + $(CC) $(CFLAGS) -c pattern.c + +rawdsp.o: + $(CC) $(CFLAGS) -c rawdsp.c + +search.o: + $(CC) $(CFLAGS) -c search.c + +sysdeps.o: + $(CC) $(CFLAGS) -c sysdeps.c + +tcontrl.o: + $(CC) $(CFLAGS) -c tcontrl.c + +util.o: + $(CC) $(CFLAGS) -c util.c + + +# Files specific to particular targets. + +pat2inc.o: + $(CC) $(CFLAGS) $(LANGF) $(BINBOOK) $(PATTERN) -c pat2inc.c + +sizetest.o: + $(CC) $(CFLAGS) -c sizetest.c + + +# +# Other targets. +# + +gnushogi.bbk: + @if [ -f ./gnushogi.bbk ]; then rm ./gnushogi.bbk; fi + echo quit > test + cat ../misc/gnushogi.tbk > _tmp_t + cat test | ./gnushogi -R -b _tmp_t -B ./gnushogi.bbk -S 8000 -P 40 3 0 + rm test _tmp_t + @echo + + +# +# Installation. +# + +install: gnushogi + strip gnushogi + $(INSTALL_PROGRAM) -d $(BINDIR) + $(INSTALL_PROGRAM) -d $(LIBDIR) + $(INSTALL_PROGRAM) -d $(MANDIR) + $(INSTALL_PROGRAM) -d $(INFODIR) + $(INSTALL_PROGRAM) gnushogi $(BINDIR) + $(INSTALL_DATA) $(ROOT)/doc/gnushogi.6 $(MANDIR) + $(INSTALL_DATA) $(ROOT)/doc/gnushogi.info* $(INFODIR) + $(INSTALL_DATA) gnushogi.bbk $(LIBDIR)/gnushogi.bbk + + +# +# Cleanup. +# + +CLEANFILES = *.o gnushogi sizetest pat2inc CLp* *.bbk + +clean: + @for file in $(CLEANFILES); do \ + if [ -f $$file ]; then rm $$file; fi; \ + done + + +# +# Dependencies. +# + +gnushogi: $(GNUSHOGI_FILES) +pat2inc: $(PAT2INCFILES) +sizetest: sizetest.o +attacks.o: attacks.c gnushogi.h ../version.h +book.o: book.c gnushogi.h ../version.h +commondsp.o: commondsp.c gnushogi.h ../version.h +cursesdsp.o: cursesdsp.c gnushogi.h ../version.h +dspwrappers.o: dspwrappers.c gnushogi.h ../version.h +genmove.o: genmove.c gnushogi.h ../version.h +globals.o: globals.c gnushogi.h ../version.h +eval.o: eval.c eval.h gnushogi.h ../version.h pattern.h +init.o: init.c gnushogi.h ../version.h pattern.h +main.o: main.c gnushogi.h ../version.h +makepattern.o: pattern.c gnushogi.h pattern.h +pattern.o: pattern.c gnushogi.h pattern.h pattern.inc +rawdsp.o: rawdsp.c gnushogi.h ../version.h +search.o: search.c gnushogi.h ../version.h +sysdeps.o: sysdeps.c gnushogi.h ../version.h +tcontrl.o: tcontrl.c gnushogi.h ../version.h +util.o: util.c gnushogi.h ../version.h +pat2inc.o: pat2inc.c pattern.h gnushogi.h +sizetest.o: sizetest.c gnushogi.h eval.h +gnushogi.bbk: gnushogi + diff --git a/gnushogi/TRANS.TBL b/gnushogi/TRANS.TBL new file mode 100644 index 0000000..17a8a33 --- /dev/null +++ b/gnushogi/TRANS.TBL @@ -0,0 +1,30 @@ +F ATTACKS.C;1 attacks.c +F BOOK.C;1 book.c +F BOOK.H;1 book.h +F COMMONDS.C;1 commondsp.c +F CURSESDS.C;1 cursesdsp.c +F CURSESDS.H;1 cursesdsp.h +F DEBUG.H;1 debug.h +F DSPWRAPP.C;1 dspwrappers.c +F DSPWRAPP.H;1 dspwrappers.h +F EVAL.C;1 eval.c +F EVAL.H;1 eval.h +F GENMOVE.C;1 genmove.c +F GLOBALS.C;1 globals.c +F GNUSHOGI.H;1 gnushogi.h +F INIT.C;1 init.c +F MAIN.C;1 main.c +F MAKEFILE.IN;1 Makefile.in +F MAKEPATT.C;1 makepattern.c +F OPTS.H;1 opts.h +F PAT2INC.C;1 pat2inc.c +F PATTERN.C;1 pattern.c +F PATTERN.H;1 pattern.h +F PATTERN.INC;1 pattern.inc +F RAWDSP.C;1 rawdsp.c +F RAWDSP.H;1 rawdsp.h +F SEARCH.C;1 search.c +F SIZETEST.C;1 sizetest.c +F SYSDEPS.C;1 sysdeps.c +F TCONTRL.C;1 tcontrl.c +F UTIL.C;1 util.c diff --git a/gnushogi/attacks.c b/gnushogi/attacks.c new file mode 100644 index 0000000..e70f358 --- /dev/null +++ b/gnushogi/attacks.c @@ -0,0 +1,254 @@ +/* + * FILE: attacks.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" + + +#define CHECK_DISTANCE + +/* + * See if any piece with color 'side' attacks sq. + * *blockable == attack could be blocked by drop + */ + +int +SqAttacked(short square, short side, short *blockable) +{ +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + + short u, ptyp; + + if (MatchSignature(threats_signature[side])) + { + *blockable = true; /* don't know */ + return Anyattack(side, square); + } + + /* + * First check neighbouring squares, + * then check Knights. + * then check Bishops, + * then (last) check Rooks, + */ + + *blockable = false; + + /* try a capture from direct neighboured squares */ + + ptyp = ptype[black][king]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, square); +#else + pdir = (*nextdir[ptyp])[square]; + u = pdir[square]; +#endif + + do + { + if (color[u] == side) /* can piece reach square in one step ? */ +#ifdef CHECK_DISTANCE + { + if (piece_distance(side, board[u], u, square) == 1) + return true; + } +#else + { + short v; + short ptypv = ptype[side][board[u]]; +#ifdef SAVE_NEXTPOS + short dv; + v = first_direction(ptypv, &dv, u); +#else + unsigned char *qdir; + qdir = (*nextdir[ptypv])[u]; + v = qdir[u]; +#endif + do + { + if (v == square) + return true; +#ifdef SAVE_NEXTPOS + v = next_direction(ptypv, &dv, u); +#else + v = qdir[v]; +#endif + } + while (v != u); + } +#endif + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, square); +#else + u = pdir[u]; +#endif + } + while (u != square); + + /* try a knight capture (using xside's knight moves) */ + + ptyp = ptype[side ^ 1][knight]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, square); +#else + pdir = (*nextdir[ptyp])[square]; + u = pdir[square]; +#endif + + do + { + if (color[u] == side && board[u] == knight) + return true; + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, square); +#else + u = pdir[u]; +#endif + } + while (u != square); + + *blockable = true; + + /* try a (promoted) bishop capture */ + + ptyp = ptype[black][bishop]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, square); +#else + ppos = (*nextpos[ptyp])[square]; + pdir = (*nextdir[ptyp])[square]; + u = ppos[square]; +#endif + + do + { + if (color[u] == neutral) +#ifdef SAVE_NEXTPOS + u = next_position(ptyp, &d, square, u); +#else + u = ppos[u]; +#endif + else + { + if (color[u] == side && (unpromoted[board[u]] == bishop)) + return true; + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, square); +#else + u = pdir[u]; +#endif + } + } + while (u != square); + + /* try a (promoted) rook capture */ + + ptyp = ptype[black][rook]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, square); +#else + ppos = (*nextpos[ptyp])[square]; + pdir = (*nextdir[ptyp])[square]; + u = ppos[square]; +#endif + + do + { + if (color[u] == neutral) +#ifdef SAVE_NEXTPOS + { + u = next_position(ptyp, &d, square, u); + } +#else + { + u = ppos[u]; + } +#endif + else + { + if (color[u] == side && (unpromoted[board[u]] == rook)) + return true; + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, square); +#else + u = pdir[u]; +#endif + } + } + while (u != square); + + /* try a lance capture (using xside's lance moves) */ + + ptyp = ptype[side ^ 1][lance]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, square); +#else + ppos = (*nextpos[ptyp])[square]; + u = ppos[square]; +#endif + + do + { + if (color[u] == neutral) +#ifdef SAVE_NEXTPOS + { + u = next_position(ptyp, &d, square, u); + } +#else + { + u = ppos[u]; + } +#endif + else + { + if ((color[u] == side) && (board[u] == lance)) + return true; + + u = square; + } + } + while (u != square); + + return false; +} + diff --git a/gnushogi/book.c b/gnushogi/book.c new file mode 100644 index 0000000..e379363 --- /dev/null +++ b/gnushogi/book.c @@ -0,0 +1,1067 @@ +/* + * FILE: book.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" + +#define O_BINARY 0 + +#if HAVE_UNISTD_H +/* Declarations of read(), write(), close(), and lseek(). */ +#include +#endif + +#if HAVE_FCNTL_H +#include +#endif + +#include "book.h" + +unsigned booksize = BOOKSIZE; +unsigned short bookmaxply = BOOKMAXPLY; +unsigned bookcount = 0; + +#ifdef BOOK +char *bookfile = BOOK; +#else +char *bookfile = NULL; +#endif + +#ifdef BINBOOK +char *binbookfile = BINBOOK; +#else +char *binbookfile = NULL; +#endif + +static char bmvstr[3][7]; + +static ULONG bhashbd; +static ULONG bhashkey; + + +/* + * Balgbr(f, t, flag) + * + * Generate move strings in different formats. + */ + +void +Balgbr(short f, short t, short flag) +{ + short promoted = false; + + if ((f & 0x80) != 0) + { + f &= 0x7f; + promoted = true; + } + + if (f > NO_SQUARES) + { + short piece; + piece = f - NO_SQUARES; + + if (f > (NO_SQUARES + NO_PIECES)) + piece -= NO_PIECES; + + flag = (dropmask | piece); + } + + if ((t & 0x80) != 0) + { + flag |= promote; + t &= 0x7f; + } + + if ((f == t) && ((f != 0) || (t != 0))) + { + /* + * error in algbr: FROM=TO=t + */ + + bmvstr[0][0] = bmvstr[1][0] = bmvstr[2][0] = '\0'; + } + else + { + if ((flag & dropmask) != 0) + { + /* bmvstr[0]: P*3c bmvstr[1]: P'3c */ + short piece = flag & pmask; + bmvstr[0][0] = pxx[piece]; + bmvstr[0][1] = '*'; + bmvstr[0][2] = cxx[column(t)]; + bmvstr[0][3] = rxx[row(t)]; + bmvstr[0][4] = bmvstr[2][0] = '\0'; + strcpy(bmvstr[1], bmvstr[0]); + bmvstr[1][1] = '\''; + } + else + { + if ((f != 0) || (t != 0)) + { + /* algebraic notation */ + /* bmvstr[0]: 7g7f bmvstr[1]: + * (+)P7g7f(+) bmvstr[2]: (+)P7f(+) */ + bmvstr[0][0] = cxx[column(f)]; + bmvstr[0][1] = rxx[row(f)]; + bmvstr[0][2] = cxx[column(t)]; + bmvstr[0][3] = rxx[row(t)]; + bmvstr[0][4] = '\0'; + + if (promoted) + { + bmvstr[1][0] = bmvstr[2][0] = '+'; + bmvstr[1][1] = bmvstr[2][1] = pxx[board[f]]; + strcpy(&bmvstr[1][2], &bmvstr[0][0]); + strcpy(&bmvstr[2][2], &bmvstr[0][2]); + } + else + { + bmvstr[1][0] = bmvstr[2][0] = pxx[board[f]]; + strcpy(&bmvstr[1][1], &bmvstr[0][0]); + strcpy(&bmvstr[2][1], &bmvstr[0][2]); + } + + if (flag & promote) + { + strcat(bmvstr[0], "+"); + strcat(bmvstr[1], "+"); + strcat(bmvstr[2], "+"); + } + } + else + { + bmvstr[0][0] = bmvstr[1][0] = bmvstr[2][0] = '\0'; + } + } + } +} + + + + +#ifndef QUIETBOOKGEN +void +bkdisplay(char *s, int cnt, int moveno) +{ + static short pnt; + struct leaf *node; + int r, c, l; + + pnt = TrPnt[2]; + printf("matches = %d\n", cnt); + printf("inout move is :%s: move number %d side %s\n", + s, moveno / 2 + 1, (moveno & 1) ? "white" : "black"); + +#ifndef SEMIQUIETBOOKGEN + printf("legal moves are \n"); + + while (pnt < TrPnt[3]) + { + node = &Tree[pnt++]; + + if (is_promoted[board[node->f]] ) + Balgbr(node->f | 0x80, node->t, (short) node->flags); + else + Balgbr(node->f, node->t, (short) node->flags); + + printf("%s %s %s\n", + bmvstr[0], bmvstr[1], bmvstr[2]); + } + + printf("\n current board is\n"); + + for (r = (NO_ROWS - 1); r >= 0; r--) + { + for (c = 0; c <= (NO_COLS - 1); c++) + { + char pc; + + l = locn(r, c); + pc = (is_promoted[board[l]] ? '+' : ' '); + + if (color[l] == neutral) + printf(" -"); + else if (color[l] == black) + printf("%c%c", pc, qxx[board[l]]); + else + printf("%c%c", pc, pxx[board[l]]); + } + + printf("\n"); + } + + printf("\n"); + { + short color; + + for (color = black; color <= white; color++) + { + short piece, c; + + printf((color == black) ? "black " : "white "); + + for (piece = pawn; piece <= king; piece++) + { + if ((c = Captured[color][piece])) + printf("%i%c ", c, pxx[piece]); + } + + printf("\n"); + }; + } +#endif /* SEMIQUIETBOOKGEN */ +} + +#endif /* QUIETBOOKGEN */ + + + +/* + * BVerifyMove(s, mv, moveno) + * + * Compare the string 's' to the list of legal moves available for the + * opponent. If a match is found, make the move on the board. + */ + +int +BVerifyMove(char *s, unsigned short *mv, int moveno) +{ + static short pnt, tempb, tempc, tempsf, tempst, cnt; + static struct leaf xnode; + struct leaf *node; + + *mv = 0; + cnt = 0; + MoveList(opponent, 2, -2, true); + pnt = TrPnt[2]; + + while (pnt < TrPnt[3]) + { + node = &Tree[pnt++]; + + if (is_promoted[board[node->f]] ) + Balgbr(node->f | 0x80, node->t, (short) node->flags); + else + Balgbr(node->f, node->t, (short) node->flags); + + if (strcmp(s, bmvstr[0]) == 0 || strcmp(s, bmvstr[1]) == 0 || + strcmp(s, bmvstr[2]) == 0) + { + cnt++; + xnode = *node; + } + } + + if (cnt == 1) + { + short blockable; + + MakeMove(opponent, &xnode, &tempb, + &tempc, &tempsf, &tempst, &INCscore); + + if (SqAttacked(PieceList[opponent][0], computer, &blockable)) + { + UnmakeMove(opponent, &xnode, &tempb, &tempc, &tempsf, &tempst); + /* Illegal move in check */ +#if !defined QUIETBOOKGEN + /* 077: "Illegal move (in check) %s" */ + printf(CP[77]); + printf("\n"); + bkdisplay(s, cnt, moveno); +#endif + return false; + } + else + { + *mv = (xnode.f << 8) | xnode.t; + + if (is_promoted[board[xnode.t]] ) + Balgbr(xnode.f | 0x80, xnode.t, false); + else + Balgbr(xnode.f, xnode.t, false); + + return true; + } + } + + /* Illegal move */ +#if !defined QUIETBOOKGEN + /* 075: "Illegal move (no match)%s\n" */ + printf(CP[75], s); + bkdisplay(s, cnt, moveno); +#endif + return false; +} + + + + +/* + * RESET() + * + * Reset the board and other variables to start a new game. + * + */ + +void +RESET(void) +{ + short l; + + flag.illegal = flag.mate = flag.post = flag.quit + = flag.reverse = flag.bothsides = flag.onemove = flag.force + = false; + + flag.material = flag.coords = flag.hash = flag.easy + = flag.beep = flag.rcptr + = true; + + flag.stars = flag.shade = flag.back = flag.musttimeout = false; + flag.gamein = false; + GenCnt = 0; + GameCnt = 0; + CptrFlag[0] = TesujiFlag[0] = false; + opponent = black; + computer = white; + + for (l = 0; l < NO_SQUARES; l++) + { + board[l] = Stboard[l]; + color[l] = Stcolor[l]; + Mvboard[l] = 0; + } + + ClearCaptured(); + InitializeStats(); + hashbd = hashkey = 0; +} + + + +static +int +Vparse (FILE * fd, USHORT *mv, USHORT *flags, USHORT side, int moveno) +{ + int c, i; + char s[255]; + + *flags = 0; + + while (true) + { + while (((c = getc(fd)) == ' ') + || (c == '!') || (c == '/') || (c == '\n')); + + if (c == '(') + { + /* amount of time spent for the last move */ + while (((c = getc(fd)) != ')') && (c != EOF)); + + if (c == ')') + { + while (((c = getc(fd)) == ' ') || (c == '\n')); + } + } + + if (c == '[') + { + /* comment for the actual game */ + while (((c = getc(fd))) != ']' && (c != EOF)); + + if (c == ']') + { + while (((c = getc(fd))) == ' ' || (c == '\n')); + } + } + + if (c == '\r') + continue; + + if (c == '#') + { + /* comment */ + do + { + c = getc(fd); + + if (c == '\r') + continue; + /* goes to end of line */ + + if (c == '\n') + return 0; + + if (c == EOF) + return -1; + } + while (true); + } + + s[i = 0] = (char) c; + + while ((c >= '0') && (c <= '9')) + { + c = getc(fd); + s[++i] = (char) c; + } + + if (c == '.') + { + while (((c = getc(fd)) == ' ') || (c == '.') || (c == '\n')); + s[i = 0] = (char) c; + } + + while (((c = getc(fd)) != '?') && (c != '!') && (c != ' ') + && (c != '(') && (c != '\n') && (c != '\t') && (c != EOF)) + { + if (c == '\r') + continue; + + if ((c != 'x') && (c != '-') && (c != ',') + && (c != ';') && (c != '=')) + { + s[++i] = (char) c; + } + } + + s[++i] = '\0'; + + if (c == '(') + { + while (((c = getc(fd)) != ')') && (c != EOF)); + + if (c == ')') + c = getc(fd); + } + + if (c == EOF) + return -1; + + if (s[0] == '#') + { + while ((c != '\n') && (c != EOF)) + c = getc(fd); + + if (c == EOF) + return -1; + else + return 0; + } + + if (strcmp(s, "draw") == 0) + continue; + else if (strcmp(s, "1-0") == 0) + continue; + else if (strcmp(s, "0-1") == 0) + continue; + else if (strcmp(s, "Resigns") == 0) + continue; + else if (strcmp(s, "Resigns.") == 0) + continue; + else if (strcmp(s, "Sennichite") == 0) + continue; + else if (strcmp(s, "Sennichite.") == 0) + continue; + else if (strcmp(s, "Jishogi") == 0) + continue; + else if (strcmp(s, "Jishogi.") == 0) + continue; + + bhashkey = hashkey; + bhashbd = hashbd; + + i = BVerifyMove(s, mv, moveno); + + if (c == '?') + { + /* Bad move, not for the program to play */ + *flags |= BADMOVE; /* Flag it ! */ + while (((c = getc(fd)) == '?') || (c == '!') || (c == '/')); + } +#ifdef EASY_OPENINGS + else if (c == '~') + { + /* Do not use by computer */ + *flags |= BADMOVE; /* Flag it ! */ + + while (((c = getc(fd)) == '?') || (c == '!') || (c == '/')); + } +#endif + else if (c == '!') + { + /* Good move */ + *flags |= GOODMOVE; /* Flag it ! */ + + while (((c = getc(fd)) == '?') || (c == '!') || (c == '/')); + } + else if (c == '\r') + { + c = getc(fd); + } + + if (c == '(' ) + while (((c = getc(fd)) != ')') && (c != EOF)); + + if (!i) + { + /* flush to start of next */ + while (((c = getc(fd)) != '#') && (c != EOF)); + + if (c == EOF) + { + return -1; + } + else + { + ungetc(c, fd); + return i; + } + } + + return i; + } +} + + +static struct gdxadmin ADMIN; +struct gdxadmin B; +static struct gdxdata DATA; + +/* lts(l) returns most significant 16 bits of l */ + +#if SIZEOF_LONG == 8 /* 64-bit long i.e. 8 bytes */ +# define lts(x) (USHORT)(((x >> 48) & 0xfffe) | side) +#else +# if defined USE_LTSIMP +static USHORT ltsimp(long x) +{ + USHORT n; + n = (((x >> 16) & 0xfffe)); + return n; +} +# define lts(x) (USHORT)(ltsimp(x) | side) +# else +# define lts(x) (USHORT)(((x >> 16)&0xfffe) | side) +# endif +#endif + + +/* #define HashValue(l) lts(l) */ +#define HashValue(l) (USHORT)(l & 0xffff) + + +static int gfd; +static ULONG currentoffset; + + +#define MAXOFFSET(B) ((B.booksize - 1) * sizeof_gdxdata + sizeof_gdxadmin) + +#define HashOffset(hashkey, B) \ +{ \ + currentoffset = ((ULONG)hashkey % B.booksize) \ + * sizeof_gdxdata + sizeof_gdxadmin; \ +} + + +#define NextOffset(B) \ +{ \ + currentoffset += sizeof_gdxdata; \ + if (currentoffset > B.maxoffset) \ + currentoffset = sizeof_gdxadmin; \ +} + + +#define WriteAdmin() \ +{ \ + lseek(gfd, 0, 0); \ + write(gfd, (char *)&ADMIN, sizeof_gdxadmin); \ +} + +#define WriteData() \ +{ \ + if (mustwrite ) \ + { \ + lseek(gfd, currentoffset, 0); \ + write(gfd, (char *)&DATA, sizeof_gdxdata); \ + mustwrite = false; \ + } \ +} + +static int ReadAdmin(void) +{ + lseek(gfd, 0, 0); + return (sizeof_gdxadmin == read(gfd, (char *)&ADMIN, sizeof_gdxadmin)); +} + +static int ReadData(struct gdxdata *DATA) +{ + lseek(gfd, currentoffset, 0); + return (sizeof_gdxdata == read(gfd, (char *)DATA, sizeof_gdxdata)); +} + + +/* + * GetOpenings() + * + * CHECKME: is this still valid esp. wrt gnushogi.book? + * + * Read in the Opening Book file and parse the algebraic notation for a move + * into an unsigned integer format indicating the from and to square. Create + * a linked list of opening lines of play, with entry->next pointing to the + * next line and entry->move pointing to a chunk of memory containing the + * moves. More Opening lines of up to 100 half moves may be added to + * gnushogi.book. But now it's a hashed table by position which yields a move + * or moves for each position. It no longer knows about openings per se only + * positions and recommended moves in those positions. + * + */ + +void +GetOpenings(void) +{ + short i; + int mustwrite = false, first; + unsigned short xside, side; + short c; + USHORT mv, flags; + unsigned int x; + unsigned int games = 0; + LONG collisions = 0; + char msg[80]; + + FILE *fd; + + if ((fd = fopen(bookfile, "r")) == NULL) + fd = fopen("gnushogi.tbk", "r"); + + if (fd != NULL) + { + /* yes add to book */ + /* open book as writer */ + gfd = open(binbookfile, O_RDONLY | O_BINARY); + + if (gfd >= 0) + { + if (ReadAdmin()) + { + B.bookcount = ADMIN.bookcount; + B.booksize = ADMIN.booksize; + B.maxoffset = ADMIN.maxoffset; + + if (B.booksize && !(B.maxoffset == MAXOFFSET(B))) + { + printf("bad format %s\n", binbookfile); + exit(1); + } + } + else + { + printf("bad format %s\n", binbookfile); + exit(1); + } + close(gfd); + gfd = open(binbookfile, O_RDWR | O_BINARY); + + } + else + { + gfd = open(binbookfile, O_RDWR | O_CREAT | O_BINARY, 0644); + + ADMIN.bookcount = B.bookcount = 0; + ADMIN.booksize = B.booksize = booksize; + B.maxoffset = ADMIN.maxoffset = MAXOFFSET(B); + DATA.hashbd = 0; + DATA.hashkey = 0; + DATA.bmove = 0; + DATA.flags = 0; + DATA.hint = 0; + DATA.count = 0; + write(gfd, (char *)&ADMIN, sizeof_gdxadmin); + printf("creating bookfile %s %ld %ld\n", + binbookfile, B.maxoffset, B.booksize); + + for (x = 0; x < B.booksize; x++) + { + write(gfd, (char *)&DATA, sizeof_gdxdata); + } + } + + if (gfd >= 0) + { + /* setvbuf(fd, buffr, _IOFBF, 2048); */ + side = black; + xside = white; + hashbd = hashkey = 0; + i = 0; + + while ((c = Vparse(fd, &mv, &flags, side, i)) >= 0) + { + if (c == 1) + { + /* + * If this is not the first move of an opening and + * if it's the first time we have seen it then + * save the next move as a hint. + */ + i++; + + if (i < bookmaxply + 2) + { + if (i > 1 && !(flags & BADMOVE)) + DATA.hint = mv; + + if (i < bookmaxply + 1) + { + /* + * See if this position and move already + * exist from some other opening. + */ + + WriteData(); + HashOffset(bhashkey, B); + first = true; + + while (true) + { + if (!ReadData(&DATA)) + break; /* corrupted binbook file */ + + if (DATA.bmove == 0) + break; /* free entry */ + + if (DATA.hashkey == HashValue(bhashkey) + && DATA.hashbd == bhashbd) + { + if (DATA.bmove == mv) + { + /* + * Yes, so just bump count - count + * is used to choose the opening + * move in proportion to its + * presence in the book. + */ + + DATA.count++; + DATA.flags |= flags; + mustwrite = true; + break; + } + else + { + if (first) + collisions++; + + if (DATA.flags & LASTMOVE) + { + DATA.flags &= (~LASTMOVE); + mustwrite = true; + WriteData(); + } + } + } + + NextOffset(B); + first = false; + } + + /* + * Doesn't exist so add it to the book. + */ + + if (!mustwrite) + { + B.bookcount++; + + if ((B.bookcount % 1000) == 0) + { + /* CHECKME: may want to get rid of this, + * especially for xshogi. */ + printf("%ld rec %d openings " + "processed\n", + B.bookcount, games); + } + + /* initialize a record */ + DATA.hashbd = bhashbd; + DATA.hashkey = HashValue(bhashkey); + DATA.bmove = mv; + DATA.flags = flags | LASTMOVE; + DATA.count = 1; + DATA.hint = 0; + mustwrite = true; + } + } + } + + computer = opponent; + opponent = computer ^ 1; + + xside = side; + side = side ^ 1; + } + else if (i > 0) + { + /* reset for next opening */ + games++; + WriteData(); + RESET(); + i = 0; + side = black; + xside = white; + + } + } + + WriteData(); + fclose(fd); + /* write admin rec with counts */ + ADMIN.bookcount = B.bookcount; + WriteAdmin(); + + close(gfd); + } + } + + if (binbookfile != NULL) + { + /* open book as reader */ + gfd = open(binbookfile, O_RDONLY | O_BINARY); + + if (gfd >= 0) + { + if (ReadAdmin() && (!ADMIN.booksize + || (ADMIN.maxoffset == MAXOFFSET(ADMIN)))) + { + B.bookcount = ADMIN.bookcount; + B.booksize = ADMIN.booksize; + B.maxoffset = ADMIN.maxoffset; + } + else + { + printf("bad format %s\n", binbookfile); + exit(1); + } + + } + else + { + B.bookcount = 0; + B.booksize = booksize; + + } + + /* 213: "Book used %d(%d)." */ + sprintf(msg, CP[213], B.bookcount, B.booksize); + ShowMessage(msg); + } + + /* Set everything back to start the game. */ + Book = BOOKFAIL; + RESET(); + + /* Now get ready to play .*/ + if (!B.bookcount) + { + /* 212: "Can't find book." */ + ShowMessage(CP[212]); + Book = 0; + } +} + + + +/* + * OpeningBook(hint, side) + * + * Go through each of the opening lines of play and check for a match with + * the current game listing. If a match occurs, generate a random + * number. If this number is the largest generated so far then the next + * move in this line becomes the current "candidate". After all lines are + * checked, the candidate move is put at the top of the Tree[] array and + * will be played by the program. Note that the program does not handle + * book transpositions. + */ + +int +OpeningBook(unsigned short *hint, short side) +{ + unsigned short r, m; + int possibles = TrPnt[2] - TrPnt[1]; + + gsrand((unsigned int) time((long *) 0)); + m = 0; + + /* + * Find all the moves for this position - count them and get their + * total count. + */ + + { + USHORT i, x; + USHORT rec = 0; + USHORT summ = 0; + USHORT h = 0, b = 0; + struct gdxdata OBB[128]; + + if (B.bookcount == 0) + { + Book--; + return false; + } + + x = 0; + HashOffset(hashkey, B); +#ifdef BOOKTEST + printf("looking for book move, bhashbd = 0x%lx bhashkey = 0x%x\n", + (ULONG)hashbd, HashValue(hashkey)); +#endif + while (true) + { + if (!ReadData(&OBB[x])) + break; + + if (OBB[x].bmove == 0) + break; + +#ifdef BOOKTEST + printf("compare with bhashbd = 0x%lx bhashkey = 0x%x\n", + OBB[x].hashbd, OBB[x].hashkey); +#endif + if ((OBB[x].hashkey == HashValue(hashkey)) + && (OBB[x].hashbd == (ULONG)hashbd)) + { + x++; + + if (OBB[x-1].flags & LASTMOVE) + break; + } + + NextOffset(B); + } + +#ifdef BOOKTEST + printf("%d book move(s) found.\n", x); +#endif + + if (x == 0) + { + Book--; + return false; + } + + for (i = 0; i < x; i++) + { + if (OBB[i].flags & BADMOVE) + { + m = OBB[i].bmove; + + /* Is the move in the MoveList? */ + for (b = TrPnt[1]; b < (unsigned) TrPnt[2]; b++) + { + if (((Tree[b].f << 8) | Tree[b].t) == m) + { + if (--possibles) + Tree[b].score = DONTUSE; + break; + } + } + } + else + { +#if defined BOOKTEST + char s[20]; + movealgbr(m = OBB[i].bmove, s); + printf("finding book move: %s\n", s); +#endif + summ += OBB[i].count; + } + } + + if (summ == 0) + { + Book--; + return false; + } + + r = (urand() % summ); + + for (i = 0; i < x; i++) + { + if (!(OBB[i].flags & BADMOVE)) + { + if (r < OBB[i].count) + { + rec = i; + break; + } + else + { + r -= OBB[i].count; + } + } + } + + h = OBB[rec].hint; + m = OBB[rec].bmove; + + /* Make sure the move is in the MoveList. */ + for (b = TrPnt[1]; b < (unsigned) TrPnt[2]; b++) + { + if (((Tree[b].f << 8) | Tree[b].t) == m) + { + Tree[b].flags |= book; + Tree[b].score = 0; + break; + } + } + + /* Make sure it's the best. */ + + pick(TrPnt[1], TrPnt[2] - 1); + + if (Tree[TrPnt[1]].score) + { + /* no! */ + Book--; + return false; + } + + /* Ok, pick up the hint and go. */ + *hint = h; + return true; + } + + Book--; + return false; +} + + + diff --git a/gnushogi/book.h b/gnushogi/book.h new file mode 100644 index 0000000..aec063f --- /dev/null +++ b/gnushogi/book.h @@ -0,0 +1,64 @@ +/* + * FILE: book.h + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#ifndef _BOOK_H_ +#define _BOOK_H_ + +struct gdxadmin +{ + ULONG bookcount; + ULONG booksize; + ULONG maxoffset; +}; + +extern struct gdxadmin B; + + +#define GOODMOVE 0x1000 +#define BADMOVE 0x0100 +#define LASTMOVE 0x0010 + +struct gdxdata +{ + ULONG hashbd; + USHORT hashkey; + USHORT bmove; + USHORT flags; /* flags BADMOVE, GOODMOVE, LASTMOVE */ + USHORT hint; + USHORT count; +}; + + +#define sizeof_gdxadmin sizeof(struct gdxadmin) +#define sizeof_gdxdata sizeof(struct gdxdata) + +#endif /* _BOOK_H_ */ + diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c new file mode 100644 index 0000000..73afb95 --- /dev/null +++ b/gnushogi/commondsp.c @@ -0,0 +1,2181 @@ +/* + * FILE: commondsp.c + * + * Common display routines for GNU Shogi. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" + +#if defined HAVE_GETTIMEOFDAY +#include +#endif + +char mvstr[4][6]; +char *InPtr; +int InBackground = false; + + +#include +#include + +#include +#include +#include + +#include + + +#if defined(BOOKTEST) + +void +movealgbr(short m, char *s) +{ + unsigned int f, t; + short piece = 0, flag = 0; + + if (m == 0) + { + strcpy(s, "none"); + return; + } + + f = (m >> 8) & 0x7f; + t = m & 0xff; + + if (f > NO_SQUARES) + { + piece = f - NO_SQUARES; + + if (piece > NO_PIECES) + piece -= NO_PIECES; + + flag = (dropmask | piece); + } + + if (t & 0x80) + { + flag |= promote; + t &= 0x7f; + } + + if (flag & dropmask) + { + *s = pxx[piece]; + s++; + *s = '*'; + s++; + *s = cxx[column(t)]; + s++; + *s = rxx[row(t)]; + s++; + } + else + { + *s = cxx[column(f)]; + s++; + *s = rxx[row(f)]; + s++; + *s = cxx[column(t)]; + s++; + *s = rxx[row(t)]; + s++; + + if (flag & promote) + { + *s = '+'; + s++; + } + } + + if (m & 0x8000) + { + *s = '?'; + s++; + } + + *s = '\0'; +} + +#endif /* BOOKTEST */ + + + + +/* + * Generate move strings in different formats. + */ + +void +algbr(short f, short t, short flag) +{ + if (f > NO_SQUARES) + { + short piece; + + piece = f - NO_SQUARES; + + if (f > (NO_SQUARES + NO_PIECES)) + piece -= NO_PIECES; + + flag = (dropmask | piece); + } + + if ((t & 0x80) != 0) + { + flag |= promote; + t &= 0x7f; + } + + if ((f == t) && ((f != 0) || (t != 0))) + { + if (!barebones) + { + if (NOT_CURSES) + printf("error in algbr: FROM=TO=%d, flag=0x%4x\n", t, flag); + else + printw("error in algbr: FROM=TO=%d, flag=0x%4x\n", t, flag); + } + + mvstr[0][0] = mvstr[1][0] = mvstr[2][0] = mvstr[3][0] = '\0'; + } + else if ((flag & dropmask) != 0) + { + short piece = flag & pmask; + + mvstr[0][0] = pxx[piece]; + mvstr[0][1] = '*'; + mvstr[0][2] = cxx[column(t)]; + mvstr[0][3] = rxx[row(t)]; + mvstr[0][4] = '\0'; + strcpy(mvstr[1], mvstr[0]); + strcpy(mvstr[2], mvstr[0]); + strcpy(mvstr[3], mvstr[0]); + } + else if ((f != 0) || (t != 0)) + { + /* algebraic notation */ + mvstr[0][0] = cxx[column(f)]; + mvstr[0][1] = rxx[row(f)]; + mvstr[0][2] = cxx[column(t)]; + mvstr[0][3] = rxx[row(t)]; + mvstr[0][4] = mvstr[3][0] = '\0'; + mvstr[1][0] = pxx[board[f]]; + + mvstr[2][0] = mvstr[1][0]; + mvstr[2][1] = mvstr[0][1]; + + mvstr[2][2] = mvstr[1][1] = mvstr[0][2]; /* to column */ + mvstr[2][3] = mvstr[1][2] = mvstr[0][3]; /* to row */ + mvstr[2][4] = mvstr[1][3] = '\0'; + strcpy(mvstr[3], mvstr[2]); + mvstr[3][1] = mvstr[0][0]; + + if (flag & promote) + { + strcat(mvstr[0], "+"); + strcat(mvstr[1], "+"); + strcat(mvstr[2], "+"); + strcat(mvstr[3], "+"); + } + } + else + { + mvstr[0][0] = mvstr[1][0] = mvstr[2][0] = mvstr[3][0] = '\0'; + } +} + + + +/* + * Compare the string 's' to the list of legal moves available for the + * opponent. If a match is found, make the move on the board. + */ + +int +VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) +{ + static short pnt, tempb, tempc, tempsf, tempst, cnt; + static struct leaf xnode; + struct leaf *node; + short i, l, local_flags; + char buffer[60]; + + /* check and remove quality flags */ + for (i = local_flags = 0, l = strlen(s); i < l; i++) + { + switch(s[i]) + { + case '?': + local_flags |= badmove; + s[i] = '\0'; + break; + + case '!': + local_flags |= goodmove; + s[i] = '\0'; + break; + +#ifdef EASY_OPENINGS + case '~': + local_flags |= difficult; + s[i] = '\0'; + break; +#endif + } + } + + *mv = 0; + + if (iop == UNMAKE_MODE) + { + UnmakeMove(opponent, &xnode, &tempb, &tempc, &tempsf, &tempst); + return false; + } + + cnt = 0; + + if (iop == VERIFY_AND_MAKE_MODE) + generate_move_flags = true; + + MoveList(opponent, 2, -1, true); + generate_move_flags = false; + pnt = TrPnt[2]; + + while (pnt < TrPnt[3]) + { + node = &Tree[pnt++]; + algbr(node->f, node->t, (short) node->flags); + + if ((strcmp(s, mvstr[0]) == 0) + || (strcmp(s, mvstr[1]) == 0) + || (strcmp(s, mvstr[2]) == 0) + || (strcmp(s, mvstr[3]) == 0)) + { + cnt++; + xnode = *node; + } + } + + if ((cnt == 1) && (xnode.score > DONTUSE)) + { + short blocked; + + MakeMove(opponent, &xnode, &tempb, &tempc, + &tempsf, &tempst, &INCscore); + + if (SqAttacked(PieceList[opponent][0], computer, &blocked)) + { + UnmakeMove(opponent, &xnode, &tempb, &tempc, &tempsf, &tempst); + + if (NOT_CURSES) + { + /* Illegal move in check */ + printf(CP[77], mvstr[0]); + printf("\n"); + } + else + { + /* Illegal move in check */ + sprintf(buffer, CP[77], s); + ShowMessage(buffer); + } + + return false; + } + else + { + if (iop == VERIFY_AND_TRY_MODE) + return true; + + UpdateDisplay(xnode.f, xnode.t, 0, (short) xnode.flags); + GameList[GameCnt].depth = GameList[GameCnt].score = 0; + GameList[GameCnt].nodes = 0; + ElapsedTime(COMPUTE_AND_INIT_MODE); + GameList[GameCnt].time = (short) (et + 50)/100; + GameList[GameCnt].flags |= local_flags; + + if (TCflag) + { + TimeControl.clock[opponent] -= et; + timeopp[oppptr] = et; + --TimeControl.moves[opponent]; + } + + *mv = (xnode.f << 8) | xnode.t; + algbr(xnode.f, xnode.t, false); + + /* in force mode, check for mate conditions */ + if (flag.force) + { + if (IsCheckmate(opponent ^ 1, -1, -1)) + { + char buf[20]; + + sprintf(buf, "%s mates!\n", ColorStr[opponent]); + ShowMessage(buf); + flag.mate = true; + } + } + + return true; + } + } + + if (NOT_CURSES) + { + /* Illegal move */ + printf (CP[75], s); + } + else /* Curses. */ + { + /* Illegal move */ + sprintf(buffer, CP[76], s); + ShowMessage(buffer); + } + + if (!barebones && (cnt > 1)) + { + sprintf(buffer, CP[32], s); + ShowMessage(buffer); + } + + return false; +} + + + +static int +parser(char *f, int side, short *fpiece) +{ + int c1, r1, c2, r2; + short i, p = false; + + if (*f == '+') + f++, p = true; + + for (i = 1, *fpiece = no_piece; i < NO_PIECES; i++) + { + if (f[0] == pxx[i] || f[0] == qxx[i]) + { + *fpiece = (p ? promoted[i] : unpromoted[i]); + break; + } + } + + if (f[1] == '*' || f[1] == '\'') + { + c2 = '9' - f[2]; + r2 = 'i' - f[3]; + + return ((NO_SQUARES + *fpiece) << 8) | locn(r2, c2); + } + else + { + c1 = '9' - f[1]; + r1 = 'i' - f[2]; + c2 = '9' - f[3]; + r2 = 'i' - f[4]; + p = (f[5] == '+') ? 0x80 : 0; + + return (locn(r1, c1) << 8) | locn(r2, c2) | p; + } +} + + +void +skip() +{ + while (*InPtr != ' ') + InPtr++; + + while (*InPtr == ' ') + InPtr++; +} + + + +void +skipb() +{ + while (*InPtr == ' ') + InPtr++; +} + + + +void +GetGame(void) +{ + FILE *fd; + char fname[256], *p; + int c, i, j; + short sq; + short side, isp; + + if (savefile[0]) + { + strcpy(fname, savefile); + } + else + { + /* Enter file name */ + ShowMessage(CP[63]); + + if (NOT_CURSES) + { + scanf("%s", fname); + } + else + { + fflush(stdout); + scanw("%s", fname); + } + } + + /* shogi.000 */ + if (fname[0] == '\0') + strcpy(fname, CP[137]); + + if ((fd = fopen(fname, "r")) != NULL) + { + NewGame(); + fgets(fname, 256, fd); + computer = opponent = black; + InPtr = fname; + skip(); + + if (*InPtr == 'c') + computer = white; + else + opponent = white; + + /* FIXME: write a skipn() function so that we can get + * 3 skips by doing skipn(3) */ + skip(); + skip(); + skip(); + Game50 = atoi(InPtr); + skip(); + flag.force = (*InPtr == 'f'); + fgets(fname, 256, fd); /* empty */ + fgets(fname, 256, fd); + InPtr = &fname[11]; + skipb(); + TCflag = atoi(InPtr); + skip(); + InPtr += 14; + skipb(); + OperatorTime = atoi(InPtr); + fgets(fname, 256, fd); + InPtr = &fname[11]; + skipb(); + TimeControl.clock[black] = atol(InPtr); + skip(); + skip(); + TimeControl.moves[black] = atoi(InPtr); + fgets(fname, 256, fd); + InPtr = &fname[11]; + skipb(); + TimeControl.clock[white] = atol(InPtr); + skip(); + skip(); + TimeControl.moves[white] = atoi(InPtr); + fgets(fname, 256, fd); /* empty */ + + for (i = NO_ROWS - 1; i > -1; i--) + { + fgets(fname, 256, fd); + p = &fname[2]; + InPtr = &fname[23]; + + for (j = 0; j < NO_COLS; j++) + { + sq = i * NO_COLS + j; + isp = (*p == '+'); + p++; + + if (*p == '-') + { + board[sq] = no_piece; + color[sq] = neutral; + } + else + { + for (c = 0; c < NO_PIECES; c++) + { + if (*p == pxx[c]) + { + if (isp) + board[sq] = promoted[c]; + else + board[sq] = unpromoted[c]; + + color[sq] = white; + } + } + + for (c = 0; c < NO_PIECES; c++) + { + if (*p == qxx[c]) + { + if (isp) + board[sq] = promoted[c]; + else + board[sq] = unpromoted[c]; + + color[sq] = black; + } + } + } + + p++; + Mvboard[sq] = atoi(InPtr); + skip(); + } + } + + fgets(fname, 256, fd); /* empty */ + fgets(fname, 256, fd); /* 9 8 7 ... */ + fgets(fname, 256, fd); /* empty */ + fgets(fname, 256, fd); /* p l n ... */ + ClearCaptured(); + + for (side = 0; side <= 1; side++) + { + fgets(fname, 256, fd); + InPtr = fname; + skip(); + skipb(); + Captured[side][pawn] = atoi(InPtr); + skip(); + Captured[side][lance] = atoi(InPtr); + skip(); + Captured[side][knight] = atoi(InPtr); + skip(); + Captured[side][silver] = atoi(InPtr); + skip(); + Captured[side][gold] = atoi(InPtr); + skip(); + Captured[side][bishop] = atoi(InPtr); + skip(); + Captured[side][rook] = atoi(InPtr); + skip(); + Captured[side][king] = atoi(InPtr); + } + + GameCnt = 0; + flag.regularstart = true; + Book = BOOKFAIL; + fgets(fname, 256, fd); /* empty */ + fgets(fname, 256, fd); /* move score ... */ + + while (fgets(fname, 256, fd)) + { + struct GameRec *g; + int side = computer; + + side = side ^ 1; + ++GameCnt; + InPtr = fname; + skipb(); + g = &GameList[GameCnt]; + g->gmove = parser(InPtr, side, &g->fpiece); + skip(); + g->score = atoi(InPtr); + skip(); + g->depth = atoi(InPtr); + skip(); + g->nodes = atol(InPtr); + skip(); + g->time = atol(InPtr); + skip(); + g->flags = c = atoi(InPtr); + skip(); + g->hashkey = strtol(InPtr, (char **) NULL, 16); + skip(); + g->hashbd = strtol(InPtr, (char **) NULL, 16); + + if (c & capture) + { + short i, piece; + + skip(); + + for (piece = no_piece, i = 0; i < NO_PIECES; i++) + { + if (pxx[i] == *InPtr) + { + piece = i; + break; + } + } + + skip(); + g->color = ((*InPtr == CP[119][0]) ? white : black); + skip(); + g->piece = (*InPtr == '+' + ? promoted[piece] + : unpromoted[piece]); + } + else + { + g->color = neutral; + g->piece = no_piece; + } + } + + if (TimeControl.clock[black] > 0) + TCflag = true; + + fclose(fd); + } + + ZeroRPT(); + InitializeStats(); + UpdateDisplay(0, 0, 1, 0); + Sdepth = 0; + hint = 0; +} + + + +void +SaveGame(void) +{ + FILE *fd; + char fname[256]; + short sq, i, c, f, t; + char p; + short side, piece; + char empty[2] = "\n"; + + if (savefile[0]) + { + strcpy(fname, savefile); + } + else + { + /* Enter file name */ + ShowMessage(CP[63]); + + if (NOT_CURSES) + { + scanf("%s", fname); + } + else + { + fflush(stdout); + scanw("%s", fname); + } + } + + if (fname[0] == '\0') /* shogi.000 */ + strcpy(fname, CP[137]); + + if ((fd = fopen(fname, "w")) != NULL) + { + char *b, *w; + b = w = CP[74]; + + if (computer == white) + w = CP[141]; + + if (computer == black) + b = CP[141]; + + fprintf(fd, CP[37], w, b, Game50, + flag.force ? "force" : ""); + fprintf(fd, empty); + fprintf(fd, CP[111], TCflag, OperatorTime); + fprintf(fd, CP[117], + TimeControl.clock[black], TimeControl.moves[black], + TimeControl.clock[white], TimeControl.moves[white]); + fprintf(fd, empty); + + for (i = NO_ROWS - 1; i > -1; i--) + { + fprintf(fd, "%c ", 'i' - i); + + for (c = 0; c < NO_COLS; c++) + { + sq = i * NO_COLS + c; + piece = board[sq]; + p = is_promoted[piece] ? '+' : ' '; + fprintf(fd, "%c", p); + + switch(color[sq]) + { + case white: + p = pxx[piece]; + break; + + case black: + p = qxx[piece]; + break; + + default: + p = '-'; + } + + fprintf(fd, "%c", p); + } + + fprintf(fd, " "); + + for (f = i * NO_COLS; f < i * NO_COLS + NO_ROWS; f++) + fprintf(fd, " %d", Mvboard[f]); + + fprintf(fd, "\n"); + } + + fprintf(fd, empty); + fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); + fprintf(fd, empty); + fprintf(fd, " p l n s g b r k\n"); + + for (side = 0; side <= 1; side++) + { + fprintf(fd, "%c", (side == black) ? 'B' : 'W'); + fprintf(fd, " %2d", Captured[side][pawn]); + fprintf(fd, " %2d", Captured[side][lance]); + fprintf(fd, " %2d", Captured[side][knight]); + fprintf(fd, " %2d", Captured[side][silver]); + fprintf(fd, " %2d", Captured[side][gold]); + fprintf(fd, " %2d", Captured[side][bishop]); + fprintf(fd, " %2d", Captured[side][rook]); + fprintf(fd, " %2d", Captured[side][king]); + fprintf(fd, "\n"); + } + + fprintf(fd, empty); + fprintf(fd, CP[126]); + + for (i = 1; i <= GameCnt; i++) + { + struct GameRec *g = &GameList[i]; + + f = g->gmove >> 8; + t = (g->gmove & 0xFF); + algbr(f, t, g->flags); + + fprintf(fd, "%c%c%-5s %6d %5d %7ld %6ld %5d 0x%08lx 0x%08lx", + ((f > NO_SQUARES) + ? ' ' + : (is_promoted[g->fpiece] ? '+' : ' ')), + pxx[g->fpiece], + ((f > NO_SQUARES) ? &mvstr[0][1] : mvstr[0]), + g->score, g->depth, + g->nodes, g->time, g->flags, + g->hashkey, g->hashbd); + + if (g->piece != no_piece) + { + fprintf(fd, " %c %s %c\n", + pxx[g->piece], ColorStr[g->color], + (is_promoted[g->piece] ? '+' : ' ')); + } + else + { + fprintf(fd, "\n"); + } + } + + fclose(fd); + + /* Game saved */ + ShowMessage(CP[70]); + } + else + { + /* ShowMessage("Could not open file"); */ + ShowMessage(CP[48]); + } +} + + + +/* + * GetXGame, SaveXGame and BookGame used to only be defined if + * xshogi wasn't defined -- wonder why? + */ + +void +GetXGame(void) +{ + FILE *fd; + char fname[256], *p; + int c, i, j; + short sq; + short side, isp; + + /* Enter file name */ + ShowMessage(CP[63]); + + if (NOT_CURSES) + { + scanf("%s", fname); + } + else + { + fflush(stdout); + scanw("%s", fname); + } + + if (fname[0] == '\0') /* XSHOGI.position.read */ + strcpy(fname, CP[205]); + + if ((fd = fopen(fname, "r")) != NULL) + { + NewGame(); + flag.regularstart = false; + Book = false; + + /* xshogi position file ... */ + fgets(fname, 256, fd); + +#ifdef notdef + fname[6] = '\0'; + + if (strcmp(fname, CP[206])) + return; +#endif + + /* -- empty line -- */ + fgets(fname, 256, fd); + /* -- empty line -- */ + fgets(fname, 256, fd); + + for (i = NO_ROWS - 1; i > -1; i--) + { + fgets(fname, 256, fd); + p = fname; + + for (j = 0; j < NO_COLS; j++) + { + sq = i * NO_COLS + j; + isp = (*p == '+'); + p++; + + if (*p == '.') + { + board[sq] = no_piece; + color[sq] = neutral; + } + else + { + for (c = 0; c < NO_PIECES; c++) + { + if (*p == qxx[c]) + { + if (isp) + board[sq] = promoted[c]; + else + board[sq] = unpromoted[c]; + + color[sq] = white; + } + } + + for (c = 0; c < NO_PIECES; c++) + { + if (*p == pxx[c]) + { + if (isp) + board[sq] = promoted[c]; + else + board[sq] = unpromoted[c]; + + color[sq] = black; + } + } + } + + p++; + } + } + + ClearCaptured(); + + for (side = 0; side <= 1; side++) + { + fgets(fname, 256, fd); + InPtr = fname; + Captured[side][pawn] = atoi(InPtr); + skip(); + Captured[side][lance] = atoi(InPtr); + skip(); + Captured[side][knight] = atoi(InPtr); + skip(); + Captured[side][silver] = atoi(InPtr); + skip(); + Captured[side][gold] = atoi(InPtr); + skip(); + Captured[side][bishop] = atoi(InPtr); + skip(); + Captured[side][rook] = atoi(InPtr); + skip(); + Captured[side][king] = atoi(InPtr); + } + + if (fgets(fname, 256, fd) != NULL && strncmp(fname, "white", 5) == 0) + { + computer = black; + opponent = white; + xwndw = BXWNDW; + } + + fclose(fd); + } + + Game50 = 1; + ZeroRPT(); + InitializeStats(); + UpdateDisplay(0, 0, 1, 0); + Sdepth = 0; + hint = 0; +} + + +void +SaveXGame(void) +{ + FILE *fd; + char fname[256], *p; + int i, j; + short sq, piece; + short side, isp; + + /* Enter file name */ + ShowMessage(CP[63]); + + if (NOT_CURSES) + { + scanf("%s", fname); + } + else + { + fflush(stdout); + scanw("%s", fname); + } + + if (fname[0] == '\0') /* XSHOGI.position.read */ + strcpy(fname, CP[205]); + + if ((fd = fopen(fname, "w")) != NULL) + { + /* xshogi position file ... */ + fputs("# xshogi position file -- \n", fd); + /* -- empty line -- */ + fputs("\n", fd); + /* -- empty line -- */ + fputs("\n", fd); + + for (i = NO_ROWS - 1; i > -1; i--) + { + p = fname; + + for (j = 0; j < NO_COLS; j++) + { + sq = i * NO_COLS + j; + piece = board[sq]; + isp = is_promoted[piece]; + *p = (isp ? '+' : ' '); + p++; + + if (piece == no_piece) + *p = '.'; + else if (color[sq] == white) + *p = qxx[piece]; + else + *p = pxx[piece]; + + p++; + } + + *p++ = '\n'; + *p++ = '\0'; + fputs(fname, fd); + } + + for (side = 0; side <= 1; side++) + { + sprintf(fname, "%d %d %d %d %d %d %d %d\n", + Captured[side][pawn], + Captured[side][lance], + Captured[side][knight], + Captured[side][silver], + Captured[side][gold], + Captured[side][bishop], + Captured[side][rook], + Captured[side][king]); + + fputs(fname, fd); + } + + if (computer == black) + fputs("white to play\n", fd); + else + fputs("black to play\n", fd); + + fclose(fd); + } +} + + +void +BookSave(void) +{ + FILE *fd; + char fname[256], sflags[4]; + short i, j, f, t; + + if (savefile[0]) + { + strcpy(fname, savefile); + } + else + { + /* Enter file name */ + ShowMessage(CP[63]); + + if (NOT_CURSES) + { + scanf("%s", fname); + } + else + { + fflush(stdout); + scanw("%s", fname); + } + } + + if (fname[0] == '\0') + return; + + if ((fd = fopen(fname, "a")) != NULL) + { + fprintf(fd, "#\n"); + + for (i = 1; i <= GameCnt; i++) + { + struct GameRec *g = &GameList[i]; + char mvnr[20], mvs[20]; + + if (i % 2) + sprintf(mvnr, "%d.", (i + 1)/2); + else + strcpy(mvnr, ""); + + f = g->gmove >> 8; + t = (g->gmove & 0xFF); + algbr(f, t, g->flags); + j = 0; + + /* determine move quality string */ + if (g->flags & goodmove) + sflags[j++] = '!'; + + if (g->flags & badmove) + sflags[j++] = '?'; + +#ifdef EASY_OPENINGS + if (g->flags & difficult) + sflags[j++] = '~'; +#endif + + sflags[j] = '\0'; + + /* determine move string */ + if (f > NO_SQUARES) + { + sprintf(mvs, "%s%s ", &mvstr[0][1], sflags); + } + else + { + sprintf(mvs, "%c%c%c%c%c%s%s ", + mvstr[0][0], mvstr[0][1], + (g->flags & capture) ? 'x' : '-', + mvstr[0][2], mvstr[0][3], + (mvstr[0][4] == '+') ? "+" : "", + sflags); + } + + fprintf(fd, "%s%s%c%s", + mvnr, + (f > NO_SQUARES + ? "" + : (is_promoted[g->fpiece] ? "+" : "")), + pxx[g->fpiece], + mvs); + + if ((i % 10) == 0) + fprintf(fd, "\n"); + } + + if ((i % 10) != 1) + fprintf(fd, "\n"); + + fclose(fd); + + /* Game saved */ + ShowMessage(CP[70]); + } + else + { + /* ShowMessage("Could not open file"); */ + ShowMessage(CP[48]); + } +} + + + +void +ListGame(void) +{ + FILE *fd; + short i, f, t; + time_t when; + char fname[256], dbuf[256]; + + if (listfile[0]) + { + strcpy(fname, listfile); + } + else + { + time(&when); + strncpy(dbuf, ctime(&when), 20); + dbuf[7] = '\0'; + dbuf[10] = '\0'; + dbuf[13] = '\0'; + dbuf[16] = '\0'; + dbuf[19] = '\0'; + + /* use format "CLp16.Jan01-020304B" when patchlevel is 16, + date is Jan 1 + time is 02:03:04 + program played white */ + + sprintf(fname, "CLp%s.%s%s-%s%s%s%c", + patchlevel, dbuf + 4, dbuf + 8, dbuf + 11, dbuf + 14, + dbuf + 17, ColorStr[computer][0]); + + /* replace space padding with 0 */ + for (i = 0; fname[i] != '\0'; i++) + { + if (fname[i] == ' ') + fname[i] = '0'; + } + } + + fd = fopen(fname, "w"); + + if (!fd) + { + printf(CP[219], fname); + exit(1); + } + + /* fprintf(fd, "gnushogi game %d\n", u); */ + fprintf(fd, CP[161], version, patchlevel); + fprintf(fd, CP[10]); + fprintf(fd, CP[11]); + + for (i = 1; i <= GameCnt; i++) + { + f = GameList[i].gmove >> 8; + t = (GameList[i].gmove & 0xFF); + algbr(f, t, GameList[i].flags); + + if (GameList[i].flags & book) + { + fprintf(fd, "%c%c%-5s %5d Book%7ld %5ld", + ((f > NO_SQUARES) + ? ' ' + : (is_promoted[GameList[i].fpiece] ? '+' : ' ')), + pxx[GameList[i].fpiece], + ((f > NO_SQUARES) + ? &mvstr[0][1] : mvstr[0]), + GameList[i].score, + GameList[i].nodes, + GameList[i].time); + } + else + { + fprintf(fd, "%c%c%-5s %5d %2d %7ld %5ld", + (f > NO_SQUARES + ? ' ' + : (is_promoted[GameList[i].fpiece] ? '+' : ' ')), + pxx[GameList[i].fpiece], + (f > NO_SQUARES ? &mvstr[0][1] : mvstr[0]), + GameList[i].score, GameList[i].depth, + GameList[i].nodes, GameList[i].time); + } + + if ((i % 2) == 0) + { + fprintf(fd, "\n"); + } + else + { + fprintf(fd, " "); + } + } + + fprintf(fd, "\n\n"); + + if (GameList[GameCnt].flags & draw) + { + fprintf(fd, CP[54], DRAW); + + if (DRAW == CP[101]) + { + short j; + + fprintf(fd, "repetition by positions "); + + for (j = GameCnt - 1; j >= Game50; j -= 2) + { + if (GameList[j].hashkey == hashkey && + GameList[j].hashbd == hashbd) + fprintf(fd, "%d ", j); + } + + fprintf(fd, "\n"); + } + } + else if (GameList[GameCnt].score == -(SCORE_LIMIT + 999)) + { + fprintf(fd, "%s\n", ColorStr[player ]); + } + else if (GameList[GameCnt].score == (SCORE_LIMIT + 998)) + { + fprintf(fd, "%s\n", ColorStr[player ^ 1]); + } + + fclose(fd); +} + + + +void +FlagMove(char c) +{ + switch(c) + { + case '?' : + GameList[GameCnt].flags |= badmove; + break; + + case '!' : + GameList[GameCnt].flags |= goodmove; + break; + +#ifdef EASY_OPENINGS + case '~' : + GameList[GameCnt].flags |= difficult; + break; +#endif + } +} + + + + +/* + * Undo the most recent half-move. + */ + +void +Undo(void) +{ + short f, t; + + f = GameList[GameCnt].gmove >> 8; + t = GameList[GameCnt].gmove & 0x7F; + + if (f > NO_SQUARES) + { + /* the move was a drop */ + Captured[color[t]][board[t]]++; + board[t] = no_piece; + color[t] = neutral; + Mvboard[t]--; + } + else + { + if (GameList[GameCnt].flags & promote) + board[f] = unpromoted[board[t]]; + else + board[f] = board[t]; + + color[f] = color[t]; + board[t] = GameList[GameCnt].piece; + color[t] = GameList[GameCnt].color; + + if (board[t] != no_piece) + Captured[color[f]][unpromoted[board[t]]]--; + + if (color[t] != neutral) + Mvboard[t]--; + + Mvboard[f]--; + } + + InitializeStats(); + + if (TCflag && (TCmoves > 1)) + ++TimeControl.moves[color[f]]; + + hashkey = GameList[GameCnt].hashkey; + hashbd = GameList[GameCnt].hashbd; + GameCnt--; + computer = computer ^ 1; + opponent = opponent ^ 1; + flag.mate = false; + Sdepth = 0; + player = player ^ 1; + ShowSidetoMove(); + UpdateDisplay(0, 0, 1, 0); + + if (flag.regularstart) + Book = false; +} + + + +void +FlagString(unsigned short flags, char *s) +{ + short l, piece; + *s = '\0'; + + if (flags & promote) + strcat(s, " promote"); + + if (flags & dropmask) + strcat(s, " drop:"); + + if ((piece = (flags & pmask))) + { + l = strlen(s); + + if (is_promoted[piece]) + s[l++] = '+'; + + s[l++] = pxx[piece]; + s[l] = '\0'; + } + + if (flags & capture) + strcat(s, " capture"); + + if (flags & exact) + strcat(s, " exact"); + + if (flags & tesuji) + strcat(s, " tesuji"); + + if (flags & check) + strcat(s, " check"); + + if (flags & draw) + strcat(s, " draw"); + + if (flags & stupid) + strcat(s, " stupid"); + + if (flags & questionable) + strcat(s, " questionable"); + + if (flags & kingattack) + strcat(s, " kingattack"); + + if (flags & book) + strcat(s, " book"); +} + + + +void +TestSpeed(void(*f)(short side, short ply, + short in_check, short blockable), + unsigned j) +{ +#ifdef test + unsigned jj; +#endif + + unsigned i; + long cnt, rate, t1, t2; + +#ifdef HAVE_GETTIMEOFDAY + struct timeval tv; +#endif + +#ifdef HAVE_GETTIMEOFDAY + gettimeofday(&tv, NULL); + t1 = (tv.tv_sec*100 + (tv.tv_usec/10000)); +#else + t1 = time(0); +#endif + + for (i = 0; i < j; i++) + { + f(opponent, 2, -1, true); + +#ifdef test + for (jj = TrPnt[2]; i < TrPnt[3]; jj++) + { + if (!pick(jj, TrPnt[3] - 1)) + break; + } +#endif + } + +#ifdef HAVE_GETTIMEOFDAY + gettimeofday(&tv, NULL); + t2 = (tv.tv_sec * 100 + (tv.tv_usec / 10000)); +#else + t2 = time(0); +#endif + + cnt = j * (TrPnt[3] - TrPnt[2]); + + if (t2 - t1) + et = (t2 - t1); + else + et = 1; + + rate = (((et) ? ((cnt * 100) / et) : 0)); + +#ifdef DYNAMIC_ZNODES + if (rate > 0) + znodes = rate; +#endif + + if (NOT_CURSES) + printf(CP[91], cnt, rate); + else + ShowNodeCnt(cnt); +} + + + +void +TestPSpeed(short(*f) (short side), unsigned j) +{ + short i; + long cnt, rate, t1, t2; +#ifdef HAVE_GETTIMEOFDAY + struct timeval tv; +#endif + +#ifdef HAVE_GETTIMEOFDAY + gettimeofday(&tv, NULL); + t1 = (tv.tv_sec * 100 + (tv.tv_usec / 10000)); +#else + t1 = time(0); +#endif + + for (i = 0; i < j; i++) + (void) f(opponent); + +#ifdef HAVE_GETTIMEOFDAY + gettimeofday(&tv, NULL); + t2 = (tv.tv_sec * 100 + (tv.tv_usec / 10000)); +#else + t2 = time(0); +#endif + + cnt = j; + + if (t2 - t1) + et = (t2 - t1); + else + et = 1; + + rate = (et) ? ((cnt * 100) / et) : 0; + + /* printf("Nodes= %ld Nodes/sec= %ld\n", cnt, rate); */ + + if (NOT_CURSES) + printf(CP[91], cnt, rate); + else + ShowNodeCnt(cnt); +} + + + +void +SetOppTime(char *s) +{ + char *time; + int m, t, sec; + + sec = 0; + time = &s[strlen(CP[228])]; + t = (int)strtol(time, &time, 10); + + if (*time == ':') + { + time++; + sec = (int)strtol(time, &time, 10); + } + + m = (int)strtol(time, &time, 10); + + if (t) + TimeControl.clock[opponent] = t; + + if (m) + TimeControl.moves[opponent] = m; + + ElapsedTime(COMPUTE_AND_INIT_MODE); + + if (XSHOGI) + { + /* just to inform xshogi about availability of otime command */ + printf("otime %d %d\n", t, m); + } +} + + + +void +SetMachineTime(char *s) +{ + char *time; + int m, t, sec; + + time = &s[strlen(CP[197])]; + sec = 0; + t = (int)strtol(time, &time, 10); + + if (*time == ':') + { + time++; + sec = (int)strtol(time, &time, 10); + } + + m = (int)strtol(time, &time, 10); + + if (t) + TimeControl.clock[computer] = t; + + if (m) + TimeControl.moves[computer] = m; + + ElapsedTime(COMPUTE_AND_INIT_MODE); + + if (XSHOGI) + { + /* just to inform xshogi about availability of time command */ + printf("time %d %d\n", t, m); + } +} + + + + + +/* FIXME! This is truly the function from hell! */ + +/* + * Process the user's command. If easy mode is OFF (the computer is thinking + * on opponents time) and the program is out of book, then make the 'hint' + * move on the board and call SelectMove() to find a response. The user + * terminates the search by entering ^C (quit siqnal) before entering a + * command. If the opponent does not make the hint move, then set Sdepth to + * zero. + */ + +void +InputCommand(char *command) +{ + int eof = 0; + short have_shown_prompt = false; + short ok, done, is_move = false; + unsigned short mv; + char s[80], sx[80]; + + ok = flag.quit = done = false; + player = opponent; + +#if ttblsz + if (TTadd > ttbllimit) + ZeroTTable(); +#endif + + if ((hint > 0) && !flag.easy && !flag.force) + { + /* + * A hint move for the player is available. Compute a move for the + * opponent in background mode assuming that the hint move will be + * selected by the player. + */ + + ft = time0; /* Save reference time for the player. */ + fflush(stdout); + algbr((short) hint >> 8, (short) hint & 0xff, false); + strcpy(s, mvstr[0]); + +#if !defined NOPOST + if (flag.post) + GiveHint(); +#endif + + /* do the hint move */ + if (VerifyMove(s, VERIFY_AND_TRY_MODE, &mv)) + { + Sdepth = 0; + +#ifdef QUIETBACKGROUND + if (NOT_CURSES) + { + PromptForMove(); + } + else + { + ShowSidetoMove(); + ShowPrompt(); + } + + have_shown_prompt = true; +#endif /* QUIETBACKGROUND */ + + /* Start computing a move until the search is interrupted. */ + +#ifdef INTERRUPT_TEST + itime0 = 0; +#endif + + /* would love to put null move in here */ + /* after we make the hint move make a 2 ply search + * with both plys our moves */ + /* think on opponents time */ + SelectMove(computer, BACKGROUND_MODE); + +#ifdef INTERRUPT_TEST + ElapsedTime(COMPUTE_INTERRUPT_MODE); + + if (itime0 == 0) + { + printf("searching not terminated by interrupt!\n"); + } + else + { + printf("elapsed time from interrupt to " + "terminating search: %ld\n", it); + } +#endif + + /* undo the hint and carry on */ + VerifyMove(s, UNMAKE_MODE, &mv); + Sdepth = 0; + } + + time0 = ft; /* Restore reference time for the player. */ + } + + while(!(ok || flag.quit || done)) + { + player = opponent; + +#ifdef QUIETBACKGROUND + if (!have_shown_prompt) + { +#endif /* QUIETBACKGROUND */ + + if (NOT_CURSES) + { + PromptForMove(); + } + else + { + ShowSidetoMove(); + ShowPrompt(); + } + +#ifdef QUIETBACKGROUND + } + + have_shown_prompt = false; +#endif /* QUIETBACKGROUND */ + + if (command == NULL) + { + if (NOT_CURSES) + { + s[0] = sx[0] = '\0'; + + while(!sx[0]) + (void)fgets(sx, 256, stdin); + } + else + { + fflush(stdout); + eof = (getstr(sx) == ERR); + } + } + else + { + strcpy(sx, command); + done = true; + } + + sscanf(sx, "%s", s); + + if (eof) + ExitShogi(); + + if (s[0] == '\0') + continue; + + if (strcmp(s, CP[131]) == 0) /* bd -- display board */ + { + /* FIXME: Hack alert! */ + short old_xshogi = XSHOGI; + + if (old_xshogi) + display_type = DISPLAY_RAW; + + ClearScreen(); + UpdateDisplay(0, 0, 1, 0); + + if (old_xshogi) + display_type = DISPLAY_X; + } + else if (strcmp(s, "post") == 0) + { + flag.post = !flag.post; + } + else if (strcmp(s, CP[129]) == 0) + { + /* noop */ ; /* alg */ + } + else if ((strcmp(s, CP[180]) == 0) + || (strcmp(s, CP[216]) == 0)) /* quit exit */ + { + flag.quit = true; + } +#if !defined NOPOST + else if (strcmp(s, CP[178]) == 0) /* post */ + { + flag.post = !flag.post; + } +#endif + else if ((strcmp(s, CP[191]) == 0) + || (strcmp(s, CP[154]) == 0)) /* set edit */ + { + EditBoard(); + } + else if (NOT_CURSES && (strcmp(s, CP[190]) == 0)) /* setup */ + { + SetupBoard(); + } + else if (strcmp(s, CP[156]) == 0) /* first */ + { + ok = true; + } + else if (strcmp(s, CP[162]) == 0) /* go */ + { + ok = true; + flag.force = false; + + if (computer == black) + { + computer = white; + opponent = black; + } + else + { + computer = black; + opponent = white; + } + } + else if (strcmp(s, CP[166]) == 0) /* help */ + { + help(); + } + else if (strcmp(s, CP[221]) == 0) /* material */ + { + flag.material = !flag.material; + } + else if (strcmp(s, CP[157]) == 0) /* force */ + { + if (XSHOGI) + { + flag.force = true; + flag.bothsides = false; + } + else + { + flag.force = !flag.force; + flag.bothsides = false; + } + } + else if (strcmp(s, CP[134]) == 0) /* book */ + { + Book = Book ? 0 : BOOKFAIL; + } + else if (strcmp(s, CP[172]) == 0) /* new */ + { + NewGame(); + UpdateDisplay(0, 0, 1, 0); + } + else if (strcmp(s, CP[171]) == 0) /* list */ + { + ListGame(); + } + else if ((strcmp(s, CP[169]) == 0) + || (strcmp(s, CP[217]) == 0)) /* level clock */ + { + SelectLevel(sx); + } + else if (strcmp(s, CP[165]) == 0) /* hash */ + { + flag.hash = !flag.hash; + } + else if (strcmp(s, CP[227]) == 0) /* gamein */ + { + flag.gamein = !flag.gamein; + } + else if (strcmp(s, CP[226]) == 0) /* beep */ + { + flag.beep = !flag.beep; + } + else if (strcmp(s, CP[197]) == 0) /* time */ + { + SetMachineTime(sx); + } + else if (strcmp(s, CP[228]) == 0) /* otime */ + { + SetOppTime(sx); + } + else if (strcmp(s, CP[33]) == 0) /* Awindow */ + { + ChangeAlphaWindow(); + } + else if (strcmp(s, CP[39]) == 0) /* Bwindow */ + { + ChangeBetaWindow(); + } + else if (strcmp(s, CP[183]) == 0) /* rcptr */ + { + flag.rcptr = !flag.rcptr; + } + else if (strcmp(s, CP[168]) == 0) /* hint */ + { + GiveHint(); + } + else if (strcmp(s, CP[135]) == 0) /* both */ + { + flag.bothsides = !flag.bothsides; + flag.force = false; + Sdepth = 0; + ElapsedTime(COMPUTE_AND_INIT_MODE); + SelectMove(opponent, FOREGROUND_MODE); + ok = true; + } + else if (strcmp(s, CP[185]) == 0) /* reverse */ + { + flag.reverse = !flag.reverse; + ClearScreen(); + UpdateDisplay(0, 0, 1, 0); + } + else if (strcmp(s, CP[195]) == 0) /* switch */ + { + computer = computer ^ 1; + opponent = opponent ^ 1; + xwndw = (computer == black) ? WXWNDW : BXWNDW; + flag.force = false; + Sdepth = 0; + ok = true; + } + else if (strcmp(s, CP[203]) == 0) /* black */ + { + computer = white; + opponent = black; + xwndw = WXWNDW; + flag.force = false; + Sdepth = 0; + + /* + * ok = true; don't automatically start with black command + */ + } + else if (strcmp(s, CP[133]) == 0) /* white */ + { + computer = black; + opponent = white; + xwndw = BXWNDW; + flag.force = false; + Sdepth = 0; + + /* + * ok = true; don't automatically start with white command + */ + } + else if (strcmp(s, CP[201]) == 0 && GameCnt > 0) /* undo */ + { + Undo(); + } + else if (strcmp(s, CP[184]) == 0 && GameCnt > 1) /* remove */ + { + Undo(); + Undo(); + } + /* CHECKME: are these next three correct? */ + else if (!XSHOGI && strcmp(s, CP[207]) == 0) /* xget */ + { + GetXGame(); + } + else if (!XSHOGI && strcmp(s, "xsave") == 0) /* xsave */ + { + SaveXGame(); + } + else if (!XSHOGI && strcmp(s, "bsave") == 0) /* bsave */ + { + BookSave(); + } +#ifdef EASY_OPENINGS + else if ((strcmp(s, "?") == 0) + || (strcmp(s, "!") == 0) + || (strcmp(s, "~") == 0)) +#else + else if ((strcmp(s, "?") == 0) + || (strcmp(s, "!") == 0)) +#endif + { + FlagMove(*s); + } + else if (strcmp(s, CP[160]) == 0) /* get */ + { + GetGame(); + } + else if (strcmp(s, CP[189]) == 0) /* save */ + { + SaveGame(); + } + else if (strcmp(s, CP[151]) == 0) /* depth */ + { + ChangeSearchDepth(); + } + else if (strcmp(s, CP[164]) == 0) /* hashdepth */ + { + ChangeHashDepth(); + } + else if (strcmp(s, CP[182]) == 0) /* random */ + { + dither = DITHER; + } + else if (strcmp(s, CP[229]) == 0) /* hard */ + { + flag.easy = false; + } + else if (strcmp(s, CP[152]) == 0) /* easy */ + { + flag.easy = !flag.easy; + } + else if (strcmp(s, CP[230]) == 0) /* tsume */ + { + flag.tsume = !flag.tsume; + } + else if (strcmp(s, CP[143]) == 0) /* contempt */ + { + SetContempt(); + } + else if (strcmp(s, CP[209]) == 0) /* xwndw */ + { + ChangeXwindow(); + } + else if (strcmp(s, CP[186]) == 0) /* rv */ + { + flag.rv = !flag.rv; + UpdateDisplay(0, 0, 1, 0); + } + else if (strcmp(s, CP[145]) == 0) /* coords */ + { + flag.coords = !flag.coords; + UpdateDisplay(0, 0, 1, 0); + } + else if (strcmp(s, CP[193]) == 0) /* stars */ + { + flag.stars = !flag.stars; + UpdateDisplay(0, 0, 1, 0); + } + else if (!XSHOGI && strcmp(s, CP[5]) == 0) /* moves */ + { + short temp; + +#if MAXDEPTH > 3 + if (GameCnt > 0) + { + extern unsigned short PrVar[MAXDEPTH]; + + SwagHt = (GameList[GameCnt].gmove == PrVar[1]) + ? PrVar[2] : 0; + } + else +#endif + SwagHt = 0; + + ShowMessage(CP[108]); /* test movelist */ + temp = generate_move_flags; + generate_move_flags = true; + TestSpeed(MoveList, 1); + generate_move_flags = temp; + ShowMessage(CP[107]); /* test capturelist */ + TestSpeed(CaptureList, 1); + ShowMessage(CP[85]); /* test score position */ + ExaminePosition(opponent); + TestPSpeed(ScorePosition, 1); + } + else if (!XSHOGI && strcmp(s, CP[196]) == 0) /* test */ + { +#ifdef SLOW_CPU + ShowMessage(CP[108]); /* test movelist */ + TestSpeed(MoveList, 2000); + ShowMessage(CP[107]); /* test capturelist */ + TestSpeed(CaptureList, 3000); + ShowMessage(CP[85]); /* test score position */ + ExaminePosition(opponent); + TestPSpeed(ScorePosition, 1500); +#else + ShowMessage(CP[108]); /* test movelist */ + TestSpeed(MoveList, 20000); + ShowMessage(CP[107]); /* test capturelist */ + TestSpeed(CaptureList, 30000); + ShowMessage(CP[85]); /* test score position */ + ExaminePosition(opponent); + TestPSpeed(ScorePosition, 15000); +#endif + } + else if (!XSHOGI && strcmp(s, CP[179]) == 0) /* p */ + { + ShowPostnValues(); + } + else if (!XSHOGI && strcmp(s, CP[148]) == 0) /* debug */ + { + DoDebug(); + } + else + { + if (flag.mate) + { + ok = true; + } + else if ((ok = VerifyMove(s, VERIFY_AND_MAKE_MODE, &mv))) + { + /* check for repetition */ + short rpt = repetition(); + + if (rpt >= 3) + { + DRAW = CP[101]; + ShowMessage(DRAW); + GameList[GameCnt].flags |= draw; + + flag.mate = true; + } + else + { + is_move = true; + } + } + + Sdepth = 0; + } + } + + ElapsedTime(COMPUTE_AND_INIT_MODE); + + if (flag.force) + { + computer = opponent; + opponent = computer ^ 1; + } + + if (XSHOGI) + { + /* add remaining time in milliseconds for xshogi */ + if (is_move) + { + printf("%d. %s %ld\n", + ++mycnt2, s, TimeControl.clock[player] * 10); + } + +#ifdef notdef /* optional pass best line to frontend with move */ +# if !defined NOPOST + + if (flag.post && !flag.mate) + { + int i; + + printf(" %6d ", MSCORE); + + for (i = 1; MV[i] > 0; i++) + { + algbr((short) (MV[i] >> 8), (short) (MV[i] & 0xFF), false); + printf("%5s ", mvstr[0]); + } + } +# endif + printf("\n"); +#endif + } + + signal(SIGINT, TerminateSearch); +} + + + + +void +SetTimeControl(void) +{ + if (TCflag) + { + TimeControl.moves[black] = TimeControl.moves[white] = TCmoves; + TimeControl.clock[black] += 6000L * TCminutes + TCseconds * 100; + TimeControl.clock[white] += 6000L * TCminutes + TCseconds * 100; + } + else + { + TimeControl.moves[black] = TimeControl.moves[white] = 0; + TimeControl.clock[black] = TimeControl.clock[white] = 0; + } + + flag.onemove = (TCmoves == 1); + et = 0; + ElapsedTime(COMPUTE_AND_INIT_MODE); +} + diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c new file mode 100644 index 0000000..d8d7391 --- /dev/null +++ b/gnushogi/cursesdsp.c @@ -0,0 +1,1166 @@ +/* + * FILE: cursesdsp.c + * + * Curses interface for GNU Shogi + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * GNU Shogi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Shogi; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include +#include + +#include +#include +#include +#include + +#include "gnushogi.h" +#include "cursesdsp.h" + +#define FLUSH_SCANW fflush(stdout), scanw + +int mycnt1, mycnt2; + +#define TAB (58) + +#define VIR_C(s) ((flag.reverse) ? (8 - column(s)) : column(s)) +#define VIR_R(s) ((flag.reverse) ? (8 - row(s)) : row(s)) + +unsigned short MV[MAXDEPTH]; +int MSCORE; +char *DRAW; + +/* Forward declarations. */ +/* FIXME: change this name, puh-leeze! */ + +static void UpdateCatched(); + + +/**************************************** + * Trivial output functions. + ****************************************/ + +void +ClearEoln(void) +{ + clrtoeol(); + refresh(); +} + + +void +Curses_ClearScreen(void) +{ + clear(); + refresh(); +} + + +void +ClearMessage(void) +{ + gotoXY(TAB, 6); + ClearEoln(); +} + + + +void +gotoXY(short x, short y) +{ + move(y - 1, x - 1); +} + + +void +Curses_ShowCurrentMove(short pnt, short f, short t) +{ + algbr(f, t, false); + gotoXY(TAB, 7); + printw("(%2d) %5s ", pnt, mvstr[0]); +} + + +void +Curses_ShowDepth(char ch) +{ + gotoXY(TAB, 4); + printw(CP[53], Sdepth, ch); /* Depth = %d%c */ + ClearEoln(); +} + + +void +Curses_ShowGameType(void) +{ + if (flag.post) + { + gotoXY(TAB, 20); + printw("%c vs. %c", GameType[black], GameType[white]); + } +} + + +void +ShowHeader(void) +{ + gotoXY(TAB, 2); + printw(CP[69], version, patchlevel); +} + + +void +Curses_ShowLine(unsigned short *bstline) +{ +} + + +void +Curses_ShowMessage(char *s) +{ + gotoXY(TAB, 6); + printw("%s", s); + ClearEoln(); +} + + +void +ShowNodeCnt(long NodeCnt) +{ + gotoXY(TAB, 22); + /* printw(CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0); */ + printw("n = %ld n/s = %ld", + NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0); + ClearEoln(); +} + + +void +Curses_ShowPatternCount(short side, short n) +{ + if (flag.post) + { + gotoXY(TAB + 10 + 3 * side, 20); + + if (n >= 0) + printw("%3d", n); + else + printw(" "); + } +} + + +void +ShowPlayers(void) +{ + gotoXY(5, ((flag.reverse) ? 23 : 2)); + printw("%s", (computer == white) ? CP[218] : CP[74]); + gotoXY(5, ((flag.reverse) ? 2 : 23)); + printw("%s", (computer == black) ? CP[218] : CP[74]); +} + + +void +ShowPrompt(void) +{ + gotoXY(TAB, 17); + printw(CP[121]); /* Your move is? */ + ClearEoln(); +} + + +void +Curses_ShowResponseTime(void) +{ + if (flag.post) + { + short TCC = TCcount; + gotoXY(TAB, 21); + /* printw("RT = %ld TCC = %d TCL = %ld EX = %ld ET = %ld TO = %d", + ResponseTime, TCC, TCleft, ExtraTime, et, flag.timeout); */ + printw("%ld, %d, %ld, %ld, %ld, %d", + ResponseTime, TCC, TCleft, ExtraTime, et, flag.timeout); + ClearEoln(); + } +} + + +void +Curses_ShowResults(short score, unsigned short *bstline, char ch) +{ + unsigned char d, ply; + + if (flag.post) + { + Curses_ShowDepth(ch); + ShowScore(score); + d = 7; + + for (ply = 1; bstline[ply] > 0; ply++) + { + if (ply % 2 == 1) + { + gotoXY(TAB, ++d); + ClearEoln(); + } + + algbr((short) bstline[ply] >> 8, + (short) bstline[ply] & 0xFF, false); + printw("%5s ", mvstr[0]); + } + + ClearEoln(); + + while (d < 13) + { + gotoXY(TAB, ++d); + ClearEoln(); + } + } +} + + +void +ShowScore(short score) +{ + gotoXY(TAB, 5); + printw(CP[104], score); + ClearEoln(); +} + + +void +Curses_ShowSidetoMove(void) +{ + gotoXY(TAB, 14); + printw("%2d: %s", 1 + GameCnt / 2, ColorStr[player]); + ClearEoln(); +} + + +void +Curses_ShowStage(void) +{ + gotoXY(TAB, 19); + printw("Stage= %2d%c B= %2d W= %2d", + stage, flag.tsume?'T':' ', balance[black], balance[white]); + ClearEoln(); +} + + +/**************************************** + * End of trivial output routines. + ****************************************/ + + +void +Curses_Initialize(void) +{ + signal(SIGINT, Curses_Die); + signal(SIGQUIT, Curses_Die); + initscr(); + crmode(); +} + + +void +Curses_ExitShogi(void) +{ + if (!nolist) + ListGame(); + + gotoXY(1, 24); + + refresh(); + nocrmode(); + endwin(); + + exit(0); +} + + + +void +Curses_Die(int sig) +{ + char s[80]; + + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + + Curses_ShowMessage(CP[31]); /* Abort? */ + FLUSH_SCANW("%s", s); + + if (strcmp(s, CP[210]) == 0) /* yes */ + Curses_ExitShogi(); + + signal(SIGINT, Curses_Die); + signal(SIGQUIT, Curses_Die); +} + + + +void +Curses_TerminateSearch(int sig) +{ + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + + if (!flag.timeout) + flag.musttimeout = true; + + Curses_ShowMessage("Terminate Search"); + flag.bothsides = false; + signal(SIGINT, Curses_Die); + signal(SIGQUIT, Curses_Die); +} + + + +void +Curses_help(void) +{ + Curses_ClearScreen(); + /* printw("GNU Shogi ??p? command summary\n"); */ + printw(CP[40], version, patchlevel); + printw("-------------------------------" + "---------------------------------\n"); + /* printw("7g7f move from 7g to 7f quit + * Exit Shogi\n"); */ + printw(CP[158]); + /* printw("S6h move silver to 6h beep + * turn %s\n", (flag.beep) ? "off" : "on"); */ + printw(CP[86], (flag.beep) ? CP[92] : CP[93]); + /* printw("2d2c+ move to 2c and promote\n"); */ + printw(CP[128], (flag.material) ? CP[92] : CP[93]); + /* printw("P*5e drop a pawn to 5e easy + * turn %s\n", (flag.easy) ? "off" : "on"); */ + printw(CP[173], (flag.easy) ? CP[92] : CP[93]); + /* printw(" hash + * turn %s\n", (flag.hash) ? "off" : "on"); */ + printw(CP[174], (flag.hash) ? CP[92] : CP[93]); + /* printw("bd redraw board reverse + * board display\n"); */ + printw(CP[130]); + /* printw("list game to shogi.lst book + * turn %s used %d of %d\n", (Book) ? "off" : "on", book + count, booksize); */ + printw(CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE); + /* printw("undo undo last ply remove + * take back a move\n"); */ + printw(CP[200]); + /* printw("edit edit board force + * enter game moves\n"); */ + printw(CP[153]); + /* printw("switch sides with computer both + * computer match\n"); */ + printw(CP[194]); + /* printw("black computer plays black white + * computer plays white\n"); */ + printw(CP[202]); + /* printw("depth set search depth clock + * set time control\n"); */ + printw(CP[149]); + /* printw("hint suggest a move post + * turn %s principle variation\n", (flag.post) ? "off" : + * "on"); */ + printw(CP[177], (flag.post) ? CP[92] : CP[93]); + /* printw("save game to file get + * game from file\n"); */ + printw(CP[188]); + /* printw("random randomize play new + * start new game\n"); */ + printw(CP[181]); + gotoXY(10, 20); + printw(CP[47], ColorStr[computer]); + gotoXY(10, 21); + printw(CP[97], ColorStr[opponent]); + gotoXY(10, 22); + printw(CP[79], MaxResponseTime/100); + gotoXY(10, 23); + printw(CP[59], (flag.easy) ? CP[93] : CP[92]); + gotoXY(25, 23); + printw(CP[231], (flag.tsume) ? CP[93] : CP[92]); + gotoXY(40, 20); + printw(CP[52], MaxSearchDepth); + gotoXY(40, 21); + printw(CP[100], (dither) ? CP[93] : CP[92]); + gotoXY(40, 22); + printw(CP[112], (flag.hash) ? CP[93] : CP[92]); + gotoXY(40, 23); + printw(CP[73]); + gotoXY(10, 24); + printw(CP[110], (TCflag) ? CP[93] : CP[92], + TimeControl.moves[black], + TimeControl.clock[black] / 100, + OperatorTime, MaxSearchDepth); + + refresh(); + +#ifdef BOGUS + fflush(stdin); /* what is this supposed to do?? */ +#endif /* BOGUS */ + + getchar(); + Curses_ClearScreen(); + Curses_UpdateDisplay(0, 0, 1, 0); +} + + +static const short x0[2] = { 54, 2 }; +static const short y0[2] = { 20, 4 }; + + +/* + * Set up a board position. Pieces are entered by typing the piece followed + * by the location. For example, N3f will place a knight on square 3f. + * P* will put a pawn to the captured pieces. + */ + +void +Curses_EditBoard(void) +{ + short a, c, sq, i; + short r = 0; + char s[80]; + + flag.regularstart = true; + Book = BOOKFAIL; + Curses_ClearScreen(); + Curses_UpdateDisplay(0, 0, 1, 0); + gotoXY(TAB, 3); + printw(CP[29]); + gotoXY(TAB, 4); + printw(CP[28]); + gotoXY(TAB, 5); + printw(CP[136]); + gotoXY(TAB, 7); + printw(CP[64]); + a = black; + + do + { + gotoXY(TAB, 6); + printw(CP[60], ColorStr[a]); /* Editing %s */ + gotoXY(TAB + 24, 7); + ClearEoln(); + FLUSH_SCANW("%s", s); + + if (s[0] == CP[28][0]) /* # */ + { + for (sq = 0; sq < NO_SQUARES; sq++) + { + board[sq] = no_piece; + color[sq] = neutral; + DrawPiece(sq); + } + + ClearCaptured(); + UpdateCatched(); + } + + if (s[0] == CP[136][0]) /* c */ + a = otherside[a]; + + if (s[1] == '*') + { + for (i = NO_PIECES; i > no_piece; i--) + { + if ((s[0] == pxx[i]) || (s[0] == qxx[i])) + break; + } + + Captured[a][unpromoted[i]]++; + UpdateCatched(); + c = -1; + } + else + { + c = '9' - s[1]; + r = 'i' - s[2]; + } + + if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS)) + { + sq = locn(r, c); + + for (i = NO_PIECES; i > no_piece; i--) + { + if ((s[0] == pxx[i]) || (s[0] == qxx[i])) + break; + } + + if (s[3] == '+') + i = promoted[i]; + else + i = unpromoted[i]; + + board[sq] = i; + color[sq] = ((board[sq] == no_piece) ? neutral : a); + DrawPiece(sq); + } + } + while (s[0] != CP[29][0]); /* . */ + + for (sq = 0; sq < NO_SQUARES; sq++) + Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0); + + GameCnt = 0; + Game50 = 1; + ZeroRPT(); + Sdepth = 0; + InitializeStats(); + Curses_ClearScreen(); + Curses_UpdateDisplay(0, 0, 1, 0); +} + + + +static void +UpdateCatched() +{ + short side; + + for (side = black; side <= white; side++) + { + short x, y, piece, cside, k; + + cside = flag.reverse ? (side ^ 1) : side; + x = x0[cside]; + y = y0[cside]; + k = 0; + + for (piece = pawn; piece <= king; piece++) + { + short n; + + if ((n = Captured[side][piece])) + { + gotoXY(x, y); + printw("%i%c", n, pxx[piece]); + + if (cside == black) + y--; + else + y++; + } + else + { + k++; + } + } + + while (k) + { + k--; + gotoXY(x, y); + printw(" "); + + if (cside == black) + y--; + else + y++; + } + } + + refresh(); +} + + + +void +Curses_SearchStartStuff(short side) +{ + short i; + + signal(SIGINT, Curses_TerminateSearch); + signal(SIGQUIT, Curses_TerminateSearch); + + for (i = 4; i < 14; i++) + { + gotoXY(TAB, i); + ClearEoln(); + } +} + + + +void +Curses_OutputMove(void) +{ + + Curses_UpdateDisplay(root->f, root->t, 0, (short) root->flags); + gotoXY(TAB, 16); + + if (flag.illegal) + { + printw(CP[225]); + return; + } + + printw(CP[84], mvstr[0]); /* My move is %s */ + + if (flag.beep) + putchar(7); + + ClearEoln(); + + gotoXY(TAB, 18); + + if (root->flags & draw) + printw(CP[58]); + else if (root->score == -(SCORE_LIMIT + 999)) + printw(CP[95]); + else if (root->score == SCORE_LIMIT + 998) + printw(CP[44]); +#ifdef VERYBUGGY + else if (root->score < -SCORE_LIMIT) + printw(CP[96], SCORE_LIMIT + 999 + root->score - 1); + else if (root->score > SCORE_LIMIT) + printw(CP[45], SCORE_LIMIT + 998 - root->score - 1); +#endif /* VERYBUGGY */ + + ClearEoln(); + + if (flag.post) + { + short h, l, t; + + h = TREE; + l = 0; + t = TREE >> 1; + + while (l != t) + { + if (Tree[t].f || Tree[t].t) + l = t; + else + h = t; + + t = (l + h) >> 1; + } + + ShowNodeCnt(NodeCnt); + gotoXY(TAB, 23); + printw(CP[81], t); /* Max Tree= */ + ClearEoln(); + } + + Curses_ShowSidetoMove(); +} + + + +void +UpdateClocks(void) +{ + short m, s; + long dt; + + if (TCflag) + { + m = (short) ((dt = (TimeControl.clock[player] - et)) / 6000); + s = (short) ((dt - 6000 * (long) m) / 100); + } + else + { + m = (short) ((dt = et) / 6000); + s = (short) (et - 6000 * (long) m) / 100; + } + + if (m < 0) + m = 0; + + if (s < 0) + s = 0; + + if (player == black) + gotoXY(20, (flag.reverse) ? 2 : 23); + else + gotoXY(20, (flag.reverse) ? 23 : 2); + + /* printw("%d:%02d %ld ", m, s, dt); */ + printw("%d:%02d ", m, s); + + if (flag.post) + ShowNodeCnt(NodeCnt); + + refresh(); +} + + + +void +DrawPiece(short sq) +{ + char y; + char piece, l, r, p; + + if (color[sq] == neutral) + { + l = r = ' '; + } + else if (flag.reverse ^ (color[sq] == black)) + { + l = '/'; + r = '\\'; + } + else + { + l = '\\', r = '/'; + } + + piece = board[sq]; + + if (is_promoted[(int)piece]) + { + p = '+'; + y = pxx[unpromoted[(int)piece]]; + } + else + { + p = ' '; + y = pxx[(int)piece]; + } + + gotoXY(8 + 5 * VIR_C(sq), 4 + 2 * (8 - VIR_R(sq))); + printw("%c%c%c%c", l, p, y, r); +} + + + + +/* + * Curses_ShowPostnValue(): must have called ExaminePosition() first + */ + +void +Curses_ShowPostnValue(short sq) +{ + short score; + + gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); + score = ScorePosition(color[sq]); + + if (color[sq] != neutral) +#if defined SAVE_SVALUE + { + printw("??? "); + } +#else + { + printw("%3d ", svalue[sq]); + } +#endif + else + { + printw(" "); + } +} + + + +void +Curses_ShowPostnValues(void) +{ + short sq, score; + + ExaminePosition(opponent); + + for (sq = 0; sq < NO_SQUARES; sq++) + Curses_ShowPostnValue(sq); + + score = ScorePosition(opponent); + gotoXY(TAB, 5); + printw(CP[103], score, + mtl[computer], pscore[computer], GameType[computer], + mtl[opponent], pscore[opponent], GameType[opponent]); + + ClearEoln(); +} + + + +void +Curses_UpdateDisplay(short f, short t, short redraw, short isspec) +{ + short i, sq, z; + + if (redraw) + { + ShowHeader(); + ShowPlayers(); + + i = 2; + gotoXY(3, ++i); + + printw(" +----+----+----+----+----+----+----+----+----+"); + + while (i < 20) + { + gotoXY(1, ++i); + + if (flag.reverse) + z = (i / 2) - 1; + else + z = 11 - ((i + 1) / 2); + + printw(" %c | | | | | |" + " | | | |", 'a' + 9 - z); + + gotoXY(3, ++i); + + if (i < 20) + { + printw(" +----+----+----+----+----+----+----+----+----+"); + } + } + + printw(" +----+----+----+----+----+----+----+----+----+"); + + gotoXY(3, 22); + printw(" "); + + if (flag.reverse) + printw(CP[16]); + else + printw(CP[15]); + + for (sq = 0; sq < NO_SQUARES; sq++) + DrawPiece(sq); + } + else /* not redraw */ + { + if (f < NO_SQUARES) + DrawPiece(f); + + DrawPiece(t & 0x7f); + } + + if ((isspec & capture) || (isspec & dropmask) || redraw) + { + short side; + + for (side = black; side <= white; side++) + { + short x, y, piece, cside, k; + cside = flag.reverse ? (side ^ 1) : side; + x = x0[cside]; + y = y0[cside]; + k = 0; + + for (piece = pawn; piece <= king; piece++) + { + short n; + + if ((n = Captured[side][piece])) + { + gotoXY(x, y); + printw("%i%c", n, pxx[piece]); + + if (cside == black) y--; else y++; + } + else + { + k++; + } + } + + while (k) + { + k--; + gotoXY(x, y); + printw(" "); + + if (cside == black) + y--; + else + y++; + } + } + } + + refresh(); +} + + +extern char *InPtr; + + +void +Curses_ChangeAlphaWindow(void) +{ + Curses_ShowMessage(CP[114]); + FLUSH_SCANW("%hd", &WAwindow); + Curses_ShowMessage(CP[34]); + FLUSH_SCANW("%hd", &BAwindow); +} + + + +void +Curses_ChangeBetaWindow(void) +{ + Curses_ShowMessage(CP[115]); + FLUSH_SCANW("%hd", &WBwindow); + Curses_ShowMessage(CP[35]); + FLUSH_SCANW("%hd", &BBwindow); +} + + + +void +Curses_GiveHint(void) +{ + char s[40]; + + if (hint) + { + algbr((short) (hint >> 8), (short) (hint & 0xFF), false); + strcpy(s, CP[198]); /* try */ + strcat(s, mvstr[0]); + Curses_ShowMessage(s); + } + else + { + Curses_ShowMessage(CP[223]); + } +} + + + +void +Curses_ChangeSearchDepth(void) +{ + Curses_ShowMessage(CP[150]); + FLUSH_SCANW("%hd", &MaxSearchDepth); + TCflag = !(MaxSearchDepth > 0); +} + + +void +Curses_ChangeHashDepth(void) +{ + Curses_ShowMessage(CP[163]); + FLUSH_SCANW("%hd", &HashDepth); + Curses_ShowMessage(CP[82]); + FLUSH_SCANW("%hd", &HashMoveLimit); +} + + +void +Curses_SetContempt(void) +{ + Curses_ShowMessage(CP[142]); + FLUSH_SCANW("%hd", &contempt); +} + + + +void +Curses_ChangeXwindow(void) +{ + Curses_ShowMessage(CP[208]); + FLUSH_SCANW("%hd", &xwndw); +} + + + +void +Curses_SelectLevel(char *sx) +{ + int item; + + Curses_ClearScreen(); + gotoXY(32, 2); + printw(CP[41], version, patchlevel); + gotoXY(20, 4); + printw(CP[18]); + gotoXY(20, 5); + printw(CP[19]); + gotoXY(20, 6); + printw(CP[20]); + gotoXY(20, 7); + printw(CP[21]); + gotoXY(20, 8); + printw(CP[22]); + gotoXY(20, 9); + printw(CP[23]); + gotoXY(20, 10); + printw(CP[24]); + gotoXY(20, 11); + printw(CP[25]); + gotoXY(20, 12); + printw(CP[26]); + gotoXY(20, 13); + printw(CP[27]); + + OperatorTime = 0; + TCmoves = 40; + TCminutes = 5; + TCseconds = 0; + + gotoXY(20, 17); + printw(CP[62]); + refresh(); + FLUSH_SCANW("%d", &item); + + switch(item) + { + case 1: + TCmoves = 40; + TCminutes = 5; + break; + + case 2: + TCmoves = 40; + TCminutes = 15; + break; + + case 3: + TCmoves = 40; + TCminutes = 30; + break; + + case 4: + TCmoves = 80; + TCminutes = 15; + flag.gamein = true; + break; + + case 5: + TCmoves = 80; + TCminutes = 30; + flag.gamein = true; + break; + + case 6: + TCmoves = 80; + TCminutes = 15; + TCadd = 3000; + flag.gamein = true; + break; + + case 7: + TCmoves = 80; + TCminutes = 30; + TCadd = 3000; + break; + + case 8: + TCmoves = 1; + TCminutes = 1; + flag.onemove = true; + break; + + case 9: + TCmoves = 1; + TCminutes = 15; + flag.onemove = true; + break; + + case 10: + TCmoves = 1; + TCminutes = 30; + flag.onemove = true; + break; + } + + TCflag = (TCmoves > 0); + + TimeControl.clock[black] = TimeControl.clock[white] = 0; + + SetTimeControl(); + Curses_ClearScreen(); + Curses_UpdateDisplay(0, 0, 1, 0); +} + + + +void +Curses_DoDebug(void) +{ + short c, p, sq, tp, tc, tsq, score; + char s[40]; + + ExaminePosition(opponent); + Curses_ShowMessage(CP[65]); + FLUSH_SCANW("%s", s); + c = neutral; + + if ((s[0] == CP[9][0]) || (s[0] == CP[9][1])) /* b B */ + c = black; + + if ((s[0] == CP[9][2]) || (s[0] == CP[9][3])) /* w W */ + c = white; + + for (p = king; p > no_piece; p--) + { + if ((s[1] == pxx[p]) || (s[1] == qxx[p])) + break; + } + + for (sq = 0; sq < NO_SQUARES; sq++) + { + tp = board[sq]; + tc = color[sq]; + board[sq] = p; + color[sq] = c; + tsq = PieceList[c][1]; + PieceList[c][1] = sq; + Curses_ShowPostnValue(sq); + PieceList[c][1] = tsq; + board[sq] = tp; + color[sq] = tc; + } + + score = ScorePosition(opponent); + gotoXY(TAB, 5); + printw(CP[103], score, + mtl[computer], pscore[computer], GameType[computer], + mtl[opponent], pscore[opponent], GameType[opponent]); + + ClearEoln(); +} + + + +void +Curses_DoTable(short table[NO_SQUARES]) +{ + short sq; + ExaminePosition(opponent); + + for (sq = 0; sq < NO_SQUARES; sq++) + { + gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); + printw("%3d ", table[sq]); + } +} + + + diff --git a/gnushogi/cursesdsp.h b/gnushogi/cursesdsp.h new file mode 100644 index 0000000..c33af9c --- /dev/null +++ b/gnushogi/cursesdsp.h @@ -0,0 +1,87 @@ +/* + * FILE: cursesdsp.h + * + * Curses interface for GNU Shogi. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#ifndef _CURSESDSP_H_ +#define _CURSESDSP_H_ + +/* The following are common to rawdsp.h and cursesdsp.h */ + +void Curses_ChangeAlphaWindow(void); +void Curses_ChangeBetaWindow(void); +void Curses_ChangeHashDepth(void); +void Curses_ChangeSearchDepth(void); +void Curses_ChangeXwindow(void); +void Curses_ClearScreen(void); +void Curses_Die(int sig); +void Curses_DoDebug(void); +void Curses_DoTable(short table[NO_SQUARES]); +void Curses_EditBoard(void); +void Curses_ExitShogi(void); +void Curses_GiveHint(void); +void Curses_Initialize(void); +void Curses_OutputMove(void); +void Curses_SearchStartStuff(short side); +void Curses_SelectLevel(char *sx); +void Curses_SetContempt(void); +void Curses_ShowCurrentMove(short pnt, short f, short t); +void Curses_ShowDepth(char ch); +void Curses_ShowGameType(void); +void Curses_ShowLine(unsigned short *bstline); +void Curses_ShowMessage(char *s); +void Curses_ShowPatternCount(short side, short n); +void Curses_ShowPostnValue(short sq); +void Curses_ShowPostnValues(void); +void Curses_ShowResponseTime(void); +void Curses_ShowResults(short score, unsigned short *bstline, char ch); +void Curses_ShowSidetoMove(void); +void Curses_ShowStage(void); +void Curses_TerminateSearch(int sig); +void Curses_UpdateDisplay(short f, short t, short redraw, short isspec); +void Curses_help(void); + + +/* The following are only found in cursesdsp.h: */ + +void ClearEoln(void); +void ClearMessage(void); +void DrawPiece(short sq); +void ShowHeader(void); +void ShowNodeCnt(long NodeCnt); +void ShowPlayers(void); +void ShowPrompt(void); +void ShowScore(short score); +void UpdateClocks(void); +void gotoXY(short x, short y); + +#endif /* _CURSESDSP_H_ */ + diff --git a/gnushogi/debug.h b/gnushogi/debug.h new file mode 100644 index 0000000..c708628 --- /dev/null +++ b/gnushogi/debug.h @@ -0,0 +1,70 @@ +/* + * FILE: debug.h + * + * Various macros to help in debugging. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +/* Some of this code requires gcc. */ + + +#ifndef _DEBUG_H_ +#define _DEBUG_H_ + +/* + * Define simple macros PRINT_ENTER and PRINT_EXIT to print info when + * a function is entered or left. They only work if DEBUG is #defined. + * This requires gcc. You have to invoke them with a semicolon after them, + * like this: + * + * PRINT_ENTER; + * PRINT_EXIT; + * + * This is so as not to screw up automatic indentation in emacs. + */ + +#if (defined __GNUC__) + +# define PRINT_ENTER printf("Entering function: %s().\n", __FUNCTION__) +# define PRINT_EXIT printf("Exiting function: %s().\n", __FUNCTION__) + +#else + +# define PRINT_ENTER +# define PRINT_EXIT + +#endif /* __GNUC__ */ + +/* Function inlining; not all C compilers support this. */ +#if (!defined __GNUC__) +# define inline +#endif + +#endif /* _DEBUG_H_ */ + diff --git a/gnushogi/dspwrappers.c b/gnushogi/dspwrappers.c new file mode 100644 index 0000000..5ae9e65 --- /dev/null +++ b/gnushogi/dspwrappers.c @@ -0,0 +1,566 @@ +/* + * FILE: dspwrappers.c + * + * Wrapper functions which call analogous functions in rawdsp.c + * or cursesdsp.c depending on the interface. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" +#include "dspwrappers.h" +#include "rawdsp.h" +#include "cursesdsp.h" + + +void +ChangeAlphaWindow(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ChangeAlphaWindow(); + break; + + case DISPLAY_CURSES: + Curses_ChangeAlphaWindow(); + break; + } +} + + +void +ChangeBetaWindow(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ChangeBetaWindow(); + break; + + case DISPLAY_CURSES: + Curses_ChangeBetaWindow(); + break; + } +} + + +void +ChangeHashDepth(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ChangeHashDepth(); + break; + + case DISPLAY_CURSES: + Curses_ChangeHashDepth(); + break; + } +} + + +void +ChangeSearchDepth(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ChangeSearchDepth(); + break; + + case DISPLAY_CURSES: + Curses_ChangeSearchDepth(); + break; + } +} + + +void +ChangeXwindow(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ChangeXwindow(); + break; + + case DISPLAY_CURSES: + Curses_ChangeXwindow(); + break; + } +} + + +void +ClearScreen(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ClearScreen(); + break; + + case DISPLAY_CURSES: + Curses_ClearScreen(); + break; + } +} + + +void +DoDebug(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_DoDebug(); + break; + + case DISPLAY_CURSES: + Curses_DoDebug(); + break; + } +} + + +void +DoTable(short table[NO_SQUARES]) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_DoTable(table); + break; + + case DISPLAY_CURSES: + Curses_DoTable(table); + break; + } +} + + +void +EditBoard(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_EditBoard(); + break; + + case DISPLAY_CURSES: + Curses_EditBoard(); + break; + } +} + + +void +ExitShogi(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ExitShogi(); + break; + + case DISPLAY_CURSES: + Curses_ExitShogi(); + break; + } +} + + +void +GiveHint(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_GiveHint(); + break; + + case DISPLAY_CURSES: + Curses_GiveHint(); + break; + } +} + + +void +Initialize(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_Initialize(); + break; + + case DISPLAY_CURSES: + Curses_Initialize(); + break; + } +} + + +void +OutputMove(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_OutputMove(); + break; + + case DISPLAY_CURSES: + Curses_OutputMove(); + break; + } +} + + +void +SetContempt(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_SetContempt(); + break; + + case DISPLAY_CURSES: + Curses_SetContempt(); + break; + } +} + + +void +SearchStartStuff(short side) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_SearchStartStuff(side); + break; + + case DISPLAY_CURSES: + Curses_SearchStartStuff(side); + break; + } +} + + +void +SelectLevel(char *sx) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_SelectLevel(sx); + break; + + case DISPLAY_CURSES: + Curses_SelectLevel(sx); + break; + } +} + + +void +ShowCurrentMove(short pnt, short f, short t) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowCurrentMove(pnt, f, t); + break; + + case DISPLAY_CURSES: + Curses_ShowCurrentMove(pnt, f, t); + break; + } +} + + +void +ShowDepth(char ch) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowDepth(ch); + break; + + case DISPLAY_CURSES: + Curses_ShowDepth(ch); + break; + } +} + + +void +ShowGameType(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowGameType(); + break; + + case DISPLAY_CURSES: + Curses_ShowGameType(); + break; + } +} + + +void +ShowLine(unsigned short *bstline) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowLine(bstline); + break; + + case DISPLAY_CURSES: + Curses_ShowLine(bstline); + break; + } +} + + +void +ShowMessage(char *s) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowMessage(s); + break; + + case DISPLAY_CURSES: + Curses_ShowMessage(s); + break; + } +} + + +void +ShowPatternCount(short side, short n) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowPatternCount(side, n); + break; + + case DISPLAY_CURSES: + Curses_ShowPatternCount(side, n); + break; + } +} + + +void +ShowPostnValue(short sq) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowPostnValue(sq); + break; + + case DISPLAY_CURSES: + Curses_ShowPostnValue(sq); + break; + } +} + + +void +ShowPostnValues(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowPostnValues(); + break; + + case DISPLAY_CURSES: + Curses_ShowPostnValues(); + break; + } +} + + +void +ShowResponseTime(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowResponseTime(); + break; + + case DISPLAY_CURSES: + Curses_ShowResponseTime(); + break; + } +} + + +void +ShowResults(short score, unsigned short *bstline, char ch) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowResults(score, bstline, ch); + break; + + case DISPLAY_CURSES: + Curses_ShowResults(score, bstline, ch); + break; + } +} + + +void +ShowSidetoMove(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowSidetoMove(); + break; + + case DISPLAY_CURSES: + Curses_ShowSidetoMove(); + break; + } +} + + +void +ShowStage(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_ShowStage(); + break; + + case DISPLAY_CURSES: + Curses_ShowStage(); + break; + } +} + + +void +TerminateSearch(int sig) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_TerminateSearch(sig); + break; + + case DISPLAY_CURSES: + Curses_TerminateSearch(sig); + break; + } +} + + +void +UpdateDisplay(short f, short t, short redraw, short isspec) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_UpdateDisplay(f, t, redraw, isspec); + break; + + case DISPLAY_CURSES: + Curses_UpdateDisplay(f, t, redraw, isspec); + break; + } +} + + +void +help(void) +{ + switch (display_type) + { + case DISPLAY_RAW: + case DISPLAY_X: + Raw_help(); + break; + + case DISPLAY_CURSES: + Curses_help(); + break; + } +} + diff --git a/gnushogi/dspwrappers.h b/gnushogi/dspwrappers.h new file mode 100644 index 0000000..5fa3904 --- /dev/null +++ b/gnushogi/dspwrappers.h @@ -0,0 +1,70 @@ +/* + * FILE: dspwrappers.h + * + * Wrapper functions which call analogous functions in rawdsp.c + * or cursesdsp.c depending on the interface. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#ifndef _DSPWRAPPERS_H_ +#define _DSPWRAPPERS_H_ + +extern void ChangeAlphaWindow(void); +extern void ChangeBetaWindow(void); +extern void ChangeHashDepth(void); +extern void ChangeSearchDepth(void); +extern void ChangeXwindow(void); +extern void ClearScreen(void); +extern void DoDebug(void); +extern void DoTable(short table[NO_SQUARES]); +extern void EditBoard(void); +extern void ExitShogi(void); +extern void GiveHint(void); +extern void Initialize(void); +extern void OutputMove(void); +extern void SetContempt(void); +extern void SearchStartStuff(short side); +extern void SelectLevel(char *sx); +extern void ShowCurrentMove(short pnt, short f, short t); +extern void ShowDepth(char ch); +extern void ShowGameType(void); +extern void ShowLine(unsigned short *bstline); +extern void ShowMessage(char *s); +extern void ShowPatternCount(short side, short n); +extern void ShowPostnValue(short sq); +extern void ShowPostnValues(void); +extern void ShowResponseTime(void); +extern void ShowResults(short score, unsigned short *bstline, char ch); +extern void ShowSidetoMove(void); +extern void ShowStage(void); +extern void TerminateSearch(int sig); +extern void UpdateDisplay(short f, short t, short redraw, short isspec); +extern void help(void); + +#endif /* _DSPWRAPPERS_H_ */ diff --git a/gnushogi/eval.c b/gnushogi/eval.c new file mode 100644 index 0000000..2cfa756 --- /dev/null +++ b/gnushogi/eval.c @@ -0,0 +1,2730 @@ +/* + * FILE: eval.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" +#include "pattern.h" + +extern void +ShowStage(void); + +/* Hash table for preventing multiple scoring of the same position */ + +int EADD = 0; /* number of writes to the cache table */ +int EGET = 0; /* number of hits to the cache table */ +int PUTVAR = false; /* shall the current scoring be cached? */ + + +/* Pieces and colors of initial board setup */ + +const small_short Stboard[NO_SQUARES] = +{ + lance, knight, silver, gold, king, gold, silver, knight, lance, + 0, bishop, 0, 0, 0, 0, 0, rook, 0, + pawn, pawn, pawn, pawn, pawn, pawn, pawn, pawn, pawn, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + pawn, pawn, pawn, pawn, pawn, pawn, pawn, pawn, pawn, + 0, rook, 0, 0, 0, 0, 0, bishop, 0, + lance, knight, silver, gold, king, gold, silver, knight, lance +}; + + +const small_short Stcolor[NO_SQUARES] = +{ + black, black, black, black, + black, black, black, black, black, + neutral, black, neutral, neutral, + neutral, neutral, neutral, black, neutral, + black, black, black, black, + black, black, black, black, black, + neutral, neutral, neutral, neutral, + neutral, neutral, neutral, neutral, neutral, + neutral, neutral, neutral, neutral, + neutral, neutral, neutral, neutral, neutral, + neutral, neutral, neutral, neutral, + neutral, neutral, neutral, neutral, neutral, + white, white, white, white, + white, white, white, white, white, + neutral, white, neutral, neutral, + neutral, neutral, neutral, white, neutral, + white, white, white, white, + white, white, white, white, white +}; + + +/* Actual pieces and colors */ + +small_short board[NO_SQUARES], color[NO_SQUARES]; + + +/* relative piece values at the beginning of main stages */ + +#define MAIN_STAGES 4 + +static small_short ispvalue[NO_PIECES][MAIN_STAGES] = +{ + { 0, 35, 70, 99 }, /* main stage borders */ + /* ------------------------------------------ */ + { 7, 7, 8, 10 }, /* Pawn */ + { 20, 35, 45, 60 }, /* Lance */ + { 20, 35, 45, 60 }, /* Knight */ + { 35, 40, 60, 80 }, /* Silver */ + { 35, 50, 65, 80 }, /* Gold */ + { 90, 90, 90, 90 }, /* Bishop */ + { 95, 95, 95, 95 }, /* Rook */ + { 15, 25, 40, 65 }, /* promoted Pawn */ + { 25, 45, 55, 65 }, /* promoted Lance */ + { 25, 45, 55, 65 }, /* promoted Knight */ + { 35, 55, 75, 75 }, /* promoted Silver */ + { 99, 99, 99, 99 }, /* promoted Bishop */ + { 97, 97, 99, 99 }, /* promoted Rook */ + { 100, 100, 100, 100 }, /* King */ +}; + +/* Features and Weights */ + +#define ATTACKED 0 +#define HUNGP 1 +#define HUNGX 2 +#define CNTRL5TH 3 +#define HOLES 4 +#define PCASTLE 5 +#define PATTACK 6 +#define CTRLK 7 +#define PROTECT 8 +#define HCLSD 9 +#define PINVAL 10 +#define XRAY 11 +#define OPENWRONG 12 +#define SEED 13 +#define LOOSE 14 +#define MOBILITY 15 +#define TARGET 16 +#define KSFTY 17 +#define HOPN 18 +#define PROMD 19 +#define KINGOD 20 +#define PWNDROP 21 +#define DFFDROP 22 +#define FCLATTACK 23 +#define KNGATTACK 24 +#define KNGPROTECT 25 +#define DNGLPC 26 +#define LSATTACK 27 +#define NIHATTACK 28 +#define COHESION 29 +#define OPPDROP 30 + + +static small_short weight[NO_FEATURES + 1][MAIN_STAGES + 2] = +{ + { 80, 100, 100, 40, 10, 15 }, /* ATTACKED */ + { 80, 100, 100, 50, 14, 10 }, /* HUNGP */ + { 80, 100, 100, 50, 18, 12 }, /* HUNGX */ + { 100, 50, 0, 0, 2, 1 }, /* CNTRL5TH */ + { 100, 100, 60, 10, 4, 2 }, /* HOLES */ + { 100, 50, 0, 0, 14, 7 }, /* PCASTLE */ + { 100, 50, 0, 0, 6, 12 }, /* PATTACK */ + { 10, 40, 70, 100, 10, 15 }, /* CTRLK */ + { 100, 80, 50, 40, 2, 1 }, /* PROTECT */ + { 40, 100, 40, 5, 4, 4 }, /* HCLSD */ + { 80, 100, 80, 30, 10, 15 }, /* PINVAL */ + { 80, 100, 60, 15, 6, 10 }, /* XRAY */ + { 100, 50, 0, 0, 15, 15 }, /* OPENWRONG */ + { 0, 40, 70, 100, 8, 12 }, /* SEED */ + { 50, 100, 80, 20, 5, 3 }, /* LOOSE */ + { 50, 100, 80, 50, 100, 100 }, /* MOBILITY (%) */ + { 50, 100, 80, 50, 4, 8 }, /* TARGET */ + { 50, 40, 100, 80, 8, 4 }, /* KSFTY */ + { 80, 100, 60, 20, 5, 5 }, /* HOPN */ + { 20, 40, 80, 100, 3, 6 }, /* PROMD */ + { 20, 40, 80, 100, 4, 1 }, /* KINGOD */ + { 5, 40, 100, 50, 0, 4 }, /* PWNDROP */ + { 0, 20, 80, 100, 0, 4 }, /* DFFDROP */ + { 20, 50, 100, 80, 0, 4 }, /* FCLATTACK */ + { 0, 20, 80, 100, 0, 8 }, /* KNGATTACK */ + { 40, 80, 100, 80, 6, 0 }, /* KNGPROTECT */ + { 50, 100, 60, 10, 0, 8 }, /* DNGPC */ + { 30, 100, 60, 5, 0, 6 }, /* LSATTACK */ + { 0, 50, 80, 100, 0, 8 }, /* NIHATTACK */ + { 50, 100, 80, 60, 8, 0 }, /* COHESION */ + { 100, 100, 80, 60, 4, 4 }, /* OPPDROP */ +}; + + +short ADVNCM[NO_PIECES]; + +/* distance to enemy king */ +static const short EnemyKingDistanceBonus[10] = +{ 0, 6, 4, -1, -3, -4, -6, -8, -10, -12 }; + +/* distance to own king */ +static const short OwnKingDistanceBonus[10] = +{ 0, 5, 2, 1, 0, -1, -2, -3, -4, -5 }; + +/* distance to promotion zone */ +static const int PromotionZoneDistanceBonus[NO_ROWS] = +{ 0, 0, 0, 0, 2, 6, 6, 8, 8 }; + +#define MAX_BMBLTY 20 +#define MAX_RMBLTY 20 +#define MAX_LMBLTY 8 + +/* Bishop mobility bonus indexed by # reachable squares */ +static const short BMBLTY[MAX_BMBLTY] = +{ 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 14, 16, 16, 16, 16 }; + +/* Rook mobility bonus indexed by # reachable squares */ +static const short RMBLTY[MAX_RMBLTY] = +{ 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 14, 16, 16, 16, 16 }; + +/* Lance mobility bonus indexed by # reachable squares */ +static const short LMBLTY[MAX_LMBLTY] = +{ 0, 0, 0, 0, 4, 6, 8, 10 }; + +static const short MBLTY[NO_PIECES] = +{ 0, 2, 1, 10, 5, 5, 1, 1, 5, 5, 5, 5, 1, 1, 4 }; + +static const short KTHRT[36] = +{ 0, -8, -20, -36, -52, -68, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80 }; + +static small_short fvalue[2][NO_FEATURES]; + +long attack[2][NO_SQUARES]; /* threats to squares */ +small_short sseed[NO_SQUARES]; /* square occupied by a seed piece? */ + +struct signature threats_signature[2] = /* statistics valid for position.. */ +{ { -1, -1 }, { -1, -1 } }; /* attack and sseed available */ + +small_short starget[2][NO_SQUARES]; /* significance as a target for a + * side of a square */ +small_short sloose[NO_SQUARES]; /* square occupied by a loose piece? */ +small_short shole[NO_SQUARES]; /* empty square a hole? */ +small_short shung[NO_SQUARES]; /* hung piece? */ + +struct signature squares_signature = /* statistics valid for position ... */ +{ 0, 0 }; /* starget, sloose, shole, shung available */ + +short target[2], seed[2], loose[2], hole[2]; + +short captured[2]; /* number of captured pieces */ +short dcaptured[2]; /* different types of captured pieces */ + +small_short Kdist[2][NO_SQUARES]; /* distance to king */ + +short MAXADIST, MAXCDIST; /* maximum half move distance to pattern */ + +char GameType[2] = { UNKNOWN, UNKNOWN }; /* chosen game type of each side */ + + +static short attack_opening_sequence[2]; /* current castle patterns */ +static short castle_opening_sequence[2]; /* current attack formations */ + +static small_short Mpawn [2][NO_SQUARES]; +static small_short Msilver[2][NO_SQUARES]; +static small_short Mgold [2][NO_SQUARES]; +static small_short Mking [2][NO_SQUARES]; +static small_short Mlance [2][NO_SQUARES]; +static small_short Mknight[2][NO_SQUARES]; +static small_short Mbishop[2][NO_SQUARES]; +static small_short Mrook [2][NO_SQUARES]; + +static Mpiece_array Mpawn, Mlance, Mknight, Msilver, Mgold, + Mbishop, Mrook, Mking; + +Mpiece_array *Mpiece[NO_PIECES] = +{ NULL, &Mpawn, &Mlance, &Mknight, &Msilver, &Mgold, &Mbishop, &Mrook, + &Mgold, &Mgold, &Mgold, &Mgold, &Mbishop, &Mrook, &Mking }; + + +static short c1, c2; +static small_short *PC1, *PC2; +static small_short *fv1; +static long *atk1, *atk2; +static long a1, a2; + +#define csquare(side, sq) ((side == black) ? sq : (NO_SQUARES_1 - sq)) +#define crow(side, sq) row(csquare(side, sq)) +#define ccolumn(side, sq) column(csquare(side, sq)) + + +inline static short +on_csquare(short side, short piece, short square) +{ + short sq; + /* FIXME: un-obfuscate this! */ + return ((board[sq = csquare(side, square)] == piece) + && (color[sq] == side)); +} + + +inline static short +on_column(short side, short piece, short c) +{ + short sq; + + for (sq = c; sq < NO_SQUARES; sq += 9) + { + if (on_csquare(side, piece, sq)) + return true; + } + + return false; +} + + +#define empty_csquare(side, square) \ + (board[csquare(side, square)] == no_piece) + +inline static short +on_left_side(short side, short piece) +{ + short c; + + for (c = 0; c < 4; c++) + { + if (on_column(side, piece, c)) + return true; + } + + return false; +} + + +inline static short +on_right_side(short side, short piece) +{ + short c; + + for (c = 5; c < NO_COLS; c++) + { + if (on_column(side, piece, c)) + return true; + } + + return false; +} + + +short pscore[2]; /* piece score for each side */ + + + + +/* + * Fill array attack[side][] with info about attacks to a square. Bits + * 16-31 are set if the piece (king .. pawn) attacks the square. Bits 0-15 + * contain a count of total attacks to the square. Fill array sseed[] with + * info about occupation by a seed piece. + */ + +void +threats(short side) +{ + short u, sq; + long c; + long *a; +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + short i, kd, piece, xside; + small_short *PL; + + if (MatchSignature(threats_signature[side])) + { + /* data valid for current positional signature */ + return; + } + + a = attack[side]; + xside = side ^ 1; + + array_zero(a, NO_SQUARES * sizeof(a[0])); + + PL = PieceList[side]; + + for (i = PieceCnt[side]; i >= 0; i--) + { + short ptyp; + + sq = PL[i]; + piece = board[sq]; + ptyp = ptype[side][piece]; + c = control[piece]; +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + ppos = (*nextpos[ptyp])[sq]; + pdir = (*nextdir[ptyp])[sq]; + u = ppos[sq]; +#endif + + do + { + a[u] = ((a[u] + 1) | c); + + if ((kd = Kdist[xside][u]) < 2) + { + sseed[sq] += 2 - kd; + seed[side]++; + } + +#ifdef SAVE_NEXTPOS + u = ((color[u] == neutral) + ? next_position(ptyp, &d, sq, u) + : next_direction(ptyp, &d, sq)); +#else + u = ((color[u] == neutral) ? ppos[u] : pdir[u]); +#endif + } + while (u != sq); + } + + /* data valid for current positional signature */ + CopySignature(threats_signature[side]); +} + + + +/* + * Compute the board square with nunmap offset "id". If side == white, + * offset is negated. inunmap[sq] is the corresponding nunmap index isq. + * nunmap[isq + id] computes the board square. If negative, it is outside + * the board. + */ + +static void +add_target(short sq, short side, short id) +{ + short isq, tsq, xside; + isq = inunmap[sq]; + tsq = (side == black) ? nunmap[isq + id] : nunmap[isq - id]; + + if (tsq >= 0) + { + target[xside = side^1]++; + + if (attack[side][tsq]) + starget[xside][tsq]++; /* protected target square */ + else + starget[xside][tsq] += 2; /* unprotected target square */ + } +} + + + +/* + * Target squares can be vertically ahead, diagonally ahead + * or diagonally behind. + */ + +static void +CheckTargetPiece(short sq, short side) +{ + switch (board[sq]) + { + case pawn: /* vertically ahead if unprotected */ + if (!attack[side][sq]) + add_target(sq, side, 11); + break; + + case king: /* diagonally and vertically ahead */ + add_target(sq, side, 10); + add_target(sq, side, 11); + add_target(sq, side, 12); + break; + + case rook: /* diagonally ahead and behind */ + add_target(sq, side, 10); + add_target(sq, side, 12); + add_target(sq, side, -10); + add_target(sq, side, -12); + break; + + case bishop: /* vertically ahead */ + add_target(sq, side, 11); + break; + + case knight: /* vertically ahead if advanced */ + /* FIXME: gotta love them magic numbers... */ + if ((sq != 1) && (sq != 7) && (sq != 73) && (sq != 79)) + add_target(sq, side, 11); + break; + } +} + + + +static short +ScoreKingOpeningFeatures(void) +{ + short s = 0, sq = OwnKing, ds; + + if (GameType[c1] == STATIC_ROOK) + { + /* Penalty for king on right side or fifth file */ + short c; + c = 4 - ccolumn(c1, sq); + + if ((c < 0) || ((c == 0) && (sq != kingP[c1]))) + s += (ds = -c - c - fv1[OPENWRONG]); + } + else if (GameType[c1] == RANGING_ROOK) + { + /* Penalty for king on left side or fifth file */ + short c; + c = 4 - ccolumn(c1, sq); + + if ((c > 0) || ((c == 0) && (sq != kingP[c1]))) + { + s += (ds = -c - c - fv1[OPENWRONG]); + } + + /* Penalty for king moved before rook switch */ + if (sq != kingP[c1]) + { + if (on_csquare(c1, rook, 16)) + { + s += (ds = -4 * fv1[OPENWRONG]); + } + } + else + { + /* Penalty for sitting king after rook switch */ + if (!on_csquare(c1, rook, 16)) + { + s += (ds = -2 * fv1[OPENWRONG]); + } + } + + /* Penalty for defending general moved + * before king switch to right side */ + if (ccolumn(c1, sq) < 6) + { + if (Mvboard[csquare(c1, 5)] || Mvboard[csquare(c1, 6)]) + { + s += (ds = -2 * fv1[OPENWRONG]); + } + } + } + + return s; +} + + + + +inline static void +ExamineSquares(void) +{ + short sq, side, piece, n; + + if (MatchSignature(squares_signature)) + { + /* data valid for current positional signature */ + return; + } + + array_zero(shole, sizeof(shole)); + array_zero(sloose, sizeof(sloose)); + array_zero(starget, sizeof(starget)); + + hole[0] = hole[1] = loose[0] = loose[1] + = target[0] = target[1] = 0; + + for (sq = 0; sq < NO_SQUARES; sq++) + { + if ((side = color[sq]) == neutral) + { + if (InWhiteCamp(sq)) + { + if (!attack[white][sq]) + { + shole[sq] = 1; + hole[white]++; + } + } + else if (InBlackCamp(sq)) + { + if (!attack[black][sq]) + { + shole[sq] = 1; + hole[black]++; + } + } + } + else + { + /* occupied by "side" piece */ + if (!attack[side][sq]) + { + sloose[sq] = 1; + loose[side]++; + } + + CheckTargetPiece(sq, side); + } + } + + for (side = black; side <= white; side++) + { + captured[side] = dcaptured[side] = 0; + + for (piece = pawn; piece <= rook; piece++) + { + if ((n = Captured[side][piece]) != 0) + { + if (piece != pawn) + captured[side] += n; + + dcaptured[side]++; + } + } + } + + /* Data valid for current positional signature */ + CopySignature(squares_signature); +} + + + +/* ............ POSITIONAL EVALUATION ROUTINES ............ */ + +/* + * Inputs are: + * mtl[side] - value of all material + * hung[side] - count of hung pieces + * Tscore[ply] - search tree score for ply ply + * Pscore[ply] - positional score for ply ply + * INCscore - bonus score or penalty for certain moves + * Sdepth - search goal depth + * xwndw - evaluation window about alpha/beta + * EWNDW - second evaluation window about alpha/beta + * ChkFlag[ply] - checking piece at level ply or 0 if no check + * TesujiFlag[ply] - 1 if tesuji move at level ply or 0 if no tesuji + * PC1[column] - # of my pawns in this column + * PC2[column] - # of opponents pawns in column + * PieceCnt[side] - just what it says + */ + + + + +/* + * Compute an estimate of the score by adding the positional score from the + * previous ply to the material difference. If this score falls inside a + * window which is 180 points wider than the alpha-beta window (or within a + * 50 point window during quiescence search) call ScorePosition() to + * determine a score, otherwise return the estimated score. "side" is the + * side which has to move. + */ + +int +evaluate(short side, + short ply, + short alpha, + short beta, + short INCscore, + short *InChk, /* output Check flag */ + short *blockable) /* king threat blockable */ +{ + short xside; + short s; + + xside = side ^ 1; + s = -Pscore[ply - 1] + mtl[side] - mtl[xside] /* - INCscore */; + hung[black] = hung[white] = 0; + + /* should we use the estimete or score the position */ + if ((ply == 1) + || (ply == Sdepth) + || (ply > Sdepth && s >= (alpha - 30) && s <= (beta + 30)) +#ifdef CACHE + || (use_etable && CheckEETable(side)) +#endif + ) + { + short sq; + + /* score the position */ + array_zero(sseed, sizeof(sseed)); + + seed[0] = seed[1] = 0; + threats(side); + + if (Anyattack(side, sq = PieceList[xside][0]) && (board[sq] == king)) + { + *InChk = (board[sq = PieceList[side][0]] == king) + ? SqAttacked(sq, xside, blockable) + : false; + + return ((SCORE_LIMIT + 1001) - ply); + } + + threats(xside); + *InChk = (board[sq = PieceList[side][0]] == king) + ? Anyattack(xside, sq) + : false; + *blockable = true; + EvalNodes++; + + if (ply > 4) + PUTVAR = true; + + ExamineSquares(); + s = ScorePosition(side); + PUTVAR = false; + } + else + { + /* use the estimate but look at check */ + short sq; + + *InChk = (board[sq = PieceList[side][0]] == king) + ? SqAttacked(sq, xside, blockable) + : false; + + if ((board[sq = PieceList[xside][0]] == king) + && SqAttacked(sq, side, blockable)) + { + return ((SCORE_LIMIT + 1001) - ply); + } + } + + Pscore[ply] = s - mtl[side] + mtl[xside]; + ChkFlag[ply - 1] = ((*InChk) ? Pindex[TOsquare] : 0); + + return s; +} + + + +static short +value_of_weakest_attacker(long a2) +{ + short piece; + short min_value, v; + min_value = SCORE_LIMIT; + + for (piece = pawn; piece <= king; piece++) + { + if (control[piece] & a2) + { + if (min_value > (v = (*value)[stage][piece])) + min_value = v; + } + } + + return min_value; +} + + + + +/* + * Find (promoted) Bishop, (promoted) Rook, and Lance mobility, x-ray + * attacks, and pins. Let BRL be the bishop, rook, or lance. Let P be the + * first piece (not a king or a pawn) in a direction and let Q be the + * second piece in the same direction. If Q is an unprotected opponent's + * piece with bigger relative value than BRL, there is a pin if P is an + * opponent's piece and there is an x-ray attack if P belongs to this side. + * Increment the hung[] array if a pin is found. + */ + +inline int +BRLscan(short sq, short *mob) +{ +#ifdef SAVE_NEXTPOS + short d, dd; +#else + unsigned char *ppos, *pdir; +#endif + + short s, mobx; + short u, xu, pin, ptyp, csq = column(sq); + short piece, upiece, xupiece, rvalue, ds; + small_short *Kd = Kdist[c2]; + + mobx = s = 0; + piece = board[sq]; + + rvalue = (*value)[stage][piece]; + ptyp = ptype[c1][upiece = unpromoted[piece]]; + rvalue = (*value)[stage][upiece]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + ppos = (*nextpos[ptyp])[sq]; + pdir = (*nextdir[ptyp])[sq]; + u = ppos[sq]; +#endif + + pin = -1; /* start new direction */ + + do + { + if (Kd[u] < 2) + { + s += (ds = fv1[CTRLK] * (2 - Kd[u])); + } + + if ((ds = starget[c1][u]) != 0) + { + /* threatening a target square */ + if ((pin < 0) /* direct threat */ + || (color[pin] == c2)) /* pin threat */ + { + s += (ds *= fv1[TARGET]); + } + } + + if ((ds = shole[u]) != 0) + { + /* attacking or protecting a hole */ + s += (ds = fv1[HOLES]); + } + else if (InPromotionZone(c1, u)) + { + /* attacking a square in promotion zone */ + s += (ds = fv1[HOLES] / 2); + } + + if (color[u] == neutral) + { +#ifdef SAVE_NEXTPOS + dd = d; + xu = next_position(ptyp, &d, sq, u); + + if (xu == next_direction(ptyp, &dd, sq)) + pin = -1; /* oops new direction */ +#else + + if ((xu = ppos[u]) == pdir[u]) + pin = -1; /* oops new direction */ +#endif + u = xu; + mobx++; + } + else + { + /* there is a piece in current direction */ + if (pin < 0) + { + /* it's the first piece in the current direction */ + if (color[u] == c1) + { + /* own intercepting piece in x-ray attack */ + if (upiece == lance) + { + /* lance x-ray */ + if (board[u] == pawn) + { + s += (ds = 2*fv1[PROTECT]); + } + else if (in_opening_stage) + { + s += (ds = -2*fv1[PROTECT]); + } + } + else + { + /* bishop or rook x-ray */ + if ((upiece == bishop) && (board[u] == pawn) + && (GameType[c1] == STATIC_ROOK)) + { + s += (ds = -2*fv1[HCLSD]); + } + else if ((upiece == rook) && (board[u] == lance) + && (GameType[c1] == STATIC_ROOK) + && (column(u) == csq)) + { + s += (ds = fv1[XRAY]); + } + } + } + else + { + /* enemy's intercepting piece in pin attack */ + if (upiece == lance) + { + /* lance pin attack */ + if (board[u] == pawn) + { + s += (ds = -2*fv1[PROTECT]); + } + else if (in_opening_stage) + { + s += (ds = 2 * fv1[PROTECT]); + } + } + else + { + /* bishop or rook pin attack */ + if (board[u] == pawn) + { + s += (ds = -fv1[HCLSD]); + } + } + } + +#ifdef SAVE_NEXTPOS + dd = d; + xu = next_position(ptyp, &d, sq, u); + + if (xu != next_direction(ptyp, &dd, sq)) + pin = u; /* not on the edge and on to find a pin */ +#else + if ((xu = ppos[u]) != pdir[u]) + pin = u; /* not on the edge and on to find a pin */ +#endif + u = xu; + } + else + { + /* it's the second piece in the current direction */ + + if (color[u] == c1) + { + /* second piece is an own piece */ + if ((upiece == bishop) && (board[u] == pawn) + && (GameType[c1] == STATIC_ROOK)) + { + s += (ds = -fv1[HCLSD]); + } + } + else + { + /* second piece is an enemy piece */ + if (upiece == bishop && board[u] == pawn) + { + s += (ds = -fv1[HCLSD]/2); + } + + if (((*value)[stage][xupiece = unpromoted[board[u]]] + > rvalue) + || (atk2[u] == 0)) + { + if (color[pin] == c2) + { + if ((xupiece == king) && (in_endgame_stage)) + { + s += (ds = 2 * fv1[PINVAL]); + } + else + { + s += (ds = fv1[PINVAL]); + } + + if ((atk2[pin] == 0) + || (atk1[pin] > control[board[pin]] + 1)) + { + hung[c2]++; + shung[u]++; + } + } + else + { + if (upiece == lance) + { + s += (ds = fv1[XRAY] / 2); + } + else + { + s += (ds = fv1[XRAY]); + } + } + } + } + + pin = -1; /* new direction */ + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, sq); +#else + u = pdir[u]; +#endif + } + } + } + while (u != sq); + + *mob = mobx; + + return s; +} + + +#define ctlSG (ctlS | ctlG | ctlPp | ctlLp | ctlNp | ctlSp) + + + +/* + * Assign penalties if king can be threatened by checks, if squares near + * the king are controlled by the enemy (especially by promoted pieces), or + * if there are no own generals near the king. + * + * The following must be true: + * board[sq] == king, c1 == color[sq], c2 == otherside[c1] + */ + +#define SCORETHREAT \ +{ \ + if (color[u] != c2) \ + { \ + if ((atk1[u] == 0) || ((atk2[u] & CNT_MASK) > 1)) \ + { \ + ++cnt; \ + } \ + else \ + { \ + s += (ds = -fv1[CTRLK]); \ + } \ + } \ +} + + + + +inline short +KingScan(short sq) +{ + short cnt; + +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + + short s; + short u, ptyp; + short ok, ds; + + /* Penalties, if a king can be threatened by checks. */ + + s = 0; + cnt = 0; + + { + short p; + + for (p = pawn; p < king; p++) + { + if (HasPiece[c2][p] || Captured[c2][p]) + { + short ptyp; + + /* if a c1 piece can reach u from sq, + * then a c2 piece can reach sq from u. + * That means, each u is a square, from which a + * piece of type p and color c2 threats square sq. + */ + ptyp = ptype[c1][p]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + ppos = (*nextpos[ptyp])[sq]; + pdir = (*nextdir[ptyp])[sq]; + u = ppos[sq]; +#endif + + do + { + /* If a p piece can reach (controls or can drop to) + * square u, then score threat. + */ + + if (atk2[u] & control[p]) + SCORETHREAT + else if ((Captured[c2][p] && color[u]) == neutral) + SCORETHREAT + +#ifdef SAVE_NEXTPOS + u = ((color[u] == neutral) + ? next_position(ptyp, &d, sq, u) + : next_direction(ptyp, &d, sq)); +#else + u = ((color[u] == neutral) ? ppos[u] : pdir[u]); +#endif + } + while (u != sq); + } + } + } + + s += (ds = fv1[KSFTY] * KTHRT[cnt] / 16); + + /* Penalties, if squares near king are controlled by enemy. */ + + cnt = 0; + ok = false; + ptyp = ptype[c1][king]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + pdir = (*nextpos[ptyp])[sq]; + u = pdir[sq]; +#endif + + do + { + if (!ok && color[u] == c1) + { + short ptype_piece = ptype[black][board[u]]; + + if ((ptype_piece == ptype_silver) || (ptype_piece == ptype_gold)) + ok = true; + } + + if (atk2[u] > atk1[u]) + { + ++cnt; + + if (atk2[u] & ctlSG) + { + s += (ds = -fv1[KSFTY] / 2); + } + } + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, sq); +#else + u = pdir[u]; +#endif + } + while (u != sq); + + if (!ok || (cnt > 1)) + { + if (cnt > 1) + s += (ds = -fv1[KSFTY]/2); + else + s += (ds = -fv1[KSFTY]); + } + + return s; +} + + +static short checked_trapped; + + +/* + * See if the attacked piece has unattacked squares to move to. The following + * must be true: c1 == color[sq] c2 == otherside[c1] + */ + +inline int +trapped(short sq) +{ + short u, ptyp; +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + short piece; + short rvalue; + + piece = board[sq]; + rvalue = (*value)[stage][piece]; + ptyp = ptype[c1][piece]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + ppos = (*nextpos[ptyp])[sq]; + pdir = (*nextdir[ptyp])[sq]; + u = ppos[sq]; +#endif + + do + { + if (color[u] != c1) + { + if ((atk2[u] == 0) || ((*value)[stage][board[u]] >= rvalue)) + return false; + } + +#ifdef SAVE_NEXTPOS + u = ((color[u] == neutral) + ? next_position(ptyp, &d, sq, u) + : next_direction(ptyp, &d, sq)); +#else + u = ((color[u] == neutral) ? ppos[u] : pdir[u]); +#endif + } + while (u != sq); + + checked_trapped = true; + + return true; +} + + + +static int +AttackedPieceValue(short sq, short side) +{ + short s, ds; + + s = 0; + + ds += (ds = -fv1[HUNGP]); + hung[c1]++; + shung[sq]++; + + if (trapped(sq)) + { + hung[c1] += 2; + shung[sq] += 2; + } + + return s; +} + + + +static inline int +OpenFileValue(short sq, short hopn, short hopnx) +{ + short s = 0, fyle; + + if (PC1[fyle = column(sq)] == 0) + { + s += hopn; + } + + if (PC2[fyle] == 0) + { + s += hopnx; + } + + return s; +} + + + + +/* Distance bonus */ + +#define PromotionZoneDistanceValue(sq, dd) \ +if ((ds = fv1[PROMD])) \ +{ \ + s += (ds = ds * PromotionZoneDistanceBonus[crow(c1, sq)] * dd); \ +} + +#define OwnKingDistanceValue(sq, dd, maxd) \ +if ((ds = fv1[KINGOD]) && ((ad = Kdist[c1][sq]) <= maxd)) \ +{ \ + s += (ds = ds * OwnKingDistanceBonus[ad] * dd); \ +} + +#define EnemyKingDistanceValue(sq, dd, maxd) \ +if ((ds = fv1[KINGOD]) && ((ad = Kdist[c2][sq]) <= maxd)) \ +{ \ + s += (ds = ds * EnemyKingDistanceBonus[ad] * dd); \ +} + + + + + +/* + * Calculate the positional value for a pawn on 'sq'. + */ + +static inline int +PawnValue(short sq, short side) +{ + short s = 0; + short ds; + short ccol = ccolumn(c1, sq); + + PromotionZoneDistanceValue(sq, 3); + + /* pawn mobility */ + if (color[(c1 == black) ? (sq + 9) : (sq - 9)] == neutral) + { + s += (ds = MBLTY[pawn]); + } + + if ((a1 & ((ctlR | ctlRp) | ctlL))) + { + s += (ds = fv1[ATTACKED]); + } + + if (in_opening_stage) + { + if (crow(c1, sq) == 2) /* pawn on 3d rank */ + { + if (board[(c1 == black) ? (sq + 27) : (sq - 27)] == pawn) + { + /* opposing pawn has been moved (even column == (sq & 1)) */ + + short m; + + switch (ccol) + { + case 0: + case 8: + m = (side == c1) ? 3 : 5; + break; + + case 4: + m = (side == c1) ? 2 : 3; + break; + + default: + m = (side == c1) ? 1 : 2; + break; + } + + s += (ds = -m * MBLTY[pawn]); + } + } + + if ((GameType[c1] == STATIC_ROOK) && (sq == csquare(c1, 43))) + { + if ((atk2[csquare(c1, 52)] & CNT_MASK) < 2) + { + s += (ds = fv1[ATTACKED]); + } + } + + if ((GameType[c2] == STATIC_ROOK) && (ccol == 1)) + { + if (sq == csquare(c1, 28)) + { + s += (ds = -fv1[ATTACKED]); + } + + if (((atk1[csquare(c1, 19)] & CNT_MASK) < 2) + && ((atk1[csquare(c1, 28)] & CNT_MASK) < 2)) + { + s += (ds = -2 * fv1[ATTACKED]); + } + } + } + + return s; +} + + + +/* + * Calculate the positional value for a lance on 'sq'. + */ + +static inline int +LanceValue(short sq, short side) +{ + short s = 0, ds, ad; + + OwnKingDistanceValue(sq, 1, 2); + + OpenFileValue(sq, -fv1[HOPN], fv1[HOPN]); + + if (!checked_trapped && (crow(c1, sq) > 2)) + { + if (in_opening_stage || trapped(sq)) + { + s += (ds = -3 * fv1[ATTACKED]); + } + else + { + s += (ds = -2 * fv1[ATTACKED]); + } + } + + return s; +} + + + +/* + * Calculate the positional value for a knight on 'sq'. + */ + +static inline int +KnightValue(short sq, short side) +{ + short s = 0, ad; + short ds, checked_trapped = false; + short c = column(sq); + + PromotionZoneDistanceValue(sq, 1); + OwnKingDistanceValue(sq, 1, 2); + + if (!checked_trapped && (crow(c1, sq) > 2)) + { + if (trapped(sq)) + { + s += (ds = -4 * fv1[ATTACKED]); + } + else + { + s += (ds = -3 * fv1[ATTACKED]); + } + } + + if ((c == 0) || (c == 8)) + { + s += (ds = -fv1[ATTACKED]); + } + + return s; +} + + + +/* + * Calculate the positional value for a silver on 'sq'. + */ + +static inline int +SilverValue(short sq, short side) +{ + short s= 0, ds, ad; + + OwnKingDistanceValue(sq, 2, 3); + + if ((Kdist[c1][sq] < 3) + && (atk1[sq] & (control[gold] | control[silver]))) + { + s += (ds = fv1[COHESION]); + } + + if (in_opening_stage) + { + if (GameType[c1] == STATIC_ROOK) + { + if (csquare(c1, sq) == 12) + { + short csq; + + if ((board[csq = csquare(c1, 20)] == bishop) + && (color[csq] == c1)) + { + s += (ds = -2 * fv1[OPENWRONG]); + } + } + } + } + else + { + EnemyKingDistanceValue(sq, 2, 3); + } + + return s; +} + + + +/* + * Calculate the positional value for a gold on 'sq'. + */ + +static inline int +GoldValue(short sq, short side) +{ + short s = 0, ds, ad; + + OwnKingDistanceValue(sq, 2, 3); + + if ((Kdist[c1][sq] < 3) + && (atk1[sq] & (control[gold] | control[silver]))) + { + s += (ds = fv1[COHESION]); + } + + if (in_opening_stage) + { + if ((GameType[c1] == STATIC_ROOK) && (GameType[c2] != STATIC_ROOK)) + { + if (Mvboard[csquare(c1, 3)]) + { + s += (ds = -2 * fv1[OPENWRONG]); + } + } + } + else + { + EnemyKingDistanceValue(sq, 2, 3); + } + + return s; +} + + + +/* + * Calculate the positional value for a bishop on 'sq'. + */ + +static inline int +BishopValue(short sq, short side) +{ + short s = 0, ds, ad; + + if (in_opening_stage) + { + if (GameType[c1] == RANGING_ROOK) + { + /* Bishops diagonal should not be open */ + if (!on_csquare(c1, pawn, 30)) + { + s += (ds = -fv1[OPENWRONG]); + } + } + else if (GameType[c2] == RANGING_ROOK) + { + /* Bishops diagonal should be open */ + if ((csquare(c1, sq) == 10) + && (!empty_csquare(c1, 20) || !empty_csquare(c1, 30))) + { + s += (ds = -fv1[OPENWRONG]); + } + else if ((csquare(c1, sq) == 20) && !empty_csquare(c1, 30)) + { + s += (ds = -fv1[OPENWRONG]); + } + } + } + else + { + EnemyKingDistanceValue(sq, 1, 3); + } + + return s; +} + + + +/* + * Calculate the positional value for a rook on 'sq'. + */ + +static inline int +RookValue(short sq, short side) +{ + short s = 0, ds, ad; + + OpenFileValue(sq, 2 * fv1[HOPN], 4*fv1[HOPN]); + + if (in_opening_stage) + { + short WRONG = fv1[OPENWRONG], OPOK = WRONG / 3; + + if (GameType[c1] == STATIC_ROOK) + { + short c = ccolumn(c1, sq); + + /* Bonus for rook on 8th file */ + if (c == 7) + { + s += (ds = OPOK); + } + + /* + * Bonus for rook on right side, + * penalty for rook on left side + */ + + c = 4 - c; + ds = 0; + + if (c < 0) + { + s += (ds = c + c + OPOK); + } + else if (c >= 0) + { + s += (ds = -c - c - WRONG); + } + } + else if (GameType[c1] == RANGING_ROOK) + { + /* Bonus for rook on left side and + * bishops diagonal closed, penalty otherwise. */ + + short c; + c = 4 - ccolumn(c1, sq); + ds = 0; + + if (c >= 0) + { + /* Bishops diagonal should not be open. */ + if (on_csquare(c1, pawn, 30)) + s += (ds = OPOK); + else + s += (ds = -c - c - WRONG); + } + else if (c < 0) + { + s += (ds = -c - c - WRONG); + + /* Penalty for king not on initial square. */ + if (!on_csquare(side, king, 4)) + { + s += -4 * WRONG; + ds += -4 * WRONG; + } + } + } + } + else + { + EnemyKingDistanceValue(sq, 1, 3); + } + + return s; +} + + + +/* + * Calculate the positional value for a promoted pawn on 'sq'. + */ + +static inline int +PPawnValue(short sq, short side) +{ + short s = 0, ds, ad; + + EnemyKingDistanceValue(sq, 3, 10); + + return s; +} + + + +/* + * Calculate the positional value for a promoted lance on 'sq'. + */ + +static inline int +PLanceValue(short sq, short side) +{ + short s = 0, ds, ad; + + EnemyKingDistanceValue(sq, 3, 10); + + return s; +} + + + +/* + * Calculate the positional value for a promoted knight on 'sq'. + */ + +static inline int +PKnightValue(short sq, short side) +{ + short s = 0, ds, ad; + + EnemyKingDistanceValue(sq, 3, 10); + + return s; +} + + + +/* + * Calculate the positional value for a promoted silver on 'sq'. + */ + +static inline int +PSilverValue(short sq, short side) +{ + short s = 0, ds, ad; + + EnemyKingDistanceValue(sq, 3, 10); + + return s; +} + + + +/* + * Calculate the positional value for a promoted bishop on 'sq'. + */ + +static inline int +PBishopValue(short sq, short side) +{ + short s = 0, ds, ad; + + EnemyKingDistanceValue(sq, 3, 4); + + return s; +} + + + +/* + * Calculate the positional value for a promoted rook on 'sq'. + */ + +static inline int +PRookValue(short sq, short side) +{ + short s = 0, ds, ad; + + EnemyKingDistanceValue(sq, 3, 4); + + OpenFileValue(sq, 3 * fv1[HOPN], 2 * fv1[HOPN]); + + return s; +} + + + +/* + * Calculate the positional value for a king on 'sq'. + */ + +static inline int +KingValue(short sq, short side) +{ + short s = 0, ds; + + if (fv1[KSFTY] != 0) + s += KingScan(sq); + + if (in_opening_stage) + { + if ((GameType[c1] != UNKNOWN) && (ccolumn(c1, sq) == 4)) + { + s += (ds = -fv1[OPENWRONG] / 3); + } + else if ((GameType[c1] == STATIC_ROOK) && on_right_side(c1, sq)) + { + s += (ds = -fv1[OPENWRONG] / 2); + } + else if ((GameType[c1] == RANGING_ROOK) && on_left_side(c1, sq)) + { + s += (ds = -fv1[OPENWRONG] / 2); + } + } + + /* CHECKME: is this correct? */ + if ((ds = fv1[HOPN])) + { + s += OpenFileValue(sq, -2 * ds, -4 * ds); + } + + return s; +} + + + +/* + * Calculate the positional value for a piece on 'sq'. + */ + +static inline int +PieceValue(short sq, short side) +{ + short s, piece, ds; + short mob; + + piece = board[sq]; + + if (piece == no_piece) + return 0; + + s = (*Mpiece[piece])[c1][sq]; + + checked_trapped = false; + + if (sweep[piece]) + { + /* pin/x-ray attack and mobility for sweeping pieces */ + s += (ds = BRLscan(sq, &mob)); + + if ((piece == bishop) || (piece == pbishop)) + s += (ds = BMBLTY[mob] * fv1[MOBILITY] / 100); + else if ((piece == rook) || (piece == prook)) + s += (ds = RMBLTY[mob] * fv1[MOBILITY] / 100); + else + s += (ds = LMBLTY[mob] * fv1[MOBILITY] / 100); + } + else + { + /* mobility for non-sweeping pieces */ + } + + a2 = atk2[sq]; + a1 = atk1[sq]; + + if (a2 > 0) + { + /* opponent attacks piece */ + if (a1 == 0) + { + /* undefended piece */ + s += AttackedPieceValue(sq, side); + } + else + { + /* defended piece */ + short attack_value = value_of_weakest_attacker(a2); + short piece_value = (*value)[stage][piece]; + + if (attack_value < piece_value) + { + /* attacked by a weaker piece */ + s += AttackedPieceValue(sq, side) / 2; + } + else if (abs(attack_value - piece_value) < 10) + { + /* opponent has the option to exchange equal pieces */ + s += (ds = -fv1[ATTACKED]); + } + } + } + + if (piece != king) + { + + if (a1 > 0) + { + /* piece is defended */ + s += (ds = (a1 & CNT_MASK) * fv1[PROTECT]); + } + + if (sseed[sq]) + { + s += (ds = fv1[SEED]); + } + + if (sloose[sq]) + { + s += (ds = -fv1[LOOSE]); + } + + if (starget[c1][sq]) + { + if (sweep[piece]) + { + s -= (ds = -fv1[ATTACKED]/2); + } + else if (piece == pawn) + { + s += (ds = fv1[ATTACKED]); + } + } + + if (starget[c2][sq]) + { + if (piece != pawn) + { + s -= (ds = -fv1[ATTACKED] / 3); + } + else + { + s += (ds = fv1[ATTACKED]); + } + } + + if (Kdist[c1][sq] == 1) + { + s += (ds = fv1[KSFTY]); + } + } + + switch (piece) + { + case pawn: + s += PawnValue(sq, side); + break; + + case lance: + s += LanceValue(sq, side); + break; + + case knight: + s += KnightValue(sq, side); + break; + + case silver: + s += SilverValue(sq, side); + break; + + case gold: + s += GoldValue(sq, side); + break; + + case bishop: + s += BishopValue(sq, side); + break; + + case rook: + s += RookValue(sq, side); + break; + + case king: + s += KingValue(sq, side); + break; + + case ppawn: + s += PPawnValue(sq, side); + break; + + case plance: + s += PLanceValue(sq, side); + break; + + case pknight: + s += PKnightValue(sq, side); + break; + + case psilver: + s += PSilverValue(sq, side); + break; + + case pbishop: + s += PBishopValue(sq, side); + break; + + case prook: + s += PRookValue(sq, side); + break; + } + + return s; +} + + + +/* + * Score distance to pattern regarding the game type which side plays. + */ + +short +ScorePatternDistance(short c1) +{ + short ds, s = 0; + small_short *fv1 = fvalue[c1]; + short os = 0; + + if ((MAXCDIST > 0) && (fv1[PCASTLE] != 0) + && ((os = castle_opening_sequence[c1]) >= 0)) + { + ds = board_to_pattern_distance(c1, os, MAXCDIST, GameCnt); + + if (ds != 0) + { + s += (ds *= fv1[PCASTLE]); + } + } + + if ((MAXADIST > 0) && (fv1[PATTACK] != 0) + && ((os = attack_opening_sequence[c1]) >= 0)) + { + ds = board_to_pattern_distance(c1, os, MAXADIST, GameCnt); + + if (ds != 0) + { + s += (ds *= fv1[PATTACK]); + } + } + + return s; +} + + + + +/* + * Determine castle and attack pattern which should be reached next. + * Only patterns are considered, which have not been reached yet. + */ + +static void +UpdatePatterns(short side, short GameCnt) +{ + char s[12]; + short xside = side ^ 1; + short os; + short j, k, n = 0; + + strcpy(s, "CASTLE_?_?"); + s[7] = GameType[side]; + s[9] = GameType[xside]; + castle_opening_sequence[side] = os + = locate_opening_sequence(side, s, GameCnt); + + if (flag.post && (os != END_OF_SEQUENCES)) + { + for (j = 0; j < MAX_SEQUENCE; j++) + { + for (k = OpeningSequence[os].first_pattern[j]; + k != END_OF_PATTERNS; + k = Pattern[k].next_pattern) + { + if (Pattern[k].distance[side] >= 0) + n++; + } + } + } + + if (os != END_OF_SEQUENCES) + update_advance_bonus(side, os); + + strcpy(s, "ATTACK_?_?"); + s[7] = GameType[side]; + s[9] = GameType[xside]; + attack_opening_sequence[side] = os + = locate_opening_sequence(side, s, GameCnt); + + if (flag.post && (os != END_OF_SEQUENCES)) + { + for (j = 0; j < MAX_SEQUENCE; j++) + { + for (k = OpeningSequence[os].first_pattern[j]; + k != END_OF_PATTERNS; + k = Pattern[k].next_pattern) + { + if (Pattern[k].distance[side] >= 0) + n++; + } + } + } + + if (flag.post) + ShowPatternCount(side, n); + + if (os != END_OF_SEQUENCES) + update_advance_bonus(side, os); +} + + + +static void +ScoreCaptures(void) +{ + short ds, col, n, m, piece; + + if ((n = Captured[c1][pawn])) + { + ds = m = 0; + + for (col = 0; col < NO_COLS; col++) + { + if (!PC1[col]) + { + m++; + ds += fv1[PWNDROP]; + } + } + + /* FIXME! another great obfuscated line... */ + pscore[c1] += (ds *= ((n > 2) ? 3 : n)); + } + + if ((m = seed[c1])) + { + for (piece = lance, n = 0; piece <= rook; piece++) + { + if (Captured[c1][piece]) + n++; + } + + pscore[c1] += (ds = m * fv1[DFFDROP]); + } + + for (piece = pawn, n = 0; piece <= rook; piece++) + { + if (Captured[c1][piece]) + { + switch (piece) + { + case bishop: + ds = BMBLTY[MAX_BMBLTY - 1]; + break; + + case rook: + ds = RMBLTY[MAX_RMBLTY - 1]; + break; + + case lance: + ds = LMBLTY[MAX_LMBLTY - 1]; + break; + + default: + ds = MBLTY[piece]; + } + + pscore[c1] += ds; + + if (!Captured[c2][piece]) + n += relative_value[piece]; + } + } + + if (n) + { + pscore[c1] += (ds = -n * fv1[OPPDROP] / 2); + } +} + + + + + +/* + * Perform normal static evaluation of board position. A score is generated + * for each piece and these are summed to get a score for each side. + */ + +short +ScorePosition(short side) +{ + short score; + short sq, i, xside; + short s; + short ds; + + xside = side ^ 1; + + UpdateWeights(side); + + hung[black] = hung[white] = pscore[black] = pscore[white] = 0; + + array_zero(shung, sizeof(shung)); + +#ifdef CACHE + if (!(use_etable && ProbeEETable(side, &s))) + { +#endif + for (c1 = black; c1 <= white; c1++) + { + c2 = c1 ^ 1; + + /* atk1 is array of attacks on squares by my side */ + atk1 = attack[c1]; + + /* atk2 is array of attacks on squares by other side */ + atk2 = attack[c2]; + + /* same for PC1 and PC2 */ + PC1 = PawnCnt[c1]; + PC2 = PawnCnt[c2]; + + /* same for fv1 and fv2 */ + fv1 = fvalue[c1]; + + for (i = PieceCnt[c1]; i >= 0; i--) + { + sq = PieceList[c1][i]; + +#if defined SAVE_SVALUE + pscore[c1] += PieceValue(sq, side); +#else + pscore[c1] += (svalue[sq] = PieceValue(sq, side)); +#endif + } + + ScoreCaptures(); + } + + for (c1 = black, c2 = white; c1 <= white; c1++, c2--) + { + short n; + + fv1 = fvalue[c1]; + + /* Score fifth rank */ + for (sq = 36, n = 0; sq <= 44; sq++) + { + if ((color[sq] == c1) || (attack[c1][sq] != 0)) + n++; + } + + if (n != 0) + { + pscore[c1] += (ds = n * fv1[CNTRL5TH]); + } + + /* Score holes */ + for (sq = ((c1 == black) ? 0 : 54), n = 0; + sq <= ((c1 == black) ? 26 : 80); + sq++) + { + if (board[sq] == no_piece && attack[c1][sq] == 0) + n++; + } + + if (n != 0) + { + pscore[c1] += (ds = -n * fv1[HOLES]); + } + + if (hung[c1] > 1) + { + pscore[c1] += (ds = -fv1[HUNGX]); + } + + /* Score opening features and + * castle/attack pattern distances */ + + if (in_opening_stage) + { + pscore[c1] += (ds = ScoreKingOpeningFeatures()); + pscore[c1] += (ds = ScorePatternDistance(c1)); + } + } + + score = mtl[side] - mtl[xside] + + pscore[side] - pscore[xside] + 10; + +#ifdef CACHE + if (use_etable && PUTVAR) + PutInEETable(side, score); +#endif + + return score; +#ifdef CACHE /* CHECKME: this looks bad */ + } + + return s; +#endif +} + + + +/* + * Try to determine the game type of "side". + */ + +inline static void +GuessGameType(short side_to_move) +{ + short side, gt; + short StaticRook[2] = { 0, 0 }; + short RangingRook[2] = { 0, 0 }; + + for (side = black; side <= white; side++) + { + /* computer should not change its mind */ + + extern int bookflag; + + gt = GameType[side]; + + if (!bookflag && (side == side_to_move)) + { + if (gt == STATIC_ROOK) + StaticRook[side] += 4; + else if (gt == RANGING_ROOK) + RangingRook[side] += 4; + } + + /* static rook conditions */ + + if (on_column(side, rook, 7)) + StaticRook[side] += 3; + + if (on_csquare(side, pawn, 34)) + StaticRook[side] += 6; + else if (on_csquare(side, pawn, 43)) + StaticRook[side] += 4; + else if (!on_column(side, pawn, 7)) + StaticRook[side] += 5; + + if (empty_csquare(side, 5) || empty_csquare(side, 6)) + StaticRook[side] += 2; + + if (on_left_side(side, king)) + StaticRook[side] += 2; + + /* ranging rook conditions */ + + if (on_left_side(side, rook)) + RangingRook[side] += 5; + else if (!on_column(side, rook, 7)) + RangingRook[side] += 3; + + if (on_csquare(side, pawn, 25)) + RangingRook[side] += 1; + + if (on_csquare(side, pawn, 30)) + RangingRook[side] += 1; + else + RangingRook[side] -= 2; + + if (!on_right_side(side, rook)) + RangingRook[side] += 4; + + if (on_right_side(side, king)) + RangingRook[side] += 4; + + if (on_csquare(side, bishop, 20)) + { + if (on_csquare(side, silver, 11) + || on_csquare(side, silver, 12) + || on_csquare(side, silver, 21)) + { + RangingRook[side] += 3; + } + } + + if ((StaticRook[side] > 5) || (RangingRook[side] > 5)) + { + GameType[side] = (StaticRook[side] > RangingRook[side]) + ? STATIC_ROOK : RANGING_ROOK; + } + else + { + GameType[side] = UNKNOWN; + } + } + + if ((GameType[black] == UNKNOWN) || (GameType[white] == UNKNOWN)) + { + for (side = black; side <= white; side++) + { + if ((side == computer) && (GameType[side] == UNKNOWN)) + { + /* + * Game type is UNKNOWN. + * Make a decision what type of game to play. + * To make computer games more interesting, make a + * random decision. + */ + + if (!on_csquare(side, pawn, 25)) + { + /* Play static rook if rook pawn has been pushed! */ + GameType[side] = STATIC_ROOK; + } + else + { + unsigned int random = urand() % 100; + short d = StaticRook[side] - RangingRook[side]; + + switch (GameType[side ^ 1]) + { + case STATIC_ROOK: + if (random < 35 + d) + GameType[side] = STATIC_ROOK; + else if (random < 95) + GameType[side] = RANGING_ROOK; + break; + + case RANGING_ROOK: + if (random < 75 + d) + GameType[side] = STATIC_ROOK; + else if (random < 95) + GameType[side] = RANGING_ROOK; + break; + + default: + if (random < 33 + d) + GameType[side] = STATIC_ROOK; + else if (random < 66) + GameType[side] = RANGING_ROOK; + } + } + } + } + } +} + + + + +static void +DetermineGameType(short side_to_move) +{ + short side; + + GuessGameType(side_to_move); + + array_zero(Mpawn, sizeof(Mpawn)); + array_zero(Mlance, sizeof(Mlance)); + array_zero(Mknight, sizeof(Mknight)); + array_zero(Msilver, sizeof(Msilver)); + array_zero(Mgold, sizeof(Mgold)); + array_zero(Mbishop, sizeof(Mbishop)); + array_zero(Mrook, sizeof(Mrook)); + array_zero(Mking, sizeof(Mking)); + + if (in_opening_stage) + { + for (side = black; side <= white; side++) + UpdatePatterns(side, GameCnt); + } + else + { + ShowPatternCount(black, -1); + ShowPatternCount(white, -1); + } +} + + + +/* + * This is done one time before the search is started. Set up arrays + * Mwpawn, Mbpawn, Mknight, Mbishop, Mking which are used in the SqValue() + * function to determine the positional value of each piece. + */ + +void +ExaminePosition(short side) +{ + short c1, piece, sq, i, bsq, wsq; + + /* Build enemy king distance tables. */ + + for (sq = 0, bsq = BlackKing, wsq = WhiteKing; sq < NO_SQUARES; sq++) + { + Kdist[black][sq] = distance(sq, bsq); + Kdist[white][sq] = distance(sq, wsq); + } + + threats(black); + threats(white); + + ExamineSquares(); + + DetermineGameType(side); + DetermineStage(side); + + UpdateWeights(side); + + array_zero(HasPiece, sizeof(HasPiece)); + + for (c1 = black; c1 <= white; c1++) + { + for (i = PieceCnt[c1]; i >= 0; i--) + { + ++HasPiece[c1][piece = board[sq = PieceList[c1][i]]]; + } + } +} + + + +void +DetermineStage(short side) +{ + short xside = side ^ 1, ds, db1, c1, c2, feature; + + /* Determine initial stage */ + + balance[side] = balance[xside] = 50; + + if ((GameType[side] == STATIC_ROOK) + && (GameType[xside] == STATIC_ROOK)) + { + if (GameCnt < 40) + stage = 0; + else if (GameCnt < 60) + stage = 15; + else if (GameCnt < 80) + stage = 25; + else + stage = 30; + } + else if ((GameType[side] == RANGING_ROOK) + || (GameType[xside] == RANGING_ROOK)) + { + if (GameCnt < 30) + stage = 0; + else if (GameCnt < 50) + stage = 15; + else if (GameCnt < 70) + stage = 25; + else + stage = 30; + } + else + { + if (GameCnt < 35) + stage = 0; + else if (GameCnt < 55) + stage = 15; + else if (GameCnt < 75) + stage = 25; + else + stage = 30; + } + + /* Update stage depending on board features and attack balance value */ + + if (abs(ds = (mtl[side] - mtl[xside])) + > (db1 = (*value)[stage][lance])) + { + db1 = abs(4 * ds / db1); + + if (ds < 0) + balance[side] += db1; + else if (ds > 0) + balance[xside] += db1; + + stage += (ds = db1); + } + + for (c1 = black, c2 = white; c1 <= white; c1++, c2--) + { + if ((ds = seed[c1]) > 2) + { + balance[c1] += (db1 = ds * 2); + balance[c2] -= db1; + + if (stage < 30) + stage = 30; + + stage += ds; + } + + if ((db1 = hung[c1]) > 2) + { + balance[c1] -= (db1 *= 2); + balance[c2] += db1; + } + + if ((db1 = loose[c1]) > 4) + { + balance[c1] -= (db1 /= 2); + balance[c2] += db1; + stage += (ds = 1); + } + + if ((ds = hole[c1])) + { + balance[c1] -= (db1 = ds); + balance[c2] += db1; + stage += (ds /= 2); + } + + if ((db1 = target[c1]) > 3) + { + balance[c1] += (db1 /= 3); + balance[c2] -= db1; + stage += (ds = db1 / 4); + } + + stage += (ds = captured[c1] / 2); + + if ((db1 = captured[c1]) > 4) + { + balance[c1] += (db1 /= 2); + stage += (ds = 3); + } + + if ((db1 = dcaptured[c1]) > 3) + { + balance[c1] += db1; + stage += (ds = 3); + } + + if (balance[c1] > 99) + balance[c1] = 99; + else if (balance[c1] < 0) + balance[c1] = 0; + } + + if (stage > 99) + stage = 99; + else if (stage < 0) + stage = 0; + + if (flag.post) + ShowStage(); + + /* Determine stage dependant weights */ + + ADVNCM[pawn] = 1; /* advanced pawn bonus increment */ + ADVNCM[lance] = 1; + ADVNCM[knight] = 1; + ADVNCM[silver] = 1; /* advanced silver bonus increment */ + ADVNCM[gold] = 1; /* advanced gold bonus increment */ + ADVNCM[bishop] = 1; + ADVNCM[rook] = 1; + ADVNCM[king] = 1; /* advanced king bonus increment */ + + MAXCDIST = (stage < 33) ? (33 - stage) / 4 : 0; + MAXADIST = (stage < 30) ? (30 - stage) / 4 : 0; + + for (c1 = black; c1 <= white; c1++) + { + for (feature = 0; feature < NO_FEATURES; feature++) + { + fvalue[c1][feature] = + ((((*fscore)[stage][feature][0] * (99 - balance[c1])) + 50) + / 100) + + ((((*fscore)[stage][feature][1] * balance[c1]) + 50) + / 100); + } + } +} + + + +void +UpdateWeights(short stage) +{ +} + + + +/* + * Compute stage dependent relative material values assuming + * linearity between the main stages: + * + * minstage < stage < maxstage => + * stage - minstage value - minvalue + * ------------------- = ------------------- + * maxstage - minstage maxvalue - minvalue + */ + + +static short +linear_piece_value(short piece, short stage, short i, short j) +{ + short minvalue, maxvalue, minstage, maxstage; + + minstage = ispvalue[0][i]; + maxstage = ispvalue[0][j]; + minvalue = ispvalue[piece][i]; + maxvalue = ispvalue[piece][j]; + + /* FIXME: set a variable then return it, puh-leeze! */ + return ((stage - minstage) * (maxvalue - minvalue) + / (maxstage - minstage)) + minvalue; +} + + + +static short +linear_feature_value(short feature, short stage, short i, short j) +{ + short minvalue, maxvalue, minstage, maxstage; + + minstage = ispvalue[0][i]; + maxstage = ispvalue[0][j]; + minvalue = weight[feature][i]; + maxvalue = weight[feature][j]; + + /* FIXME: set a variable then return it, puh-leeze! */ + return ((stage - minstage) * (maxvalue - minvalue) + / (maxstage - minstage)) + minvalue; +} + + +/* + * matweight = percentage_of_max_value * max_value(stage) / 100 + * max_value(0) = MAX_VALUE; max_value(100) = MIN_VALUE + * => max_value(stage) = a * stage + b; b = MAX_VALUE, + * a = (MIN_VALUE - MAX_VALUE)/100 + */ + +#define MIN_VALUE 300 +#define MAX_VALUE 1000 + +#define max_value(stage) \ +((long)(MIN_VALUE - MAX_VALUE) * stage + (long)100 * MAX_VALUE) +#define matweight(value, stage) \ +((long)max_value(stage) * value / 10000) + + + +void +Initialize_eval(void) +{ + short stage, piece, feature, i; + + for (stage = 0; stage < NO_STAGES; stage++) + { + for (i = 0; i < MAIN_STAGES; i++) + { + if (stage == ispvalue[0][i]) + { + for (piece = 0; piece < NO_PIECES; piece++) + { + (*value)[stage][piece] = + matweight(ispvalue[piece][i], stage); + } + + for (feature = 0; feature < NO_FEATURES; feature++) + { + (*fscore)[stage][feature][0] = + (weight[feature][i] + * weight[feature][MAIN_STAGES] + 50) / 100; + + (*fscore)[stage][feature][1] = + (weight[feature][i] + * weight[feature][MAIN_STAGES + 1] + 50) / 100; + } + + break; + } + + if (stage < ispvalue[0][i + 1]) + { + for (piece = 0; piece < NO_PIECES; piece++) + { + (*value)[stage][piece] = + matweight( + linear_piece_value(piece, stage, i, i + 1), + stage); + } + + for (feature = 0; feature < NO_FEATURES; feature++) + { + (*fscore)[stage][feature][0] = + (linear_feature_value(feature, stage, i, i + 1) + * weight[feature][MAIN_STAGES] + 50) / 100; + + (*fscore)[stage][feature][1] = + (linear_feature_value(feature, stage, i, i + 1) + * weight[feature][MAIN_STAGES + 1] + 50) / 100; + } + + break; + } + } + } +} + diff --git a/gnushogi/eval.h b/gnushogi/eval.h new file mode 100644 index 0000000..06609fd --- /dev/null +++ b/gnushogi/eval.h @@ -0,0 +1,71 @@ +/* + * FILE: eval.h + * + * Interface to the board evaluator. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + + +#ifndef _EVAL_H_ +#define _EVAL_H_ + +#define NO_STAGES 100 +#define NO_FEATURES 31 + + +struct signature +{ + unsigned long hashbd; + unsigned long hashkey; +}; + +#define MatchSignature(s) ((s.hashbd == hashbd) && (s.hashkey == hashkey)) +#define CopySignature(s) { s.hashbd = hashbd; s.hashkey = hashkey; } + +typedef short value_array[NO_STAGES][NO_PIECES]; +typedef small_short fscore_array[NO_STAGES][NO_FEATURES][2]; + +extern value_array *value; +extern fscore_array *fscore; + +extern void threats (short side); + +extern long attack[2][NO_SQUARES]; +extern small_short sseed[NO_SQUARES]; + +extern struct signature threats_signature[2]; + +extern small_short starget[2][NO_SQUARES]; +extern small_short sloose[NO_SQUARES]; +extern small_short shole[NO_SQUARES]; +extern small_short shung[NO_SQUARES]; + +extern struct signature squares_signature; + +#endif /* _EVAL_H_ */ diff --git a/gnushogi/genmove.c b/gnushogi/genmove.c new file mode 100644 index 0000000..6490319 --- /dev/null +++ b/gnushogi/genmove.c @@ -0,0 +1,1654 @@ +/* + * FILE: genmove.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" + +/* #define DONTUSE_HEURISTIC */ + +short *TrP; + +static struct leaf *node; +static short sqking, sqxking; +static short InCheck = false, GenerateAllMoves = false; +static short check_determined = false; + +static short INCscore = 0; + +short deepsearchcut = true; +short tas = false, taxs = false, ssa = false; + +short generate_move_flags = false; + + +/* + * Ply limits for deep search cut. No moves or drops flagged with "stupid" + * are considered beyond ply BEYOND_STUPID. Only moves or drops flagged + * with "kingattack" are considered beyond ply BEYOND_KINGATTACK. No moves + * or drops flagged with "questionable" are considered beyond ply + * BEYOND_QUESTIONABLE. Only moves or drops flagged with "tesuji" are + * considered beyond ply BEYOND_TESUJI. No drops are considered beyond ply + * BEYOND_DROP. Exceptions: moves or drops that prevent check or give + * check are always considered. + */ + +#define BEYOND_STUPID 0 +#define BEYOND_TIMEOUT 2 +#define BEYOND_KINGATTACK 6 +#define BEYOND_QUESTIONABLE 8 +#define BEYOND_TESUJI 8 +#define BEYOND_DROP 10 + +#ifdef DONTUSE_HEURISTIC +static short MaxNum[MAXDEPTH] = +{ + -1, 40, 80, 20, 40, 10, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, +}; +#endif + +#ifdef HASHKEYTEST +extern int CheckHashKey(); +extern char mvstr[4][6]; +#endif + + +/* + * Update Arrays board[] and color[] to reflect the new board + * position obtained after making the move pointed to by node. + */ + +inline static void +GenMakeMove(short side, + short f, + short t, + short *tempb, /* piece at to square */ + short *tempc, /* color of to square */ + short promote_piece) +{ + short piece, upiece, n; + + t = t & 0x7f; + + if (f > NO_SQUARES) + { + piece = f - NO_SQUARES; + + if (piece > NO_PIECES) + piece -= NO_PIECES; + + board[t] = piece; + color[t] = side; + n = (Captured[side][piece])--; + UpdateDropHashbd(side, piece, n); + UpdateHashbd(side, piece, -1, t); + UpdatePieceList(side, t, ADD_PIECE); + } + else + { + *tempb = board[t]; + *tempc = color[t]; + + if (*tempb != no_piece) + { + n = ++Captured[side][upiece = unpromoted[*tempb]]; + UpdateDropHashbd(side, upiece, n); + UpdateHashbd(*tempc, *tempb, -1, t); + UpdatePieceList(*tempc, t, REMOVE_PIECE); + } + + piece = board[f]; + Pindex[t] = Pindex[f]; + PieceList[side][Pindex[t]] = t; + color[f] = neutral; + board[f] = no_piece; + color[t] = side; + + if (promote_piece) + { + UpdateHashbd(side, piece, f, -1); + board[t] = promoted[piece]; + UpdateHashbd(side, board[t], -1, t); + } + else + { + board[t] = piece; + UpdateHashbd(side, piece, f, t); + } + } + +#ifdef HASHKEYTEST + if (CheckHashKey()) + { + algbr(f, t, 0); + printf("error in GenMakeMove: %s\n", mvstr[0]); + exit(1); + } +#endif +} + + + +/* + * Take back a move. + */ + +static void +GenUnmakeMove(short side, + short f, + short t, + short tempb, + short tempc, + short promote_piece) +{ + short piece, upiece, n; + + t = t & 0x7f; + + if (f > NO_SQUARES) + { + piece = f - NO_SQUARES; + + if (piece > NO_PIECES) + piece -= NO_PIECES; + + board[t] = no_piece; + color[t] = neutral; + n = ++Captured[side][piece]; + UpdateDropHashbd(side, piece, n); + UpdateHashbd(side, piece, -1, t); + UpdatePieceList(side, t, REMOVE_PIECE); + } + else + { + piece = board[t]; + color[t] = tempc; + board[t] = tempb; + Pindex[f] = Pindex[t]; + PieceList[side][Pindex[f]] = f; + + if (tempb != no_piece) + { + /* FIXME: make this next line a bit more reasonable... */ + n = (Captured[side][upiece = unpromoted[tempb]])--; + UpdateDropHashbd(side, upiece, n); + UpdateHashbd(tempc, tempb, -1, t); + UpdatePieceList(tempc, t, ADD_PIECE); + } + + color[f] = side; + + if (promote_piece) + { + UpdateHashbd(side, piece, -1, t); + board[f] = unpromoted[piece]; + UpdateHashbd(side, board[f], f, -1); + } + else + { + board[f] = piece; + UpdateHashbd(side, piece, f, t); + } + } + +#ifdef HASHKEYTEST + if (CheckHashKey()) + { + algbr(f, t, 0); + printf("error in GenUnmakeMove: %s\n", mvstr[0]); + exit(1); + } +#endif +} + + + +static void +gives_check_flag(unsigned short *flags, short side, short f, short t) +{ + short tempb, tempc, blockable, promote_piece; + promote_piece = (*flags & promote) != 0; + GenMakeMove(side, f, t, &tempb, &tempc, promote_piece); + + if (SqAttacked(sqxking, side, &blockable)) + *flags |= check; + + GenUnmakeMove(side, f, t, tempb, tempc, promote_piece); +} + + +inline static void +Link(short side, short piece, + short from, short to, unsigned short local_flag, short s) +{ + if (*TrP == TREE) + { + ShowMessage("TREE overflow\n"); + } + else + { + node->f = from; + node->t = (local_flag & promote) ? (to | 0x80) : to; + node->reply = 0; + node->flags = local_flag; + node->score = s; + node->INCscore = INCscore; + + if (GenerateAllMoves) + { + /* FIXME: gimme a break! */ + (*TrP)++, node++; + } + else if (InCheck) + { + /* only moves out of check */ + short tempb, tempc, sq, threat, blockable, promote_piece; + promote_piece = (node->flags & promote) != 0; + GenMakeMove(side, node->f, node->t, + &tempb, &tempc, promote_piece); + sq = (from == sqking) ? to : sqking; + threat = SqAttacked(sq, side ^ 1, &blockable); + GenUnmakeMove(side, node->f, node->t, + tempb, tempc, promote_piece); + + if (!threat) + { + /* FIXME! Gimme a break! */ + (*TrP)++, node++; + } + } + else if (flag.tsume) + { + /* only moves that give check */ + if (!(node->flags & check) && !check_determined) + { + /* determine check flag */ + gives_check_flag(&node->flags, side, node->f, node->t); + } + + if (node->flags & check) + { + /* FIXME! Gimme a break! */ + (*TrP)++, node++; + } + } + else + { + /* FIXME! Gimme a break! */ + (*TrP)++, node++; + } + } +} + + +inline int +PromotionPossible(short color, short f, short t, short p) +{ + if (color == black) + { + if ((f < 54) && (t < 54)) + return false; + } + else + { + if ((f > 26) && (t > 26)) + return false; + } + + /* FIXME: this can be simplified... */ + switch (p) + { + case pawn: + case lance: + case knight: + case silver: + case bishop: + case rook: + return true; + }; + + return false; +} + + +inline int +NonPromotionPossible(short color, short f, + short t, short p) +{ + switch (p) + { + case pawn : + if (color == black) + { + return ((t < 72) + ? true + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } + else + { + return ((t > 8) + ? true + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } + + case lance: + if (color == black) + { + return ((t < 72) + ? true + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } + else + { + return ((t > 8) + ? true + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } + + case knight: + if (color == black) + { + return ((t < 63) + ? true + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } + else + { + return ((t > 17) + ? true + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } + } + + return true; +} + + +#if defined FIELDBONUS || defined DROPBONUS + +/* bonus for possible next moves */ + +inline static short +field_bonus(short ply, short side, short piece, + short f, short t, unsigned short *local_flag) +{ + short s, u, ptyp; + unsigned char *ppos, *pdir; + short c1, c2; + +#ifdef SAVE_NEXTPOS + short d; +#endif + + c1 = side; + c2 = side ^ 1; + s = 0; + check_determined = true; + + ptyp = ptype[side][piece]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, t); +#else + ppos = (*nextpos[ptyp])[t]; + pdir = (*nextdir[ptyp])[t]; + u = ppos[t]; +#endif + + do + { + short coloru = color[u]; + + if (piece != king && GameCnt > 40) + { + if (distance(u, EnemyKing) <= 1) + { + /* can reach square near own king */ + s += 2; + *local_flag |= kingattack; + } + else if (distance(u, OwnKing) <= 1) + { + /* can reach square near enemy king */ + s++; + *local_flag |= kingattack; + } + } + + if (coloru == side) + { + /* impossible next move */ +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, t); +#else + u = pdir[u]; +#endif + } + else + { + /* possible next move */ + if (PromotionPossible(side, t, u, piece)) + { + /* possible promotion in next move */ + if (piece == pawn) + { + s += 2; +#ifdef TESUJIBONUS + if (!InPromotionZone(side, t)) + { + *local_flag |= tesuji; /* The dangling pawn */ + s++; + } +#endif + } + else + { + s++; + } + } + + if (coloru == neutral) + { + /* next move to an empty square */ + if (u == FROMsquare) + { + /* opponent has just left this square */ + s++; + } + +#ifdef SAVE_NEXTPOS + u = next_position(ptyp, &d, t, u); +#else + u = ppos[u]; +#endif + } + else + { + /* attack opponents piece */ +#ifdef TESUJIBONUS + short boardu, upiece, rvupiece, rvuboard; +#endif + s++; + + if (u == TOsquare) /* opponent has moved to TOsquare */ + s++; + + if ((boardu = board[u]) == king) + { + s += 20; INCscore -= 18; + *local_flag |= check; /* move threatens + * opponents king */ + } + +#ifdef TESUJIBONUS + upiece = unpromoted[piece]; + rvupiece = relative_value[upiece]; + rvuboard = relative_value[unpromoted[boardu]]; + + if ((upiece == pawn) && (Captured[side][pawn] > 1)) + { + *local_flag |= tesuji; /* The joining pawn attack */ + s++; + } + + if (rvupiece <= rvuboard) + { + *local_flag |= tesuji; /* The striking pawn + * (piece) attack */ + + if (f > NO_SQUARES) + s += 2; + else + s++; + + if (upiece == pawn) + s++; + + /* CHECKME: is this right? */ + if (((rvupiece == rvuboard) && (upiece == pawn)) + || (upiece == bishop) || (upiece == knight)) + { + s++; /* The opposing pawn (piece) */ + + if (upiece == pawn) + s++; + } + } +#endif + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, t); +#else + u = pdir[u]; +#endif + } + } + } + while (u != t); + + INCscore += s; + + return s; +} + +#endif + + + + +/* + * Add a move to the tree. Assign a bonus to order the moves as follows: + * 1. Principle variation 2. Capture of last moved piece 3. Other captures + * (major pieces first) 4. Killer moves 5. Tesuji drops 6. Other Moves + * 7. Other drops. 8. Non-promoting moves + * If the flag.tsume is set, assign a high bonus for checks. + */ + +/* inline */ void +LinkMove(short ply, short f, + short t, + unsigned short local_flag, + short xside, + short score_if_impossible) +{ + short s = 0; + short side, piece, mv; + short flag_tsume, try_link = true; + short c1, c2, ds, is_drop = f > NO_SQUARES; + unsigned long as = 0; + + flag_tsume = flag.tsume; + + c1 = side = xside ^ 1; + c2 = xside; + + /* + * Is it determined whether the move gives check ? + */ + + check_determined = ((local_flag & check) != 0); + + mv = (f << 8) | ((local_flag & promote) ? (t | 0x80) : t); + + if (f > NO_SQUARES) + { + piece = f - NO_SQUARES; + + if (piece > NO_PIECES) + piece -= NO_PIECES; + } + else + { + piece = board[f]; + } + + if (score_if_impossible < 0) + { + /* The move is flagged as illegal. */ + Link(side, piece, + f, t, local_flag, score_if_impossible); + + return; + } + + INCscore = 0; + +#ifdef HISTORY + s += history[hindex(side, mv)]; +#endif + + /* If we're running short of tree nodes, go into tsume mode. */ + + if (!(local_flag & capture)) + { + if (*TrP > (TREE - 300)) + { + /* too close to tree table limit */ + flag.tsume = true; + } + } + + /* Guess strength of move and set flags. */ + + if ((piece != king) && (!in_opening_stage)) + { + if (distance(t, EnemyKing) <= 1) + { + /* bonus for square near enemy king */ + s += 15; + INCscore += 2; + local_flag |= kingattack; + } + else if (distance(t, OwnKing) <= 1) + { + /* bonus for square near own king */ + s += 10; + INCscore++; + local_flag |= kingattack; + } + } + + if (tas) /* own attack array available */ + { + /* square t defended by own piece (don't count piece to move) ? */ + if (is_drop + ? (as = attack[side][t]) + : (as = ((attack[side][t] & CNT_MASK) > 1))) + s += (ds = in_endgame_stage ? 100 : 10); + } + + if (taxs) /* opponents attack array available */ + { + /* square t not threatened by opponent or + * defended and only threatened by opponents king ? + */ + unsigned long axs; + + if (!(axs = attack[xside][t]) + || (tas && as && (axs & control[king]) && (axs & CNT_MASK) == 1)) + { + /* FIXME: this is a mess; clean up. */ + s += (ds = in_endgame_stage + ? 200 + : (is_drop + ? (InPromotionZone(side, t) + ? 40 + relative_value[piece] + : 10) + : 20)); + } + } + + /* target square near area of action */ + + if (TOsquare >= 0) + s += (9 - distance(TOsquare, t)); + + if (FROMsquare >= 0) + s += (9 - distance(FROMsquare, t)) / 2; + + /* target square near own or enemy king */ + + if (!in_opening_stage && piece != king) + { + if (balance[c1] < 50) + s += (9 - distance(EnemyKing, t)) * (50 - balance[c1]) / 20; + else + s += (9 - distance(OwnKing, t)) * (balance[c1] - 50) / 20; + } + + if (f > NO_SQUARES) + { + /* bonus for drops, in order to place + * drops before questionable moves */ + s += in_endgame_stage ? 25 : 10; + + if (t == FROMsquare) + { + /* drop to the square the opponent has just left */ + s += 5; + }; + + if (piece == gold) + s -= 32 / Captured[side][gold]; + else if (piece == silver) + s -= 16 / Captured[side][silver]; + +#if defined DROPBONUS + s += field_bonus(ply, side, piece, f, t, &local_flag); + + if (s == 10 && piece != pawn) + local_flag |= questionable; +#endif + } + else + { + /* bonus for moves (non-drops) */ + int consider_last = false; + + if (in_endgame_stage && Captured[side][gold]) + s += 10; + + s += 20; + + if (t == FROMsquare) + { + /* move to the square the opponent has just left */ + s += in_endgame_stage ? 10 : 1; + } + + if (color[t] != neutral) + { + /* Captures */ + if (in_endgame_stage) + { + s += relative_value[board[t]] - relative_value[piece]; + } + else + { + s += (*value)[stage][board[t]] - relative_value[piece]; + } + + if (t == TOsquare) /* Capture of last moved piece */ + s += in_endgame_stage ? 5 : 50; + } + + if (local_flag & promote) + { + /* bonus for promotions */ + s++; + INCscore += value[stage][promoted[piece]] - value[stage][piece]; + } + else + { + /* bonus for non-promotions */ + if (PromotionPossible(side, f, t, piece)) + { +#ifdef TESUJIBONUS + /* Look at non-promoting silver or knight */ + if (piece == silver || piece == knight) + { + local_flag |= tesuji; /* Non-promotion */ + s++; + } + else +#endif + { + consider_last = true; + + if (piece == pawn || piece == bishop || piece == rook) + { + local_flag |= stupid; + INCscore -= 20; + } + else + { + local_flag |= questionable; + INCscore -= 10; + } + } + } + } + + if (consider_last) + { + if (local_flag & stupid) + s = 0; + else + s = s % 20; + } + else + { +#if defined FIELDBONUS + s += field_bonus(ply, side, piece, f, t, &local_flag); +#endif + } + } + +#if defined CHECKBONUS + /* determine check flag */ + if (!(local_flag & check) && !check_determined) + { + gives_check_flag(&local_flag, side, f, t); + + if (local_flag & check) + s += 20; + } +#endif + + /* check conditions for deep search cut (flag.tsume = true) */ + +#ifdef DEEPSEARCHCUT + if (!flag.tsume && deepsearchcut) + { + if ((ply > BEYOND_STUPID) && (local_flag & stupid)) + { + try_link = flag.force || ((ply == 1) && (side != computer)); + } + else if (hard_time_limit && (ply > BEYOND_TIMEOUT) && flag.timeout) + { + flag.tsume = true; + } + else if ((ply > BEYOND_KINGATTACK) && !(local_flag & kingattack)) + { + flag.tsume = true; + } + else if ((ply > BEYOND_QUESTIONABLE) && (local_flag & questionable)) + { + flag.tsume = true; +#ifdef TESUJIBONUS + } + else if ((ply > BEYOND_TESUJI) && !(local_flag & tesuji)) + { + flag.tsume = true; +#endif + } + else if ((ply > BEYOND_DROP) && (f > NO_SQUARES)) + { + flag.tsume = true; + } + } +#endif + + if (try_link || GenerateAllMoves) + { + Link(side, piece, f, t, local_flag, + s - ((SCORE_LIMIT + 1000) * 2)); + } + + flag.tsume = flag_tsume; +} + + + +short +DropPossible(short piece, short side, short sq) +{ + short r = row(sq), possible = true; + + if (board[sq] != no_piece) + { + possible = false; + } + else if (piece == pawn) + { + if ((side == black) && (r == 8)) + { + possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); + } + else if ((side == white) && (r == 0)) + { + possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); + } + else if (PawnCnt[side][column(sq)]) + { + possible = (generate_move_flags ? ILLEGAL_DOUBLED : false); + } + + /* Pawn drops are invalid if they mate the opponent. */ + if (possible) + { + short f, tempb, tempc; + f = pawn + NO_SQUARES; + + if (side == white) + f += NO_PIECES; + + GenMakeMove(side, f, sq, &tempb, &tempc, false); + + if (IsCheckmate(side^1, -1, -1)) + possible = (generate_move_flags ? ILLEGAL_MATE : false); + + GenUnmakeMove(side, f, sq, tempb, tempc, false); + } + } + else if (piece == lance) + { + if ((side == black) && (r == 8)) + possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); + else if ((side == white) && (r == 0)) + possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); + } + else if (piece == knight) + { + if ((side == black) && (r >= 7)) + possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); + else if ((side == white) && (r <= 1)) + possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); + } + + return possible; +} + + +#if defined DONTUSE_HEURISTIC +static void +SortMoves(short ply) +{ + short p; + + for (p = TrPnt[ply]; p < TrPnt[ply+1]; p++) + pick(p, TrPnt[ply+1] - 1); +} +#endif /* DONTUSE_HEURISTIC */ + + +#ifdef DONTUSE_HEURISTIC + +static void +DontUseMoves(short ply, short n) +{ + struct leaf *p; + short i, k; + + /* k = number of check moves + number of captures */ + for (i = TrPnt[ply], k = 0; i < TrPnt[ply+1]; i++) + { + p = &Tree[i]; + + if ((p->flags & check) || (p->flags & capture)) + { + if (++k >= n) + return; + } + } + + /* use n moves */ + for (i = TrPnt[ply]; i < TrPnt[ply+1]; i++) + { + p = &Tree[i]; + + if (!((p->flags & check) || (p->flags & capture))) + { + if (k < n) + k++; + else + { + p->score = DONTUSE; + } + } + } +} + +#endif + + + +/* + * Generate moves for a piece. The moves are taken from the precalculated + * array nextpos/nextdir. If the board is free, next move is chosen from + * nextpos else from nextdir. + */ + +inline void +GenMoves(short ply, short sq, short side, + short xside) +{ + short u, piece; + short ptyp, possible; +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + + piece = board[sq]; + ptyp = ptype[side][piece]; + +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + ppos = (*nextpos[ptyp])[sq]; + pdir = (*nextdir[ptyp])[sq]; + u = ppos[sq]; +#endif + + do + { + unsigned short local_flag; + short c; + + if ((c = color[u]) == xside) + local_flag = capture; + else + local_flag = 0; + + if (c != side && board[u] != king) + { + if (PromotionPossible(color[sq], sq, u, piece)) + { + LinkMove(ply, sq, u, local_flag | promote, xside, true); + + if ((possible + = NonPromotionPossible(color[sq], sq, u, piece))) + { + LinkMove(ply, sq, u, local_flag, xside, possible); + } + } + else + { + LinkMove(ply, sq, u, local_flag, xside, true); + } + } + + if (c == neutral) +#ifdef SAVE_NEXTPOS + { + u = next_position(ptyp, &d, sq, u); + } + else + { + u = next_direction(ptyp, &d, sq); + } +#else + { + u = ppos[u]; + } + else + { + u = pdir[u]; + } +#endif + } + while (u != sq); +} + + + + +/* + * Drop each piece in hand of "side" to square "u" (if allowed). + */ + +static void +DropToSquare(short side, short xside, short ply, short u) +{ + short i, possible; + + for (i = pawn; i < king; i++) + { + if (Captured[side][i]) + { + if ((possible = DropPossible(i, side, u))) + { + short f; + f = NO_SQUARES + i; + + if (side == white) + f += NO_PIECES; + + LinkMove(ply, f, u, (dropmask | i), xside, possible); + } + } + } +} + + + +/* + * Add drops of side that prevent own king from being in check + * from xside's sweeping pieces. + */ + +static void +LinkPreventCheckDrops(short side, short xside, short ply) +{ +#ifdef SAVE_NEXTPOS + short d, dd; +#else + unsigned char *ppos, *pdir; +#endif + short piece, u, xu, square, ptyp; + short n, drop_square[9]; + + if (board[square = PieceList[side][0]] != king) + return; + + for (piece = lance; piece <= rook; piece++) + { + if (piece == lance || piece == bishop || piece == rook) + { + /* check for threat of xside piece */ + ptyp = ptype[side][piece]; + n = 0; +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, square); +#else + ppos = (*nextpos[ptyp])[square]; + pdir = (*nextdir[ptyp])[square]; + u = ppos[square]; +#endif + + do + { + if (color[u] == neutral) + { +#ifdef SAVE_NEXTPOS + dd = d; + xu = next_position(ptyp, &d, square, u); + + if (xu == next_direction(ptyp, &dd, square)) + { + n = 0; /* oops new direction */ + } + else + { + drop_square[n++] = u; + } +#else + + if ((xu = ppos[u]) == pdir[u]) + { + n = 0; /* oops new direction */ + } + else + { + drop_square[n++] = u; + } +#endif + u = xu; + } + else + { + if (color[u] == xside && (unpromoted[board[u]] == piece)) + { + /* king is threatened by opponents piece */ + while (n > 0) + { + DropToSquare(side, xside, ply, drop_square[--n]); + } + } + else + { + n = 0; + } +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, square); +#else + u = pdir[u]; +#endif + } + } + while (u != square); + } + } +} + + + +/* + * Add drops that check enemy king. + */ + +static void +LinkCheckDrops(short side, short xside, short ply) +{ +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + short u, ptyp; + short square, piece; + + if (board[square = PieceList[xside][0]] != king) + return; + + for (piece = pawn; piece < king; piece++) + { + if (Captured[side][piece]) + { + /* + * "side" has "piece" in hand. Try to make a piece move from + * opponents king square and drop this piece to each reachable + * empty square. This definitely gives check! For a pawn drop + * it must not double pawns and it must not be checkmate! + */ + + ptyp = ptype[xside][piece]; +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, square); +#else + ppos = (*nextpos[ptyp])[square]; + pdir = (*nextdir[ptyp])[square]; + u = ppos[square]; +#endif + do + { + if (color[u] == neutral) + { + if (piece != pawn || DropPossible(pawn, side, u)) + { + short f; + f = NO_SQUARES + piece; + + if (side == white) + f += NO_PIECES; + + LinkMove(ply, f, u, + (dropmask | piece | check), xside, true); + } + +#ifdef SAVE_NEXTPOS + u = next_position(ptyp, &d, square, u); +#else + u = ppos[u]; +#endif + } + else + { +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, square); +#else + u = pdir[u]; +#endif + } + } + while (u != square); + } + } +} + + + +/* + * Fill the array Tree[] with all available moves for side to play. Array + * TrPnt[ply] contains the index into Tree[] of the first move at a ply. + * in_check = 0 side is not in check + * in_check > 1 side is in check + * in_check < 0 don't know + * in_check -2 indicates move generation for book moves + */ + +void +MoveList(short side, short ply, + short in_check, short blockable) +{ + short i, xside, u; + struct leaf *firstnode; + short flag_tsume, num; + +#ifdef HISTORY + unsigned short hiHt = 0, hi0 = 0, hi1 = 0, hi2 = 0, hi3 = 0, hi4 = 0; +#endif + + flag_tsume = flag.tsume; + + xside = side ^ 1; + + sqking = PieceList[side][0]; + sqxking = PieceList[xside][0]; + + if (in_check >= 0) + { + InCheck = in_check; + } + else + { + InCheck = (board[sqking] == king) + ? SqAttacked(sqking, xside, &blockable) + : false; + } + + GenerateAllMoves = (in_check == -2) || generate_move_flags; + + if (InCheck /* && (ply > 1 || side == computer) */) + { + /* Own king in check */ + flag.tsume = true; + } + + TrP = &TrPnt[ply + 1]; + *TrP = TrPnt[ply]; + + firstnode = node = &Tree[*TrP]; + + if (!PV) + Swag0 = killr0[ply]; + else + Swag0 = PV; + + Swag1 = killr1[ply]; + Swag2 = killr2[ply]; + Swag3 = killr3[ply]; + + if (ply > 2) + Swag4 = killr1[ply - 2]; + else + Swag4 = 0; + +#ifdef HISTORY + if (use_history) + { + history[hiHt = hindex(side, SwagHt)] += 5000; + history[hi0 = hindex(side, Swag0)] += 2000; + history[hi1 = hindex(side, Swag1)] += 60; + history[hi2 = hindex(side, Swag2)] += 50; + history[hi3 = hindex(side, Swag3)] += 40; + history[hi4 = hindex(side, Swag4)] += 30; + } +#endif + + for (i = PieceCnt[side]; i >= 0; i--) + GenMoves(ply, PieceList[side][i], side, xside); + + if (!InCheck || blockable) + { + if (flag.tsume) + { + /* special drop routine for tsume problems */ + if (InCheck) + LinkPreventCheckDrops(side, xside, ply); + else + LinkCheckDrops(side, xside, ply); + } + else + { + for (u = 0; u < NO_SQUARES; u++) + DropToSquare(side, xside, ply, u); + } + } + +#ifdef HISTORY + if (use_history) + { + history[hiHt] -= 5000; + history[hi0] -= 2000; + history[hi1] -= 60; + history[hi2] -= 50; + history[hi3] -= 40; + history[hi4] -= 30; + } +#endif + + SwagHt = 0; /* SwagHt is only used once */ + + if (flag.tsume && node == firstnode) + (*TrP)++; + + GenCnt += (num = (TrPnt[ply+1] - TrPnt[ply])); + +#ifdef DONTUSE_HEURISTIC + /* remove some nodes in case of wide spread in depth */ + if (!flag.tsume && (i = MaxNum[ply]) > 0 && num > i) + { + SortMoves(ply); + DontUseMoves(ply, i); + } +#endif + + flag.tsume = flag_tsume; +} + + + +/* + * Fill the array Tree[] with all available captures for side to play. If + * there is a non-promote option, discard the non-promoting move. Array + * TrPnt[ply] contains the index into Tree[] of the first move at a ply. + * If flag.tsume is set, only add captures (but also the non-promoting) + * that threaten the opponents king. + * + * in_check = 0: side is not in check + * in_check > 1: side is in check + * in_check < 0: we don't know + */ + +void +CaptureList(short side, short ply, + short in_check, short blockable) +{ + short u, sq, xside; +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + short i, piece, flag_tsume; + small_short *PL; + + xside = side ^ 1; + + TrP = &TrPnt[ply + 1]; + *TrP = TrPnt[ply]; + node = &Tree[*TrP]; + + flag_tsume = flag.tsume; + + sqking = PieceList[side][0]; + sqxking = PieceList[xside][0]; + + if (in_check >= 0) + { + InCheck = in_check; + } + else + { + InCheck = (board[sqking] == king) + ? SqAttacked(sqking, xside, &blockable) + : false; + } + + GenerateAllMoves = (in_check == -2); + + if (InCheck && (ply > 1 || side == computer)) + { + /* Own king is in check */ + flag.tsume = true; + } + + check_determined = false; + + PL = PieceList[side]; + + for (i = 0; i <= PieceCnt[side]; i++) + { + short ptyp; + sq = PL[i]; + piece = board[sq]; + ptyp = ptype[side][piece]; +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + ppos = (*nextpos[ptyp])[sq]; + pdir = (*nextdir[ptyp])[sq]; + u = ppos[sq]; +#endif + do + { + if (color[u] == neutral) + { +#ifdef SAVE_NEXTPOS + u = next_position(ptyp, &d, sq, u); +#else + u = ppos[u]; +#endif + } + else + { + if (color[u] == xside && board[u] != king) + { + short PP; + + if ((PP = PromotionPossible(color[sq], sq, u, piece))) + { + Link(side, piece, + sq, u, capture | promote, + (*value)[stage][board[u]] +#if !defined SAVE_SVALUE + + svalue[board[u]] +#endif + - relative_value[piece]); + } + + if (!PP || flag.tsume) + { + Link(side, piece, + sq, u, capture, + (*value)[stage][board[u]] +#if !defined SAVE_SVALUE + + svalue[board[u]] +#endif + - relative_value[piece]); + } + } + +#ifdef SAVE_NEXTPOS + u = next_direction(ptyp, &d, sq); +#else + u = pdir[u]; +#endif + } + } + while (u != sq); + } + + flag.tsume = flag_tsume; + + SwagHt = 0; /* SwagHt is only used once */ +} + + + + +/* + * If the king is in check, try to find a move that prevents check. + * If such a move is found, return false, otherwise return true. + * in_check = 0: side is not in check + * in_check > 1: side is in check + * in_check < 0: don't know + * blockable > 0 && check: check can possibly be prevented by a drop + * blockable = 0 && check: check can definitely not be prevented by a drop + * blockable < 0 && check: nothing known about type of check + */ + +short +IsCheckmate(short side, short in_check, short blockable) +{ + short u, sq, xside; +#ifdef SAVE_NEXTPOS + short d; +#else + unsigned char *ppos, *pdir; +#endif + short i, piece; + small_short *PL; + short tempb, tempc, ksq, threat, dummy, sqking; + short InCheck; + + xside = side ^ 1; + + sqking = PieceList[side][0]; + + /* + * Checkmate is possible only if king is in check. + */ + + if (in_check >= 0) + InCheck = in_check; + else if (board[sqking] == king) + InCheck = SqAttacked(sqking, xside, &blockable); + else + InCheck = false; + + if (!InCheck) + return false; + + /* + * Try to find a move that prevents check. + */ + + PL = PieceList[side]; + + for (i = 0; i <= PieceCnt[side]; i++) + { + short ptyp; + sq = PL[i]; + piece = board[sq]; + ptyp = ptype[side][piece]; +#ifdef SAVE_NEXTPOS + u = first_direction(ptyp, &d, sq); +#else + ppos = (*nextpos[ptyp])[sq]; + pdir = (*nextdir[ptyp])[sq]; + u = ppos[sq]; +#endif + do + { + if (color[u] == neutral || color[u] == xside) + { + GenMakeMove(side, sq, u, &tempb, &tempc, false); + ksq = (sq == sqking) ? u : sqking; + threat = SqAttacked(ksq, xside, &dummy); + GenUnmakeMove(side, sq, u, tempb, tempc, false); + + if (!threat) + return false; + } + +#ifdef SAVE_NEXTPOS + u = (color[u] == neutral) + ? next_position(ptyp, &d, sq, u) + : next_direction(ptyp, &d, sq); +#else + u = (color[u] == neutral) ? ppos[u] : pdir[u]; +#endif + } + while (u != sq); + } + + /* + * Couldn't find a move that prevents check. + * Try to find a drop that prevents check. + */ + + if (blockable != 0) + { + for (piece = king - 1; piece >= pawn; piece--) + { + if (Captured[side][piece]) + { + for (u = 0; u < NO_SQUARES; u++) + { + if (DropPossible(piece, side, u)) + { + short f; + f = NO_SQUARES + piece; + + if (side == white) + f += NO_PIECES; + + GenMakeMove(side, f, u, &tempb, &tempc, false); + threat = SqAttacked(sqking, xside, &dummy); + GenUnmakeMove(side, f, u, tempb, tempc, false); + + if (!threat) + return false; + } + } + + /* + * If the piece could be dropped at any square, it is + * impossible for any other piece drop to prevent check. + * Drops are restricted for pawns, lances, and knights. + */ + + if (piece > knight) + break; + } + } + } + + return true; + +} + + diff --git a/gnushogi/globals.c b/gnushogi/globals.c new file mode 100644 index 0000000..5308ab0 --- /dev/null +++ b/gnushogi/globals.c @@ -0,0 +1,181 @@ +/* + * FILE: globals.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" + + +short ahead = true, hash = true; +char *xwin = 0; +char *Lang = NULL; + + +short FROMsquare, TOsquare; + +small_short ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], TesujiFlag[MAXDEPTH]; +short Pscore[MAXDEPTH], Tscore[MAXDEPTH]; +small_short Pindex[NO_SQUARES]; + +short mtl[2], hung[2]; +small_short PieceCnt[2]; + +char ColorStr[2][10]; + +long znodes; + + + +#ifdef BINBOOK +extern char *binbookfile; +#endif + +extern char *bookfile; + +unsigned long hashkey, hashbd; + +char savefile[128]; +char listfile[128]; + +short rpthash[2][256]; +short TrPnt[MAXDEPTH]; +small_short PieceList[2][NO_SQUARES]; +small_short PawnCnt[2][NO_COLS]; +small_short Captured[2][NO_PIECES]; +small_short Mvboard[NO_SQUARES]; + +#if !defined SAVE_SVALUE +short svalue[NO_SQUARES]; +#endif + +struct flags flag; + +short opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, + INCscore; +long ResponseTime = 0, ExtraTime = 0, MaxResponseTime = 0, + et = 0, et0 = 0, time0 = 0, ft = 0; + +#ifdef INTERRUPT_TEST +long it, itime0; +#endif + +long GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, + FHashCnt, FHashAdd, HashCol, THashCol, filesz, hashmask, hashbase; +long replus, reminus; +short HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT; +short player, xwndw; +short rehash = -1; +short Sdepth, Game50, MaxSearchDepth; +short GameCnt = 0; +short contempt; +int Book; +struct TimeControlRec TimeControl; +int TCadd = 0; +short TCflag, TCmoves, TCminutes, TCseconds, OperatorTime; +short XCmoves[3] = { 0, 0, 0 }; +short XCminutes[3] = { 0, 0, 0 }; +short XCseconds[3] = { 0, 0, 0 }; +short XC = 0, XCmore = 0; +const short otherside[3] = { white, black, neutral }; +unsigned short hint; +short TOflag; /* force search re-init if we backup search */ + +unsigned short killr0[MAXDEPTH], killr1[MAXDEPTH]; +unsigned short killr2[MAXDEPTH], killr3[MAXDEPTH]; +unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit; + +small_short HasPiece[2][NO_PIECES]; + +const short kingP[3] = +{ 4, 76, 0 }; + +const small_short relative_value[NO_PIECES] = +{ 0, 1, 3, 4, 7, 9, 10, 12, + 2, 5, 6, 8, 11, 13, 14 }; + +const long control[NO_PIECES] = +{ 0, ctlP, ctlL, ctlN, ctlS, ctlG, ctlB, ctlR, + ctlPp, ctlLp, ctlNp, ctlSp, ctlBp, ctlRp, ctlK }; + +short stage, stage2; +short balance[2]; + +#ifdef HASHFILE +FILE *hashfile; +#endif + +unsigned int starttime; + +int timeopp[MINGAMEIN], timecomp[MINGAMEIN]; +int compptr, oppptr; + + +struct leaf *Tree = NULL; + +hashcode_array *hashcode = NULL; +drop_hashcode_array *drop_hashcode = NULL; + +struct leaf *root = NULL; + +struct GameRec *GameList = NULL; + +value_array *value = NULL; +fscore_array *fscore = NULL; + +#ifndef SAVE_DISTDATA +short use_distdata = true; +distdata_array *distdata = NULL; +#endif + +#ifndef SAVE_PTYPE_DISTDATA +short use_ptype_distdata = true; +distdata_array *ptype_distdata[NO_PTYPE_PIECES]; +#endif + +#if !defined SAVE_NEXTPOS +next_array *nextdir[NO_PTYPE_PIECES]; +next_array *nextpos[NO_PTYPE_PIECES]; +short use_nextpos = true; +#endif + +#if defined HISTORY +short use_history = true; +unsigned short *history = NULL; +#endif + +#ifdef CACHE +short use_etable = true; +etable_field *etab[2] = { NULL, NULL }; +#endif + +#if ttblsz +short use_ttable = true; +unsigned int ttblsize = ttblsz; +struct hashentry *ttable[2] = { NULL, NULL }; +#endif diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h new file mode 100644 index 0000000..37972f4 --- /dev/null +++ b/gnushogi/gnushogi.h @@ -0,0 +1,1081 @@ +/* + * FILE: gnushogi.h + * + * Main header file for GNU Shogi. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +/* FIXME: this file needs to be reorganized in some rational manner. */ + +#ifndef _GNUSHOGI_H_ +#define _GNUSHOGI_H_ + +#include "../config.h" /* Portability #defines. */ +#include "debug.h" +#include "opts.h" /* Various option-setting #defines. */ + +/* + * Display options. + */ + +typedef enum { DISPLAY_RAW, DISPLAY_CURSES, DISPLAY_X } display_t; +extern display_t display_type; + +#define XSHOGI (display_type == DISPLAY_X) +#define NOT_CURSES ((display_type == DISPLAY_X) \ + || (display_type == DISPLAY_RAW)) + + +/* Miscellaneous globals. */ + +extern short hard_time_limit; /* If you exceed time limit, you lose. */ +extern short barebones; /* Don't print of stats for x interface. */ +extern short nolist; /* Don't list game after exit. */ + + +/* + * Options for various compilers/OSs. + */ + +/* + * type small_short must cover -128 .. 127. In case of trouble, + * try commenting out "signed". If this doesn't help, use short. + */ + +#define small_short signed char +#define small_ushort unsigned char + + +typedef small_short BYTE; +typedef small_ushort UBYTE; +typedef short SHORT; +typedef unsigned short USHORT; +typedef int INT; +typedef unsigned int UINT; +typedef long LONG; +typedef unsigned long ULONG; + + +#if !defined(HAVE_MEMCPY) && !defined(HAVE_BCOPY) +# define array_copy(src, dst, len) \ + { \ + long i; \ + char *psrc = (char *)src, *pdst = (char *)dst; \ + for (i = len; i; pdst[--i] = psrc[i]); \ + } +# define array_zero(dst, len) \ + { \ + long i; \ + char *pdst = (char *)dst; \ + for (i = len; i; pdst[--i] = 0); \ + } +#elif !defined(HAVE_MEMCPY) /* BSD and derivatives */ +# define array_copy(src, dst, len) bcopy(src, dst, len) +# define array_zero(dst, len) bzero(dst, len) +#else /* System V and derivatives */ +# define array_copy(src, dst, len) memcpy(dst, src, len) +# define array_zero(dst, len) memset(dst, 0, len) +#endif + + +#ifndef __GNUC__ +# define inline +#endif + + +/* + * Standard header files. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + + +#define RWA_ACC "r+" +#define WA_ACC "w+" +#ifdef BINBOOK +extern char *binbookfile; +#endif + +extern char *bookfile; +extern short ahead; +extern char *xwin; +extern char *Lang; +extern void movealgbr(short m, char *s); + + +#define SEEK_SET 0 +#define SEEK_END 2 + +#define NO_PIECES 15 +#define MAX_CAPTURED 19 +#define NO_PTYPE_PIECES 15 +#define NO_SQUARES 81 +#define NO_SQUARES_1 80 +#define NO_COLS 9 +#define NO_ROWS 9 + +#if defined HASHFILE || defined CACHE +# define PTBLBDSIZE (NO_SQUARES + NO_PIECES) +#endif + +#include "dspwrappers.h" /* Display functions. */ +#include "eval.h" + +#define SCORE_LIMIT 12000 + +/* masks into upper 16 bits of attacks array */ +/* observe order of relative piece values */ +#define CNT_MASK 0x000000FF +#define ctlP 0x00200000 +#define ctlPp 0x00100000 +#define ctlL 0x00080000 +#define ctlN 0x00040000 +#define ctlLp 0x00020000 +#define ctlNp 0x00010000 +#define ctlS 0x00008000 +#define ctlSp 0x00004000 +#define ctlG 0x00002000 +#define ctlB 0x00001000 +#define ctlBp 0x00000800 +#define ctlR 0x00000400 +#define ctlRp 0x00000200 +#define ctlK 0x00000100 + +/* attack functions */ +#define Pattack(c, u) (attack[c][u] > ctlP) +#define Anyattack(c, u) (attack[c][u] != 0) + +/* hashtable flags */ +#define truescore 0x0001 +#define lowerbound 0x0002 +#define upperbound 0x0004 +#define kingcastle 0x0008 +#define queencastle 0x0010 +#define evalflag 0x0020 + +/* King positions */ +#define BlackKing PieceList[black][0] +#define WhiteKing PieceList[white][0] +#define OwnKing PieceList[c1][0] +#define EnemyKing PieceList[c2][0] + + +/* board properties */ +#define InBlackCamp(sq) ((sq) < 27) +#define InWhiteCamp(sq) ((sq) > 53) +#define InPromotionZone(side, sq) \ +(((side) == black) ? InWhiteCamp(sq) : InBlackCamp(sq)) + +/* constants */ +#define OPENING_HINT 0x141d /* P7g-7f (20->29) */ + +/* truth values */ +#define false 0 +#define true 1 + +/* colors */ +#define black 0 +#define white 1 +#define neutral 2 + +/* piece code defines */ +/* CHECKME: Replace with an enum? */ +#define no_piece 0 +#define pawn 1 +#define lance 2 +#define knight 3 +#define silver 4 +#define gold 5 +#define bishop 6 +#define rook 7 +#define ppawn 8 +#define plance 9 +#define pknight 10 +#define psilver 11 +#define pbishop 12 +#define prook 13 +#define king 14 + +#define ptype_no_piece 0 +#define ptype_pawn 0 +#define ptype_lance 1 +#define ptype_knight 2 +#define ptype_silver 3 +#define ptype_gold 4 +#define ptype_bishop 5 +#define ptype_rook 6 +#define ptype_pbishop 7 +#define ptype_prook 8 +#define ptype_king 9 +#define ptype_wpawn 10 +#define ptype_wlance 11 +#define ptype_wknight 12 +#define ptype_wsilver 13 +#define ptype_wgold 14 + +/* node flags */ +#define pmask 0x000f /* 15 */ +#define promote 0x0010 /* 16 */ +#define dropmask 0x0020 /* 32 */ +#define exact 0x0040 /* 64 */ +#define tesuji 0x0080 /* 128 */ +#define check 0x0100 /* 256 */ +#define capture 0x0200 /* 512 */ +#define draw 0x0400 /* 1024 */ +#define stupid 0x0800 /* 2048 */ +#define questionable 0x1000 /* 4096 */ +#define kingattack 0x2000 /* 8192 */ +#define book 0x4000 /* 16384 */ + +/* move quality flags */ +#define goodmove tesuji +#define badmove stupid +#ifdef EASY_OPENINGS +#define difficult questionable +#endif + +/* move symbols */ +#define pxx (CP[2]) +#define qxx (CP[1]) +#define rxx (CP[4]) +#define cxx (CP[3]) + +/***************** Table limits ********************************************/ + +/* + * ttblsz must be a power of 2. Setting ttblsz 0 removes the transposition + * tables. + */ + +#if defined NOTTABLE +# define vttblsz 0 +#elif defined SMALL_MEMORY +# if defined SAVE_SSCORE +# define vttblsz (1 << 12) +# else +# if defined EXTRA_2MB +# define vttblsz (1 << 12) +# else +# define vttblsz (1 << 10) +# endif +# endif +#else +# define vttblsz (100001) +#endif + +#if defined SMALL_MEMORY +# define MINTTABLE (0) +#else +# define MINTTABLE (8000) /* min ttable size -1 */ +#endif + +#define ttblsz vttblsz + +#if defined SMALL_MEMORY +# if !defined SAVE_SSCORE +# define TREE 1500 /* max number of tree entries */ +# else +# define TREE 2500 /* max number of tree entries */ +# endif +#else +# define TREE 4000 /* max number of tree entries */ +#endif + +#define MAXDEPTH 40 /* max depth a search can be carried */ +#define MINDEPTH 2 /* min search depth =1 (no hint), >1 hint */ +#define MAXMOVES 300 /* max number of half moves in a game */ +#define CPSIZE 235 /* size of lang file max */ + +#if defined SMALL_MEMORY +# if defined SAVE_SSCORE +# define ETABLE (1 << 10) /* static eval cache */ +# else +# if defined EXTRA_2MB +# define ETABLE (1 << 10) /* static eval cache */ +# else +# define ETABLE (1 << 8) /* static eval cache */ +# endif +# endif +#else +# define ETABLE (10001) /* static eval cache */ +#endif + +/***************** tuning paramaters *******************/ + +#if defined VERY_SLOW_CPU +# define MINRESPONSETIME 300 +#elif defined SLOW_CPU +# define MINRESPONSETIME 200 +#else +# define MINRESPONSETIME 100 /* 1 s */ +#endif + +#define MINGAMEIN 4 +#define MINMOVES 15 +#define CHKDEPTH 1 /* always look forward CHKDEPTH + * half-moves if in check */ + +#if defined SLOW_CPU || defined VERY_SLOW_CPU +# define DEPTHBEYOND 7 /* Max to go beyond Sdepth */ +#else +# define DEPTHBEYOND 11 /* Max to go beyond Sdepth */ +#endif + +#define HASHDEPTH 4 /* depth above which to use HashFile */ +#define HASHMOVELIMIT 40 /* Use HashFile only for this many moves */ +#define PTVALUE 0 /* material value below which pawn threats at + * 5 & 3 are used */ +#define ZDEPTH 3 /* depth beyond which to check + * ZDELTA for extra time */ +#define ZDELTA 10 /* score delta per ply to cause + * extra time to be given */ +#define BESTDELTA 90 + +/* about 1/2 second worth of nodes for your machine */ +#if defined VERY_SLOW_CPU +/* check the time every ZNODES positions */ +# define ZNODES (flag.tsume ? 20 : 50) +#elif defined SLOW_CPU +# define ZNODES (flag.tsume ? 40 : 100) +#else +# define ZNODES (flag.tsume ? 400 : 1000) +#endif + +#define MAXTCCOUNTX 10 /* max number of time clicks + * per search to complete ply */ +#define MAXTCCOUNTR 4 /* max number of time clicks + * per search extensions*/ +#define SCORESPLIM 8 /* Score space doesn't apply after this stage */ +#define SDEPTHLIM (Sdepth + 1) +#define HISTORYLIM 4096 /* Max value of history killer */ + +#ifdef EXACTHISTORY +# if defined SMALL_MEMORY +# define HISTORY_MASK 0x8000 /* mask to MSB of history index */ +# define HISTORY_SIZE 0x10000 /* size of history table */ +# else +# define HISTORY_MASK (1 << 15) /* mask to MSB of history index */ +# define HISTORY_SIZE (1 << 16) /* size of history table */ +# endif +#else +/* smaller history table, but dangerous because of collisions */ +# define HISTORY_MASK 0x3fff /* mask to significant bits + * of history index */ +# if defined SMALL_MEMORY +# define HISTORY_SIZE 0x4000 /* size of history table */ +# else +# define HISTORY_SIZE (1 << 14) /* size of history table */ +# endif +#endif + +#define sizeof_history (sizeof(unsigned short) * (size_t)HISTORY_SIZE) + +#ifdef EXACTHISTORY +/* Map from.to (8bit.8bit) to from.to (0.7bit.8bit) */ +# define khmove(mv) (mv & 0x7fff) +# define hmove(mv) ((mv & 0x7fff) ^ 0x5555) +#else +/* Map from.to (8bit.8bit) to from.to (00.7bit.7bit) */ +/* Swap bits of ToSquare in case of promotions, hoping that + no catastrophic collision occurs. */ +# define khmove(mv) (((mv & 0x7f00) >> 1) | \ + ((mv & 0x0080) ? ((mv & 0x007f) ^ 0x007f) : (mv & 0x007f))) +# define hmove(mv) (khmove(mv) ^ 0x2aaa) +#endif + +/* mask color to 15th bit */ +#ifdef EXACTHISTORY +# define hindex(c, mv) ((c ? HISTORY_MASK : 0) | hmove(mv)) +#else +/* for white, swap bits, hoping that no catastrophic collision occurs. */ +# define hindex(c, mv) (c ? ((~hmove(mv)) & HISTORY_MASK) : hmove(mv)) +#endif + +#define EWNDW 10 /* Eval window to force position scoring at depth + * greater than (Sdepth + 2) */ +#define WAWNDW 90 /* alpha window when computer black */ +#define WBWNDW 90 /* beta window when computer black */ +#define BAWNDW 90 /* alpha window when computer white */ +#define BBWNDW 90 /* beta window when computer white */ +#define BXWNDW 90 /* window to force position scoring at lower */ +#define WXWNDW 90 /* window to force position scoring at lower */ + +#define DITHER 5 /* max amount random can alter a pos value */ +#define LBONUS 1 /* points per stage value of L increases */ +#define BBONUS 2 /* points per stage value of B increases */ +#define RBONUS 2 /* points per stage value of R increases */ + +#define QUESTIONABLE (valueK) /* Penalty for questionable moves. */ + +#if defined STUPID +# undef STUPID +#endif + +#define STUPID (valueR << 1) /* Penalty for stupid moves. */ + +#define KINGPOSLIMIT (-1) /* King positional scoring limit */ +#define KINGSAFETY 32 +#define MAXrehash (7) + +/******* parameters for Opening Book ****************/ + +#define BOOKSIZE 8000 /* Number of unique position/move + * combinations allowed */ +#define BOOKMAXPLY 40 /* Max plys to keep in book database */ +#define BOOKFAIL (BOOKMAXPLY / 2) /* if no book move found for BOOKFAIL + * turns stop using book */ +#define BOOKPOCKET 64 +#define BOOKRAND 1000 /* used to select an opening move + * from a list */ +#define BOOKENDPCT 950 /* 5 % chance a BOOKEND will stop the book */ +#define DONTUSE -32760 /* flag move as don't use */ +#define ILLEGAL_TRAPPED -32761 /* flag move as illegal: + * no move from this square */ +#define ILLEGAL_DOUBLED -32762 /* flag move as illegal: + * two pawns on one column */ +#define ILLEGAL_MATE -32763 /* flag move as illegal: + * pawn drop with mate */ + +/*****************************************************/ + +struct hashval +{ + unsigned long key, bd; +}; + +struct hashentry +{ + unsigned long hashbd; + unsigned short mv; + unsigned char depth; /* unsigned char saves some space */ + unsigned char flags; +#ifdef notdef + unsigned short age; +#endif + short score; +#ifdef HASHTEST + unsigned char bd[PTBLBDSIZE]; +#endif /* HASHTEST */ +}; + +#if defined HASHFILE || defined CACHE +struct etable +{ + unsigned long ehashbd; + short escore[2]; +#if !defined SAVE_SSCORE + short sscore[NO_SQUARES]; +#endif + short score; + small_short hung[2]; +#ifdef CACHETEST + unsigned char bd[PTBLBDSIZE]; +#endif /* CACHETEST */ +}; + +#if defined CACHE +extern short use_etable; +typedef struct etable etable_field[ETABLE]; +extern etable_field *etab[2]; +#endif + +/* + * CHECKME! Is this valid? + * + * persistent transposition table. By default, the size is (1 << vfilesz). + * If you change the size, be sure to run gnushogi -c [vfilesz] + * before anything else. + */ + +#define frehash 6 + +#if defined SMALL_MEMORY +# define vfilesz 10 +#else +# define vfilesz 14 +#endif + +struct fileentry +{ + unsigned char bd[PTBLBDSIZE]; + unsigned char f, t, flags, depth, sh, sl; +}; + +#endif /* HASHFILE */ + + +struct leaf +{ + small_ushort f, t; + short score, reply, width; + short INCscore; + unsigned short flags; +}; + + +struct GameRec +{ + unsigned short gmove; /* this move */ + short score; /* score after this move */ + short depth; /* search depth this move */ + long time; /* search time this move */ + short fpiece; /* moved or dropped piece */ + short piece; /* piece captured */ + short color; /* color */ + short flags; /* move flags capture, promote, castle */ + short Game50; /* flag for repetition */ + long nodes; /* nodes searched for this move */ + unsigned long hashkey, hashbd; /* board key before this move */ +}; + + +struct TimeControlRec +{ + short moves[2]; + long clock[2]; +}; + + +struct flags +{ + short mate; /* the game is over */ + short post; /* show principle variation */ + short quit; /* quit/exit */ + short regularstart; /* did the game start from standard + * initial board ? */ + short reverse; /* reverse board display */ + short bothsides; /* computer plays both sides */ + short hash; /* enable/disable transposition table */ + short force; /* enter moves */ + short easy; /* disable thinking on opponents time */ + short beep; /* enable/disable beep */ + short timeout; /* time to make a move */ + short musttimeout; /* time to make a move */ + short back; /* time to make a move */ + short rcptr; /* enable/disable recapture heuristics */ + short rv; /* reverse video */ + short stars; /* add stars to uxdsp screen */ + short coords; /* add coords to visual screen */ + short shade; + short material; /* draw on lack of material */ + short illegal; /* illegal position */ + short onemove; /* timing is onemove */ + short gamein; /* timing is gamein */ + short tsume; /* first consider checks */ +}; + +extern FILE *debugfile; + +#ifndef EVALFILE +#define EVALFILE "/tmp/EVAL" +#endif + +extern FILE *debug_eval_file; +extern short debug_moves; + + +#ifdef HISTORY +extern short use_history; +extern unsigned short *history; +#endif + +extern long znodes; + +extern char ColorStr[2][10]; + +extern char mvstr[4][6]; +extern unsigned short MV[MAXDEPTH]; +extern int MSCORE; +extern int mycnt1, mycnt2; +extern short ahead; +extern struct leaf rootnode; +extern struct leaf *Tree; +extern struct leaf *root; +extern char savefile[], listfile[]; +extern short TrPnt[]; +extern small_short board[], color[]; +extern const small_short sweep[NO_PIECES]; +extern small_short PieceList[2][NO_SQUARES], PawnCnt[2][NO_COLS]; +extern small_short Captured[2][NO_PIECES]; + +#ifndef HAVE_MEMSET +# define ClearCaptured() \ + { \ + short piece, color; \ + for (color = black; color <= white; color++) \ + for (piece = 0; piece < NO_PIECES; piece++) \ + Captured[color][piece] = 0; \ + } +#else +# define ClearCaptured() \ + memset((char *)Captured, 0, (unsigned long)sizeof(Captured)) +#endif /* HAVE_MEMSET */ + +extern small_short Mvboard[]; + +#if !defined SAVE_SVALUE +extern short svalue[NO_SQUARES]; +#endif + +extern short pscore[2]; /* eval.c */ +extern int EADD; /* eval.c */ +extern int EGET; /* eval.c */ +extern struct flags flag; +extern short opponent, computer, INCscore; +extern short WAwindow, BAwindow, WBwindow, BBwindow; +extern short dither, player; +extern short xwndw, contempt; +extern long ResponseTime, ExtraTime, TCleft, + MaxResponseTime, et, et0, time0, ft; +extern int TCcount; + +#ifdef INTERRUPT_TEST +extern long itime0, it; +#endif + +extern long reminus, replus; +extern long GenCnt, NodeCnt, ETnodes, EvalNodes, HashAdd, HashCnt, + HashCol, THashCol, FHashCnt, FHashAdd; +extern short HashDepth, HashMoveLimit; +extern struct GameRec *GameList; +extern short GameCnt, Game50; +extern short Sdepth, MaxSearchDepth; +extern int Book; +extern struct TimeControlRec TimeControl; +extern int TCadd; +extern short TCflag, TCmoves, TCminutes, TCseconds, OperatorTime; +extern int timecomp[MINGAMEIN], timeopp[MINGAMEIN]; +extern int compptr, oppptr; +extern short XCmore, XCmoves[], XCminutes[], XCseconds[], XC; +extern const short otherside[]; +extern const small_short Stboard[]; +extern const small_short Stcolor[]; +extern unsigned short hint; +extern short TOflag; +extern short stage, stage2; + +#define in_opening_stage (!flag.tsume && (stage < 33)) +#define in_middlegame_stage (!flag.tsume && (stage >= 33) && (stage <= 66)) +#define in_endgame_stage (flag.tsume || (stage > 66)) + +extern short ahead, hash; +extern short balance[2]; +extern small_short ChkFlag[], CptrFlag[], TesujiFlag[]; +extern short Pscore[], Tscore[]; +extern /*unsigned*/ short rehash; /* -1 is used as a flag --tpm */ +extern char version[], patchlevel[]; +extern unsigned int ttbllimit; +extern unsigned int TTadd; +extern unsigned int ttblsize; +extern short mtl[], hung[]; +extern small_short Pindex[]; +extern small_short PieceCnt[]; +extern short FROMsquare, TOsquare; +extern small_short HasPiece[2][NO_PIECES]; +extern const short kingP[]; +extern unsigned short killr0[], killr1[]; +extern unsigned short killr2[], killr3[]; +extern unsigned short PrVar[MAXDEPTH]; +extern unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit; +extern short mtl[2], pmtl[2], hung[2]; +extern const small_short relative_value[]; +extern const long control[]; +extern small_short diagonal(short delta); +extern const small_short promoted[NO_PIECES], unpromoted[NO_PIECES]; +extern const small_short is_promoted[NO_PIECES]; + +typedef unsigned char next_array[NO_SQUARES][NO_SQUARES]; +typedef small_short distdata_array[NO_SQUARES][NO_SQUARES]; + +extern const small_short inunmap[NO_SQUARES]; +extern const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 4)]; + +#if defined SAVE_NEXTPOS +extern const small_short direc[NO_PTYPE_PIECES][8]; +extern short first_direction(short ptyp, short *d, short sq); +extern short next_direction(short ptyp, short *d, short sq); +extern short next_position(short ptyp, short *d, short sq, short u); +#else +extern short use_nextpos; +extern next_array *nextpos[NO_PTYPE_PIECES]; +extern next_array *nextdir[NO_PTYPE_PIECES]; +#endif + +extern value_array *value; +extern fscore_array *fscore; + +#ifndef SAVE_DISTDATA +extern short use_distdata; +extern distdata_array *distdata; +#endif + +#ifndef SAVE_PTYPE_DISTDATA +extern short use_ptype_distdata; +extern distdata_array *ptype_distdata[NO_PTYPE_PIECES]; +#endif + +extern const small_short ptype[2][NO_PIECES]; + +extern long filesz, hashmask, hashbase; +extern FILE *hashfile; +extern unsigned int starttime; + +/* eval.c */ +typedef small_short Mpiece_array[2][NO_SQUARES]; +extern Mpiece_array *Mpiece[NO_PIECES]; +extern short ADVNCM[NO_PIECES]; + +#define computed_distance(a, b) \ + ((abs(column(a) - column(b)) > abs(row(a) - row(b))) \ + ? abs(column(a) - column(b)) : abs(row(a) - row(b))) + +extern short distance(short a, short b); +extern short ptype_distance(short ptyp, short f, short t); +extern short piece_distance(short side, short piece, short f, short t); + +#if defined UNKNOWN +# undef UNKNOWN +#endif + +#define UNKNOWN 'U' +#define STATIC_ROOK 'S' +#define RANGING_ROOK 'R' + +extern char GameType[2]; +void ShowGameType(void); + +extern unsigned short bookmaxply; +extern unsigned int bookcount; +extern unsigned int booksize; +extern unsigned long hashkey, hashbd; + +typedef struct hashval hashcode_array[2][NO_PIECES][NO_SQUARES]; +typedef struct hashval drop_hashcode_array[2][NO_PIECES][NO_SQUARES]; + +extern hashcode_array *hashcode; +extern drop_hashcode_array *drop_hashcode; +extern char *CP[]; + +#ifdef QUIETBACKGROUND +extern short background; +#endif /* QUIETBACKGROUND */ + +#if ttblsz +extern short use_ttable; +extern struct hashentry *ttable[2]; +#endif + +/* + * hashbd contains a 32 bit "signature" of the board position. hashkey + * contains a 16 bit code used to address the hash table. When a move is + * made, XOR'ing the hashcode of moved piece on the from and to squares with + * the hashbd and hashkey values keeps things current. + */ + +#define UpdateHashbd(side, piece, f, t) \ +{ \ + if ((f) >= 0) \ + { \ + hashbd ^= (*hashcode)[side][piece][f].bd; \ + hashkey ^= (*hashcode)[side][piece][f].key; \ + } \ + \ + if ((t) >= 0) \ + { \ + hashbd ^= (*hashcode)[side][piece][t].bd; \ + hashkey ^= (*hashcode)[side][piece][t].key; \ + } \ +} + +#define UpdateDropHashbd(side, piece, count) \ +{ \ + hashbd ^= (*drop_hashcode)[side][piece][count].bd; \ + hashkey ^= (*drop_hashcode)[side][piece][count].key; \ +} + + +extern short rpthash[2][256]; +extern char *DRAW; + +/* + * FIXME: these should be more generic instead of using the + * magic number 9. + */ + +#define row(a) ((a) / 9) +#define column(a) ((a) % 9) +#define locn(a, b) (((a) * 9) + b) + +/* init external functions */ +extern void InitConst(char *lang); /* init.c */ +extern int Initialize_data(void); /* init.c */ +extern void Free_data(void); /* init.c */ +extern int Lock_data(void); /* init.c */ +extern void Unlock_data(void); /* init.c */ +extern void Initialize_dist(void); /* init.c */ +extern void Initialize_eval(void); /* eval.c */ +extern void NewGame(void); +extern int parse(FILE * fd, unsigned short *mv, + short side, char *opening); +extern void GetOpenings(void); +extern int OpeningBook(unsigned short *hint, short side); + +typedef enum +{ + REMOVE_PIECE = 1, ADD_PIECE +} UpdatePieceList_mode; + +extern void +UpdatePieceList(short side, short sq, UpdatePieceList_mode iop); + +typedef enum +{ + FOREGROUND_MODE = 1, BACKGROUND_MODE +} SelectMove_mode; + +extern void +SelectMove(short side, SelectMove_mode iop); + +extern int +search(short side, + short ply, + short depth, + short alpha, + short beta, + unsigned short *bstline, + short *rpt); + +#ifdef CACHE +void PutInEETable(short side, int score); +int CheckEETable(short side); +int ProbeEETable(short side, short *score); +#endif + +#if ttblsz +extern int +ProbeTTable(short side, + short depth, + short ply, + short *alpha, + short *beta, + short *score); + +extern int +PutInTTable(short side, + short score, + short depth, + short ply, + short alpha, + short beta, + unsigned short mv); + +extern void ZeroTTable(void); +extern void ZeroRPT(void); +extern void Initialize_ttable(void); +extern unsigned int urand(void); + +# ifdef HASHFILE +extern void gsrand(unsigned int); + +extern int +ProbeFTable(short side, + short depth, + short ply, + short *alpha, + short *beta, + short *score); + +extern void +PutInFTable(short side, + short score, + short depth, + short ply, + short alpha, + short beta, + unsigned short f, + unsigned short t); + +# endif /* HASHFILE */ +#endif /* ttblsz */ + +#if !defined SAVE_NEXTPOS +extern void Initialize_moves(void); +#endif + +extern short generate_move_flags; + +extern void MoveList(short side, short ply, + short in_check, short blockable); +extern void CaptureList(short side, short ply, + short in_check, short blockable); + +/* from attacks.c */ +extern int +SqAttacked(short square, short side, short *blockable); + +extern void +MakeMove(short side, + struct leaf *node, + short *tempb, + short *tempc, + short *tempsf, + short *tempst, + short *INCscore); + +extern void +UnmakeMove(short side, + struct leaf *node, + short *tempb, + short *tempc, + short *tempsf, + short *tempst); + +extern void +InitializeStats(void); + +extern int +evaluate(short side, + short ply, + short alpha, + short beta, + short INCscore, + short *InChk, + short *blockable); + +extern short ScorePosition(short side); +extern void ExaminePosition(short side); +extern short ScorePatternDistance(short side); +extern void DetermineStage(short side); +extern void UpdateWeights(short side); +extern int InitMain(void); +extern void ExitMain(void); +extern void Initialize(void); +extern void InputCommand(char *command); +extern void ExitShogi(void); +extern void ClearScreen(void); +extern void SetTimeControl(void); +extern void SelectLevel(char *sx); + +extern void +UpdateDisplay(short f, + short t, + short flag, + short iscastle); + +typedef enum +{ + COMPUTE_AND_INIT_MODE = 1, COMPUTE_MODE +#ifdef INTERRUPT_TEST + , INIT_INTERRUPT_MODE, COMPUTE_INTERRUPT_MODE +#endif +} ElapsedTime_mode; + +extern void ElapsedTime(ElapsedTime_mode iop); +extern void SetResponseTime(short side); +extern void CheckForTimeout(int score, int globalscore, + int Jscore, int zwndw); +extern void ShowSidetoMove(void); +extern void ShowResponseTime(void); +extern void ShowPatternCount(short side, short n); +extern void SearchStartStuff(short side); +extern void ShowDepth(char ch); +extern void TerminateSearch(int); +extern void ShowResults(short score, unsigned short *bstline, char ch); +extern void PromptForMove(void); +extern void SetupBoard(void); +extern void algbr(short f, short t, short flag); +extern void OutputMove(void); +extern void ShowCurrentMove(short pnt, short f, short t); +extern void ListGame(void); +extern void ShowMessage(char *s); +extern void ClearScreen(void); +extern void gotoXY(short x, short y); +extern void ClearEoln(void); +extern void DrawPiece(short sq); +extern void UpdateClocks(void); +extern void DoDebug(void); +extern void DoTable(short table[NO_SQUARES]); +extern void ShowPostnValues(void); +extern void ChangeXwindow(void); +extern void SetContempt(void); +extern void ChangeHashDepth(void); +extern void ChangeBetaWindow(void); +extern void GiveHint(void); +extern void ShowPrompt(void); +extern void EditBoard(void); +extern void help(void); +extern void ChangeSearchDepth(void); +extern void skip(void); +extern void skipb(void); +extern void EnPassant(short xside, short f, short t, short iop); +extern void ShowNodeCnt(long NodeCnt); +extern void ShowLine(unsigned short *bstline); +extern int pick(short p1, short p2); +extern short repetition(void); +extern void TimeCalc(void); + +extern short +DropPossible(short piece, short side, short sq); /* genmoves.c */ + +extern short +IsCheckmate(short side, short in_check, + short blockable); /* genmoves.c */ + + +typedef enum +{ + VERIFY_AND_MAKE_MODE, VERIFY_AND_TRY_MODE, UNMAKE_MODE +} VerifyMove_mode; + +extern int VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv); +extern void AgeTT(); +extern unsigned short TTage; + +#endif /* _GNUSHOGI_H_ */ diff --git a/gnushogi/init.c b/gnushogi/init.c new file mode 100644 index 0000000..e6df8cf --- /dev/null +++ b/gnushogi/init.c @@ -0,0 +1,1347 @@ +/* + * FILE: init.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" + +#if defined HAVE_GETTIMEOFDAY +#include +#endif + +#include + +#include "pattern.h" + +/**************************************** + * A variety of global flags. + ****************************************/ + +/* + * If hard_time_limit is nonzero, exceeding the time limit means + * losing the game. + */ + +short hard_time_limit = 1; +short barebones = 0; /* Suppress printing of statistics + * (mainly for xshogi). */ +#ifdef LIST_ON_EXIT +short nolist = 0; /* List the game after exit. */ +#else +short nolist = 1; /* Don't list the game after exit. */ +#endif + +/* + * The default display type can be DISPLAY_RAW, DISPLAY_CURSES, + * or DISPLAY_X; the default is DISPLAY_X to make life easier for xshogi. + */ + +display_t display_type = DISPLAY_X; + +unsigned int ttbllimit; + +/* .... MOVE GENERATION VARIABLES AND INITIALIZATIONS .... */ + + +#define max(a, b) (((a) < (b))?(b):(a)) +#define odd(a) ((a) & 1) + + +const small_short piece_of_ptype[NO_PTYPE_PIECES] = +{ + pawn, lance, knight, silver, gold, bishop, rook, pbishop, prook, king, + pawn, lance, knight, silver, gold +}; + + +const small_short side_of_ptype[NO_PTYPE_PIECES] = +{ + black, black, black, black, black, black, black, black, black, black, + white, white, white, white, white +}; + +#ifdef SAVE_NEXTPOS +const small_short psweep[NO_PTYPE_PIECES] = +{ + false, true, false, false, false, true, true, true, true, false, + false, true, false, false, false +}; +#endif + +const small_short sweep[NO_PIECES] = +{ + false, false, true, false, false, false, true, true, + false, false, false, false, true, true, false +}; + + +#if !defined EXTLANGFILE + +char *CP[CPSIZE] = + +{ +/* 000: eng: */ "", +#ifdef LANGFILE +#include LANGFILE +#else +#include "gnushogi.lng" +#endif +}; + +#else + +char *CP[CPSIZE]; + +#endif + + +/* + * Determine the minimum number of moves for a piece from + * square "f" to square "t". If the piece cannot reach "t", + * the count is set to CANNOT_REACH. + */ + +#define csquare(sq) ((side == black) ? sq : (NO_SQUARES - 1 - sq)) +#define crow(sq) row(csquare(sq)) +#define ccol(sq) column(csquare(sq)) + +short +ptype_distance(short ptyp, short f, short t) +{ + short side, piece; + short colf, colt, rowf, rowt, dcol, drow; + + if (f == t) + return 0; + + piece = piece_of_ptype[ptyp]; + side = side_of_ptype[ptyp]; + + dcol = (colt = ccol(t)) - (colf = ccol(f)); + drow = (rowt = crow(t)) - (rowf = crow(f)); + + switch (piece) + { + case pawn: + if ((dcol != 0) || (drow < 1)) + return CANNOT_REACH; + else + return drow; + + case lance: + if ((dcol != 0) || (drow < 1)) + return CANNOT_REACH; + else + return 1; + + case knight: + if (odd(drow) || (odd(drow / 2) != odd(dcol))) + return CANNOT_REACH; + else if ((drow == 0) || ((drow / 2) < abs(dcol))) + return CANNOT_REACH; + else + return (drow / 2); + + case silver: + if (drow > 0) + { + if (odd(drow) == odd(dcol)) + { + return max(abs(drow), abs(dcol)); + } + else + { + if (abs(dcol) <= drow) + return drow; + else + return (max(abs(drow), abs(dcol)) + 1); + } + } + else + { + if (odd(drow) == odd(dcol)) + return (max(abs(drow), abs(dcol))); + else + return (max(abs(drow) + 1, abs(dcol)) + 1); + }; + + case gold: + case ppawn: + case pknight: + case plance: + case psilver: + if (abs(dcol) == 0) + return (abs(drow)); + else if (drow >= 0) + return max(drow, abs(dcol)); + else + return (abs(dcol) - drow); + + case bishop: + if (odd(dcol) != odd(drow)) + return CANNOT_REACH; + else + return ((abs(dcol) == abs(drow)) ? 1 : 2); + + case pbishop: + if (odd(dcol) != odd(drow)) + { + if ((abs(dcol) <= 1) && (abs(drow) <= 1)) + return 1; + else if (abs(abs(dcol) - abs(drow)) == 1) + return 2; + else + return 3; + } + else + { + return ((abs(dcol) == abs(drow)) ? 1 : 2); + } + + case rook: + if ((dcol == 0) || (drow == 0)) + return 1; + else + return 2; + + case prook: + if ((dcol == 0) || (drow == 0)) + return 1; + else if ((abs(dcol) == 1) && (abs(drow) == 1)) + return 1; + else + return 2; + + case king: + return max(abs(drow), abs(dcol)); + + default: + /* should never occur */ + return (CANNOT_REACH); + } +} + + +#ifdef SAVE_DISTDATA +short +distance(short a, short b) +{ + return (short)computed_distance(a, b); +} +#else +short +distance(short a, short b) +{ + return (use_distdata + ? (short)(*distdata)[(int)a][(int)b] + : (short)computed_distance(a, b)); +} +#endif + + +#ifdef SAVE_PTYPE_DISTDATA +short +piece_distance(short side, short piece, short f, short t) +{ + return ((f > NO_SQUARES) + ? (short)1 + : (short)ptype_distance(ptype[side][piece], f, t)); +} +#else +short +piece_distance(short side, short piece, short f, short t) +{ + return ((f > NO_SQUARES) + ? (short)1 + : (use_ptype_distdata + ? (short)(*ptype_distdata[ptype[side][piece]])[f][t] + : (short)ptype_distance(ptype[side][piece], f, t))); +} +#endif + + +void +Initialize_dist(void) +{ + short a, b, d, di, ptyp; +#ifndef SAVE_DISTDATA + for (a = 0; a < NO_SQUARES; a++) + { + for (b = 0; b < NO_SQUARES; b++) + { + d = abs(column(a) - column(b)); + di = abs(row(a) - row(b)); + (*distdata)[a][b] = (small_short)((d > di) ? d : di); + } + } +#endif +#ifndef SAVE_PTYPE_DISTDATA + for (ptyp = 0; ptyp < NO_PTYPE_PIECES; ptyp++) + { + for (a = 0; a < NO_SQUARES; a++) + for (b = 0; b < NO_SQUARES; b++) + (*ptype_distdata[ptyp])[a][b] = ptype_distance(ptyp, a, b); + } +#endif +} + + +/* + * nextpos[piece][from-square], nextdir[piece][from-square] gives vector + * of positions reachable from from-square in ppos with piece such that the + * sequence + * + * ppos = nextpos[piece][from-square]; + * pdir = nextdir[piece][from-square]; + * u = ppos[sq]; + * + * do + * { + * u = ppos[u]; + * + * if(color[u] != neutral) + * u = pdir[u]; + * } + * while (sq != u); + * + * will generate the sequence of all squares reachable from sq. + * + * If the path is blocked u = pdir[sq] will generate the continuation of the + * sequence in other directions. + */ + + +/* + * ptype is used to separate black and white pawns, like this; ptyp = + * ptype[side][piece] piece can be used directly in nextpos/nextdir when + * generating moves for pieces that are not white pawns. + */ + +const small_short ptype[2][NO_PIECES] = +{ + { + ptype_no_piece, ptype_pawn, ptype_lance, ptype_knight, + ptype_silver, ptype_gold, ptype_bishop, ptype_rook, + ptype_gold, ptype_gold, ptype_gold, ptype_gold, + ptype_pbishop, ptype_prook, ptype_king + }, + { + ptype_no_piece, ptype_wpawn, ptype_wlance, ptype_wknight, + ptype_wsilver, ptype_wgold, ptype_bishop, ptype_rook, + ptype_wgold, ptype_wgold, ptype_wgold, ptype_wgold, + ptype_pbishop, ptype_prook, ptype_king + }, +}; + +const small_short promoted[NO_PIECES] = +{ + no_piece, ppawn, plance, pknight, psilver, gold, pbishop, prook, + ppawn, plance, pknight, psilver, pbishop, prook, king +}; + +const small_short unpromoted[NO_PIECES] = +{ + no_piece, pawn, lance, knight, silver, gold, bishop, rook, + pawn, lance, knight, silver, bishop, rook, king +}; + +const small_short is_promoted[NO_PIECES] = +{ + false, false, false, false, false, false, false, false, + true, true, true, true, true, true, false +}; + +/* data used to generate nextpos/nextdir */ +#if !defined SAVE_NEXTPOS +static +#endif +const small_short direc[NO_PTYPE_PIECES][8] = +{ + { 11, 0, 0, 0, 0, 0, 0, 0 }, /* 0 ptype_pawn */ + { 11, 0, 0, 0, 0, 0, 0, 0 }, /* 1 ptype_lance */ + { 21, 23, 0, 0, 0, 0, 0, 0 }, /* 2 ptype_knight */ + { 10, 11, 12, -12, -10, 0, 0, 0 }, /* 3 ptype_silver */ + { 10, 11, 12, -1, 1, -11, 0, 0 }, /* 4 ptype_gold */ + { 10, 12, -12, -10, 0, 0, 0, 0 }, /* 5 ptype_bishop */ + { 11, -1, 1, -11, 0, 0, 0, 0 }, /* 6 ptype_rook */ + { 10, 12, -12, -10, 11, -1, 1, -11 }, /* 7 ptype_pbishop */ + { 11, -1, 1, -11, 10, 12, -12, -10 }, /* 8 ptype_prook */ + { 10, 11, 12, -1, 1, -12, -11, -10 }, /* 9 ptype_king */ + { -11, 0, 0, 0, 0, 0, 0, 0 }, /* 10 ptype_wpawn */ + { -11, 0, 0, 0, 0, 0, 0, 0 }, /* 11 ptype_wlance */ + { -21, -23, 0, 0, 0, 0, 0, 0 }, /* 12 ptype_wknight */ + { -10, -11, -12, 12, 10, 0, 0, 0 }, /* 13 ptype_wsilver */ + { -10, -11, -12, 1, -1, 11, 0, 0 } +}; /* 14 ptype_wgold */ + + +small_short diagonal(short d) +{ + return (abs(d) == 10 || abs(d) == 12); +} + + +static const small_short max_steps[NO_PTYPE_PIECES] = +{ + 1, 8, 1, 1, 1, 8, 8, 8, 8, 1, 1, 8, 1, 1, 1 +}; + + +const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 4)] = +{ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, + -1, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, + -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, -1, + -1, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, -1, + -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, + -1, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, + -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +}; + + +const small_short inunmap[NO_SQUARES] = +{ + 23, 24, 25, 26, 27, 28, 29, 30, 31, + 34, 35, 36, 37, 38, 39, 40, 41, 42, + 45, 46, 47, 48, 49, 50, 51, 52, 53, + 56, 57, 58, 59, 60, 61, 62, 63, 64, + 67, 68, 69, 70, 71, 72, 73, 74, 75, + 78, 79, 80, 81, 82, 83, 84, 85, 86, + 89, 90, 91, 92, 93, 94, 95, 96, 97, + 100, 101, 102, 103, 104, 105, 106, 107, 108, + 111, 112, 113, 114, 115, 116, 117, 118, 119 +}; + + +int InitFlag = false; + + +#if defined SAVE_NEXTPOS + +short +next_direction(short ptyp, short *d, short sq) +{ + short delta, to, sfrom = inunmap[sq]; + + do + { + (*d)++; + if (*d >= 8) + return sq; + + delta = direc[ptyp][*d]; + if (delta == 0) + return sq; + + to = nunmap[sfrom + delta]; + } + while (to < 0); + + return to; +} + + +short +next_position(short ptyp, short *d, short sq, short u) +{ + if (*d < 4 && psweep[ptyp]) + { + short to = nunmap[inunmap[u] + direc[ptyp][*d]]; + + if (to < 0) + return next_direction(ptyp, d, sq); + else + return to; + } + else + { + return next_direction(ptyp, d, sq); + } +} + + +short +first_direction(short ptyp, short *d, short sq) +{ + *d = -1; + return next_direction(ptyp, d, sq); +} + +#else + +/* + * This procedure pre-calculates all moves for every piece from every + * square. This data is stored in nextpos/nextdir and used later in the + * move generation routines. + */ + +void +Initialize_moves(void) +{ + short ptyp, po, p0, d, di, s, delta; + unsigned char *ppos, *pdir; + short dest[8][9]; + short sorted[9]; + short steps[8]; + short fpo = 23, tpo = 120; + + for (ptyp = 0; ptyp < NO_PTYPE_PIECES; ptyp++) + { + for (po = 0; po < NO_SQUARES; po++) + { + for (p0 = 0; p0 < NO_SQUARES; p0++) + { + (*nextpos[ptyp])[po][p0] = (unsigned char)po; + (*nextdir[ptyp])[po][p0] = (unsigned char)po; + } + } + } + + for (ptyp = 0; ptyp < NO_PTYPE_PIECES; ptyp++) + { + for (po = fpo; po < tpo; po++) + { + if (nunmap[po] >= (small_short)0) + { + ppos = (*nextpos[ptyp])[nunmap[po]]; + pdir = (*nextdir[ptyp])[nunmap[po]]; + + /* dest is a function of direction and steps */ + for (d = 0; d < 8; d++) + { + dest[d][0] = nunmap[po]; + delta = direc[ptyp][d]; + + if (delta != 0) + { + p0 = po; + + for (s = 0; s < max_steps[ptyp]; s++) + { + p0 = p0 + delta; + + /* + * break if (off board) or (promoted rooks + * wishes to move two steps diagonal) or + * (promoted bishops wishes to move two steps + * non-diagonal) + */ + if ((nunmap[p0] < (small_short)0) + || ((ptyp == ptype_prook) + && (s > 0) + && diagonal(delta)) + || ((ptyp == ptype_pbishop) + && (s > 0) + && !diagonal(delta))) + break; + else + dest[d][s] = nunmap[p0]; + } + } + else + { + s = 0; + } + + /* + * Sort dest in number of steps order; currently no sort + * is done due to compatibility with the move generation + * order in old gnuchess. + */ + + steps[d] = s; + + for (di = d; s > 0 && di > 0; di--) + { + if (steps[sorted[di - 1]] == 0) /* should be: < s */ + sorted[di] = sorted[di - 1]; + else + break; + } + + sorted[di] = d; + } + + /* + * update nextpos/nextdir + */ + + p0 = nunmap[po]; + pdir[p0] = (unsigned char)dest[sorted[0]][0]; + + for (d = 0; d < 8; d++) + { + for (s = 0; s < steps[sorted[d]]; s++) + { + ppos[p0] = (unsigned char)dest[sorted[d]][s]; + p0 = dest[sorted[d]][s]; + + if (d < 7) + pdir[p0] = (unsigned char)dest[sorted[d + 1]][0]; + + /* + * else is already initialized + */ + } + } + } + } + } +} + +#endif + + + +/* + * Reset the board and other variables to start a new game. + */ + +void +NewGame(void) +{ + short l, c, p, max_opening_sequence; +#ifdef HAVE_GETTIMEOFDAY + struct timeval tv; +#endif + compptr = oppptr = 0; + stage = 0; + stage2 = -1; /* the game is not yet started */ + flag.illegal = flag.mate = flag.post = flag.quit + = flag.reverse = flag.bothsides = flag.onemove = flag.force + = false; + flag.material = flag.coords = flag.hash = flag.easy + = flag.beep = flag.rcptr + = true; + flag.stars = flag.shade = flag.back = flag.musttimeout = false; + flag.gamein = false; + flag.rv = true; + + mycnt1 = mycnt2 = 0; + GenCnt = NodeCnt = et0 = dither = XCmore = 0; + znodes = ZNODES; + WAwindow = WAWNDW; + WBwindow = WBWNDW; + BAwindow = BAWNDW; + BBwindow = BBWNDW; + xwndw = BXWNDW; + + if (!MaxSearchDepth) + MaxSearchDepth = MAXDEPTH - 1; + + contempt = 0; + GameCnt = 0; + Game50 = 1; + CptrFlag[0] = TesujiFlag[0] = false; + hint = OPENING_HINT; + ZeroRPT(); + GameType[0] = GameType[1] = UNKNOWN; + Pscore[0] = Tscore[0] = (SCORE_LIMIT + 3000); + opponent = player = black; + computer = white; + + for (l = 0; l < TREE; l++) + Tree[l].f = Tree[l].t = 0; + + gsrand((unsigned int) 1); + + if (!InitFlag) + { + for (c = black; c <= white; c++) + { + for (p = pawn; p <= king; p++) + { + for (l = 0; l < NO_SQUARES; l++) + { + (*hashcode)[c][p][l].key + = (((unsigned long) urand())); + (*hashcode)[c][p][l].key + += (((unsigned long) urand()) << 16); + (*hashcode)[c][p][l].bd + = (((unsigned long) urand())); + (*hashcode)[c][p][l].bd + += (((unsigned long) urand()) << 16); +#if SIZEOF_LONG == 8 /* 64-bit long i.e. 8 bytes */ + (*hashcode)[c][p][l].key + += (((unsigned long) urand()) << 32); + (*hashcode)[c][p][l].key + += (((unsigned long) urand()) << 48); + (*hashcode)[c][p][l].bd + += (((unsigned long) urand()) << 32); + (*hashcode)[c][p][l].bd + += (((unsigned long) urand()) << 48); +#endif + } + } + } + + for (c = black; c <= white; c++) + { + for (p = pawn; p <= king; p++) + { + for (l = 0; l < MAX_CAPTURED; l++) + { + (*drop_hashcode)[c][p][l].key + = (((unsigned long) urand())); + (*drop_hashcode)[c][p][l].key + += (((unsigned long) urand()) << 16); + (*drop_hashcode)[c][p][l].bd + = (((unsigned long) urand())); + (*drop_hashcode)[c][p][l].bd + += (((unsigned long) urand()) << 16); +#if SIZEOF_LONG == 8 /* 64-bit long i.e. 8 bytes */ + (*drop_hashcode)[c][p][l].key + += (((unsigned long) urand()) << 32); + (*drop_hashcode)[c][p][l].key + += (((unsigned long) urand()) << 48); + (*drop_hashcode)[c][p][l].bd + += (((unsigned long) urand()) << 32); + (*drop_hashcode)[c][p][l].bd + += (((unsigned long) urand()) << 48); +#endif + } + } + } + } + + for (l = 0; l < NO_SQUARES; l++) + { + board[l] = Stboard[l]; + color[l] = Stcolor[l]; + Mvboard[l] = 0; + } + + ClearCaptured(); + ClearScreen(); + InitializeStats(); + +#ifdef HAVE_GETTIMEOFDAY + gettimeofday(&tv, NULL); + time0 = tv.tv_sec*100 + tv.tv_usec/10000; +#else + time0 = time((long *) 0); +#endif + + /* resetting reference time */ + ElapsedTime(COMPUTE_AND_INIT_MODE); + flag.regularstart = true; + Book = BOOKFAIL; + + if (!InitFlag) + { + char sx[256]; + strcpy(sx, CP[169]); + + if (TCflag) + SetTimeControl(); + else if (MaxResponseTime == 0) + SelectLevel(sx); + + UpdateDisplay(0, 0, 1, 0); + GetOpenings(); + GetOpeningPatterns(&max_opening_sequence); + + InitFlag = true; + } + +#if ttblsz + if (TTadd) + { + ZeroTTable(); + TTadd = 0; + } +#endif /* ttblsz */ + + hashbd = hashkey = 0; + return; +} + + + +int +Initialize_data(void) +{ + size_t n; + int i; + char buffer[60]; + int doit = true; + + { + small_short x = -1; + + if (x >= 0) + { + ShowMessage("datatype 'small_short' is unsigned; " + "check gnushogi.h\n"); + return 1; + } + } + + n = sizeof(struct leaf) * (size_t)TREE; + Tree = malloc(n); + + if (!Tree) + { + sprintf(buffer, "Cannot allocate %ld bytes for search tree", + (long)n); + ShowMessage(buffer); + return 1; + } + + n = sizeof(hashcode_array); + hashcode = malloc(n); + + if (!hashcode) + { + sprintf(buffer, "Cannot allocate %ld bytes for hashcode", (long)n); + ShowMessage(buffer); + return 1; + } + + n = sizeof(drop_hashcode_array); + drop_hashcode = malloc(n); + + if (!drop_hashcode) + { + sprintf(buffer, + "Cannot allocate %ld bytes for drop_hashcode", + (long)n); + ShowMessage(buffer); + return 1; + } + + n = sizeof(struct GameRec) * (size_t)(MAXMOVES + MAXDEPTH); + GameList = malloc(n); + + if (!GameList) + { + sprintf(buffer, + "Cannot allocate %ld bytes for game record", + (long)n); + ShowMessage(buffer); + return 1; + } + +#if !defined SAVE_NEXTPOS + n = sizeof(next_array); + + for (i = 0; i < NO_PTYPE_PIECES; i++) + { + nextdir[i] = use_nextpos ? malloc(n) : NULL; + + if (!nextdir[i]) + { + if (use_nextpos) + { + sprintf(buffer, "cannot allocate %ld space for nextdir %d", + (long)(n), i); + ShowMessage(buffer); + } + + nextdir[i] = NULL; + use_nextpos = false; + } + + nextpos[i] = use_nextpos ? malloc(n) : NULL; + + if (!nextpos[i]) + { + if (use_nextpos) + { + sprintf(buffer, "cannot allocate %ld space for nextpos %d", + (long)(n), i); + ShowMessage(buffer); + } + + use_nextpos = false; + } + } + + if (!use_nextpos) + { + return 1; + } +#endif + + n = sizeof(value_array); + value = malloc(n); + + if (!value) + { + ShowMessage("cannot allocate value space"); + return 1; + } + + n = sizeof(fscore_array); + fscore = malloc(n); + + if (!fscore) + { + ShowMessage("cannot allocate fscore space"); + return 1; + } + +#if defined HISTORY + n = sizeof_history; + history = malloc(n); + + if (!history) + { + sprintf(buffer, "Cannot allocate %ld bytes for history table", + (long)sizeof_history); + ShowMessage(buffer); + use_history = false; + } +#endif + +#if defined CACHE + n = sizeof(struct etable) * (size_t)ETABLE; + + for (i = 0; i < 2; i++) + { + etab[i] = use_etable ? malloc(n) : 0; + + if (!etab[i]) + { + sprintf(buffer, "Cannot allocate %ld bytes for cache table %ld", + (long)n, (long)i); + ShowMessage(buffer); + use_etable = false; + } + } +#endif + +#if ttblsz + + if (rehash < 0) + rehash = MAXrehash; + + n = sizeof(struct hashentry)*(ttblsize + rehash); + + while (doit && ttblsize > MINTTABLE) + { + ttable[0] = malloc(n); /* FIXME: cast to the correct type. */ + ttable[1] = ttable[0] ? malloc(n) : NULL; + + if (!ttable[0] || !ttable[1]) + { + if (!ttable[0]) + free(ttable[0]); + + if (!ttable[1]) + free(ttable[1]); + + ttblsize = ttblsize >> 1; + n = sizeof(struct hashentry) * (ttblsize + rehash); + } + else + { + doit = false; + } + } + + if (ttblsize <= MINTTABLE) + { + use_ttable = false; + } + + if (use_ttable) + { + /* CHECKME: is the precedence here correct? */ + /* ttbllimit = ttblsize << 1 - ttblsize >> 2; */ + ttbllimit = (ttblsize << 1) - (ttblsize >> 2); + } + else + { + sprintf(buffer, "Cannot allocate %ld bytes for transposition table", + (long)(2 * n)); + ShowMessage(buffer); + ttable[0] = ttable[1] = NULL; + } +#endif /* ttblsz */ + +#if !defined SAVE_DISTDATA + n = sizeof(distdata_array); + distdata = malloc(n); + + if (!distdata) + { + ShowMessage("cannot allocate distdata space..."); + use_distdata = false; + } +#endif + +#if !defined SAVE_PTYPE_DISTDATA + n = sizeof(distdata_array); + + for (i = 0; i < NO_PTYPE_PIECES; i++) + { + ptype_distdata[i] = use_ptype_distdata ? malloc(n) : 0; + + if (!ptype_distdata[i]) + { + sprintf(buffer, + "cannot allocate %ld bytes for ptype_distdata %d...", + (long)n, i); + use_ptype_distdata = false; + } + } +#endif + + return 0; +} + + +#if defined EXTLANGFILE + +#ifdef OLDLANGFILE + +void +InitConst(char *lang) +{ + FILE *constfile; + char s[256]; + char sl[5]; + char buffer[120]; + int len, entry; + char *p, *q; + constfile = fopen(LANGFILE, "r"); + + if (!constfile) + { + ShowMessage("NO LANGFILE"); + exit(1); + } + + while (fgets(s, sizeof(s), constfile)) + { + if (s[0] == '!') + continue; + + len = strlen(s); + + for (q = &s[len]; q > &s[8]; q--) + if (*q == '}') + break; + + if (q == &s[8]) + { + ShowMessage("{ error in cinstfile"); + exit(1); + } + + *q = '\0'; + + if ((s[3] != ':') || (s[7] != ':') || (s[8] != '{')) + { + sprintf(buffer, "Langfile format error %s", s); + ShowMessage(buffer); + exit(1); + } + + s[3] = s[7] = '\0'; + + if (lang == NULL) + { + lang = sl; + strcpy(sl, &s[4]); + } + + if (strcmp(&s[4], lang)) + continue; + + entry = atoi(s); + + if ((entry < 0) || (entry >= CPSIZE)) + { + ShowMessage("Langfile number error"); + exit(1); + } + + for (q = p = &s[9]; *p; p++) + { + if (*p != '\\') + { + *q++ = *p; + } + else if (*(p + 1) == 'n') + { + *q++ = '\n'; + p++; + } + } + + *q = '\0'; + + if ((entry < 0) || (entry > 255)) + { + sprintf(buffer, "Langfile error %d\n", entry); + ShowMessage(buffer); + exit(0); + } + + CP[entry] = (char *)GLOBAL_ALLOC((unsigned) strlen(&s[9]) + 1); + + if (CP[entry] == NULL) + { + char buffer[80]; + sprintf(buffer, "CP MALLOC, entry %d", entry); + perror(buffer); + exit(0); + } + + strcpy(CP[entry], &s[9]); + } + + fclose(constfile); +} + +#else + +void +InitConst(char *lang) +{ + FILE *constfile; + char s[256]; + char sl[5]; + char buffer[120]; + int len, entry; + char *p, *q; + constfile = fopen(LANGFILE, "r"); + + if (!constfile) + { + ShowMessage("NO LANGFILE"); + exit(1); + } + + while (fgets(s, sizeof(s), constfile)) + { + if (s[0] == '!') + continue; + + len = strlen(s); + + if ((len > 3) && (s[3] == ':') || (len > 7) && (s[7] == ':')) + { + ShowMessage("old Langfile error"); + exit(1); + } + + if (len <= 15) + { + ShowMessage("length error in Langfile"); + exit(1); + } + + for (q = &s[len]; q > &s[15]; q--) + { + if (*q == '"') + break; + } + + if (q == &s[15]) + { + ShowMessage("\" error in Langfile"); + exit(1); + } + + *q = '\0'; + + if ((s[6] != ':') || (s[10] != ':') || (s[15] != '"')) + { + sprintf(buffer, "Langfile format error %s", s); + ShowMessage(buffer); + exit(1); + } + + s[6] = s[10] = '\0'; + + if (lang == NULL) + { + lang = sl; + strcpy(sl, &s[7]); + } + + if (strcmp(&s[7], lang)) + continue; + + entry = atoi(&s[3]); + + if ((entry < 0) || (entry >= CPSIZE)) + { + ShowMessage("Langfile number error"); + exit(1); + } + + for (q = p = &s[16]; *p; p++) + { + if (*p != '\\') + { + *q++ = *p; + } + else if (*(p + 1) == 'n') + { + *q++ = '\n'; + p++; + } + } + + *q = '\0'; + + if ((entry < 0) || (entry > 255)) + { + sprintf(buffer, "Langfile error %d\n", entry); + ShowMessage(buffer); + exit(0); + } + + CP[entry] = (char *)GLOBAL_ALLOC((unsigned)strlen(&s[16]) + 1); + + if (CP[entry] == NULL) + { + char buffer[80]; + sprintf(buffer, "CP MALLOC, entry %d", entry); + perror(buffer); + exit(0); + } + + strcpy(CP[entry], &s[16]); + } + + fclose(constfile); +} + +#endif + +#endif + + +int +InitMain(void) +{ + gsrand(starttime = ((unsigned int)time((long *)0))); /* init urand */ + +#if ttblsz + ttblsize = ttblsz; + rehash = -1; +#endif /* ttblsz */ + + if (Initialize_data() != 0) + return 1; + +#if defined EXTLANGFILE + InitConst(Lang); +#endif + + strcpy(ColorStr[0], CP[118]); + strcpy(ColorStr[1], CP[119]); + + XC = 0; + MaxResponseTime = 0; + + if (XSHOGI) + { + signal(SIGINT, TerminateSearch); + + TCmoves = 40; + TCminutes = 5; + TCseconds = 0; + TCadd = 0; + + TCflag = true; + OperatorTime = 0; + barebones = 1; + } + else + { + TCflag = false; + OperatorTime = 0; + barebones = 0; + } + + Initialize(); + Initialize_dist(); + Initialize_eval(); +#if !defined SAVE_NEXTPOS + Initialize_moves(); +#endif + + NewGame(); + + flag.easy = ahead; + flag.hash = hash; + + if (xwin) + xwndw = atoi(xwin); + +#ifdef HASHFILE + hashfile = NULL; +#endif + +#if ttblsz +#ifdef HASHFILE + hashfile = fopen(HASHFILE, RWA_ACC); + + if (hashfile) + { + fseek(hashfile, 0L, SEEK_END); + filesz = ftell(hashfile) / sizeof(struct fileentry) - 1 - MAXrehash; + hashmask = filesz >> 1; + hashbase = hashmask + 1; + } +#endif /* HASHFILE */ +#endif /* ttblsz */ + + savefile[0] = '\0'; + listfile[0] = '\0'; + + return 0; +} + + +void +ExitMain(void) +{ +#if ttblsz +#ifdef HASHFILE + if (hashfile) + fclose(hashfile); +#endif /* HASHFILE */ +#endif /* ttblsz */ + + ExitShogi(); +} + diff --git a/gnushogi/main.c b/gnushogi/main.c new file mode 100644 index 0000000..ccbfe87 --- /dev/null +++ b/gnushogi/main.c @@ -0,0 +1,468 @@ +/* + * FILE: main.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "version.h" +#include "gnushogi.h" + +#include + + +void print_arglist(int argc, char **argv) +{ + int i; + + for (i = 0; i < argc; i++) + printf("argv[%d] = %s\n", i, argv[i]); + + printf("\n"); +} + + +int +main (int argc, char **argv) +{ + /* + * Process command-line arguments. + */ + + /* Get rid of the program name. */ + + argc--; + argv++; + + /* CHECKME: get rid of the '+' syntax? */ + + while ((argc > 0) && ((argv[0][0] == '-') || (argv[0][0] == '+'))) + { + switch (argv[0][1]) + { + case 'a': + /* Need the "+" syntax here... */ + ahead = ((argv[0][0] == '-') ? false : true); + break; + + + case 'b': + argc--; + argv++; + + if (argc > 0) + { + bookfile = argv[0]; +#ifdef BINBOOK + binbookfile = NULL; +#endif + } + + break; + +#ifdef BINBOOK + case 'B': + argc--; + argv++; + + if (argc > 0) + binbookfile = argv[0]; + + break; +#endif + + case 'C': + /* Curses interface. */ + display_type = DISPLAY_CURSES; + + break; + + + case 'h': + /* Need the "+" syntax here... */ + hash = ((argv[0][0] == '-') ? false : true); + break; + + + case 'l': + argc--; + argv++; + + if (argc > 0) + Lang = argv[0]; + + break; + + + case 'L': + argc--; + argv++; + + if (argc > 0) + strcpy(listfile, argv[0]); + break; + + + case 's': + argc--; + argv++; + + if (argc > 0) + strcpy(savefile, argv[0]); + + break; + + + case 'P': + argc--; + argv++; + + if (argc > 0) + bookmaxply = atoi(argv[0]); + + break; + + + case 'R': + /* Raw text interface. */ + display_type = DISPLAY_RAW; + + break; + + + case 'S': + argc--; + argv++; + + if (argc > 0) + booksize = atoi(argv[0]); + break; + +#if ttblsz + case 'r': + argc--; + argv++; + + if (argc > 0) + rehash = atoi(argv[0]); + + if (rehash > MAXrehash) + rehash = MAXrehash; + + break; + + + case 'T': + argc--; + argv++; + + if (argc > 0) + ttblsize = atoi(argv[0]); + + if ((ttblsize <= MINTTABLE)) + ttblsize = (MINTTABLE) + 1; + + break; + +#ifdef HASHFILE + case 'c': /* Create or test persistent transposition table. */ + argc--; + argv++; + + if (argc > 0) + filesz = atoi(argv[0]); + else + filesz = vfilesz; + + if ((filesz > 0) && (filesz < 24)) + filesz = (1 << filesz) - 1 + MAXrehash; + else + filesz = filesz + MAXrehash; + + if ((hashfile = fopen(HASHFILE, RWA_ACC)) == NULL) + hashfile = fopen(HASHFILE, WA_ACC); + + if (hashfile != NULL) + { + long j; + struct fileentry n; + + printf(CP[66]); + n.f = n.t = 0; + n.flags = 0; + n.depth = 0; + n.sh = n.sl = 0; + + for (j = 0; j < filesz + 1; j++) + fwrite(&n, sizeof(struct fileentry), 1, hashfile); + + fclose(hashfile); + } + else + { + printf(CP[50], HASHFILE); + } + + return 0; + + + case 't': /* Create or test persistent transposition table. */ + hashfile = fopen(HASHFILE, RWA_ACC); + + if (hashfile) + { + fseek(hashfile, 0L, SEEK_END); + filesz = (ftell(hashfile) / (sizeof(struct fileentry))) - 1; + } + + if (hashfile != NULL) + { + long i, j; + int nr[MAXDEPTH]; + struct fileentry n; + + printf(CP[49]); + + for (i = 0; i < MAXDEPTH; i++) + nr[i] = 0; + + fseek(hashfile, 0L, SEEK_END); + i = ftell(hashfile) / (sizeof(struct fileentry)); + fseek(hashfile, 0L, SEEK_SET); + + for (j = 0; j < i + 1; j++) + { + fread(&n, sizeof(struct fileentry), 1, hashfile); + + if (n.depth > MAXDEPTH) + { + printf("ERROR\n"); + exit(1); + } + + if (n.depth) + { + nr[n.depth]++; + nr[0]++; + } + } + + printf(CP[109], nr[0], i); + + for (j = 1; j < MAXDEPTH; j++) + printf("%d ", nr[j]); + + printf("\n"); + } + + return 0; + + +#endif /* HASHFILE */ +#endif /* ttblsz */ + + case 'v': + fprintf(stderr, CP[102], version, patchlevel); + exit(1); + + + case 'X': + /* X interface. */ + display_type = DISPLAY_X; + + break; + + + case 'x': + argc--; + argv++; + + if (argc > 0) + xwin = argv[0]; + + break; + + + default: + fprintf(stderr, CP[113]); + exit(1); + } + + argc--; + argv++; + } + + if (argc == 2) + { + char *p; + + MaxResponseTime = 100L * strtol(argv[1], &p, 10); + + if (*p == ':') + { + MaxResponseTime = 60L * MaxResponseTime + + 100L * strtol(++p, (char **) NULL, 10); + } + + TCflag = false; + TCmoves = 0; + TCminutes = 0; + TCseconds = 0; + } + + if (argc >= 3) + { + char *p; + + if (argc > 9) + { + printf("%s\n", CP[220]); + exit(1); + } + + TCmoves = atoi(argv[1]); + TCminutes = (short)strtol(argv[2], &p, 10); + + if (*p == ':') + TCseconds = (short)strtol(p + 1, (char **) NULL, 10); + else + TCseconds = 0; + + TCflag = true; + argc -= 3; + argv += 3; + + while (argc > 1) + { + XCmoves[XC] = atoi(argv[0]); + XCminutes[XC] = (short)strtol(argv[1], &p, 10); + + if (*p == ':') + XCseconds[XC] = (short)strtol(p + 1, (char **) NULL, 10); + else + XCseconds[XC] = 0; + + if (XCmoves[XC] && (XCminutes[XC] || XCseconds[XC])) + XC++; + else + { + printf("%s\n", CP[220]); + exit(1); + } + + argc -= 2; + argv += 2; + } + + if (argc) + { + /* + * If we got here, there are unknown arguments, so issue + * an error message and quit. + */ + + printf("%s\n", CP[233]); + print_arglist(argc, argv); + exit(1); + } + } + + if (InitMain() != 0) + exit(1); + + while (!flag.quit) + { + oppptr = (oppptr + 1) % MINGAMEIN; + + if (flag.bothsides && !flag.mate) + SelectMove(opponent, FOREGROUND_MODE); + else + InputCommand(NULL); + + if (opponent == white) + { + if (flag.gamein || TCadd) + { + TimeCalc(); + } + else if (TimeControl.moves[opponent] == 0) + { + if (XC) + { + if (XCmore < XC) + { + TCmoves = XCmoves[XCmore]; + TCminutes = XCminutes[XCmore]; + TCseconds = XCseconds[XCmore]; + XCmore++; + } + } + + SetTimeControl(); + } + } + + compptr = (compptr + 1) % MINGAMEIN; + + if (!(flag.quit || flag.mate || flag.force)) + { +#ifdef INTERRUPT_TEST + printf("starting search...\n"); +#endif + SelectMove(computer, FOREGROUND_MODE); + + if (computer == white) + { + if (flag.gamein) + { + TimeCalc(); + } + else if (TimeControl.moves[computer] == 0) + { + if (XC) + { + if (XCmore < XC) + { + TCmoves = XCmoves[XCmore]; + TCminutes = XCminutes[XCmore]; + TCseconds = XCseconds[XCmore]; + XCmore++; + } + } + + SetTimeControl(); + } + } + } + } + + ExitMain(); + + return 0; +} + + diff --git a/gnushogi/makepattern.c b/gnushogi/makepattern.c new file mode 100644 index 0000000..b2e618a --- /dev/null +++ b/gnushogi/makepattern.c @@ -0,0 +1,297 @@ +/* + * FILE: makepattern.c + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + +#include "gnushogi.h" +#include "pattern.h" + +#define MAX_PATTERN_DATA 5000 +#define MAX_OPENING_SEQUENCE 20 +#define MAX_PATTERN 200 + +char *patternfile = PATTERNFILE; + +#define is_digit(c) (((c) >= '0') && ((c) <= '9')) +#define is_alpha(c) ((((c) >= 'a') && ((c) <= 'z')) \ + || (((c) >= 'A') && ((c) <= 'Z'))) +#define eos(s) ((*s == '\0') || (*s == '\n')) + + +/* skip blanks and comments in brackets */ + +static void +skipbb(char **s) +{ + while ((**s == ' ') || (**s == '|') || (**s == '[')) + { + if (**s == '[') + { + while (**s != ']') + (*s)++; + } + + (*s)++; + } +} + + +/* skip unsigned numbers */ + +static void +skipi(char **s) +{ + while (is_digit(**s)) + (*s)++; + + skipbb(s); +} + + +static short +ScanPiece(char **s, small_short *side, + small_short *piece, small_short *square) +{ + short isp, isw, c, r; + + /* determine promotion status */ + if (**s == '+') + isp = true, (*s)++; /* FIXME: split into two lines. */ + else + isp = false; + + /* determine side and piece */ + for (c = 0; c < NO_PIECES; c++) + { + if ((isw = (**s == pxx[c])) || (**s == qxx[c])) + { + *piece = isp ? promoted[c] : unpromoted[c]; + *side = isw; + (*s)++; + break; + } + } + + if (c == NO_PIECES) + return 1; + + if (**s == '*') + { + /* piece is captured */ + (*s)++; + *square = NO_SQUARES + *piece; + } + else + { + /* determine column */ + for (c = 0; c < NO_COLS; c++) + { + if (**s == cxx[c]) + { + (*s)++; + break; + } + } + + if (c >= NO_COLS) + return 1; + + /* determine row */ + for (r = 0; r < NO_ROWS; r++) + { + if (**s == rxx[r]) + { + (*s)++; + break; + } + } + + if (r >= NO_ROWS) + return 1; + + /* determine square */ + *square = r * NO_COLS + c; + } + + skipbb(s); + return 0; +} + + +static short +ScanPattern (char *s, short *pindex) +{ + small_short side, piece, square; + skipbb(&s); /* skip blanks and comments */ + + while (is_digit(*s)) + { + pattern_data[(*pindex)++] = atoi(s); + skipi(&s); + } + + pattern_data[(*pindex)++] = END_OF_LINKS; + skipbb(&s); + + while (!eos(s)) + { + if (ScanPiece(&s, &side, &piece, &square)) + { + return 1; + } + else + { + pattern_data[(*pindex)++] = piece; + pattern_data[(*pindex)++] = (side ? -square : square); + } + + } + + pattern_data[(*pindex)++] = END_OF_FIELDS; + return 0; +} + + +void +ReadOpeningSequences (short *pindex) + +{ + FILE *fd; + char s[256]; + short max_pattern = 0; + short max_opening_sequence = 0; + + if ((fd = fopen (patternfile, "r")) == NULL) + fd = fopen ("gnushogi.pat", "r"); + + if (fd != NULL) + { + *pindex = 0; + + while (fgets (s, 256, fd) != NULL) + { + if (*s == '#') + { + /* comment, skip line */ + } + else if (is_alpha(*s)) + { + if (max_opening_sequence++ > 0) + { + pattern_data[(*pindex)++] = END_OF_PATTERNS; + } + + pattern_data[(*pindex)++] = ValueOfOpeningName(s); + } + else + { + if (ScanPattern(s, pindex)) + { + ShowMessage("error in pattern sequence..."); + exit(1); + } + else + { + max_pattern++; + } + } + } + + pattern_data[(*pindex)++] = END_OF_PATTERNS; + pattern_data[(*pindex)++] = END_OF_SEQUENCES; + + if (NOT_CURSES) + { + sprintf(s, + "Pattern: %d bytes for %d sequences with %d patterns.\n", + *pindex, max_opening_sequence, max_pattern); + ShowMessage(s); + } + fclose(fd); + } + else if (NOT_CURSES) + { + sprintf(s, "no pattern file '%s'", patternfile); + ShowMessage(s); + } +} + + +void +WriteOpeningSequences (short pindex) +{ + FILE *fd; + short n = 0; + short max_pattern = 0; + short max_opening_sequence = 0; + + fd = fopen ("pattern.inc", "w"); + fprintf(fd, "#define MAX_PATTERN_DATA %d\n\n", pindex); + fprintf(fd, "small_short pattern_data[MAX_PATTERN_DATA] =\n{\n"); + + do + { + fprintf(fd, " %d,\n", pattern_data[n++]); + + do + { + fprintf(fd, " "); + + /* write links */ + while (pattern_data[n] != END_OF_LINKS) + { + fprintf(fd, "%d, ", pattern_data[n++]); + }; + + fprintf(fd, "%d, ", pattern_data[n++]); + + /* write pattern */ + do + { + fprintf(fd, "%d,", pattern_data[n++]); + } + while (pattern_data[n] != END_OF_FIELDS); + + fprintf(fd, "%d,\n", pattern_data[n++]); + max_pattern++; + } + while (pattern_data[n] != END_OF_PATTERNS); + + fprintf(fd, " %d,\n", pattern_data[n++]); + max_opening_sequence++; + } + while (pattern_data[n] != END_OF_SEQUENCES); + + fprintf(fd, " %d\n}; \n", pattern_data[n++]); + fprintf(fd, "\n#define MAX_OPENING_SEQUENCE %d\n", max_opening_sequence); + fprintf(fd, "\n#define MAX_PATTERN %d\n", max_pattern); + fclose(fd); +} + + diff --git a/gnushogi/opts.h b/gnushogi/opts.h new file mode 100644 index 0000000..4958ed6 --- /dev/null +++ b/gnushogi/opts.h @@ -0,0 +1,214 @@ +/* + * FILE: opts.h + * + * #defines to set various options. + * + * ---------------------------------------------------------------------- + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * + * GNU SHOGI is based on GNU CHESS + * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * + * This file is part of GNU SHOGI. + * + * GNU Shogi is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 1, or (at your option) any + * later version. + * + * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with GNU Shogi; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * ---------------------------------------------------------------------- + * + */ + + +/* + * This file is for options that control the behavior of GNU shogi, + * and also for debugging #defines. They were previously placed on the + * command line as -D