home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / game / uchess-2.89.lha / UChess / src / gnuchess.h < prev    next >
C/C++ Source or Header  |  1994-07-28  |  26KB  |  908 lines

  1. /*#define LONGINTS 1*/
  2. #define AGING 1
  3. #define NODITHER 1
  4. #define INTSIZE short
  5. /*#define LONGINTS2 1*/
  6. #ifdef LONGINTS
  7. #define INTSIZE2 long
  8. #else
  9. #define INTSIZE2 short
  10. #endif
  11.  
  12.  
  13. #ifdef _M68040
  14. #define VERSTRING "UChess v2.89L(040)"
  15. #define AVSTR "$VER: UChess 2.89L [040] (29.07.94)"
  16. #else
  17. #ifndef TINYCHESS
  18. #define VERSTRING "UChess v2.89(020)"
  19. #define AVSTR "$VER: UChess 2.89 [020] (29.07.94)"
  20. #else
  21. #define VERSTRING "UChess v2.89T(020)"
  22. #define AVSTR "$VER: UChess 2.89T [020] (29.07.94)"
  23. #endif
  24. #endif
  25.  
  26.  
  27. #define ARGSZ long
  28.  
  29. #define REG register
  30.  
  31. /* 
  32.    To fix it as a tool for pgm use, modify the routine
  33.    InputCommand() in dspcom.c and OutputMove() in nondsp.c 
  34.    modify main.c to setup screen, etc,
  35.    modify inline statement below,
  36.    Modify SelectLevel in nondsp.c so that it does not use scanf
  37.    in dspcom.c, ElapsedTime function is where you cut short
  38.    any thinking on human players time.  Around the FIONREAD
  39.    area, you need a loop for looking for the intuition events
  40.    and stop the thinking short if that happens
  41.  
  42.    Modify PromptForMove in nondsp.c, actaully may not be needed at all
  43.  
  44.    */
  45.  
  46. /*
  47.  * gnuchess.h - Header file for GNU CHESS
  48.  *
  49.  * Copyright (c) 1988,1989,1990 John Stanback
  50.  * Copyright (c) 1992 Free Software Foundation
  51.  *
  52.  * This file is part of GNU CHESS.
  53.  *
  54.  * GNU Chess is free software; you can redistribute it and/or modify
  55.  * it under the terms of the GNU General Public License as published by
  56.  * the Free Software Foundation; either version 2, or (at your option)
  57.  * any later version.
  58.  *
  59.  * GNU Chess is distributed in the hope that it will be useful,
  60.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  61.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  62.  * GNU General Public License for more details.
  63.  *
  64.  * You should have received a copy of the GNU General Public License
  65.  * along with GNU Chess; see the file COPYING.  If not, write to
  66.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  67.  */
  68.  
  69. /*
  70.  
  71.  On an Amiga 4000, Gnuchess 4.0 gets from  80,000(short), 100,000 (long)
  72.  nodes/sec on MoveList, and 3000(s)-3700(l) Nodes/sec on Eval Speed 
  73.  
  74.  On a SunStation (netcom), Gnuchess 4.0 gets from 100,000 to 133,300 nodes/sec on
  75.  MoveList, and 3700 Nodes/sec on Eval Speed 
  76.  
  77. */
  78.  
  79.  
  80. #if !defined(__STDC__) || !defined(MSDOS)
  81. #define const
  82. #endif
  83.  
  84. #ifndef __GNUC__
  85. #define inline __inline
  86. #endif
  87.  
  88. #include <stdio.h>
  89.  
  90. typedef unsigned char    UCHAR;        /* unsigned 8-bit quantity */
  91. typedef short tshort;
  92. typedef unsigned short utshort;
  93. #ifdef USEINT
  94. typedef  int SHORT;
  95. typedef  unsigned int UTSHORT;
  96. #else
  97. typedef unsigned short UTSHORT;
  98. //typedef short SHORT;
  99. #endif
  100.  
  101.  
  102. #ifdef AMIGA
  103. #undef printf
  104. #define printf NULLY
  105. #undef stdin
  106. #undef stdout
  107. #undef stderr
  108. #define stdin NULLYIN
  109. #define stdout NULLYOUT
  110. #define stderr NULLYERR
  111. #undef scanf
  112. #define scanf NULLYSCANF
  113. #endif
  114.  
  115. #define SEEK_SET 0
  116. #define SEEK_END 2
  117. #ifdef DEBUG
  118. void
  119. ShowDBLine (char *, INTSIZE int, INTSIZE int,
  120.         INTSIZE int, INTSIZE int, INTSIZE int,
  121.         INTSIZE unsigned int *);
  122.      extern FILE *debugfd;
  123.      extern INTSIZE int debuglevel;
  124.  
  125. #endif /* DEBUG */
  126.  
  127. #include <ctype.h>
  128.  
  129. #ifdef AMIGA
  130. #define __USE_SYSBASE
  131. #include <exec/types.h>
  132. #include <dos/dos.h>
  133. #include <proto/exec.h>
  134. #endif
  135.  
  136.  
  137. extern long int GenCnt;
  138.  
  139. extern int GlobalTgtDepth;
  140. extern int TCadd;
  141. extern int mycnt3;
  142. extern int globalmessage_valid;
  143. extern struct IntuiMessage __aligned globalmessage;
  144. extern char __far HintString[80];
  145. extern char __far MateString[40];
  146. extern int AmigaStarted;
  147. extern int Mate;
  148. extern int DrawnGame;
  149.  
  150. void
  151.  TestSpeed (void (*f) (INTSIZE int side, INTSIZE int ply), unsigned j);
  152. void
  153.  TestPSpeed (INTSIZE int (*f) (INTSIZE int side), unsigned j);
  154.  
  155. void GetEditText(char *,int *);
  156. void CloseAmigaEditWindow(void);
  157. int OpenAmigaEditWindow(void);
  158.  
  159. unsigned int urand (void);
  160. void gsrand (unsigned int seed);
  161.  
  162. #ifdef AMIGA
  163. void __regargs MoveMem(void *,void *,ULONG);
  164. void __regargs MoveMem128(void *,void *);
  165. void __regargs ClearMem(void *,ULONG);
  166. #endif
  167. int myfgets(char *,int ,BPTR);
  168. int DoResign(void);
  169. void EnableMoveNow(void);
  170. void DisableMoveNow(void);
  171. void UpdateClocks (void);
  172. int LoadFullBitMap(void);
  173. void DoLegalMove(char *);
  174. void DisplayComputerMove(char *);
  175. int HandleEvent(APTR);
  176. void DoAbout(void);
  177. void LoadAGame(void);
  178. void SaveAGame(void);
  179. void ListAGame(void);
  180. void DoQuit(void);
  181. void Go2D(void);
  182. void Go3D(void);
  183. void DoReverse(void);
  184. void DoSwap(void);
  185. void DoAutoPlay(void);
  186. void MoveNow(void);
  187. void TakeBack(void);
  188. void DoThinking(void);
  189. void DoShwThnk(void);
  190. void DoSuper(void);
  191. void DoBookToggle(void);
  192. void DoHint(void);
  193. void DoTest(void);
  194. void SetTime(void);
  195. int GetFileName(char *);
  196.  
  197. void DisplayError(char *);
  198. void __saveds InputThread(void);
  199. void GetOperatorEntry(void);
  200. void AmigaShutDown(void);
  201. void AnimateAmigaMove(char *,char);
  202. void GetTimeString(char *);
  203. void GiveHint(void);
  204. void EditBoard(void);
  205. void help(void);
  206. void ChangeAlphaWindow(void);
  207. void ChangeBetaWindow(void);
  208. void ChangeSearchDepth(void);
  209. void ChangeHashDepth(void);
  210. void SetContempt(void);
  211. void ChangeXwindow(void);
  212. void ShowPostnValues(void);
  213. void DoDebug(void);
  214. void DoTable(INTSIZE *);
  215.  
  216. void GetGame(void);
  217. void SaveGame(void);
  218. void DrawAmigaBoard(void);
  219. void skip(void);
  220. void skipb(void);
  221. void EnPassant (INTSIZE int xside, INTSIZE int f, INTSIZE int t, INTSIZE int iop);
  222.  
  223. void ataks(INTSIZE int, INTSIZE int *);
  224. void Initialize_dist(void);
  225. void InitConst(char *);
  226. int SetAmigaDepth(void);
  227.  
  228.  
  229. #ifdef MSDOS
  230. #include <stdlib.h>
  231. #include <string.h>
  232. #include <time.h>
  233. #define RWA_ACC "r+b"
  234. #define WA_ACC "w+b"
  235. #else
  236. #define RWA_ACC "r+"
  237. #define WA_ACC "w+"
  238. /*
  239. #include <sys/param.h>
  240. #include <sys/types.h>
  241. #include <sys/times.h>
  242. */
  243. #include <stdlib.h>
  244. #include <string.h>
  245. #include <time.h>
  246.  
  247. extern int FirstTime;
  248.  
  249. #endif /* MSDOS */
  250. #ifdef NONDSP
  251. #ifdef AMIGA
  252. #define printz NULLFUNC
  253. #define scanz NULLFUNC2
  254. #else
  255. #define printz printf
  256. #define scanz scanf
  257. #endif
  258. #else
  259. #include <curses.h>
  260. #define scanz fflush(stdout),scanw
  261. #define printz printw
  262. #endif
  263.  
  264. #if defined(__STDC__) || defined(MSDOS)
  265. /* <stdio.h> */
  266.      extern int fclose (FILE *);
  267. #ifndef __ultrix /* work around bug in c89 compiler --t.mann */
  268. #endif /*__ultrix*/
  269.  
  270. /* <stdlib.h> */
  271.  
  272. /* <time.h> */
  273.  
  274. /* <string.h> */
  275. #endif
  276.  
  277.  
  278. /* Piece values */
  279. #define valueP 100
  280. #define valueN 350
  281. #define valueB 355
  282. #define valueR 550
  283. #define valueQ 1100
  284. #define valueK 1200
  285. /* masks into upper 8 bits of ataks array */
  286. #define ctlP 0x4000
  287. #define ctlN 0x2800
  288. #define ctlB 0x1800
  289. #define ctlR 0x0400
  290. #define ctlQ 0x0200
  291. #define ctlK 0x0100
  292. #define ctlBQ 0x1200
  293. #define ctlBN 0x0800
  294. #define ctlRQ 0x0600
  295. #define ctlNN 0x2000
  296. /* attack functions */
  297. #define Patak(c, u) (atak[c][u] > ctlP)
  298. #define Anyatak(c, u) (atak[c][u] > 0)
  299. /* distance function */
  300. #define taxicab(a,b) taxidata[a][b]
  301. /* hashtable flags */
  302. #define truescore 0x0001
  303. #define lowerbound 0x0002
  304. #define upperbound 0x0004
  305. #define kingcastle 0x0008
  306. #define queencastle 0x0010
  307. #define evalflag 0x0020 /* from PL 61 */
  308. /* king positions */
  309. #define wking PieceList[white][0]
  310. #define bking PieceList[black][0]
  311. #define EnemyKing PieceList[c2][0]
  312. /* constants */
  313. /* castle moves */
  314. #define BLACKCASTLE    0x3C3E
  315. #define WHITECASTLE    0x0406
  316. #define LONGBLACKCASTLE    0x3C3A
  317. #define LONGWHITECASTLE    0x0402
  318. /* truth values */
  319. #define false 0
  320. #define true 1
  321. /* colors */
  322. #define white 0
  323. #define black 1
  324. #define neutral 2
  325. /* piece code defines */
  326. #define no_piece 0
  327. #define pawn 1
  328. #define knight 2
  329. #define bishop 3
  330. #define rook 4
  331. #define queen 5
  332. #define king 6
  333. #define bpawn 7
  334. /* node flags */
  335. #define pmask 0x0007
  336. #define promote 0x0008
  337. #define cstlmask 0x0010
  338. #define epmask 0x0020
  339. #define exact 0x0040
  340. #define pwnthrt 0x0080
  341. #define check 0x0100
  342. #define capture 0x0200
  343. #define draw 0x0400
  344. #define book 0x1000
  345. /* move symbols */
  346. #define pxx (CP[2])
  347. #define qxx (CP[1])
  348. #define rxx (CP[4])
  349. #define cxx (CP[3])
  350. /* for everything that can't use the above */
  351. #define Qxx " pnbrqk"
  352. #define Pxx " PNBRQK"
  353. #define Cxx "abcdefgh"
  354. #define Rxx "12345678"
  355. /***************************************************************************/
  356. /***************** Table limits ********************************************/
  357. /*
  358.  * ttblsz must be a power of 2.