4 * Main header file for GNU Shogi.
6 * ----------------------------------------------------------------------
7 * Copyright (c) 1993, 1994, 1995 Matthias Mutz
8 * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
10 * GNU SHOGI is based on GNU CHESS
12 * Copyright (c) 1988, 1989, 1990 John Stanback
13 * Copyright (c) 1992 Free Software Foundation
15 * This file is part of GNU SHOGI.
17 * GNU Shogi is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 3 of the License,
20 * or (at your option) any later version.
22 * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
23 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 * You should have received a copy of the GNU General Public License along
28 * with GNU Shogi; see the file COPYING. If not, see
29 * <http://www.gnu.org/licenses/>.
30 * ----------------------------------------------------------------------
34 /* Hack for anal-retentive ANSI-compliance if desired: */
37 /* FIXME: this file needs to be reorganized in some rational manner. */
42 #include "config.h" /* Portability #defines. */
44 #include "opts.h" /* Various option-setting #defines. */
57 extern display_t display_type;
59 #define XSHOGI (display_type == DISPLAY_X)
60 #define NOT_CURSES ((display_type == DISPLAY_X) \
61 || (display_type == DISPLAY_RAW))
64 /* Miscellaneous globals. */
66 extern short hard_time_limit; /* If you exceed time limit, you lose. */
67 extern short barebones; /* Don't print of stats for x interface. */
68 extern short nolist; /* Don't list game after exit. */
72 * Options for various compilers/OSs.
76 * type small_short must cover -128 .. 127. In case of trouble,
77 * try commenting out "signed". If this doesn't help, use short.
80 #define small_short signed char
81 #define small_ushort unsigned char
84 typedef small_ushort UBYTE;
86 typedef unsigned short USHORT;
88 typedef unsigned int UINT;
90 typedef unsigned long ULONG;
93 #if !defined(HAVE_MEMCPY) && !defined(HAVE_BCOPY)
94 # define array_copy(src, dst, len) \
97 char *psrc = (char *)src, *pdst = (char *)dst; \
98 for (i = len; i; pdst[--i] = psrc[i]); \
100 # define array_zero(dst, len) \
103 char *pdst = (char *)dst; \
104 for (i = len; i; pdst[--i] = 0); \
106 #elif !defined(HAVE_MEMCPY) /* BSD and derivatives */
107 # define array_copy(src, dst, len) bcopy(src, dst, len)
108 # define array_zero(dst, len) bzero(dst, len)
109 #else /* System V and derivatives */
110 # define array_copy(src, dst, len) memcpy(dst, src, len)
111 # define array_zero(dst, len) memset(dst, 0, len)
121 * Standard header files.
130 #include <sys/param.h>
131 #include <sys/types.h>
133 # include <windows.h>
135 typedef small_short BYTE;
136 # include <sys/times.h>
137 # include <sys/ioctl.h>
140 #if TIME_WITH_SYS_TIME
141 # include <sys/time.h>
145 # include <sys/time.h>
154 extern char *binbookfile;
157 extern char *bookfile;
161 extern void movealgbr(short m, char *s);
168 #define MAX_CAPTURED 19
169 #define NO_PTYPE_PIECES 15
172 #define NO_SQUARES (NO_COLS*NO_ROWS)
174 #define ROW_NAME(n) ('a' + NO_ROWS - 1 - n)
175 #define COL_NAME(n) ('1' + NO_COLS - 1 - n)
177 #if defined HASHFILE || defined CACHE
178 # define PTBLBDSIZE (NO_SQUARES + NO_PIECES)
183 #define SCORE_LIMIT 12000
185 /* masks into upper 16 bits of attacks array */
186 /* observe order of relative piece values */
187 #define CNT_MASK 0x000000FF
188 #define ctlP 0x00200000
189 #define ctlPp 0x00100000
190 #define ctlL 0x00080000
191 #define ctlN 0x00040000
192 #define ctlLp 0x00020000
193 #define ctlNp 0x00010000
194 #define ctlS 0x00008000
195 #define ctlSp 0x00004000
196 #define ctlG 0x00002000
197 #define ctlB 0x00001000
198 #define ctlBp 0x00000800
199 #define ctlR 0x00000400
200 #define ctlRp 0x00000200
201 #define ctlK 0x00000100
203 /* attack functions */
204 #define Pattack(c, u) (attack[c][u] > ctlP)
205 #define Anyattack(c, u) (attack[c][u] != 0)
207 /* hashtable flags */
208 #define truescore 0x0001
209 #define lowerbound 0x0002
210 #define upperbound 0x0004
211 #define kingcastle 0x0008
212 #define queencastle 0x0010
213 #define evalflag 0x0020
216 #define BlackKing PieceList[black][0]
217 #define WhiteKing PieceList[white][0]
218 #define OwnKing PieceList[c1][0]
219 #define EnemyKing PieceList[c2][0]
222 /* board properties */
223 #define InBlackCamp(sq) ((sq) < 27)
224 #define InWhiteCamp(sq) ((sq) > 53)
225 #define InPromotionZone(side, sq) \
226 (((side) == black) ? InWhiteCamp(sq) : InBlackCamp(sq))
229 #define OPENING_HINT 0x141d /* P7g-7f (20->29) */
245 /* piece code defines */
285 #define pmask 0x000f /* 15 */
286 #define promote 0x0010 /* 16 */
287 #define dropmask 0x0020 /* 32 */
288 #define exact 0x0040 /* 64 */
289 #define tesuji 0x0080 /* 128 */
290 #define check 0x0100 /* 256 */
291 #define capture 0x0200 /* 512 */
292 #define draw 0x0400 /* 1024 */
293 #define stupid 0x0800 /* 2048 */
294 #define questionable 0x1000 /* 4096 */
295 #define kingattack 0x2000 /* 8192 */
296 #define book 0x4000 /* 16384 */
298 /* move quality flags */
299 #define goodmove tesuji
300 #define badmove stupid
302 #define difficult questionable
306 #define pxx (" PLNSGBRPLNSBRK ")
307 #define qxx (" plnsgbrplnsbrk ")
308 #define rxx ("ihgfedcba")
309 #define cxx ("987654321")
311 /***************** Table limits ********************************************/
314 * ttblsz must be a power of 2. Setting ttblsz 0 removes the transposition
320 #elif defined SMALL_MEMORY
321 # if defined SAVE_SSCORE
322 # define vttblsz (1 << 12)
324 # if defined EXTRA_2MB
325 # define vttblsz (1 << 12)
327 # define vttblsz (1 << 10)
331 # define vttblsz (100001)
334 #if defined SMALL_MEMORY
335 # define MINTTABLE (0)
337 # define MINTTABLE (8000) /* min ttable size -1 */
340 #define ttblsz vttblsz
342 #if defined SMALL_MEMORY
343 # if !defined SAVE_SSCORE
344 # define TREE 1500 /* max number of tree entries */
346 # define TREE 2500 /* max number of tree entries */
349 # define TREE 4000 /* max number of tree entries */
352 #define MAXDEPTH 40 /* max depth a search can be carried */
353 #define MINDEPTH 2 /* min search depth =1 (no hint), >1 hint */
354 #define MAXMOVES 300 /* max number of half moves in a game */
355 #define CPSIZE 235 /* size of lang file max */
357 #if defined SMALL_MEMORY
358 # if defined SAVE_SSCORE
359 # define ETABLE (1 << 10) /* static eval cache */
361 # if defined EXTRA_2MB
362 # define ETABLE (1 << 10) /* static eval cache */
364 # define ETABLE (1 << 8) /* static eval cache */
368 # define ETABLE (10001) /* static eval cache */
371 /***************** tuning paramaters *******************/
373 #if defined VERY_SLOW_CPU
374 # define MINRESPONSETIME 300
375 #elif defined SLOW_CPU
376 # define MINRESPONSETIME 200
378 # define MINRESPONSETIME 100 /* 1 s */
383 #define CHKDEPTH 1 /* always look forward CHKDEPTH
384 * half-moves if in check */
386 #if defined SLOW_CPU || defined VERY_SLOW_CPU
387 # define DEPTHBEYOND 7 /* Max to go beyond Sdepth */
389 # define DEPTHBEYOND 11 /* Max to go beyond Sdepth */
392 #define HASHDEPTH 4 /* depth above which to use HashFile */
393 #define HASHMOVELIMIT 40 /* Use HashFile only for this many moves */
394 #define PTVALUE 0 /* material value below which pawn threats at
396 #define ZDEPTH 3 /* depth beyond which to check
397 * ZDELTA for extra time */
398 #define ZDELTA 10 /* score delta per ply to cause
399 * extra time to be given */
402 /* about 1/2 second worth of nodes for your machine */
403 #if defined VERY_SLOW_CPU
404 /* check the time every ZNODES positions */
405 # define ZNODES (flag.tsume ? 20 : 50)
406 #elif defined SLOW_CPU
407 # define ZNODES (flag.tsume ? 40 : 100)
409 # define ZNODES (flag.tsume ? 400 : 1000)
412 #define MAXTCCOUNTX 10 /* max number of time clicks
413 * per search to complete ply */
414 #define MAXTCCOUNTR 4 /* max number of time clicks
415 * per search extensions*/
416 #define SCORESPLIM 8 /* Score space doesn't apply after this stage */
417 #define SDEPTHLIM (Sdepth + 1)
418 #define HISTORYLIM 4096 /* Max value of history killer */
421 # if defined SMALL_MEMORY
422 # define HISTORY_MASK 0x8000 /* mask to MSB of history index */
423 # define HISTORY_SIZE 0x10000 /* size of history table */
425 # define HISTORY_MASK (1 << 15) /* mask to MSB of history index */
426 # define HISTORY_SIZE (1 << 16) /* size of history table */
429 /* smaller history table, but dangerous because of collisions */
430 # define HISTORY_MASK 0x3fff /* mask to significant bits
431 * of history index */
432 # if defined SMALL_MEMORY
433 # define HISTORY_SIZE 0x4000 /* size of history table */
435 # define HISTORY_SIZE (1 << 14) /* size of history table */
439 #define sizeof_history (sizeof(unsigned short) * (size_t)HISTORY_SIZE)
442 /* Map from.to (8bit.8bit) to from.to (0.7bit.8bit) */
443 # define khmove(mv) (mv & 0x7fff)
444 # define hmove(mv) ((mv & 0x7fff) ^ 0x5555)
446 /* Map from.to (8bit.8bit) to from.to (00.7bit.7bit) */
447 /* Swap bits of ToSquare in case of promotions, hoping that
448 no catastrophic collision occurs. */
449 # define khmove(mv) (((mv & 0x7f00) >> 1) | \
450 ((mv & 0x0080) ? ((mv & 0x007f) ^ 0x007f) : (mv & 0x007f)))
451 # define hmove(mv) (khmove(mv) ^ 0x2aaa)
454 /* mask color to 15th bit */
456 # define hindex(c, mv) ((c ? HISTORY_MASK : 0) | hmove(mv))
458 /* for white, swap bits, hoping that no catastrophic collision occurs. */
459 # define hindex(c, mv) (c ? ((~hmove(mv)) & HISTORY_MASK) : hmove(mv))
462 #define EWNDW 10 /* Eval window to force position scoring at depth
463 * greater than (Sdepth + 2) */
464 #define WAWNDW 90 /* alpha window when computer black */
465 #define WBWNDW 90 /* beta window when computer black */
466 #define BAWNDW 90 /* alpha window when computer white */
467 #define BBWNDW 90 /* beta window when computer white */
468 #define BXWNDW 90 /* window to force position scoring at lower */
469 #define WXWNDW 90 /* window to force position scoring at lower */
471 #define DITHER 5 /* max amount random can alter a pos value */
472 #define LBONUS 1 /* points per stage value of L increases */
473 #define BBONUS 2 /* points per stage value of B increases */
474 #define RBONUS 2 /* points per stage value of R increases */
476 #define QUESTIONABLE (valueK) /* Penalty for questionable moves. */
482 #define STUPID (valueR << 1) /* Penalty for stupid moves. */
484 #define KINGPOSLIMIT (-1) /* King positional scoring limit */
485 #define KINGSAFETY 32
486 #define MAXrehash (7)
488 /******* parameters for Opening Book ****************/
490 #define BOOKSIZE 8000 /* Number of unique position/move
491 * combinations allowed */
492 #define BOOKMAXPLY 40 /* Max plys to keep in book database */
493 #define BOOKFAIL (BOOKMAXPLY / 2) /* if no book move found for BOOKFAIL
494 * turns stop using book */
495 #define BOOKPOCKET 64
496 #define BOOKRAND 1000 /* used to select an opening move
498 #define BOOKENDPCT 950 /* 5 % chance a BOOKEND will stop the book */
499 #define DONTUSE -32760 /* flag move as don't use */
500 #define ILLEGAL_TRAPPED -32761 /* flag move as illegal:
501 * no move from this square */
502 #define ILLEGAL_DOUBLED -32762 /* flag move as illegal:
503 * two pawns on one column */
504 #define ILLEGAL_MATE -32763 /* flag move as illegal:
505 * pawn drop with mate */
507 /*****************************************************/
511 unsigned long key, bd;
516 unsigned long hashbd;
518 unsigned char depth; /* unsigned char saves some space */
525 unsigned char bd[PTBLBDSIZE];
526 #endif /* HASHTEST */
529 #if defined HASHFILE || defined CACHE
532 unsigned long ehashbd;
534 #if !defined SAVE_SSCORE
535 short sscore[NO_SQUARES];
540 unsigned char bd[PTBLBDSIZE];
541 #endif /* CACHETEST */
545 extern short use_etable;
546 typedef struct etable etable_field[ETABLE];
547 extern etable_field *etab[2];
551 * CHECKME! Is this valid?
553 * persistent transposition table. By default, the size is (1 << vfilesz).
554 * If you change the size, be sure to run gnushogi -c [vfilesz]
555 * before anything else.
560 #if defined SMALL_MEMORY
568 unsigned char bd[PTBLBDSIZE];
569 unsigned char f, t, flags, depth, sh, sl;
572 #endif /* HASHFILE */
578 short score, reply, width;
580 unsigned short flags;
586 unsigned short gmove; /* this move */
587 short score; /* score after this move */
588 short depth; /* search depth this move */
589 long time; /* search time this move */
590 short fpiece; /* moved or dropped piece */
591 short piece; /* piece captured */
592 short color; /* color */
593 short flags; /* move flags capture, promote, castle */
594 short Game50; /* flag for repetition */
595 long nodes; /* nodes searched for this move */
596 unsigned long hashkey, hashbd; /* board key before this move */
600 struct TimeControlRec
609 short mate; /* the game is over */
610 short post; /* show principle variation */
611 short quit; /* quit/exit */
612 short regularstart; /* did the game start from standard
614 short reverse; /* reverse board display */
615 short bothsides; /* computer plays both sides */
616 short hash; /* enable/disable transposition table */
617 short force; /* enter moves */
618 short easy; /* disable thinking on opponents time */
619 short beep; /* enable/disable beep */
620 short timeout; /* time to make a move */
621 short musttimeout; /* time to make a move */
622 short back; /* time to make a move */
623 short rcptr; /* enable/disable recapture heuristics */
624 short rv; /* reverse video */
625 short stars; /* add stars to uxdsp screen */
626 short coords; /* add coords to visual screen */
628 short material; /* draw on lack of material */
629 short illegal; /* illegal position */
630 short onemove; /* timing is onemove */
631 short gamein; /* timing is gamein */
632 short tsume; /* first consider checks */
635 extern FILE *debugfile;
638 #define EVALFILE "/tmp/EVAL"
641 extern FILE *debug_eval_file;
642 extern short debug_moves;
646 extern short use_history;
647 extern unsigned short *history;
652 extern char ColorStr[2][10];
654 extern char mvstr[4][6];
655 extern unsigned short MV[MAXDEPTH];
657 extern int mycnt1, mycnt2;
659 extern struct leaf rootnode;
660 extern struct leaf *Tree;
661 extern struct leaf *root;
662 extern char savefile[], listfile[];
663 extern short TrPnt[];
664 extern small_short board[], color[];
665 extern const small_short sweep[NO_PIECES];
666 extern small_short PieceList[2][NO_SQUARES], PawnCnt[2][NO_COLS];
667 extern small_short Captured[2][NO_PIECES];
670 # define ClearCaptured() \
672 short piece, color; \
673 for (color = black; color <= white; color++) \
674 for (piece = 0; piece < NO_PIECES; piece++) \
675 Captured[color][piece] = 0; \
678 # define ClearCaptured() \
679 memset((char *)Captured, 0, (unsigned long)sizeof(Captured))
680 #endif /* HAVE_MEMSET */
682 extern small_short Mvboard[];
684 #if !defined SAVE_SVALUE
685 extern short svalue[NO_SQUARES];
688 extern short pscore[2]; /* eval.c */
689 extern int EADD; /* eval.c */
690 extern int EGET; /* eval.c */
691 extern struct flags flag;
692 extern short opponent, computer, INCscore;
693 extern short WAwindow, BAwindow, WBwindow, BBwindow;
694 extern short dither, player;
695 extern short xwndw, contempt;
696 extern long ResponseTime, ExtraTime, TCleft,
697 MaxResponseTime, et, et0, time0, ft;
700 #ifdef INTERRUPT_TEST
701 extern long itime0, it;
704 extern long reminus, replus;
705 extern long GenCnt, NodeCnt, ETnodes, EvalNodes, HashAdd, HashCnt,
706 HashCol, THashCol, FHashCnt, FHashAdd;
707 extern short HashDepth, HashMoveLimit;
708 extern struct GameRec *GameList;
709 extern short GameCnt, Game50;
710 extern short Sdepth, MaxSearchDepth;
712 extern struct TimeControlRec TimeControl;
714 extern short TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
715 extern int timecomp[MINGAMEIN], timeopp[MINGAMEIN];
716 extern int compptr, oppptr;
717 extern short XCmore, XCmoves[], XCminutes[], XCseconds[], XC;
718 extern const short otherside[];
719 extern const small_short Stboard[];
720 extern const small_short Stcolor[];
721 extern unsigned short hint;
723 extern short stage, stage2;
725 #define in_opening_stage (!flag.tsume && (stage < 33))
726 #define in_middlegame_stage (!flag.tsume && (stage >= 33) && (stage <= 66))
727 #define in_endgame_stage (flag.tsume || (stage > 66))
729 extern short ahead, hash;
730 extern short balance[2];
731 extern small_short ChkFlag[], CptrFlag[], TesujiFlag[];
732 extern short Pscore[], Tscore[];
733 extern /*unsigned*/ short rehash; /* -1 is used as a flag --tpm */
734 extern unsigned int ttbllimit;
735 extern unsigned int TTadd;
736 extern unsigned int ttblsize;
737 extern short mtl[], hung[];
738 extern small_short Pindex[];
739 extern small_short PieceCnt[];
740 extern short FROMsquare, TOsquare;
741 extern small_short HasPiece[2][NO_PIECES];
742 extern const short kingP[];
743 extern unsigned short killr0[], killr1[];
744 extern unsigned short killr2[], killr3[];
745 extern unsigned short PrVar[MAXDEPTH];
746 extern unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
747 extern short mtl[2], pmtl[2], hung[2];
748 extern const small_short relative_value[];
749 extern const long control[];
750 extern small_short diagonal(short delta);
751 extern const small_short promoted[NO_PIECES], unpromoted[NO_PIECES];
752 extern const small_short is_promoted[NO_PIECES];
754 typedef unsigned char next_array[NO_SQUARES][NO_SQUARES];
755 typedef small_short distdata_array[NO_SQUARES][NO_SQUARES];
757 extern const small_short inunmap[NO_SQUARES];
758 extern const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 4)];
760 #if defined SAVE_NEXTPOS
761 extern const small_short direc[NO_PTYPE_PIECES][8];
762 extern short first_direction(short ptyp, short *d, short sq);
763 extern short next_direction(short ptyp, short *d, short sq);
764 extern short next_position(short ptyp, short *d, short sq, short u);
766 extern short use_nextpos;
767 extern next_array *nextpos[NO_PTYPE_PIECES];
768 extern next_array *nextdir[NO_PTYPE_PIECES];
771 extern value_array *value;
772 extern fscore_array *fscore;
774 #ifndef SAVE_DISTDATA
775 extern short use_distdata;
776 extern distdata_array *distdata;
779 #ifndef SAVE_PTYPE_DISTDATA
780 extern short use_ptype_distdata;
781 extern distdata_array *ptype_distdata[NO_PTYPE_PIECES];
784 extern const small_short ptype[2][NO_PIECES];
786 extern long filesz, hashmask, hashbase;
787 extern FILE *hashfile;
788 extern unsigned int starttime;
791 typedef small_short Mpiece_array[2][NO_SQUARES];
792 extern Mpiece_array *Mpiece[NO_PIECES];
793 extern short ADVNCM[NO_PIECES];
795 #define computed_distance(a, b) \
796 ((abs(column(a) - column(b)) > abs(row(a) - row(b))) \
797 ? abs(column(a) - column(b)) : abs(row(a) - row(b)))
799 extern short distance(short a, short b);
800 extern short ptype_distance(short ptyp, short f, short t);
801 extern short piece_distance(short side, short piece, short f, short t);
808 #define STATIC_ROOK 'S'
809 #define RANGING_ROOK 'R'
811 extern char GameType[2];
812 void ShowGameType(void);
814 extern unsigned short bookmaxply;
815 extern unsigned int bookcount;
816 extern unsigned int booksize;
817 extern unsigned long hashkey, hashbd;
819 typedef struct hashval hashcode_array[2][NO_PIECES][NO_SQUARES];
820 typedef struct hashval drop_hashcode_array[2][NO_PIECES][NO_SQUARES];
822 extern hashcode_array *hashcode;
823 extern drop_hashcode_array *drop_hashcode;
825 #ifdef QUIETBACKGROUND
826 extern short background;
827 #endif /* QUIETBACKGROUND */
830 extern short use_ttable;
831 extern struct hashentry *ttable[2];
835 * hashbd contains a 32 bit "signature" of the board position. hashkey
836 * contains a 16 bit code used to address the hash table. When a move is
837 * made, XOR'ing the hashcode of moved piece on the from and to squares with
838 * the hashbd and hashkey values keeps things current.
841 #define UpdateHashbd(side, piece, f, t) \
845 hashbd ^= (*hashcode)[side][piece][f].bd; \
846 hashkey ^= (*hashcode)[side][piece][f].key; \
851 hashbd ^= (*hashcode)[side][piece][t].bd; \
852 hashkey ^= (*hashcode)[side][piece][t].key; \
856 #define UpdateDropHashbd(side, piece, count) \
858 hashbd ^= (*drop_hashcode)[side][piece][count].bd; \
859 hashkey ^= (*drop_hashcode)[side][piece][count].key; \
863 extern short rpthash[2][256];
866 extern char* DRAW_REPETITION;
867 extern char *DRAW_MAXMOVES;
868 extern char *DRAW_JUSTDRAW;
870 #define row(a) ((a) / NO_COLS)
871 #define column(a) ((a) % NO_COLS)
872 #define locn(a, b) (((a) * NO_COLS) + b)
874 /* init external functions */
875 extern void InitConst(char *lang); /* init.c */
876 extern int Initialize_data(void); /* init.c */
877 extern void Free_data(void); /* init.c */
878 extern int Lock_data(void); /* init.c */
879 extern void Unlock_data(void); /* init.c */
880 extern void Initialize_dist(void); /* init.c */
881 extern void Initialize_eval(void); /* eval.c */
882 extern void NewGame(void);
883 extern int parse(FILE * fd, unsigned short *mv,
884 short side, char *opening);
885 extern void GetOpenings(void);
886 extern int OpeningBook(unsigned short *hint, short side);
890 REMOVE_PIECE = 1, ADD_PIECE
891 } UpdatePieceList_mode;
894 UpdatePieceList(short side, short sq, UpdatePieceList_mode iop);
898 FOREGROUND_MODE = 1, BACKGROUND_MODE
902 SelectMove(short side, SelectMove_mode iop);
910 unsigned short *bstline,
914 void PutInEETable(short side, int score);
915 int CheckEETable(short side);
916 int ProbeEETable(short side, short *score);
921 ProbeTTable(short side,
929 PutInTTable(short side,
937 extern void ZeroTTable(void);
938 extern void ZeroRPT(void);
939 extern void Initialize_ttable(void);
940 extern unsigned int urand(void);
943 extern void gsrand(unsigned int);
946 ProbeFTable(short side,
954 PutInFTable(short side,
963 # endif /* HASHFILE */
966 #if !defined SAVE_NEXTPOS
967 extern void Initialize_moves(void);
970 extern short generate_move_flags;
972 extern void MoveList(short side, short ply,
973 short in_check, short blockable);
974 extern void CaptureList(short side, short ply,
975 short in_check, short blockable);
979 SqAttacked(short square, short side, short *blockable);
991 UnmakeMove(short side,
999 InitializeStats(void);
1002 evaluate(short side,
1010 extern short ScorePosition(short side);
1011 extern void ExaminePosition(short side);
1012 extern short ScorePatternDistance(short side);
1013 extern void DetermineStage(short side);
1014 extern void UpdateWeights(short side);
1015 extern int InitMain(void);
1016 extern void ExitMain(void);
1017 extern void Initialize(void);
1018 extern void InputCommand(char *command);
1019 extern void ExitShogi(void);
1020 extern void ClearScreen(void);
1021 extern void SetTimeControl(void);
1022 extern void SelectLevel(char *sx);
1025 UpdateDisplay(short f,
1032 COMPUTE_AND_INIT_MODE = 1, COMPUTE_MODE
1033 #ifdef INTERRUPT_TEST
1034 , INIT_INTERRUPT_MODE, COMPUTE_INTERRUPT_MODE
1038 extern void SetResponseTime(short side);
1039 extern void CheckForTimeout(int score, int globalscore,
1040 int Jscore, int zwndw);
1041 extern void ShowSidetoMove(void);
1042 extern void ShowResponseTime(void);
1043 extern void ShowPatternCount(short side, short n);
1044 extern void SearchStartStuff(short side);
1045 extern void ShowDepth(char ch);
1046 extern void TerminateSearch(int);
1047 extern void ShowResults(short score, unsigned short *bstline, char ch);
1048 extern void SetupBoard(void);
1049 extern void algbr(short f, short t, short flag);
1050 extern void OutputMove(void);
1051 extern void ShowCurrentMove(short pnt, short f, short t);
1052 extern void ListGame(void);
1053 extern void ShowMessage(char *s);
1054 extern void ClearScreen(void);
1055 extern void DoDebug(void);
1056 extern void DoTable(short table[NO_SQUARES]);
1057 extern void ShowPostnValues(void);
1058 extern void ChangeXwindow(void);
1059 extern void SetContempt(void);
1060 extern void ChangeHashDepth(void);
1061 extern void ChangeBetaWindow(void);
1062 extern void GiveHint(void);
1063 extern void ShowPrompt(void);
1064 extern void EditBoard(void);
1065 extern void help(void);
1066 extern void ChangeSearchDepth(void);
1067 extern void skip(void);
1068 extern void skipb(void);
1069 extern void EnPassant(short xside, short f, short t, short iop);
1070 extern void ShowNodeCnt(long NodeCnt);
1071 extern void ShowLine(unsigned short *bstline);
1072 extern int pick(short p1, short p2);
1073 extern short repetition(void);
1074 extern void TimeCalc(void);
1075 extern void ElapsedTime(ElapsedTime_mode iop);
1078 DropPossible(short piece, short side, short sq); /* genmoves.c */
1081 IsCheckmate(short side, short in_check,
1082 short blockable); /* genmoves.c */
1087 VERIFY_AND_MAKE_MODE, VERIFY_AND_TRY_MODE, UNMAKE_MODE
1090 extern int VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv);
1091 extern unsigned short TTage;
1093 #include "dspwrappers.h" /* Display functions. */
1095 #endif /* _GNUSHOGI_H_ */