home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
useful
/
game
/
think
/
uchess
/
src
/
gnuchess.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-27
|
26KB
|
908 lines
/*#define LONGINTS 1*/
#define AGING 1
#define NODITHER 1
#define INTSIZE short
/*#define LONGINTS2 1*/
#ifdef LONGINTS
#define INTSIZE2 long
#else
#define INTSIZE2 short
#endif
#ifdef _M68040
#define VERSTRING "UChess v2.89L(040)"
#define AVSTR "$VER: UChess 2.89L [040] (29.07.94)"
#else
#ifndef TINYCHESS
#define VERSTRING "UChess v2.89(020)"
#define AVSTR "$VER: UChess 2.89 [020] (29.07.94)"
#else
#define VERSTRING "UChess v2.89T(020)"
#define AVSTR "$VER: UChess 2.89T [020] (29.07.94)"
#endif
#endif
#define ARGSZ long
#define REG register
/*
To fix it as a tool for pgm use, modify the routine
InputCommand() in dspcom.c and OutputMove() in nondsp.c
modify main.c to setup screen, etc,
modify inline statement below,
Modify SelectLevel in nondsp.c so that it does not use scanf
in dspcom.c, ElapsedTime function is where you cut short
any thinking on human players time. Around the FIONREAD
area, you need a loop for looking for the intuition events
and stop the thinking short if that happens
Modify PromptForMove in nondsp.c, actaully may not be needed at all
*/
/*
* gnuchess.h - Header file for GNU CHESS
*
* Copyright (c) 1988,1989,1990 John Stanback
* Copyright (c) 1992 Free Software Foundation
*
* This file is part of GNU CHESS.
*
* GNU Chess is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* GNU Chess is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Chess; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
On an Amiga 4000, Gnuchess 4.0 gets from 80,000(short), 100,000 (long)
nodes/sec on MoveList, and 3000(s)-3700(l) Nodes/sec on Eval Speed
On a SunStation (netcom), Gnuchess 4.0 gets from 100,000 to 133,300 nodes/sec on
MoveList, and 3700 Nodes/sec on Eval Speed
*/
#if !defined(__STDC__) || !defined(MSDOS)
#define const
#endif
#ifndef __GNUC__
#define inline __inline
#endif
#include <stdio.h>
typedef unsigned char UCHAR; /* unsigned 8-bit quantity */
typedef short tshort;
typedef unsigned short utshort;
#ifdef USEINT
typedef int SHORT;
typedef unsigned int UTSHORT;
#else
typedef unsigned short UTSHORT;
//typedef short SHORT;
#endif
#ifdef AMIGA
#undef printf
#define printf NULLY
#undef stdin
#undef stdout
#undef stderr
#define stdin NULLYIN
#define stdout NULLYOUT
#define stderr NULLYERR
#undef scanf
#define scanf NULLYSCANF
#endif
#define SEEK_SET 0
#define SEEK_END 2
#ifdef DEBUG
void
ShowDBLine (char *, INTSIZE int, INTSIZE int,
INTSIZE int, INTSIZE int, INTSIZE int,
INTSIZE unsigned int *);
extern FILE *debugfd;
extern INTSIZE int debuglevel;
#endif /* DEBUG */
#include <ctype.h>
#ifdef AMIGA
#define __USE_SYSBASE
#include <exec/types.h>
#include <dos/dos.h>
#include <proto/exec.h>
#endif
extern long int GenCnt;
extern int GlobalTgtDepth;
extern int TCadd;
extern int mycnt3;
extern int globalmessage_valid;
extern struct IntuiMessage __aligned globalmessage;
extern char __far HintString[80];
extern char __far MateString[40];
extern int AmigaStarted;
extern int Mate;
extern int DrawnGame;
void
TestSpeed (void (*f) (INTSIZE int side, INTSIZE int ply), unsigned j);
void
TestPSpeed (INTSIZE int (*f) (INTSIZE int side), unsigned j);
void GetEditText(char *,int *);
void CloseAmigaEditWindow(void);
int OpenAmigaEditWindow(void);
unsigned int urand (void);
void gsrand (unsigned int seed);
#ifdef AMIGA
void __regargs MoveMem(void *,void *,ULONG);
void __regargs MoveMem128(void *,void *);
void __regargs ClearMem(void *,ULONG);
#endif
int myfgets(char *,int ,BPTR);
int DoResign(void);
void EnableMoveNow(void);
void DisableMoveNow(void);
void UpdateClocks (void);
int LoadFullBitMap(void);
void DoLegalMove(char *);
void DisplayComputerMove(char *);
int HandleEvent(APTR);
void DoAbout(void);
void LoadAGame(void);
void SaveAGame(void);
void ListAGame(void);
void DoQuit(void);
void Go2D(void);
void Go3D(void);
void DoReverse(void);
void DoSwap(void);
void DoAutoPlay(void);
void MoveNow(void);
void TakeBack(void);
void DoThinking(void);
void DoShwThnk(void);
void DoSuper(void);
void DoBookToggle(void);
void DoHint(void);
void DoTest(void);
void SetTime(void);
int GetFileName(char *);
void DisplayError(char *);
void __saveds InputThread(void);
void GetOperatorEntry(void);
void AmigaShutDown(void);
void AnimateAmigaMove(char *,char);
void GetTimeString(char *);
void GiveHint(void);
void EditBoard(void);
void help(void);
void ChangeAlphaWindow(void);
void ChangeBetaWindow(void);
void ChangeSearchDepth(void);
void ChangeHashDepth(void);
void SetContempt(void);
void ChangeXwindow(void);
void ShowPostnValues(void);
void DoDebug(void);
void DoTable(INTSIZE *);
void GetGame(void);
void SaveGame(void);
void DrawAmigaBoard(void);
void skip(void);
void skipb(void);
void EnPassant (INTSIZE int xside, INTSIZE int f, INTSIZE int t, INTSIZE int iop);
void ataks(INTSIZE int, INTSIZE int *);
void Initialize_dist(void);
void InitConst(char *);
int SetAmigaDepth(void);
#ifdef MSDOS
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define RWA_ACC "r+b"
#define WA_ACC "w+b"
#else
#define RWA_ACC "r+"
#define WA_ACC "w+"
/*
#include <sys/param.h>
#include <sys/types.h>
#include <sys/times.h>
*/
#include <stdlib.h>
#include <string.h>
#include <time.h>
extern int FirstTime;
#endif /* MSDOS */
#ifdef NONDSP
#ifdef AMIGA
#define printz NULLFUNC
#define scanz NULLFUNC2
#else
#define printz printf
#define scanz scanf
#endif
#else
#include <curses.h>
#define scanz fflush(stdout),scanw
#define printz printw
#endif
#if defined(__STDC__) || defined(MSDOS)
/* <stdio.h> */
extern int fclose (FILE *);
#ifndef __ultrix /* work around bug in c89 compiler --t.mann */
#endif /*__ultrix*/
/* <stdlib.h> */
/* <time.h> */
/* <string.h> */
#endif
/* Piece values */
#define valueP 100
#define valueN 350
#define valueB 355
#define valueR 550
#define valueQ 1100
#define valueK 1200
/* masks into upper 8 bits of ataks array */
#define ctlP 0x4000
#define ctlN 0x2800
#define ctlB 0x1800
#define ctlR 0x0400
#define ctlQ 0x0200
#define ctlK 0x0100
#define ctlBQ 0x1200
#define ctlBN 0x0800
#define ctlRQ 0x0600
#define ctlNN 0x2000
/* attack functions */
#define Patak(c, u) (atak[c][u] > ctlP)
#define Anyatak(c, u) (atak[c][u] > 0)
/* distance function */
#define taxicab(a,b) taxidata[a][b]
/* hashtable flags */
#define truescore 0x0001
#define lowerbound 0x0002
#define upperbound 0x0004
#define kingcastle 0x0008
#define queencastle 0x0010
#define evalflag 0x0020 /* from PL 61 */
/* king positions */
#define wking PieceList[white][0]
#define bking PieceList[black][0]
#define EnemyKing PieceList[c2][0]
/* constants */
/* castle moves */
#define BLACKCASTLE 0x3C3E
#define WHITECASTLE 0x0406
#define LONGBLACKCASTLE 0x3C3A
#define LONGWHITECASTLE 0x0402
/* truth values */
#define false 0
#define true 1
/* colors */
#define white 0
#define black 1
#define neutral 2
/* piece code defines */
#define no_piece 0
#define pawn 1
#define knight 2
#define bishop 3
#define rook 4
#define queen 5
#define king 6
#define bpawn 7
/* node flags */
#define pmask 0x0007
#define promote 0x0008
#define cstlmask 0x0010
#define epmask 0x0020
#define exact 0x0040
#define pwnthrt 0x0080
#define check 0x0100
#define capture 0x0200
#define draw 0x0400
#define book 0x1000
/* move symbols */
#define pxx (CP[2])
#define qxx (CP[1])
#define rxx (CP[4])
#define cxx (CP[3])
/* for everything that can't use the above */
#define Qxx " pnbrqk"
#define Pxx " PNBRQK"
#define Cxx "abcdefgh"
#define Rxx "12345678"
/***************************************************************************/
/***************** Table limits ********************************************/
/*
* ttblsz must be a power of 2.