home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / PMCHESSR.ZIP / GNUCHESS.H < prev    next >
C/C++ Source or Header  |  1990-11-29  |  6KB  |  251 lines

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