home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
useful
/
game
/
think
/
uchess
/
src
/
dspcom.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-28
|
52KB
|
2,231 lines
#define CLEARHISTBETWEENMOVES // old way to handle hist table
/*
* dspcom.c - C source 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.
*/
#include "gnuchess.h"
void calc_pgm_rating(void);
void DoEasy(void);
void DoIntermediate(void);
void DoAdvanced(void);
#define PTRHEIGHT 55
extern UWORD chip myPointer[];
#define MYREPLY (1<<InputReply->mp_SigBit)
extern struct MsgPort *InputReply;
extern struct MsgPort *InThreadPort;
extern struct myMsgStruct Global_Message;
#if defined NULLMOVE || defined DEEPNULL
extern short int __aligned no_null;
extern short int __aligned null; /* Null-move already made or not */
extern short int __aligned PVari; /* Is this the PV */
#endif
extern short __aligned Threat[MAXDEPTH];
extern unsigned short int __aligned PrVar[MAXDEPTH];
extern short __aligned PawnStorm;
extern short __aligned start_stage;
extern short __aligned thrashing_tt; /* must we recycle slots at random. TomV */
extern INTSIZE __aligned amigaboard[64],amigacolor[64];
int __aligned GetEntryDone;
extern int OpEntryRecvd;
extern char __aligned OpEntryStr[64];
extern INTSIZE Mwpawn[64], Mbpawn[64], Mknight[2][64], Mbishop[2][64];
extern char *version, *patchlevel;
char __aligned mvstr[8][8];
char __aligned mvstrhint[8][8];
char __aligned *InPtr;
#define BOOKMENUNUM 0xc2
#ifdef CACHE
extern struct etable __far __aligned etab[2][ETABLE];
#endif
void algbr2 (SHORT f, SHORT t, SHORT flag);
extern unsigned int TTadd;
int __aligned SecsPerMove=10;
extern int IllegalMove;
int __aligned func_num=0;
int __aligned thinkahead=0;
int __aligned ThinkInARow=0;
int __aligned ThinkAheadWorked=0;
int __aligned ThinkAheadDepth=0;
extern int backsrchaborted;
extern short int ISZERO;
extern short __aligned background;
int __aligned verifyquiet=0;
int __aligned MouseDropped=0;
#include <ctype.h>
#include <signal.h>
#ifdef AMIGA
#define __USE_SYSBASE
#include <exec/types.h>
#include <exec/exec.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
struct IntuiMessage __aligned globalmessage;
int __aligned globalmessage_valid=0;
extern struct Window __aligned *wG;
extern int procpri;
extern struct Process *myproc;
extern struct MenuItem MenuItem6;
extern struct Menu Menu1;
extern unsigned char __far cookedchar[128];
extern struct Menu __aligned Menu1;
#define MenuList1 Menu1
extern struct MenuItem __aligned MenuItem8ab;
extern int __aligned MenuStripSet;
#endif
#define SIGQUIT SIGINT
#ifdef MSDOS
#include <dos.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#else
#include <dos.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/*
#include <sys/param.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
*/
#endif
/*
* ataks.h - Header source 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.
*/
inline int
SqAtakd2 (ARGSZ int sq, ARGSZ int side)
/*
* See if any piece with color 'side' ataks sq. First check pawns then
* Queen, Bishop, Rook and King and last Knight.
*/
{
register INTSIZE u;
register unsigned char *ppos, *pdir;
INTSIZE xside;
xside = side ^ 1;
pdir = nextdir[ptype[xside][pawn]][sq];
u = pdir[sq]; /* follow captures thread */
if (u != sq)
{
if (board[u] == pawn && color[u] == side)
return (true);
u = pdir[u];
if (u != sq && board[u] == pawn && color[u] == side)
return (true);
}
/* king capture */
if (distance (sq, PieceList[side][0]) == 1)
return (true);
/* try a queen bishop capture */
ppos = nextpos[bishop][sq];
pdir = nextdir[bishop][sq];
u = ppos[sq];
do
{
if (color[u] == neutral)
u = ppos[u];
else
{
if (color[u] == side && (board[u] == queen || board[u] == bishop))
return (true);
u = pdir[u];
}
} while (u != sq);
/* try a queen rook capture */
ppos = nextpos[rook][sq];
pdir = nextdir[rook][sq];
u = ppos[sq];
do
{
if (color[u] == neutral)
u = ppos[u];
else
{
if (color[u] == side && (board[u] == queen || board[u] == rook))
return (true);
u = pdir[u];
}
} while (u != sq);
/* try a knight capture */
pdir = nextdir[knight][sq];
u = pdir[sq];
do
{
if (color[u] == side && board[u] == knight)
return (true);
u = pdir[u];
} while (u != sq);
return (false);
}
#ifndef OLD_ALGBR
void
algbr (SHORT f, SHORT t, SHORT flag)
/*
* Generate move strings in different formats.
*/
{
int m3p;
if (f != t)
{
/* algebraic notation */
mvstr[0][0] = cxx[column (f)];
mvstr[0][1] = rxx[row (f)];
mvstr[0][2] = cxx[column (t)];
mvstr[0][3] = rxx[row (t)];
mvstr[4][0] = mvstr[0][4] = mvstr[3][0] = '\0';
if (((mvstr[1][0] = pxx[board[f]]) == 'P') || (flag & promote))
{
if (mvstr[0][0] == mvstr[0][2]) /* pawn did not eat */
{
mvstr[2][0] = mvstr[1][0] = mvstr[0][2]; /* to column */
mvstr[2][1] = mvstr[1][1] = mvstr[0][3]; /* to row */
m3p = 2;
}
else
/* pawn ate */
{
mvstr[2][0] = mvstr[1][0] = mvstr[0][0]; /* column */
mvstr[2][1] = mvstr[1][1] = mvstr[0][2]; /* to column */
mvstr[2][2] = mvstr[0][3];
m3p = 3; /* to row */
}
if (flag & promote)
{
mvstr[0][4] = mvstr[1][2] = mvstr[2][m3p] = qxx[flag & pmask];
mvstr[0][5] = mvstr[1][3] = mvstr[2][m3p + 1] = mvstr[3][0] = '\0';
#ifdef CHESSTOOL
mvstr[3][0] = mvstr[0][0]; /* Allow e7e8 for chesstool */
mvstr[3][1] = mvstr[0][1];
mvstr[3][2] = mvstr[0][2];
mvstr[3][3] = mvstr[0][3];
mvstr[3][4] = '\0';
#endif
} else mvstr[2][m3p] = mvstr[1][2] = '\0';
}
else
/* not a pawn */
{
mvstr[2][0] = mvstr[1][0];
mvstr[2][1] = mvstr[0][1];
mvstr[2][2] = mvstr[1][1] = mvstr[0][2]; /* to column */
mvstr[2][3] = mvstr[1][2] = mvstr[0][3]; /* to row */
mvstr[2][4] = mvstr[1][3] = '\0';
strcpy (mvstr[3], mvstr[2]);
mvstr[3][1] = mvstr[0][0];
mvstr[4][0] = mvstr[1][0]; strcpy(&mvstr[4][1],mvstr[0]);
if (flag & cstlmask)
{
if (t > f)
{
//strcpy (mvstr[1], mvstr[0]);
strcpy (mvstr[1], CP[5]);
strcpy (mvstr[2], CP[7]);
}
else
{
//strcpy (mvstr[1], mvstr[0]);
strcpy (mvstr[1], CP[6]);
strcpy (mvstr[2], CP[8]);
}
}
}
}
else
mvstr[0][0] = mvstr[1][0] = mvstr[2][0] = mvstr[3][0] = mvstr[4][0] = '\0';
}
void
algbr2 (SHORT f, SHORT t, SHORT flag)
/*
* Generate move strings in different formats.
*/
{
int m3p;
if (f != t)
{
/* algebraic notation */
mvstrhint[0][0] = cxx[c