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. */
60 extern display_t display_type
;
62 #define XSHOGI (display_type == DISPLAY_X)
65 /* Miscellaneous globals. */
67 extern short hard_time_limit
; /* If you exceed time limit, you lose. */
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
);
169 #define MAX_CAPTURED 19
170 #define NO_PTYPE_PIECES 11
173 #define NO_CAMP_ROWS 1
176 #define MAX_CAPTURED 19
177 #define NO_PTYPE_PIECES 15
180 #define NO_CAMP_ROWS 3
182 #define NO_SQUARES (NO_COLS*NO_ROWS)
184 #define ROW_NAME(n) ('a' + NO_ROWS - 1 - n)
185 #define COL_NAME(n) ('1' + NO_COLS - 1 - n)
187 #if defined HASHFILE || defined CACHE
188 # define PTBLBDSIZE (NO_SQUARES + NO_PIECES)
193 #define SCORE_LIMIT 12000
195 /* masks into upper 16 bits of attacks array */
196 /* observe order of relative piece values */
197 #define CNT_MASK 0x000000FF
198 #define ctlP 0x00200000
199 #define ctlPp 0x00100000
200 #define ctlL 0x00080000
201 #define ctlN 0x00040000
202 #define ctlLp 0x00020000
203 #define ctlNp 0x00010000
204 #define ctlS 0x00008000
205 #define ctlSp 0x00004000
206 #define ctlG 0x00002000
207 #define ctlB 0x00001000
208 #define ctlBp 0x00000800
209 #define ctlR 0x00000400
210 #define ctlRp 0x00000200
211 #define ctlK 0x00000100
213 /* attack functions */
214 #define Pattack(c, u) (attack[c][u] > ctlP)
215 #define Anyattack(c, u) (attack[c][u] != 0)
217 /* hashtable flags */
218 #define truescore 0x0001
219 #define lowerbound 0x0002
220 #define upperbound 0x0004
221 #define kingcastle 0x0008
222 #define queencastle 0x0010
223 #define evalflag 0x0020
226 #define BlackKing PieceList[black][0]
227 #define WhiteKing PieceList[white][0]
228 #define OwnKing PieceList[c1][0]
229 #define EnemyKing PieceList[c2][0]
232 /* board properties */
233 #define InBlackCamp(sq) ((sq) < (NO_COLS * NO_CAMP_ROWS))
234 #define InWhiteCamp(sq) ((sq) >= (NO_COLS * (NO_ROWS - NO_CAMP_ROWS)))
235 #define InPromotionZone(side, sq) \
236 (((side) == black) ? InWhiteCamp(sq) : InBlackCamp(sq))
240 #define OPENING_HINT 0x141d /* P7g-7f (20->29) */
256 /* piece code defines */
264 /* start of pieces that can be dropped at any square */
305 #define pmask 0x000f /* 15 */
306 #define promote 0x0010 /* 16 */
307 #define dropmask 0x0020 /* 32 */
308 #define exact 0x0040 /* 64 */
309 #define tesuji 0x0080 /* 128 */
310 #define check 0x0100 /* 256 */
311 #define capture 0x0200 /* 512 */
312 #define draw 0x0400 /* 1024 */
313 #define stupid 0x0800 /* 2048 */
314 #define questionable 0x1000 /* 4096 */
315 #define kingattack 0x2000 /* 8192 */
316 #define book 0x4000 /* 16384 */
318 /* move quality flags */
319 #define goodmove tesuji
320 #define badmove stupid
322 #define difficult questionable
327 #define pxx (" PLNSGBRPLNSBRK ")
328 #define qxx (" plnsgbrplnsbrk ")
330 #define pxx (" PSGBRPSBRK ")
331 #define qxx (" psgbrpsbrk ")
334 /***************** Table limits ********************************************/
337 * ttblsz must be a power of 2. Setting ttblsz 0 removes the transposition
343 #elif defined SMALL_MEMORY
344 # if defined SAVE_SSCORE
345 # define vttblsz (1 << 12)
347 # if defined EXTRA_2MB
348 # define vttblsz (1 << 12)
350 # define vttblsz (1 << 10)
354 # define vttblsz (100001)
357 #if defined SMALL_MEMORY
358 # define MINTTABLE (0)
360 # define MINTTABLE (8000) /* min ttable size -1 */
363 #define ttblsz vttblsz
365 #if defined SMALL_MEMORY
366 # if !defined SAVE_SSCORE
367 # define TREE 1500 /* max number of tree entries */
369 # define TREE 2500 /* max number of tree entries */
372 # define TREE 4000 /* max number of tree entries */
375 #define MAXDEPTH 40 /* max depth a search can be carried */
376 #define MINDEPTH 2 /* min search depth =1 (no hint), >1 hint */
377 #define MAXMOVES 300 /* max number of half moves in a game */
378 #define CPSIZE 241 /* size of lang file max */
380 #if defined SMALL_MEMORY
381 # if defined SAVE_SSCORE
382 # define ETABLE (1 << 10) /* static eval cache */
384 # if defined EXTRA_2MB
385 # define ETABLE (1 << 10) /* static eval cache */
387 # define ETABLE (1 << 8) /* static eval cache */
391 # define ETABLE (10001) /* static eval cache */
394 /***************** tuning paramaters *******************/
396 #if defined VERY_SLOW_CPU
397 # define MINRESPONSETIME 300
398 #elif defined SLOW_CPU
399 # define MINRESPONSETIME 200
401 # define MINRESPONSETIME 100 /* 1 s */
406 #define CHKDEPTH 1 /* always look forward CHKDEPTH
407 * half-moves if in check */
409 #if defined SLOW_CPU || defined VERY_SLOW_CPU
410 # define DEPTHBEYOND 7 /* Max to go beyond Sdepth */
412 # define DEPTHBEYOND 11 /* Max to go beyond Sdepth */
415 #define HASHDEPTH 4 /* depth above which to use HashFile */
416 #define HASHMOVELIMIT 40 /* Use HashFile only for this many moves */
417 #define PTVALUE 0 /* material value below which pawn threats at
419 #define ZDEPTH 3 /* depth beyond which to check
420 * ZDELTA for extra time */
421 #define ZDELTA 10 /* score delta per ply to cause
422 * extra time to be given */
425 /* about 1/2 second worth of nodes for your machine */
426 #if defined VERY_SLOW_CPU
427 /* check the time every ZNODES positions */
428 # define ZNODES (flag.tsume ? 20 : 50)
429 #elif defined SLOW_CPU
430 # define ZNODES (flag.tsume ? 40 : 100)
432 # define ZNODES (flag.tsume ? 400 : 1000)
435 #define MAXTCCOUNTX 10 /* max number of time clicks
436 * per search to complete ply */
437 #define MAXTCCOUNTR 4 /* max number of time clicks
438 * per search extensions*/
439 #define SCORESPLIM 8 /* Score space doesn't apply after this stage */
440 #define SDEPTHLIM (Sdepth + 1)
441 #define HISTORYLIM 4096 /* Max value of history killer */
444 # if defined SMALL_MEMORY
445 # define HISTORY_MASK 0x8000 /* mask to MSB of history index */
446 # define HISTORY_SIZE 0x10000 /* size of history table */
448 # define HISTORY_MASK (1 << 15) /* mask to MSB of history index */
449 # define HISTORY_SIZE (1 << 16) /* size of history table */
452 /* smaller history table, but dangerous because of collisions */
453 # define HISTORY_MASK 0x3fff /* mask to significant bits
454 * of history index */
455 # if defined SMALL_MEMORY
456 # define HISTORY_SIZE 0x4000 /* size of history table */
458 # define HISTORY_SIZE (1 << 14) /* size of history table */
462 #define sizeof_history (sizeof(unsigned short) * (size_t)HISTORY_SIZE)
465 /* Map from.to (8bit.8bit) to from.to (0.7bit.8bit) */
466 # define khmove(mv) (mv & 0x7fff)
467 # define hmove(mv) ((mv & 0x7fff) ^ 0x5555)
469 /* Map from.to (8bit.8bit) to from.to (00.7bit.7bit) */
470 /* Swap bits of ToSquare in case of promotions, hoping that
471 no catastrophic collision occurs. */
472 # define khmove(mv) (((mv & 0x7f00) >> 1) | \
473 ((mv & 0x0080) ? ((mv & 0x007f) ^ 0x007f) : (mv & 0x007f)))
474 # define hmove(mv) (khmove(mv) ^ 0x2aaa)
477 /* mask color to 15th bit */
479 # define hindex(c, mv) ((c ? HISTORY_MASK : 0) | hmove(mv))
481 /* for white, swap bits, hoping that no catastrophic collision occurs. */
482 # define hindex(c, mv) (c ? ((~hmove(mv)) & HISTORY_MASK) : hmove(mv))
485 #define EWNDW 10 /* Eval window to force position scoring at depth
486 * greater than (Sdepth + 2) */
487 #define WAWNDW 90 /* alpha window when computer black */
488 #define WBWNDW 90 /* beta window when computer black */
489 #define BAWNDW 90 /* alpha window when computer white */
490 #define BBWNDW 90 /* beta window when computer white */
491 #define BXWNDW 90 /* window to force position scoring at lower */
492 #define WXWNDW 90 /* window to force position scoring at lower */
494 #define DITHER 5 /* max amount random can alter a pos value */
495 #define LBONUS 1 /* points per stage value of L increases */
496 #define BBONUS 2 /* points per stage value of B increases */
497 #define RBONUS 2 /* points per stage value of R increases */
499 #define QUESTIONABLE (valueK) /* Penalty for questionable moves. */
505 #define STUPID (valueR << 1) /* Penalty for stupid moves. */
507 #define KINGPOSLIMIT (-1) /* King positional scoring limit */
508 #define KINGSAFETY 32
509 #define MAXrehash (7)
511 /******* parameters for Opening Book ****************/
513 #define BOOKSIZE 8000 /* Number of unique position/move
514 * combinations allowed */
515 #define BOOKMAXPLY 40 /* Max plys to keep in book database */
516 #define BOOKFAIL (BOOKMAXPLY / 2) /* if no book move found for BOOKFAIL
517 * turns stop using book */
518 #define BOOKPOCKET 64
519 #define BOOKRAND 1000 /* used to select an opening move
521 #define BOOKENDPCT 950 /* 5 % chance a BOOKEND will stop the book */
522 #define DONTUSE -32760 /* flag move as don't use */
523 #define ILLEGAL_TRAPPED -32761 /* flag move as illegal:
524 * no move from this square */
525 #define ILLEGAL_DOUBLED -32762 /* flag move as illegal:
526 * two pawns on one column */
527 #define ILLEGAL_MATE -32763 /* flag move as illegal:
528 * pawn drop with mate */
530 /*****************************************************/
534 unsigned long key
, bd
;
539 unsigned long hashbd
;
541 unsigned char depth
; /* unsigned char saves some space */
548 unsigned char bd
[PTBLBDSIZE
];
549 #endif /* HASHTEST */
552 #if defined HASHFILE || defined CACHE
555 unsigned long ehashbd
;
557 #if !defined SAVE_SSCORE
558 short sscore
[NO_SQUARES
];
563 unsigned char bd
[PTBLBDSIZE
];
564 #endif /* CACHETEST */
568 extern short use_etable
;
569 typedef struct etable etable_field
[ETABLE
];
570 extern etable_field
*etab
[2];
574 * CHECKME! Is this valid?
576 * persistent transposition table. By default, the size is (1 << vfilesz).
577 * If you change the size, be sure to run gnushogi -c [vfilesz]
578 * before anything else.
583 #if defined SMALL_MEMORY
591 unsigned char bd
[PTBLBDSIZE
];
592 unsigned char f
, t
, flags
, depth
, sh
, sl
;
595 #endif /* HASHFILE */
601 short score
, reply
, width
;
603 unsigned short flags
;
609 unsigned short gmove
; /* this move */
610 short score
; /* score after this move */
611 short depth
; /* search depth this move */
612 long time
; /* search time this move */
613 short fpiece
; /* moved or dropped piece */
614 short piece
; /* piece captured */
615 short color
; /* color */
616 short flags
; /* move flags capture, promote, castle */
617 short Game50
; /* flag for repetition */
618 long nodes
; /* nodes searched for this move */
619 unsigned long hashkey
, hashbd
; /* board key before this move */
623 struct TimeControlRec
632 short mate
; /* the game is over */
633 short post
; /* show principle variation */
634 short quit
; /* quit/exit */
635 short regularstart
; /* did the game start from standard
637 short reverse
; /* reverse board display */
638 short bothsides
; /* computer plays both sides */
639 short hash
; /* enable/disable transposition table */
640 short force
; /* enter moves */
641 short easy
; /* disable thinking on opponents time */
642 short beep
; /* enable/disable beep */
643 short timeout
; /* time to make a move */
644 short musttimeout
; /* time to make a move */
645 short back
; /* time to make a move */
646 short rcptr
; /* enable/disable recapture heuristics */
647 short rv
; /* reverse video */
648 short stars
; /* add stars to uxdsp screen */
649 short coords
; /* add coords to visual screen */
651 short material
; /* draw on lack of material */
652 short illegal
; /* illegal position */
653 short onemove
; /* timing is onemove */
654 short gamein
; /* timing is gamein */
655 short tsume
; /* first consider checks */
658 extern FILE *debugfile
;
661 #define EVALFILE "/tmp/EVAL"
664 extern FILE *debug_eval_file
;
665 extern short debug_moves
;
669 extern short use_history
;
670 extern unsigned short *history
;
675 extern char ColorStr
[2][10];
677 extern char mvstr
[4][6];
678 extern int mycnt1
, mycnt2
;
680 extern struct leaf rootnode
;
681 extern struct leaf
*Tree
;
682 extern struct leaf
*root
;
683 extern char savefile
[], listfile
[];
684 extern short TrPnt
[];
685 extern small_short board
[], color
[];
686 extern const small_short sweep
[NO_PIECES
];
687 extern small_short PieceList
[2][NO_SQUARES
], PawnCnt
[2][NO_COLS
];
688 extern small_short Captured
[2][NO_PIECES
];
691 # define ClearCaptured() \
693 short piece, color; \
694 for (color = black; color <= white; color++) \
695 for (piece = 0; piece < NO_PIECES; piece++) \
696 Captured[color][piece] = 0; \
699 # define ClearCaptured() \
700 memset((char *)Captured, 0, (unsigned long)sizeof(Captured))
701 #endif /* HAVE_MEMSET */
703 extern small_short Mvboard
[];
705 #if !defined SAVE_SVALUE
706 extern short svalue
[NO_SQUARES
];
709 extern short pscore
[2]; /* eval.c */
710 extern int EADD
; /* eval.c */
711 extern int EGET
; /* eval.c */
712 extern struct flags flag
;
713 extern short opponent
, computer
, INCscore
;
714 extern short WAwindow
, BAwindow
, WBwindow
, BBwindow
;
715 extern short dither
, player
;
716 extern short xwndw
, contempt
;
717 extern long ResponseTime
, ExtraTime
, TCleft
,
718 MaxResponseTime
, et
, et0
, time0
, ft
;
721 #ifdef INTERRUPT_TEST
722 extern long itime0
, it
;
725 extern long reminus
, replus
;
726 extern long GenCnt
, NodeCnt
, ETnodes
, EvalNodes
, HashAdd
, HashCnt
,
727 HashCol
, THashCol
, FHashCnt
, FHashAdd
;
728 extern short HashDepth
, HashMoveLimit
;
729 extern struct GameRec
*GameList
;
730 extern short GameCnt
, Game50
;
731 extern short Sdepth
, MaxSearchDepth
;
733 extern struct TimeControlRec TimeControl
;
735 extern short TCflag
, TCmoves
, TCminutes
, TCseconds
, OperatorTime
;
736 extern int timecomp
[MINGAMEIN
], timeopp
[MINGAMEIN
];
737 extern int compptr
, oppptr
;
738 extern short XCmore
, XCmoves
[], XCminutes
[], XCseconds
[], XC
;
739 extern const short otherside
[];
740 extern const small_short Stboard
[];
741 extern const small_short Stcolor
[];
742 extern unsigned short hint
;
744 extern short stage
, stage2
;
746 #define in_opening_stage (!flag.tsume && (stage < 33))
747 #define in_middlegame_stage (!flag.tsume && (stage >= 33) && (stage <= 66))
748 #define in_endgame_stage (flag.tsume || (stage > 66))
750 extern short ahead
, hash
;
751 extern short balance
[2];
752 extern small_short ChkFlag
[], CptrFlag
[], TesujiFlag
[];
753 extern short Pscore
[], Tscore
[];
754 extern /*unsigned*/ short rehash
; /* -1 is used as a flag --tpm */
755 extern unsigned int ttbllimit
;
756 extern unsigned int TTadd
;
757 extern unsigned int ttblsize
;
758 extern short mtl
[], hung
[];
759 extern small_short Pindex
[];
760 extern small_short PieceCnt
[];
761 extern short FROMsquare
, TOsquare
;
762 extern small_short HasPiece
[2][NO_PIECES
];
763 extern const short kingP
[];
764 extern unsigned short killr0
[], killr1
[];
765 extern unsigned short killr2
[], killr3
[];
766 extern unsigned short PrVar
[MAXDEPTH
];
767 extern unsigned short PV
, SwagHt
, Swag0
, Swag1
, Swag2
, Swag3
, Swag4
, sidebit
;
768 extern short mtl
[2], pmtl
[2], hung
[2];
769 extern const small_short relative_value
[];
770 extern const long control
[];
771 extern small_short
diagonal(short delta
);
772 extern const small_short promoted
[NO_PIECES
], unpromoted
[NO_PIECES
];
773 extern const small_short is_promoted
[NO_PIECES
];
775 typedef unsigned char next_array
[NO_SQUARES
][NO_SQUARES
];
776 typedef small_short distdata_array
[NO_SQUARES
][NO_SQUARES
];
778 extern const small_short inunmap
[NO_SQUARES
];
780 extern const small_short nunmap
[(NO_COLS
+ 2)*(NO_ROWS
+ 4)];
782 extern const small_short nunmap
[(NO_COLS
+ 2)*(NO_ROWS
+ 2)];
785 #if defined SAVE_NEXTPOS
786 extern const small_short direc
[NO_PTYPE_PIECES
][8];
787 extern short first_direction(short ptyp
, short *d
, short sq
);
788 extern short next_direction(short ptyp
, short *d
, short sq
);
789 extern short next_position(short ptyp
, short *d
, short sq
, short u
);
791 extern short use_nextpos
;
792 extern next_array
*nextpos
[NO_PTYPE_PIECES
];
793 extern next_array
*nextdir
[NO_PTYPE_PIECES
];
796 extern value_array
*value
;
797 extern fscore_array
*fscore
;
799 #ifndef SAVE_DISTDATA
800 extern short use_distdata
;
801 extern distdata_array
*distdata
;
804 #ifndef SAVE_PTYPE_DISTDATA
805 extern short use_ptype_distdata
;
806 extern distdata_array
*ptype_distdata
[NO_PTYPE_PIECES
];
809 extern const small_short ptype
[2][NO_PIECES
];
811 extern long filesz
, hashmask
, hashbase
;
812 extern FILE *hashfile
;
813 extern unsigned int starttime
;
816 typedef small_short Mpiece_array
[2][NO_SQUARES
];
817 extern Mpiece_array
*Mpiece
[NO_PIECES
];
818 extern short ADVNCM
[NO_PIECES
];
820 #define computed_distance(a, b) \
821 ((abs(column(a) - column(b)) > abs(row(a) - row(b))) \
822 ? abs(column(a) - column(b)) : abs(row(a) - row(b)))
824 extern short distance(short a
, short b
);
825 extern short ptype_distance(short ptyp
, short f
, short t
);
826 extern short piece_distance(short side
, short piece
, short f
, short t
);
833 #define STATIC_ROOK 'S'
834 #define RANGING_ROOK 'R'
836 extern char GameType
[2];
837 void ShowGameType(void);
839 extern unsigned short bookmaxply
;
840 extern unsigned int bookcount
;
841 extern unsigned int booksize
;
842 extern unsigned long hashkey
, hashbd
;
844 typedef struct hashval hashcode_array
[2][NO_PIECES
][NO_SQUARES
];
845 typedef struct hashval drop_hashcode_array
[2][NO_PIECES
][NO_SQUARES
];
847 extern hashcode_array
*hashcode
;
848 extern drop_hashcode_array
*drop_hashcode
;
850 #ifdef QUIETBACKGROUND
851 extern short background
;
852 #endif /* QUIETBACKGROUND */
855 extern short use_ttable
;
856 extern struct hashentry
*ttable
[2];
860 * hashbd contains a 32 bit "signature" of the board position. hashkey
861 * contains a 16 bit code used to address the hash table. When a move is
862 * made, XOR'ing the hashcode of moved piece on the from and to squares with
863 * the hashbd and hashkey values keeps things current.
866 #define UpdateHashbd(side, piece, f, t) \
870 hashbd ^= (*hashcode)[side][piece][f].bd; \
871 hashkey ^= (*hashcode)[side][piece][f].key; \
876 hashbd ^= (*hashcode)[side][piece][t].bd; \
877 hashkey ^= (*hashcode)[side][piece][t].key; \
881 #define UpdateDropHashbd(side, piece, count) \
883 hashbd ^= (*drop_hashcode)[side][piece][count].bd; \
884 hashkey ^= (*drop_hashcode)[side][piece][count].key; \
888 extern short rpthash
[2][256];
891 extern char* DRAW_REPETITION
;
892 extern char *DRAW_MAXMOVES
;
893 extern char *DRAW_JUSTDRAW
;
895 #define row(a) ((a) / NO_COLS)
896 #define column(a) ((a) % NO_COLS)
897 #define locn(a, b) (((a) * NO_COLS) + b)
899 /* init external functions */
900 extern void InitConst(char *lang
); /* init.c */
901 extern int Initialize_data(void); /* init.c */
902 extern void Free_data(void); /* init.c */
903 extern int Lock_data(void); /* init.c */
904 extern void Unlock_data(void); /* init.c */
905 extern void Initialize_dist(void); /* init.c */
906 extern void Initialize_eval(void); /* eval.c */
907 extern void NewGame(void);
908 extern void GetOpenings(void);
909 extern int OpeningBook(unsigned short *hint
);
913 REMOVE_PIECE
= 1, ADD_PIECE
914 } UpdatePieceList_mode
;
917 UpdatePieceList(short side
, short sq
, UpdatePieceList_mode iop
);
921 FOREGROUND_MODE
= 1, BACKGROUND_MODE
925 SelectMove(short side
, SelectMove_mode iop
);
933 unsigned short *bstline
,
937 void PutInEETable(short side
, int score
);
938 int CheckEETable(short side
);
939 int ProbeEETable(short side
, short *score
);
944 ProbeTTable(short side
,
952 PutInTTable(short side
,
959 extern void ZeroTTable(void);
960 extern void ZeroRPT(void);
961 extern void Initialize_ttable(void);
962 extern unsigned int urand(void);
965 extern void gsrand(unsigned int);
968 ProbeFTable(short side
,
976 PutInFTable(short side
,
985 # endif /* HASHFILE */
988 #if !defined SAVE_NEXTPOS
989 extern void Initialize_moves(void);
992 extern short generate_move_flags
;
994 extern void MoveList(short side
, short ply
,
995 short in_check
, short blockable
);
996 extern void CaptureList(short side
, short ply
,
997 short in_check
, short blockable
);
1001 SqAttacked(short square
, short side
, short *blockable
);
1004 MakeMove(short side
,
1013 UnmakeMove(short side
,
1021 InitializeStats(void);
1024 evaluate(short side
,
1032 extern short ScorePosition(short side
);
1033 extern void ExaminePosition(short side
);
1034 extern short ScorePatternDistance(short side
);
1035 extern void DetermineStage(short side
);
1036 extern void UpdateWeights(short side
);
1037 extern int InitMain(void);
1038 extern void ExitMain(void);
1039 extern void Initialize(void);
1040 extern void InputCommand(char *command
);
1041 extern void ExitShogi(void);
1042 extern void ClearScreen(void);
1043 extern void SetTimeControl(void);
1044 extern void SelectLevel(char *sx
);
1047 UpdateDisplay(short f
,
1054 COMPUTE_AND_INIT_MODE
= 1, COMPUTE_MODE
1055 #ifdef INTERRUPT_TEST
1056 , INIT_INTERRUPT_MODE
, COMPUTE_INTERRUPT_MODE
1060 extern void SetResponseTime(short side
);
1061 extern void CheckForTimeout(int score
, int globalscore
,
1062 int Jscore
, int zwndw
);
1063 extern void ShowSidetoMove(void);
1064 extern void ShowResponseTime(void);
1065 extern void ShowPatternCount(short side
, short n
);
1066 extern void SearchStartStuff(short side
);
1067 extern void ShowDepth(char ch
);
1068 extern void TerminateSearch(int);
1069 extern void ShowResults(short score
, unsigned short *bstline
, char ch
);
1070 extern void SetupBoard(void);
1071 extern void algbr(short f
, short t
, short flag
);
1072 extern void OutputMove(void);
1073 extern void ShowCurrentMove(short pnt
, short f
, short t
);
1074 extern void ListGame(void);
1075 extern void ShowMessage(char *s
);
1076 extern void ClearScreen(void);
1077 extern void DoDebug(void);
1078 extern void DoTable(short table
[NO_SQUARES
]);
1079 extern void ShowPostnValues(void);
1080 extern void ChangeXwindow(void);
1081 extern void SetContempt(void);
1082 extern void ChangeHashDepth(void);
1083 extern void ChangeBetaWindow(void);
1084 extern void GiveHint(void);
1085 extern void ShowPrompt(void);
1086 extern void EditBoard(void);
1087 extern void help(void);
1088 extern void ChangeSearchDepth(void);
1089 extern void skip(void);
1090 extern void skipb(void);
1091 extern void EnPassant(short xside
, short f
, short t
, short iop
);
1092 extern void ShowNodeCnt(long NodeCnt
);
1093 extern void ShowLine(unsigned short *bstline
);
1094 extern int pick(short p1
, short p2
);
1095 extern short repetition(void);
1096 extern void TimeCalc(void);
1097 extern void ElapsedTime(ElapsedTime_mode iop
);
1100 DropPossible(short piece
, short side
, short sq
); /* genmoves.c */
1103 IsCheckmate(short side
, short in_check
,
1104 short blockable
); /* genmoves.c */
1109 VERIFY_AND_MAKE_MODE
, VERIFY_AND_TRY_MODE
, UNMAKE_MODE
1112 extern int VerifyMove(char *s
, VerifyMove_mode iop
, unsigned short *mv
);
1113 extern unsigned short TTage
;
1115 /* display driver framework */
1119 void (*ChangeAlphaWindow
)(void);
1120 void (*ChangeBetaWindow
)(void);
1121 void (*ChangeHashDepth
)(void);
1122 void (*ChangeSearchDepth
)(char *sx
);
1123 void (*ChangeXwindow
)(void);
1124 void (*ClearScreen
)(void);
1125 void (*DoDebug
)(void);
1126 void (*DoTable
)(short table
[NO_SQUARES
]);
1127 void (*EditBoard
)(void);
1128 void (*ExitShogi
)(void);
1129 void (*GiveHint
)(void);
1130 void (*Initialize
)(void);
1131 void (*ShowNodeCnt
)(long NodeCnt
);
1132 void (*OutputMove
)(void);
1133 void (*PollForInput
)(void);
1134 void (*SetContempt
)(void);
1135 void (*SearchStartStuff
)(short side
);
1136 void (*SelectLevel
)(char *sx
);
1137 void (*ShowCurrentMove
)(short pnt
, short f
, short t
);
1138 void (*ShowDepth
)(char ch
);
1139 void (*ShowGameType
)(void);
1140 void (*ShowLine
)(unsigned short *bstline
);
1141 void (*ShowMessage
)(char *s
);
1142 void (*AlwaysShowMessage
)(const char *format
, ...);
1143 void (*Printf
)(const char *format
, ...);
1144 void (*doRequestInputString
)(const char* fmt
, char* buffer
);
1145 int (*GetString
)(char* sx
);
1146 void (*SetupBoard
)(void);
1147 void (*ShowPatternCount
)(short side
, short n
);
1148 void (*ShowPostnValue
)(short sq
);
1149 void (*ShowPostnValues
)(void);
1150 void (*ShowPrompt
)(void);
1151 void (*ShowResponseTime
)(void);
1152 void (*ShowResults
)(short score
, unsigned short *bstline
, char ch
);
1153 void (*ShowSidetoMove
)(void);
1154 void (*ShowStage
)(void);
1155 void (*TerminateSearch
)(int sig
);
1156 void (*UpdateClocks
)(void);
1157 void (*UpdateDisplay
)(short f
, short t
, short redraw
, short isspec
);
1161 extern struct display
*dsp
;
1163 extern struct display raw_display
;
1164 extern struct display curses_display
;
1166 #endif /* _GNUSHOGI_H_ */