home *** CD-ROM | disk | FTP | other *** search
- //
- // Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
- // Copyright (c) 1988, 1989, 1990 John Stanback
- //
- // Project: OS/2 PM Port of GNU CHESS 4.0 (PmChess)
- //
- // Version: 1994-4-17
- //
- // Porter: Ported to Windows 3.0 by Darly Baker
- //
- // Porter: Ported to OS/2 1.2+ by Kent Cedola
- //
- // Porter: Revised and ported to OS/2 2.1 by Yibing Fan
- //
- // System: OS2 2.1 using emx0.8g
- //
- // Remarks: This code converted to OS/2 almost as is. Mostly minor changes
- // to remove Windows code not required under OS/2.
- //
- // License:
- //
- // CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
- // WARRANTY. No author or distributor accepts responsibility to anyone for
- // the consequences of using it or for whether it serves any particular
- // purpose or works at all, unless he says so in writing. Refer to the
- // CHESS General Public License for full details.
- //
- // Everyone is granted permission to copy, modify and redistribute CHESS,
- // but only under the conditions described in the CHESS General Public
- // License. A copy of this license is supposed to have been given to you
- // along with CHESS so you can know your rights and responsibilities. It
- // should be in a file named COPYING. Among other things, the copyright
- // notice and this notice must be preserved on all copies.
- //
-
- #define INCL_DOS
- #include <os2.h>
- #include <stdio.h>
- #include "GnuChess.h"
-
-
- #if ttblsz
- unsigned long hashkey, hashbd;
- struct hashval hashcode[2][7][64];
-
- struct hashentry *ttable[2] /*[ttblsz]*/ ;
-
- #endif /* ttblsz */
-
- FILE *hashfile;
- struct leaf Tree[2000], *root;
-
- short TrPnt[MAXDEPTH];
- short PieceList[2][64], PawnCnt[2][8];
- #define wking PieceList[white][0]
- #define bking PieceList[black][0]
- #define EnemyKing PieceList[c2][0]
- short castld[2], Mvboard[64];
- short svalue[64];
- struct flags flag;
- short opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, INCscore;
- long MaxResponseTime, ResponseTime, ExtraTime, Level, et, et0, time0, ft;
- ULONG GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol, THashCol, filesz, hashmask, hashbase;
- long replus, reminus;
- short player, xwndw, rehash;
- short HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
- unsigned int starttime = 0, ttblsize = MINTTABLE;
- int timeopp[MINGAMEIN], timecomp[MINGAMEIN];
- int compptr, oppptr;
- int Book;
- int TCadd;
-
- struct GameRec GameList[512];
-
- short Sdepth, GameCnt, Game50, MaxSearchDepth;
- short epsquare, contempt;
- struct TimeControlRec TimeControl;
- short TCflag, TCmoves, TCminutes, OperatorTime;
- unsigned short hint, PrVar[MAXDEPTH];
- short Pindex[64];
- short PieceCnt[2];
- short c1, c2, *atk1, *atk2, *PC1, *PC2, atak[2][64];
- short mtl[2], pmtl[2], emtl[2], hung[2];
- short FROMsquare, TOsquare, Zscore, zwndw;
- short HasKnight[2], HasBishop[2], HasRook[2], HasQueen[2];
- short ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], PawnThreat[MAXDEPTH];
- short Pscore[MAXDEPTH], Tscore[MAXDEPTH];
- unsigned short killr0[MAXDEPTH], killr1[MAXDEPTH];
- unsigned short killr2[MAXDEPTH], killr3[MAXDEPTH];
- unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4;
- unsigned short history[32768];
-
- short rpthash[2][256];
- short Mwpawn[64], Mbpawn[64], Mknight[2][64], Mbishop[2][64];
- short Mking[2][64], Kfield[2][64];
- short KNIGHTPOST, KNIGHTSTRONG, BISHOPSTRONG, KATAK;
- short PEDRNK2B, PWEAKH, PADVNCM, PADVNCI, PAWNSHIELD, PDOUBLED, PBLOK;
- short RHOPN, RHOPNX, KHOPN, KHOPNX, KSFTY;
- short ATAKD, HUNGP, HUNGX, KCASTLD, KMOVD, XRAY, PINVAL;
- short stage, stage2, Developed[2];
- short PawnBonus, BishopBonus, RookBonus;
- short distdata[64][64], taxidata[64][64];
- short board[64], color[64];
-
- unsigned char nextpos[8][64][64];
- unsigned char nextdir[8][64][64];
- CHAR *DRAW;
-
- const short otherside[3] = {black, white, neutral};
- const short value[7] = {0, valueP, valueN, valueB, valueR, valueQ, valueK};
- const short qrook[3] = {0, 56, 0};
- const short krook[3] = {7, 63, 0};
- const short kingP[3] = {4, 60, 0};
- const short rank7[3] = {6, 1, 0};
- const short sweep[8] = {false, false, false, true, true, true, false, false};
- const short control[7] = {0, ctlP, ctlN, ctlB, ctlR, ctlQ, ctlK};
-
- #ifdef ttblsz
- #ifdef HASHFILE
- /*
- In a networked enviroment gnuchess might be compiled on different
- hosts with different random number generators, that is not acceptable
- if they are going to share the same transposition table.
- */
- static unsigned long int next = 1;
-
- unsigned int urand (void)
- {
- next *= 1103515245;
- next += 12345;
- return ((unsigned int) (next >> 16) & 0xFFFF);
- }
-
- void gsrand (unsigned int seed)
- {
- next = seed;
- }
- #endif /*HASHFILE*/
- #endif /*ttblsz*/
-
- HWND hComputerColor;
- HWND hComputerMove;
- HWND hWhosTurn;
- HWND hClockComputer;
- HWND hClockHuman;
- HWND hMsgComputer;
- HWND hMsgHuman;
- HWND hStats;