home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games 3 / cd.iso / os2 / pmgnuchs / globals.c < prev    next >
Text File  |  1994-04-20  |  5KB  |  149 lines

  1. //
  2. //  Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  3. //  Copyright (c) 1988, 1989, 1990  John Stanback
  4. //
  5. //  Project:    OS/2 PM Port of GNU CHESS 4.0 (PmChess)
  6. //
  7. //  Version:    1994-4-17
  8. //
  9. //   Porter:    Ported to Windows 3.0 by Darly Baker
  10. //
  11. //   Porter:    Ported to OS/2 1.2+ by Kent Cedola
  12. //
  13. //   Porter:    Revised and ported to OS/2 2.1 by Yibing Fan
  14. //
  15. //   System:    OS2 2.1 using emx0.8g 
  16. //
  17. //  Remarks:    This code converted to OS/2 almost as is.  Mostly minor changes
  18. //              to remove Windows code not required under OS/2.
  19. //
  20. //  License:
  21. //
  22. //    CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  23. //    WARRANTY.  No author or distributor accepts responsibility to anyone for
  24. //    the consequences of using it or for whether it serves any particular
  25. //    purpose or works at all, unless he says so in writing.  Refer to the
  26. //    CHESS General Public License for full details.
  27. //
  28. //    Everyone is granted permission to copy, modify and redistribute CHESS,
  29. //    but only under the conditions described in the CHESS General Public
  30. //    License.  A copy of this license is supposed to have been given to you
  31. //    along with CHESS so you can know your rights and responsibilities.  It
  32. //    should be in a file named COPYING.  Among other things, the copyright
  33. //    notice and this notice must be preserved on all copies.
  34. //
  35.  
  36. #define INCL_DOS
  37. #include <os2.h>
  38. #include <stdio.h>
  39. #include "GnuChess.h"
  40.  
  41.  
  42. #if ttblsz
  43. unsigned long hashkey, hashbd;
  44. struct hashval hashcode[2][7][64];
  45.  
  46. struct hashentry *ttable[2] /*[ttblsz]*/ ;
  47.  
  48. #endif /* ttblsz */
  49.  
  50. FILE *hashfile;
  51. struct leaf Tree[2000], *root;
  52.  
  53. short TrPnt[MAXDEPTH];
  54. short PieceList[2][64], PawnCnt[2][8];
  55. #define wking PieceList[white][0]
  56. #define bking PieceList[black][0]
  57. #define EnemyKing PieceList[c2][0]
  58. short castld[2], Mvboard[64];
  59. short svalue[64];
  60. struct flags flag;
  61. short opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, INCscore;
  62. long MaxResponseTime, ResponseTime, ExtraTime, Level, et, et0, time0, ft;
  63. ULONG GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol, THashCol, filesz, hashmask, hashbase;
  64. long replus, reminus;
  65. short player, xwndw, rehash;
  66. short HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
  67. unsigned int starttime = 0, ttblsize = MINTTABLE;
  68. int timeopp[MINGAMEIN], timecomp[MINGAMEIN];
  69. int compptr, oppptr;
  70. int Book;
  71. int TCadd;
  72.  
  73. struct GameRec   GameList[512];
  74.  
  75. short Sdepth, GameCnt, Game50, MaxSearchDepth;
  76. short epsquare, contempt;
  77. struct TimeControlRec TimeControl;
  78. short TCflag, TCmoves, TCminutes, OperatorTime;
  79. unsigned short hint, PrVar[MAXDEPTH];
  80. short Pindex[64];
  81. short PieceCnt[2];
  82. short c1, c2, *atk1, *atk2, *PC1, *PC2, atak[2][64];
  83. short mtl[2], pmtl[2], emtl[2], hung[2];
  84. short FROMsquare, TOsquare, Zscore, zwndw;
  85. short HasKnight[2], HasBishop[2], HasRook[2], HasQueen[2];
  86. short ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], PawnThreat[MAXDEPTH];
  87. short Pscore[MAXDEPTH], Tscore[MAXDEPTH];
  88. unsigned short killr0[MAXDEPTH], killr1[MAXDEPTH];
  89. unsigned short killr2[MAXDEPTH], killr3[MAXDEPTH];
  90. unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4;
  91. unsigned short history[32768];
  92.  
  93. short rpthash[2][256];
  94. short Mwpawn[64], Mbpawn[64], Mknight[2][64], Mbishop[2][64];
  95. short Mking[2][64], Kfield[2][64];
  96. short KNIGHTPOST, KNIGHTSTRONG, BISHOPSTRONG, KATAK;
  97. short PEDRNK2B, PWEAKH, PADVNCM, PADVNCI, PAWNSHIELD, PDOUBLED, PBLOK;
  98. short RHOPN, RHOPNX, KHOPN, KHOPNX, KSFTY;
  99. short ATAKD, HUNGP, HUNGX, KCASTLD, KMOVD, XRAY, PINVAL;
  100. short stage, stage2, Developed[2];
  101. short PawnBonus, BishopBonus, RookBonus;
  102. short distdata[64][64],   taxidata[64][64];
  103. short board[64], color[64];
  104.  
  105. unsigned char   nextpos[8][64][64];
  106. unsigned char   nextdir[8][64][64];
  107. CHAR *DRAW;
  108.  
  109. const short otherside[3] = {black, white, neutral};
  110. const short value[7] = {0, valueP, valueN, valueB, valueR, valueQ, valueK};
  111. const short qrook[3] = {0, 56, 0};
  112. const short krook[3] = {7, 63, 0};
  113. const short kingP[3] = {4, 60, 0};
  114. const short rank7[3] = {6, 1, 0};
  115. const short sweep[8] = {false, false, false, true, true, true, false, false};
  116. const short control[7] = {0, ctlP, ctlN, ctlB, ctlR, ctlQ, ctlK};
  117.  
  118. #ifdef ttblsz
  119. #ifdef HASHFILE
  120. /*
  121.   In a networked enviroment gnuchess might be compiled on different
  122.   hosts with different random number generators, that is not acceptable
  123.   if they are going to share the same transposition table.
  124. */
  125. static unsigned long int next = 1;
  126.  
  127. unsigned int urand (void)
  128. {
  129.   next *= 1103515245;
  130.   next += 12345;
  131.   return ((unsigned int) (next >> 16) & 0xFFFF);
  132. }
  133.  
  134. void gsrand (unsigned int seed)
  135. {
  136.   next = seed;
  137. }
  138. #endif /*HASHFILE*/
  139. #endif /*ttblsz*/
  140.  
  141. HWND hComputerColor;
  142. HWND hComputerMove;
  143. HWND hWhosTurn;
  144. HWND hClockComputer;
  145. HWND hClockHuman;
  146. HWND hMsgComputer;
  147. HWND hMsgHuman;
  148. HWND hStats;
  149.