home *** CD-ROM | disk | FTP | other *** search
/ MORE WinGames / WINGAMES.iso / chess / gnuchess.h < prev    next >
C/C++ Source or Header  |  1991-01-12  |  6KB  |  247 lines

  1. /*
  2.   gnuchess.h - Header file for GNU CHESS
  3.  
  4.   Revision: 1990-04-18
  5.  
  6.   Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  7.  
  8.   This file is part of CHESS.
  9.  
  10.   CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  11.   WARRANTY.  No author or distributor accepts responsibility to anyone for
  12.   the consequences of using it or for whether it serves any particular
  13.   purpose or works at all, unless he says so in writing.  Refer to the CHESS
  14.   General Public License for full details.
  15.  
  16.   Everyone is granted permission to copy, modify and redistribute CHESS, but
  17.   only under the conditions described in the CHESS General Public License.
  18.   A copy of this license is supposed to have been given to you along with
  19.   CHESS so you can know your rights and responsibilities.  It should be in a
  20.   file named COPYING.  Among other things, the copyright notice and this
  21.   notice must be preserved on all copies.
  22. */
  23.  
  24. #include <stdio.h>
  25. #define SEEK_SET 0
  26. #define SEEK_END 2
  27.  
  28. #if !defined(__STDC__) || !defined(MSDOS)
  29. #define const
  30. #endif
  31.  
  32. #ifndef __GNUC__
  33. #define inline
  34. #endif
  35.  
  36. /*
  37.   ttblsz must be a power of 2.
  38.   Setting ttblsz 0 removes the transposition tables.
  39. */
  40. #ifdef MSDOS
  41. #define ttblsz (1 << 11)
  42. #else
  43. #define ttblsz (1 << 16)
  44. #define huge
  45. #endif /* MSODS */
  46.  
  47. #define maxdepth 30
  48. #define white 0
  49. #define black 1
  50. #define neutral 2
  51. #define no_piece 0
  52. #define pawn 1
  53. #define knight 2
  54. #define bishop 3
  55. #define rook 4
  56. #define queen 5
  57. #define king 6
  58. #define bpawn 7
  59. #define pmask 0x0007
  60. #define promote 0x0008
  61. #define cstlmask 0x0010
  62. #define epmask 0x0020
  63. #define exact 0x0040
  64. #define pwnthrt 0x0080
  65. #define check 0x0100
  66. #define capture 0x0200
  67. #define draw 0x0400
  68. #define maxdepth 30
  69. #define false 0
  70. #define true 1
  71. /* #define absv(x) ((x) < 0 ? -(x) : (x)) */
  72.  
  73. #define valueP 100
  74. #define valueN 350
  75. #define valueB 355
  76. #define valueR 550
  77. #define valueQ 1100
  78. #define valueK 1200
  79. #define ctlP 0x4000
  80. #define ctlN 0x2800
  81. #define ctlB 0x1800
  82. #define ctlR 0x0400
  83. #define ctlQ 0x0200
  84. #define ctlK 0x0100
  85. #define ctlBQ 0x1200
  86. #define ctlBN 0x0800
  87. #define ctlRQ 0x0600
  88. #define ctlNN 0x2000
  89. #define Patak(c, u) (atak[c][u] > ctlP)
  90. #define Anyatak(c, u) (atak[c][u] > 0)
  91.  
  92. #if ttblsz
  93. #define truescore 0x0001
  94. #define lowerbound 0x0002
  95. #define upperbound 0x0004
  96. #define kingcastle 0x0008
  97. #define queencastle 0x0010
  98.  
  99. struct hashval
  100. {
  101.   unsigned long key,bd;
  102. };
  103. struct hashentry
  104. {
  105.   unsigned long hashbd;
  106.   unsigned short mv;
  107.   unsigned char flags, depth;   /* char saves some space */
  108.   short score;
  109. #ifdef HASHTEST
  110.   unsigned char bd[32];
  111. #endif /* HASHTEST */
  112.  
  113. };
  114.  
  115. #ifdef HASHFILE
  116. /*
  117.   persistent transposition table.
  118.   The size must be a power of 2. If you change the size,
  119.   be sure to run gnuchess -t before anything else.
  120. */
  121. #define frehash 6
  122. #ifdef MSDOS
  123. #define filesz (1 << 11)
  124. #else
  125. #define filesz (1 << 17)
  126. #endif /* MSDOS */
  127. struct fileentry
  128. {
  129.   unsigned char bd[32];
  130.   unsigned char f, t, flags, depth, sh, sl;
  131. };
  132. /*
  133.   In a networked enviroment gnuchess might be compiled on different
  134.   hosts with different random number generators, that is not acceptable
  135.   if they are going to share the same transposition table.
  136. */
  137.  
  138. unsigned int urand (void);
  139. void srand (unsigned int seed);
  140.  
  141. #else
  142. int rand (void);
  143. void srand ( unsigned int seed);
  144. #define urand rand
  145. #endif /* HASHFILE */
  146.  
  147. extern unsigned long hashkey, hashbd;
  148. /*extern struct hashval hashcode[2][7][64];*/
  149. extern struct hashval far *hashcode;
  150.  
  151. /*extern struct hashentry huge ttable[2][ttblsz];*/
  152. extern struct hashentry far *ttable;
  153.  
  154. #endif /* ttblsz */
  155.  
  156.  
  157. extern HWND hComputerColor;
  158. extern HWND hComputerMove;
  159. extern HWND hWhosTurn;
  160. extern HWND hClockComputer;
  161. extern HWND hClockHuman;
  162. extern HWND hMsgComputer;
  163. extern HWND hMsgHuman;
  164. extern HWND hStats;
  165.  
  166.  
  167.  
  168. struct leaf
  169. {
  170.   short f, t, score, reply;
  171.   unsigned short flags;
  172. };
  173. struct GameRec
  174. {
  175.   unsigned short gmove;
  176.   short score, depth, time, piece, color;
  177.   long nodes;
  178. };
  179. struct TimeControlRec
  180. {
  181.   short moves[2];
  182.   long clock[2];
  183. };
  184.  
  185. struct BookEntry
  186. {
  187.   struct BookEntry far *next;
  188.   unsigned short far *mv;
  189. };
  190.  
  191. struct flags
  192. {
  193.   short mate;        /* the game is over */
  194.   short post;        /* show principle variation */
  195.   short quit;        /* quit/exit gnuchess */
  196.   short reverse;    /* reverse board display */
  197.   short bothsides;    /* computer plays both sides */
  198.   short hash;        /* enable/disable transposition table */
  199.   short force;        /* enter moves */
  200.   short easy;        /* disable thinking on opponents time */
  201.   short beep;        /* enable/disable beep */
  202.   short timeout;    /* time to make a move */
  203.   short rcptr;        /* enable/disable recapture heuristics */
  204. };
  205.  
  206. /* extern struct leaf Tree[2000], *root; */
  207. extern struct leaf far *Tree, far *root;
  208.  
  209. extern short TrPnt[maxdepth];
  210. extern short board[64], color[64];
  211. extern short PieceList[2][16], PawnCnt[2][8];
  212. extern short castld[2], Mvboard[64];
  213. extern short svalue[64];
  214. extern struct flags flag;
  215. extern short opponent, computer, Awindow, Bwindow, INCscore;
  216. extern short dither, player;
  217. extern short xwndw, epsquare, contempt;
  218. extern long ResponseTime, ExtraTime, Level, et, et0, time0, ft;
  219. extern long NodeCnt, ETnodes, EvalNodes, HashCnt, HashCol;
  220. /* extern struct GameRec GameList[512];*/
  221. extern struct GameRec far *GameList;
  222.  
  223. extern short GameCnt, Game50;
  224. extern short Sdepth, MaxSearchDepth;
  225. /*extern struct BookEntry *Book;*/
  226. extern struct BookEntry far *Book;
  227.  
  228. extern struct TimeControlRec TimeControl;
  229. extern short TCflag, TCmoves, TCminutes, OperatorTime;
  230. extern const short otherside[3];
  231. /*
  232. extern const short otherside[3];
  233. extern const short Stboard[64];
  234. extern const short Stcolor[64];
  235. */
  236. extern unsigned short hint, PrVar[maxdepth];
  237.  
  238. /*#define distance(a,b) distdata[a][b]*/
  239. #define distance(a,b) *(distdata+a*64+b)
  240.  
  241. #define row(a) ((a) >> 3)
  242. #define column(a) ((a) & 7)
  243. #define locn(a,b) (((a) << 3) | b)
  244. /*extern short distdata[64][64];*/
  245. extern short far *distdata;
  246.  
  247.