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
9 * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation
11 * GNU SHOGI is based on GNU CHESS
13 * Copyright (c) 1988, 1989, 1990 John Stanback
14 * Copyright (c) 1992 Free Software Foundation
16 * This file is part of GNU SHOGI.
18 * GNU Shogi is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the
20 * Free Software Foundation; either version 3 of the License,
21 * or (at your option) any later version.
23 * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
24 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 * You should have received a copy of the GNU General Public License along
29 * with GNU Shogi; see the file COPYING. If not, see
30 * <http://www.gnu.org/licenses/>.
31 * ----------------------------------------------------------------------
35 /* Hack for anal-retentive ANSI-compliance if desired: */
38 /* FIXME: this file needs to be reorganized in some rational manner. */
43 #include "config.h" /* Portability #defines. */
45 #include "opts.h" /* Various option-setting #defines. */
58 extern display_t display_type
;
60 #define XSHOGI (display_type == DISPLAY_X)
61 #define NOT_CURSES ((display_type == DISPLAY_X) \
62 || (display_type == DISPLAY_RAW))
65 /* Miscellaneous globals. */
67 extern short hard_time_limit
; /* If you exceed time limit, you lose. */
68 extern short barebones
; /* Don't print of stats for x interface. */
69 extern short nolist
; /* Don't list game after exit. */
73 * Options for various compilers/OSs.
77 * type small_short must cover -128 .. 127. In case of trouble,
78 * try commenting out "signed". If this doesn't help, use short.
81 #define small_short signed char
82 #define small_ushort unsigned char
85 typedef small_ushort UBYTE
;
87 typedef unsigned short USHORT
;
89 typedef unsigned int UINT
;
91 typedef unsigned long ULONG
;
94 #if !defined(HAVE_MEMCPY) && !defined(HAVE_BCOPY)
95 # define array_copy(src, dst, len) \
98 char *psrc = (char *)src, *pdst = (char *)dst; \
99 for (i = len; i; pdst[--i] = psrc[i]); \
101 # define array_zero(dst, len) \
104 char *pdst = (char *)dst; \
105 for (i = len; i; pdst[--i] = 0); \
107 #elif !defined(HAVE_MEMCPY) /* BSD and derivatives */
108 # define array_copy(src, dst, len) bcopy(src, dst, len)
109 # define array_zero(dst, len) bzero(dst, len)
110 #else /* System V and derivatives */
111 # define array_copy(src, dst, len) memcpy(dst, src, len)
112 # define array_zero(dst, len) memset(dst, 0, len)
122 * Standard header files.
131 #include <sys/param.h>
132 #include <sys/types.h>
134 # include <windows.h>
136 typedef small_short BYTE
;
137 # include <sys/times.h>
138 # include <sys/ioctl.h>
141 #if TIME_WITH_SYS_TIME
142 # include <sys/time.h>
146 # include <sys/time.h>
155 extern char *binbookfile
;
158 extern char *bookfile
;
162 extern void movealgbr(short m
, char *s
);
170 #define MAX_CAPTURED 19
171 #define NO_PTYPE_PIECES 11
176 #define MAX_CAPTURED 19
177 #define NO_PTYPE_PIECES 15
181 #define NO_SQUARES (NO_COLS*NO_ROWS)
183 #define ROW_NAME(n) ('a' + NO_ROWS - 1 - n)
184 #define COL_NAME(n) ('1' + NO_COLS - 1 - n)
185 #define ROW_NUM(c) ('a' + NO_ROWS - 1 - c)
186 #define COL_NUM(c) ('1' + NO_COLS - 1 - c)
188 #if defined HASHFILE || defined CACHE
189 # define PTBLBDSIZE (NO_SQUARES + NO_PIECES)
194 #define SCORE_LIMIT 12000
196 /* masks into upper 16 bits of attacks array */
197 /* observe order of relative piece values */
198 #define CNT_MASK 0x000000FF
199 #define ctlP 0x00200000
200 #define ctlPp 0x00100000
201 #define ctlL 0x00080000
202 #define ctlN 0x00040000
203 #define ctlLp 0x00020000
204 #define ctlNp 0x00010000
205 #define ctlS 0x00008000
206 #define ctlSp 0x00004000
207 #define ctlG 0x00002000
208 #define ctlB 0x00001000
209 #define ctlBp 0x00000800
210 #define ctlR 0x00000400
211 #define ctlRp 0x00000200
212 #define ctlK 0x00000100
214 /* attack functions */
215 #define Pattack(c, u) (attack[c][u] > ctlP)
216 #define Anyattack(c, u) (attack[c][u] != 0)
218 /* hashtable flags */
219 #define truescore 0x0001
220 #define lowerbound 0x0002
221 #define upperbound 0x0004
222 #define kingcastle 0x0008
223 #define queencastle 0x0010
224 #define evalflag 0x0020
227 #define BlackKing PieceList[black][0]
228 #define WhiteKing PieceList[white][0]
229 #define OwnKing PieceList[c1][0]
230 #define EnemyKing PieceList[c2][0]
233 /* board properties */
235 #define InBlackCamp(sq) ((sq) < 27)
236 #define InWhiteCamp(sq) ((sq) > 53)
238 #define InBlackCamp(sq) ((sq) < 5)
239 #define InWhiteCamp(sq) ((sq) > 19)
241 #define InPromotionZone(side, sq) \
242 (((side) == black) ? InWhiteCamp(sq) : InBlackCamp(sq))
246 #define OPENING_HINT 0x141d /* P7g-7f (20->29) */
262 /* piece code defines */
270 /* start of pieces that can be dropped at any square */
311 #define pmask 0x000f /* 15 */
312 #define promote 0x0010 /* 16 */
313 #define dropmask 0x0020 /* 32 */
314 #define exact 0x0040 /* 64 */
315 #define tesuji 0x0080 /* 128 */
316 #define check 0x0100 /* 256 */
317 #define capture 0x0200 /* 512 */
318 #define draw 0x0400 /* 1024 */
319 #define stupid 0x0800 /* 2048 */
320 #define questionable 0x1000 /* 4096 */
321 #define kingattack 0x2000 /* 8192 */
322 #define book 0x4000 /* 16384 */
324 /* move quality flags */
325 #define goodmove tesuji
326 #define badmove stupid
328 #define difficult questionable
333 #define pxx (" PLNSGBRPLNSBRK ")
334 #define qxx (" plnsgbrplnsbrk ")
335 #define rxx ("ihgfedcba")
336 #define cxx ("987654321")
338 #define pxx (" PSGBRPSBRK ")
339 #define qxx (" psgbrpsbrk ")
340 #define rxx ("edcba")
341 #define cxx ("54321")
344 /***************** Table limits ********************************************/
347 * ttblsz must be a power of 2. Setting ttblsz 0 removes the transposition
353 #elif defined SMALL_MEMORY
354 # if defined SAVE_SSCORE
355 # define vttblsz (1 << 12)
357 # if defined EXTRA_2MB
358 # define vttblsz (1 << 12)
360 # define vttblsz (1 << 10)
364 # define vttblsz (100001)
367 #if defined SMALL_MEMORY
368 # define MINTTABLE (0)
370 # define MINTTABLE (8000) /* min ttable size -1 */
373 #define ttblsz vttblsz
375 #if defined SMALL_MEMORY
376 # if !defined SAVE_SSCORE
377 # define TREE 1500 /* max number of tree entries */
379 # define TREE 2500 /* max number of tree entries */
382 # define TREE 4000 /* max number of tree entries */
385 #define MAXDEPTH 40 /* max depth a search can be carried */
386 #define MINDEPTH 2 /* min search depth =1 (no hint), >1 hint */
387 #define MAXMOVES 300 /* max number of half moves in a game */
388 #define CPSIZE 241 /* size of lang file max */
390 #if defined SMALL_MEMORY
391 # if defined SAVE_SSCORE
392 # define ETABLE (1 << 10) /* static eval cache */
394 # if defined EXTRA_2MB
395 # define ETABLE (1 << 10) /* static eval cache */
397 # define ETABLE (1 << 8) /* static eval cache */
401 # define ETABLE (10001) /* static eval cache */
404 /***************** tuning paramaters *******************/
406 #if defined VERY_SLOW_CPU
407 # define MINRESPONSETIME 300
408 #elif defined SLOW_CPU
409 # define MINRESPONSETIME 200
411 # define MINRESPONSETIME 100 /* 1 s */
416 #define CHKDEPTH 1 /* always look forward CHKDEPTH
417 * half-moves if in check */
419 #if defined SLOW_CPU || defined VERY_SLOW_CPU
420 # define DEPTHBEYOND 7 /* Max to go beyond Sdepth */
422 # define DEPTHBEYOND 11 /* Max to go beyond Sdepth */
425 #define HASHDEPTH 4 /* depth above which to use HashFile */
426 #define HASHMOVELIMIT 40 /* Use HashFile only for this many moves */
427 #define PTVALUE 0 /* material value below which pawn threats at
429 #define ZDEPTH 3 /* depth beyond which to check
430 * ZDELTA for extra time */
431 #define ZDELTA 10 /* score delta per ply to cause
432 * extra time to be given */
435 /* about 1/2 second worth of nodes for your machine */
436 #if defined VERY_SLOW_CPU
437 /* check the time every ZNODES positions */
438 # define ZNODES (flag.tsume ? 20 : 50)
439 #elif defined SLOW_CPU
440 # define ZNODES (flag.tsume ? 40 : 100)
442 # define ZNODES (flag.tsume ? 400 : 1000)
445 #define MAXTCCOUNTX 10 /* max number of time clicks
446 * per search to complete ply */
447 #define MAXTCCOUNTR 4 /* max number of time clicks
448 * per search extensions*/
449 #define SCORESPLIM 8 /* Score space doesn't apply after this stage */
450 #define SDEPTHLIM (Sdepth + 1)
451 #define HISTORYLIM 4096 /* Max value of history killer */
454 # if defined SMALL_MEMORY
455 # define HISTORY_MASK 0x8000 /* mask to MSB of history index */
456 # define HISTORY_SIZE 0x10000 /* size of history table */
458 # define HISTORY_MASK (1 << 15) /* mask to MSB of history index */
459 # define HISTORY_SIZE (1 << 16) /* size of history table */
462 /* smaller history table, but dangerous because of collisions */
463 # define HISTORY_MASK 0x3fff /* mask to significant bits
464 * of history index */
465 # if defined SMALL_MEMORY
466 # define HISTORY_SIZE 0x4000 /* size of history table */
468 # define HISTORY_SIZE (1 << 14) /* size of history table */
472 #define sizeof_history (sizeof(unsigned short) * (size_t)HISTORY_SIZE)
475 /* Map from.to (8bit.8bit) to from.to (0.7bit.8bit) */
476 # define khmove(mv) (mv & 0x7fff)
477 # define hmove(mv) ((mv & 0x7fff) ^ 0x5555)
479 /* Map from.to (8bit.8bit) to from.to (00.7bit.7bit) */
480 /* Swap bits of ToSquare in case of promotions, hoping that
481 no catastrophic collision occurs. */
482 # define khmove(mv) (((mv & 0x7f00) >> 1) | \
483 ((mv & 0x0080) ? ((mv & 0x007f) ^ 0x007f) : (mv & 0x007f)))
484 # define hmove(mv) (khmove(mv) ^ 0x2aaa)
487 /* mask color to 15th bit */
489 # define hindex(c, mv) ((c ? HISTORY_MASK : 0) | hmove(mv))
491 /* for white, swap bits, hoping that no catastrophic collision occurs. */
492 # define hindex(c, mv) (c ? ((~hmove(mv)) & HISTORY_MASK) : hmove(mv))
495 #define EWNDW 10 /* Eval window to force position scoring at depth
496 * greater than (Sdepth + 2) */
497 #define WAWNDW 90 /* alpha window when computer black */
498 #define WBWNDW 90 /* beta window when computer black */
499 #define BAWNDW 90 /* alpha window when computer white */
500 #define BBWNDW 90 /* beta window when computer white */
501 #define BXWNDW 90 /* window to force position scoring at lower */
502 #define WXWNDW 90 /* window to force position scoring at lower */
504 #define DITHER 5 /* max amount random can alter a pos value */
505 #define LBONUS 1 /* points per stage value of L increases */
506 #define BBONUS 2 /* points per stage value of B increases */
507 #define RBONUS 2 /* points per stage value of R increases */
509 #define QUESTIONABLE (valueK) /* Penalty for questionable moves. */
515 #define STUPID (valueR << 1) /* Penalty for stupid moves. */
517 #define KINGPOSLIMIT (-1) /* King positional scoring limit */
518 #define KINGSAFETY 32
519 #define MAXrehash (7)
521 /******* parameters for Opening Book ****************/
523 #define BOOKSIZE 8000 /* Number of unique position/move
524 * combinations allowed */
525 #define BOOKMAXPLY 40 /* Max plys to keep in book database */
526 #define BOOKFAIL (BOOKMAXPLY / 2) /* if no book move found for BOOKFAIL
527 * turns stop using book */
528 #define BOOKPOCKET 64
529 #define BOOKRAND 1000 /* used to select an opening move
531 #define BOOKENDPCT 950 /* 5 % chance a BOOKEND will stop the book */
532 #define DONTUSE -32760 /* flag move as don't use */
533 #define ILLEGAL_TRAPPED -32761 /* flag move as illegal:
534 * no move from this square */
535 #define ILLEGAL_DOUBLED -32762 /* flag move as illegal:
536 * two pawns on one column */
537 #define ILLEGAL_MATE -32763 /* flag move as illegal:
538 * pawn drop with mate */
540 /*****************************************************/
544 unsigned long key
, bd
;
549 unsigned long hashbd
;
551 unsigned char depth
; /* unsigned char saves some space */
558 unsigned char bd
[PTBLBDSIZE
];
559 #endif /* HASHTEST */
562 #if defined HASHFILE || defined CACHE
565 unsigned long ehashbd
;
567 #if !defined SAVE_SSCORE
568 short sscore
[NO_SQUARES
];
573 unsigned char bd
[PTBLBDSIZE
];
574 #endif /* CACHETEST */
578 extern short use_etable
;
579 typedef struct etable etable_field
[ETABLE
];
580 extern etable_field
*etab
[2];
584 * CHECKME! Is this valid?
586 * persistent transposition table. By default, the size is (1 << vfilesz).
587 * If you change the size, be sure to run gnushogi -c [vfilesz]
588 * before anything else.
593 #if defined SMALL_MEMORY
601 unsigned char bd
[PTBLBDSIZE
];
602 unsigned char f
, t
, flags
, depth
, sh
, sl
;
605 #endif /* HASHFILE */
611 short score
, reply
, width
;
613 unsigned short flags
;
619 unsigned short gmove
; /* this move */
620 short score
; /* score after this move */
621 short depth
; /* search depth this move */
622 long time
; /* search time this move */
623 short fpiece
; /* moved or dropped piece */
624 short piece
; /* piece captured */
625 short color
; /* color */
626 short flags
; /* move flags capture, promote, castle */
627 short Game50
; /* flag for repetition */
628 long nodes
; /* nodes searched for this move */
629 unsigned long hashkey
, hashbd
; /* board key before this move */
633 struct TimeControlRec
642 short mate
; /* the game is over */
643 short post
; /* show principle variation */
644 short quit
; /* quit/exit */
645 short regularstart
; /* did the game start from standard
647 short reverse
; /* reverse board display */
648 short bothsides
; /* computer plays both sides */
649 short hash
; /* enable/disable transposition table */
650 short force
; /* enter moves */
651 short easy
; /* disable thinking on opponents time */
652 short beep
; /* enable/disable beep */
653 short timeout
; /* time to make a move */
654 short musttimeout
; /* time to make a move */
655 short back
; /* time to make a move */
656 short rcptr
; /* enable/disable recapture heuristics */
657 short rv
; /* reverse video */
658 short stars
; /* add stars to uxdsp screen */
659 short coords
; /* add coords to visual screen */
661 short material
; /* draw on lack of material */
662 short illegal
; /* illegal position */
663 short onemove
; /* timing is onemove */
664 short gamein
; /* timing is gamein */
665 short tsume
; /* first consider checks */
668 extern FILE *debugfile
;
671 #define EVALFILE "/tmp/EVAL"
674 extern FILE *debug_eval_file
;
675 extern short debug_moves
;
679 extern short use_history
;
680 extern unsigned short *history
;
685 extern char ColorStr
[2][10];
687 extern char mvstr
[4][6];
688 extern unsigned short MV
[MAXDEPTH
];
690 extern int mycnt1
, mycnt2
;
692 extern struct leaf rootnode
;
693 extern struct leaf
*Tree
;
694 extern struct leaf
*root
;
695 extern char savefile
[], listfile
[];
696 extern short TrPnt
[];
697 extern small_short board
[], color
[];
698 extern const small_short sweep
[NO_PIECES
];
699 extern small_short PieceList
[2][NO_SQUARES
], PawnCnt
[2][NO_COLS
];
700 extern small_short Captured
[2][NO_PIECES
];
703 # define ClearCaptured() \
705 short piece, color; \
706 for (color = black; color <= white; color++) \
707 for (piece = 0; piece < NO_PIECES; piece++) \
708 Captured[color][piece] = 0; \
711 # define ClearCaptured() \
712 memset((char *)Captured, 0, (unsigned long)sizeof(Captured))
713 #endif /* HAVE_MEMSET */
715 extern small_short Mvboard
[];
717 #if !defined SAVE_SVALUE
718 extern short svalue
[NO_SQUARES
];
721 extern short pscore
[2]; /* eval.c */
722 extern int EADD
; /* eval.c */
723 extern int EGET
; /* eval.c */
724 extern struct flags flag
;
725 extern short opponent
, computer
, INCscore
;
726 extern short WAwindow
, BAwindow
, WBwindow
, BBwindow
;
727 extern short dither
, player
;
728 extern short xwndw
, contempt
;
729 extern long ResponseTime
, ExtraTime
, TCleft
,
730 MaxResponseTime
, et
, et0
, time0
, ft
;
733 #ifdef INTERRUPT_TEST
734 extern long itime0
, it
;
737 extern long reminus
, replus
;
738 extern long GenCnt
, NodeCnt
, ETnodes
, EvalNodes
, HashAdd
, HashCnt
,
739 HashCol
, THashCol
, FHashCnt
, FHashAdd
;
740 extern short HashDepth
, HashMoveLimit
;
741 extern struct GameRec
*GameList
;
742 extern short GameCnt
, Game50
;
743 extern short Sdepth
, MaxSearchDepth
;
745 extern struct TimeControlRec TimeControl
;
747 extern short TCflag
, TCmoves
, TCminutes
, TCseconds
, OperatorTime
;
748 extern int timecomp
[MINGAMEIN
], timeopp
[MINGAMEIN
];
749 extern int compptr
, oppptr
;
750 extern short XCmore
, XCmoves
[], XCminutes
[], XCseconds
[], XC
;
751 extern const short otherside
[];
752 extern const small_short Stboard
[];
753 extern const small_short Stcolor
[];
754 extern unsigned short hint
;
756 extern short stage
, stage2
;
758 #define in_opening_stage (!flag.tsume && (stage < 33))
759 #define in_middlegame_stage (!flag.tsume && (stage >= 33) && (stage <= 66))
760 #define in_endgame_stage (flag.tsume || (stage > 66))
762 extern short ahead
, hash
;
763 extern short balance
[2];
764 extern small_short ChkFlag
[], CptrFlag
[], TesujiFlag
[];
765 extern short Pscore
[], Tscore
[];
766 extern /*unsigned*/ short rehash
; /* -1 is used as a flag --tpm */
767 extern unsigned int ttbllimit
;
768 extern unsigned int TTadd
;
769 extern unsigned int ttblsize
;
770 extern short mtl
[], hung
[];
771 extern small_short Pindex
[];
772 extern small_short PieceCnt
[];
773 extern short FROMsquare
, TOsquare
;
774 extern small_short HasPiece
[2][NO_PIECES
];
775 extern const short kingP
[];
776 extern unsigned short killr0
[], killr1
[];
777 extern unsigned short killr2
[], killr3
[];
778 extern unsigned short PrVar
[MAXDEPTH
];
779 extern unsigned short PV
, SwagHt
, Swag0
, Swag1
, Swag2
, Swag3
, Swag4
, sidebit
;
780 extern short mtl
[2], pmtl
[2], hung
[2];
781 extern const small_short relative_value
[];
782 extern const long control
[];
783 extern small_short
diagonal(short delta
);
784 extern const small_short promoted
[NO_PIECES
], unpromoted
[NO_PIECES
];
785 extern const small_short is_promoted
[NO_PIECES
];
787 typedef unsigned char next_array
[NO_SQUARES
][NO_SQUARES
];
788 typedef small_short distdata_array
[NO_SQUARES
][NO_SQUARES
];
790 extern const small_short inunmap
[NO_SQUARES
];
792 extern const small_short nunmap
[(NO_COLS
+ 2)*(NO_ROWS
+ 4)];
794 extern const small_short nunmap
[(NO_COLS
+ 2)*(NO_ROWS
+ 2)];
797 #if defined SAVE_NEXTPOS
798 extern const small_short direc
[NO_PTYPE_PIECES
][8];
799 extern short first_direction(short ptyp
, short *d
, short sq
);
800 extern short next_direction(short ptyp
, short *d
, short sq
);
801 extern short next_position(short ptyp
, short *d
, short sq
, short u
);
803 extern short use_nextpos
;
804 extern next_array
*nextpos
[NO_PTYPE_PIECES
];
805 extern next_array
*nextdir
[NO_PTYPE_PIECES
];
808 extern value_array
*value
;
809 extern fscore_array
*fscore
;
811 #ifndef SAVE_DISTDATA
812 extern short use_distdata
;
813 extern distdata_array
*distdata
;
816 #ifndef SAVE_PTYPE_DISTDATA
817 extern short use_ptype_distdata
;
818 extern distdata_array
*ptype_distdata
[NO_PTYPE_PIECES
];
821 extern const small_short ptype
[2][NO_PIECES
];
823 extern long filesz
, hashmask
, hashbase
;
824 extern FILE *hashfile
;
825 extern unsigned int starttime
;
828 typedef small_short Mpiece_array
[2][NO_SQUARES
];
829 extern Mpiece_array
*Mpiece
[NO_PIECES
];
830 extern short ADVNCM
[NO_PIECES
];
832 #define computed_distance(a, b) \
833 ((abs(column(a) - column(b)) > abs(row(a) - row(b))) \
834 ? abs(column(a) - column(b)) : abs(row(a) - row(b)))
836 extern short distance(short a
, short b
);
837 extern short ptype_distance(short ptyp
, short f
, short t
);
838 extern short piece_distance(short side
, short piece
, short f
, short t
);
845 #define STATIC_ROOK 'S'
846 #define RANGING_ROOK 'R'
848 extern char GameType
[2];
849 void ShowGameType(void);
851 extern unsigned short bookmaxply
;
852 extern unsigned int bookcount
;
853 extern unsigned int booksize
;
854 extern unsigned long hashkey
, hashbd
;
856 typedef struct hashval hashcode_array
[2][NO_PIECES
][NO_SQUARES
];
857 typedef struct hashval drop_hashcode_array
[2][NO_PIECES
][NO_SQUARES
];
859 extern hashcode_array
*hashcode
;
860 extern drop_hashcode_array
*drop_hashcode
;
862 #ifdef QUIETBACKGROUND
863 extern short background
;
864 #endif /* QUIETBACKGROUND */
867 extern short use_ttable
;
868 extern struct hashentry
*ttable
[2];
872 * hashbd contains a 32 bit "signature" of the board position. hashkey
873 * contains a 16 bit code used to address the hash table. When a move is
874 * made, XOR'ing the hashcode of moved piece on the from and to squares with
875 * the hashbd and hashkey values keeps things current.
878 #define UpdateHashbd(side, piece, f, t) \
882 hashbd ^= (*hashcode)[side][piece][f].bd; \
883 hashkey ^= (*hashcode)[side][piece][f].key; \
888 hashbd ^= (*hashcode)[side][piece][t].bd; \
889 hashkey ^= (*hashcode)[side][piece][t].key; \
893 #define UpdateDropHashbd(side, piece, count) \
895 hashbd ^= (*drop_hashcode)[side][piece][count].bd; \
896 hashkey ^= (*drop_hashcode)[side][piece][count].key; \
900 extern short rpthash
[2][256];
903 extern char* DRAW_REPETITION
;
904 extern char *DRAW_MAXMOVES
;
905 extern char *DRAW_JUSTDRAW
;
907 #define row(a) ((a) / NO_COLS)
908 #define column(a) ((a) % NO_COLS)
909 #define locn(a, b) (((a) * NO_COLS) + b)
911 /* init external functions */
912 extern void InitConst(char *lang
); /* init.c */
913 extern int Initialize_data(void); /* init.c */
914 extern void Free_data(void); /* init.c */
915 extern int Lock_data(void); /* init.c */
916 extern void Unlock_data(void); /* init.c */
917 extern void Initialize_dist(void); /* init.c */
918 extern void Initialize_eval(void); /* eval.c */
919 extern void NewGame(void);
920 extern int parse(FILE * fd
, unsigned short *mv
,
921 short side
, char *opening
);
922 extern void GetOpenings(void);
923 extern int OpeningBook(unsigned short *hint
, short side
);
927 REMOVE_PIECE
= 1, ADD_PIECE
928 } UpdatePieceList_mode
;
931 UpdatePieceList(short side
, short sq
, UpdatePieceList_mode iop
);
935 FOREGROUND_MODE
= 1, BACKGROUND_MODE
939 SelectMove(short side
, SelectMove_mode iop
);
947 unsigned short *bstline
,
951 void PutInEETable(short side
, int score
);
952 int CheckEETable(short side
);
953 int ProbeEETable(short side
, short *score
);
958 ProbeTTable(short side
,
966 PutInTTable(short side
,
974 extern void ZeroTTable(void);
975 extern void ZeroRPT(void);
976 extern void Initialize_ttable(void);
977 extern unsigned int urand(void);
980 extern void gsrand(unsigned int);
983 ProbeFTable(short side
,
991 PutInFTable(short side
,
1000 # endif /* HASHFILE */
1003 #if !defined SAVE_NEXTPOS
1004 extern void Initialize_moves(void);
1007 extern short generate_move_flags
;
1009 extern void MoveList(short side
, short ply
,
1010 short in_check
, short blockable
);
1011 extern void CaptureList(short side
, short ply
,
1012 short in_check
, short blockable
);
1014 /* from attacks.c */
1016 SqAttacked(short square
, short side
, short *blockable
);
1019 MakeMove(short side
,
1028 UnmakeMove(short side
,
1036 InitializeStats(void);
1039 evaluate(short side
,
1047 extern short ScorePosition(short side
);
1048 extern void ExaminePosition(short side
);
1049 extern short ScorePatternDistance(short side
);
1050 extern void DetermineStage(short side
);
1051 extern void UpdateWeights(short side
);
1052 extern int InitMain(void);
1053 extern void ExitMain(void);
1054 extern void Initialize(void);
1055 extern void InputCommand(char *command
);
1056 extern void ExitShogi(void);
1057 extern void ClearScreen(void);
1058 extern void SetTimeControl(void);
1059 extern void SelectLevel(char *sx
);
1062 UpdateDisplay(short f
,
1069 COMPUTE_AND_INIT_MODE
= 1, COMPUTE_MODE
1070 #ifdef INTERRUPT_TEST
1071 , INIT_INTERRUPT_MODE
, COMPUTE_INTERRUPT_MODE
1075 extern void SetResponseTime(short side
);
1076 extern void CheckForTimeout(int score
, int globalscore
,
1077 int Jscore
, int zwndw
);
1078 extern void ShowSidetoMove(void);
1079 extern void ShowResponseTime(void);
1080 extern void ShowPatternCount(short side
, short n
);
1081 extern void SearchStartStuff(short side
);
1082 extern void ShowDepth(char ch
);
1083 extern void TerminateSearch(int);
1084 extern void ShowResults(short score
, unsigned short *bstline
, char ch
);
1085 extern void SetupBoard(void);
1086 extern void algbr(short f
, short t
, short flag
);
1087 extern void OutputMove(void);
1088 extern void ShowCurrentMove(short pnt
, short f
, short t
);
1089 extern void ListGame(void);
1090 extern void ShowMessage(char *s
);
1091 extern void ClearScreen(void);
1092 extern void DoDebug(void);
1093 extern void DoTable(short table
[NO_SQUARES
]);
1094 extern void ShowPostnValues(void);
1095 extern void ChangeXwindow(void);
1096 extern void SetContempt(void);
1097 extern void ChangeHashDepth(void);
1098 extern void ChangeBetaWindow(void);
1099 extern void GiveHint(void);
1100 extern void ShowPrompt(void);
1101 extern void EditBoard(void);
1102 extern void help(void);
1103 extern void ChangeSearchDepth(void);
1104 extern void skip(void);
1105 extern void skipb(void);
1106 extern void EnPassant(short xside
, short f
, short t
, short iop
);
1107 extern void ShowNodeCnt(long NodeCnt
);
1108 extern void ShowLine(unsigned short *bstline
);
1109 extern int pick(short p1
, short p2
);
1110 extern short repetition(void);
1111 extern void TimeCalc(void);
1112 extern void ElapsedTime(ElapsedTime_mode iop
);
1115 DropPossible(short piece
, short side
, short sq
); /* genmoves.c */
1118 IsCheckmate(short side
, short in_check
,
1119 short blockable
); /* genmoves.c */
1124 VERIFY_AND_MAKE_MODE
, VERIFY_AND_TRY_MODE
, UNMAKE_MODE
1127 extern int VerifyMove(char *s
, VerifyMove_mode iop
, unsigned short *mv
);
1128 extern unsigned short TTage
;
1130 #include "dspwrappers.h" /* Display functions. */
1132 #endif /* _GNUSHOGI_H_ */