home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
games
/
gnuchess.zip
/
GNUCHESS.C2
< prev
next >
Wrap
Text File
|
1988-10-23
|
25KB
|
876 lines
InitializeStats()
{
register short i,loc;
epsquare = -1;
for (i = 0; i < 8; i++)
PawnCnt[white][i] = PawnCnt[black][i] = 0;
mtl[white] = mtl[black] = pmtl[white] = pmtl[black] = 0;
PieceCnt[white] = PieceCnt[black] = 0;
hashbd = hashkey = 0;
for (loc = 0; loc < 64; loc++)
if (color[loc] != neutral)
{
mtl[color[loc]] += value[board[loc]];
if (board[loc] == pawn)
{
pmtl[color[loc]] += valueP;
++PawnCnt[color[loc]][col[loc]];
}
if (board[loc] == king) Pindex[loc] = 0;
else Pindex[loc] = ++PieceCnt[color[loc]];
PieceList[color[loc]][Pindex[loc]] = loc;
hashbd ^= hashcode[color[loc]][board[loc]][loc].bd;
hashkey ^= hashcode[color[loc]][board[loc]][loc].key;
}
}
sort(p1,p2)
short p1,p2;
{
register short p,p0,s;
struct leaf temp;
s = 32000;
while (p1 < p2)
if (Tree[p1].score >= s) p1++;
else
{
s = Tree[p1].score; p0 = p1;
for (p = p1+1; p <= p2; p++)
if (Tree[p].score > s)
{
s = Tree[p].score; p0 = p;
}
if (p0 != p1)
{
temp = Tree[p1]; Tree[p1] = Tree[p0]; Tree[p0] = temp;
}
p1++;
}
}
repetition(cnt)
short *cnt;
/*
Check for draw by threefold repetition.
*/
{
register short i,f,t;
short c,b[64];
unsigned short m;
*cnt = c = 0;
for (i = 0; i < 64; b[i++] = 0);
/*
bzero((char *)b,sizeof(b));
memset((char *)b,0,64*sizeof(short));
*/
for (i = GameCnt; i > Game50; i--)
{
m = GameList[i].gmove; f = m>>8; t = m & 0xFF;
if (++b[f] == 0) c--; else c++;
if (--b[t] == 0) c--; else c++;
if (c == 0) (*cnt)++;
}
}
int SqAtakd(sq,side)
short sq,side;
/*
Generate moves from 'sq' for each piece and see if the appropriate
piece with color 'side' is encountered.
*/
{
register short i,u,m,d;
short m0;
m0 = map[sq];
if (HasPawn[side])
{
d = Dpwn[otherside[side]];
for (i = d; i <= d+1; i++)
if ((u = unmap[m0+Dir[i]]) >= 0)
if (board[u] == pawn && color[u] == side) return(true);
}
if (HasKnight[side])
for (i = 8; i <= 15; i++)
if ((u = unmap[m0+Dir[i]]) >= 0)
if (board[u] == knight && color[u] == side) return(true);
if (HasRook[side] || HasQueen[side])
for (i = 0; i <= 3; i++)
{
d = Dir[i]; m = m0+d; u = unmap[m];
while (u >= 0)
if (color[u] == neutral)
{
m += d; u = unmap[m];
}
else if (color[u] == side && sweep1[board[u]]) return(true);
else break;
}
if (HasBishop[side] || HasQueen[side])
for (i = 4; i <= 7; i++)
{
d = Dir[i]; m = m0+d; u = unmap[m];
while (u >= 0)
if (color[u] == neutral)
{
m += d; u = unmap[m];
}
else if (color[u] == side && sweep2[board[u]]) return(true);
else break;
}
if (distance(sq,PieceList[side][0]) == 1) return(true);
return(false);
}
ataks(side,a)
short side,a[];
/*
Fill array atak[][] with info about ataks to a square. Bits 8-15
are set if the piece (king..pawn) ataks the square. Bits 0-7
contain a count of total ataks to the square.
*/
{
register short u,m,d,c;
short j,piece,i,m0,loc;
for (u = 0; u < 64; a[u++] = 0);
/*
memset((char *)a,0,64*sizeof(short));
bzero((char *)a,sizeof(a));
*/
Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
for (i = 0; i <= PieceCnt[side]; i++)
{
loc = PieceList[side][i];
piece = board[loc]; m0 = map[loc]; c = control[piece];
if (sweep[piece])
for (j = Dstart[piece]; j <= Dstop[piece]; j++)
{
d = Dir[j]; m = m0+d; u = unmap[m];
while (u >= 0)
{
a[u] = ++a[u] | c;
if (color[u] == neutral)
{
m += d; u = unmap[m];
}
else break;
}
}
else
for (j = Dstart[piece]; j <= Dstop[piece]; j++)
if ((u = unmap[m0+Dir[j]]) >= 0)
a[u] = ++a[u] | c;
}
}
int castle(side,kf,kt,iop)
short side,kf,kt,iop;
{
short i,rf,rt,c1,c2,t0,xside;
xside = otherside[side];
if (kt > kf)
{
rf = kf+3; rt = kt-1; c1 = kf; c2 = rf;
}
else
{
rf = kf-4; rt = kt+1; c1 = rf; c2 = kf;
}
if (iop == 0)
{
if (board[kf] != king || board[rf] != rook || color[rf] != side)
return(false);
for (i = c1+1; i < c2; i++)
if (color[i] != neutral) return(false);
for (i = c1; i <= c2; i++)
if (SqAtakd(i,xside)) return(false);
}
else
{
if (iop == 1) castld[side] = true; else castld[side] = false;
if (iop == 2)
{
t0 = kt; kt = kf; kf = t0;
t0 = rt; rt = rf; rf = t0;
}
board[kt] = king; color[kt] = side; Pindex[kt] = 0;
board[kf] = no_piece; color[kf] = neutral;
board[rt] = rook; color[rt] = side; Pindex[rt] = Pindex[rf];
board[rf] = no_piece; color[rf] = neutral;
PieceList[side][Pindex[kt]] = kt;
PieceList[side][Pindex[rt]] = rt;
UpdateHashbd(side,king,kf,kt);
UpdateHashbd(side,rook,rf,rt);
}
return(true);
}
en_passant(xside,f,t,iop)
short xside,f,t,iop;
{
short l;
if (t > f) l = t-8; else l = t+8;
if (iop == 1)
{
board[l] = no_piece; color[l] = neutral;
}
else
{
board[l] = pawn; color[l] = xside;
}
InitializeStats();
}
LinkMove(ply,f,t,xside)
short ply,f,t,xside;
/*
Add a move to the tree. Assign a bonus to order the moves
as follows:
1. Principle variation
2. Capture of last moved piece
3. Other captures (major pieces first)
4. Killer moves
5. "history" killers
*/
{
register short s;
register unsigned short mv;
struct leaf *node;
node = &Tree[TrPnt[ply+1]];
++TrPnt[ply+1];
node->flags = node->reply = 0;
node->f = f; node->t = t; mv = (f<<8) + t;
s = 0;
if (mv == PV || mv == Swag0) s = 2000;
else if (mv == Swag1) s = 80;
else if (mv == Swag2) s = 70;
else if (mv == Swag3) s = 60;
else if (mv == Swag4) s = 40;
else if (mv == Swag5) s = 30;
if (color[t] != neutral)
{
node->flags |= capture;
if (t == TOsquare) s += 800;
s += value[board[t]] - board[f];
}
if (board[f] == pawn)
{
if (row[t] == 0 || row[t] == 7)
{
node->flags |= promote;
s += 500;
}
else if (row[t] == 1 || row[t] == 6)
{
node->flags |= pwnthrt;
s += 500;
}
else if (t == epsquare) node->flags |= epmask;
}
if (InChk)
{
if (board[f] == king)
if (SqAtakd(t,xside)) s -= 200; else s += 400;
if (mv == Qkillr[ply]) s += 200;
}
s += history[otherside[xside]-1][f][t];
node->score = s-20000;
}
GenMoves(ply,loc,side,xside)
short ply,loc,side,xside;
/*
Generate moves for a piece. The from square is mapped onto a 12 by
12 board and offsets (taken from array Dir[]) are added to the
mapped location. Array unmap[] maps the move back onto array
board[] (yielding a value of -1 if the to square is off the board).
This process is repeated for bishops, rooks, and queens until a
piece is encountered or the the move falls off the board. Legal
moves are then linked into the tree.
*/
{
register short m,u,d;
short i,m0,piece;
piece = board[loc]; m0 = map[loc];
if (sweep[piece])
for (i = Dstart[piece]; i <= Dstop[piece]; i++)
{
d = Dir[i]; m = m0+d; u = unmap[m];
while (u >= 0)
if (color[u] == neutral)
{
LinkMove(ply,loc,u,xside);
m += d; u = unmap[m];
}
else if (color[u] == xside)
{
LinkMove(ply,loc,u,xside);
break;
}
else break;
}
else if (piece == pawn)
{
if (side == white && color[loc+8] == neutral)
{
LinkMove(ply,loc,loc+8,xside);
if (row[loc] == 1)
if (color[loc+16] == neutral)
LinkMove(ply,loc,loc+16,xside);
}
else if (side == black && color[loc-8] == neutral)
{
LinkMove(ply,loc,loc-8,xside);
if (row[loc] == 6)
if (color[loc-16] == neutral)
LinkMove(ply,loc,loc-16,xside);
}
for (i = Dstart[piece]; i <= Dstop[piece]; i++)
if ((u = unmap[m0+Dir[i]]) >= 0)
if (color[u] == xside || u == epsquare)
LinkMove(ply,loc,u,xside);
}
else
{
for (i = Dstart[piece]; i <= Dstop[piece]; i++)
if ((u = unmap[m0+Dir[i]]) >= 0)
if (color[u] != side)
LinkMove(ply,loc,u,xside);
}
}
MoveList(side,ply)
short side,ply;
/*
Fill the array Tree[] with all available moves for side to
play. Array TrPnt[ply] contains the index into Tree[]
of the first move at a ply.
*/
{
register short i;
short xside,f;
xside = otherside[side];
Swag0 = killr0[ply]; Swag1 = killr1[ply]; Swag2 = killr2[ply];
Swag3 = killr3[ply]; Swag4 = Swag5 = 0;
if (ply > 2)
{
Swag4 = killr1[ply-2];
Swag5 = killr3[ply-2];
}
TrPnt[ply+1] = TrPnt[ply];
Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
for (i = PieceCnt[side]; i >= 0; i--)
GenMoves(ply,PieceList[side][i],side,xside);
if (kingmoved[side] == 0)
{
f = PieceList[side][0];
if (castle(side,f,f+2,0))
{
LinkMove(ply,f,f+2,xside);
Tree[TrPnt[ply+1]-1].flags |= cstlmask;
}
if (castle(side,f,f-2,0))
{
LinkMove(ply,f,f-2,xside);
Tree[TrPnt[ply+1]-1].flags |= cstlmask;
}
}
sort(TrPnt[ply],TrPnt[ply+1]-1);
}
#define LinkCapture\
{\
node = &Tree[TrPnt[ply+1]];\
++TrPnt[ply+1];\
node->f = loc; node->t = u;\
node->reply = 0;\
node->flags = capture;\
node->score = value[board[u]] + svalue[board[u]] - piece;\
if (piece == pawn && (u < 8 || u > 55))\
{\
node->flags |= promote;\
node->score = valueQ;\
}\
}
CaptureList(side,xside,ply)
short side,xside,ply;
/*
Generate a list of captures similiarly to GenMoves.
*/
{
register short m,u,d;
short loc,i,j,m0,piece;
struct leaf *node;
TrPnt[ply+1] = TrPnt[ply];
Dstart[pawn] = Dpwn[side]; Dstop[pawn] = Dstart[pawn] + 1;
for (i = 0; i <= PieceCnt[side]; i++)
{
loc = PieceList[side][i];
piece = board[loc]; m0 = map[loc];
if (sweep[piece])
for (j = Dstart[piece]; j <= Dstop[piece]; j++)
{
d = Dir[j]; m = m0+d; u = unmap[m];
while (u >= 0)
if (color[u] == neutral)
{
m += d; u = unmap[m];
}
else
{
if (color[u] == xside) LinkCapture;
break;
}
}
else
{
for (j = Dstart[piece]; j <= Dstop[piece]; j++)
if ((u = unmap[m0+Dir[j]]) >= 0)
if (color[u] == xside) LinkCapture;
if (piece == pawn && row[loc] == rank7[side])
{
if (side == white) u = loc+8; else u = loc-8;
if (color[u] == neutral) LinkCapture;
}
}
}
sort(TrPnt[ply],TrPnt[ply+1]-1);
}
MakeMove(side,node,tempb,tempc,temps)
short side,*tempc,*tempb,*temps;
struct leaf *node;
/*
Update Arrays board[], color[], and Pindex[] to reflect the new
board position obtained after making the move pointed to by
node. Also update miscellaneous stuff that changes when a move
is made.
*/
{
register short f,t;
short xside;
xside = otherside[side];
f = node->f; t = node->t; epsquare = -1;
TOsquare = t; cptrval = 0;
GameList[++GameCnt].gmove = (f<<8) + t;
if (node->flags & cstlmask)
{
GameList[GameCnt].piece = no_piece;
GameList[GameCnt].color = side;
castle(side,f,t,1);
}
else
{
*tempc = color[t]; *tempb = board[t]; *temps = svalue[t];
GameList[GameCnt].piece = *tempb;
GameList[GameCnt].color = *tempc;
if (*tempc != neutral)
{
UpdatePieceList(*tempc,t,1);
if (*tempb == pawn) --PawnCnt[*tempc][col[t]];
if (board[f] == pawn)
{
--PawnCnt[side][col[f]];
++PawnCnt[side][col[t]];
}
mtl[xside] -= value[*tempb];
if (*tempb == pawn) pmtl[xside] -= valueP;
UpdateHashbd(xside,*tempb,-1,t);
cptrval = *temps;
}
color[t] = color[f]; board[t] = board[f]; svalue[t] = svalue[f];
Pindex[t] = Pindex[f]; PieceList[side][Pindex[t]] = t;
color[f] = neutral; board[f] = no_piece;
if (board[t] == pawn)
if (t-f == 16) epsquare = f+8;
else if (f-t == 16) epsquare = f-8;
if (node->flags & promote)
{
board[t] = queen;
--PawnCnt[side][col[t]];
mtl[side] += valueQ - valueP;
pmtl[side] -= valueP;
HasQueen[side] = true;
cptrval -= svalue[f];
UpdateHashbd(side,pawn,f,-1);
UpdateHashbd(side,queen,f,-1);
}
if (board[t] == king) ++kingmoved[side];
if (node->flags & epmask) en_passant(xside,f,t,1);
else UpdateHashbd(side,board[t],f,t);
}
}
UnmakeMove(side,node,tempb,tempc,temps)
short side,*tempc,*tempb,*temps;
struct leaf *node;
/*
Take back the move pointed to by node.
*/
{
register short f,t;
short xside;
xside = otherside[side];
f = node->f; t = node->t; epsquare = -1;
GameCnt--;
if (node->flags & cstlmask) castle(side,f,t,2);
else
{
color[f] = color[t]; board[f] = board[t]; svalue[f] = svalue[t];
Pindex[f] = Pindex[t]; PieceList[side][Pindex[f]] = f;
color[t] = *tempc; board[t] = *tempb; svalue[t] = *temps;
if (node->flags & promote)
{
board[f] = pawn;
++PawnCnt[side][col[t]];
mtl[side] += valueP - valueQ;
pmtl[side] += valueP;
UpdateHashbd(side,queen,-1,t);
UpdateHashbd(side,pawn,-1,t);
}
if (*tempc != neutral)
{
UpdatePieceList(*tempc,t,2);
if (*tempb == pawn) ++PawnCnt[*tempc][col[t]];
if (board[f] == pawn)
{
--PawnCnt[side][col[t]];
++PawnCnt[side][col[f]];
}
mtl[xside] += value[*tempb];
if (*tempb == pawn) pmtl[xside] += valueP;
UpdateHashbd(xside,*tempb,-1,t);
}
if (board[f] == king) --kingmoved[side];
if (node->flags & epmask) en_passant(xside,f,t,2);
else UpdateHashbd(side,board[f],f,t);
}
}
distance(a,b)
short a,b;
{
short d1,d2;
d1 = absv(col[a]-col[b]);
d2 = absv(row[a]-row[b]);
if (d1 > d2) return(d1); else return(d2);
}
BlendBoard(a,b,c)
short a[64],b[64],c[64];
{
register int sq;
for (sq = 0; sq < 64; sq++)
c[sq] = (a[sq]*(10-stage) + b[sq]*stage) / 10;
}
CopyBoard(a,b)
short a[64],b[64];
{
register int sq;
for (sq = 0; sq < 64; sq++)
b[sq] = a[sq];
}
UpdateWeights()
{
short tmtl;
if (mtl[white] != Zwmtl || mtl[black] != Zbmtl)
{
Zwmtl = mtl[white]; Zbmtl = mtl[black];
emtl[white] = Zwmtl - pmtl[white] - valueK;
emtl[black] = Zbmtl - pmtl[black] - valueK;
tmtl = emtl[white] + emtl[black];
if (tmtl > 5700) stage = 0;
else if (tmtl < 1300) stage = 10;
else stage = (5700-tmtl) / 440;
PEDRNK2B = -15; /* centre pawn on 2nd rank & blocked */
PBKWRD = -6; /* backward pawns */
PWEAKA = -3; /* each attack to weak pawn */
PWEAKH = -3; /* weak pawn on half open file */
PAWNSHIELD = 10-stage; /* pawn near friendly king */
PADVNCM = (10+stage)/2; /* advanced pawn multiplier */
KNIGHTPOST = (stage+2)/3; /* knight near enemy pieces */
KNIGHTSTRONG = (stage+6)/2; /* occupies pawn hole */
BISHOPSTRONG = (stage+6)/2; /* occupies pawn hole */
RHOPN = 10; /* rook on half open file */
RHOPNX = 4;
XRAY = 8; /* Xray attack on major piece */
KHOPN = (3*stage-30) / 2; /* king on half open file */
KHOPNX = KHOPN / 2;
KCASTLD = 10 / (stage+1); /* king castled */
KMOVD = -40 / (stage+1); /* king moved before castling */
KATAK = 5; /* B,R attacks near enemy king */
if (stage < 8) KSFTY = 8-stage; else KSFTY = 0;
ATAKD = -6; /* defender > attacker */
HUNGP = -8; /* each hung piece */
HUNGX = -10; /* extra for >1 hung piece */
}
}
ExaminePosition()
/*
This is done one time before the search is started.
Set up arrays Mwpawn, Mbpawn, Mknight, Mbishop, Mking which are used
in the SqValue() function to determine the positional value of each
piece.
*/
{
register short i,sq;
short r,wpadv,bpadv,z,side,pp,j;
long stage2,tpmtl,Pd,val;
wking = PieceList[white][0]; bking = PieceList[black][0];
ataks(white,atak[white]); ataks(black,atak[black]);
Zwmtl = Zbmtl = 0;
UpdateWeights();
stage2 = stage*stage; tpmtl = pmtl[white] + pmtl[black];
HasPawn[white] = HasPawn[black] = false;
HasKnight[white] = HasKnight[black] = false;
HasBishop[white] = HasBishop[black] = false;
HasRook[white] = HasRook[black] = false;
HasQueen[white] = HasQueen[black] = false;
for (side = white; side <= black; side++)
for (i = 0; i <= PieceCnt[side]; i++)
switch (board[PieceList[side][i]])
{
case pawn : HasPawn[side] = true; break;
case knight : HasKnight[side] = true; break;
case bishop : HasBishop[side] = true; break;
case rook : HasRook[side] = true; break;
case queen : HasQueen[side] = true; break;
}
if (!Developed[white])
Developed[white] = (board[1] != knight && board[2] != bishop &&
board[5] != bishop && board[6] != knight);
if (!Developed[black])
Developed[black] = (board[57] != knight && board[58] != bishop &&
board[61] != bishop && board[62] != knight);
for (sq = 0; sq < 64; sq++)
{
WeakSq[white][sq] = WeakSq[black][sq] = true;
for (i = sq; i >= 0; i -= 8)
if (atak[white][i] >= ctlP) WeakSq[white][sq] = false;
for (i = sq; i < 64; i += 8)
if (atak[black][i] >= ctlP) WeakSq[black][sq] = false;
Kfield[white][sq] = Kfield[black][sq] = 0;
}
CopyBoard(pknight,Mknight[white]);
CopyBoard(pknight,Mknight[black]);
CopyBoard(pbishop,Mbishop[white]);
CopyBoard(pbishop,Mbishop[black]);
BlendBoard(KingOpening,KingEnding,Mking[white]);
BlendBoard(KingOpening,KingEnding,Mking[black]);
if (!Developed[white])
{
Mknight[white][1] -= 5;
Mbishop[white][2] -= 5;
Mbishop[white][5] -= 5;
Mknight[white][6] -= 5;
}
if (!Developed[black])
{
Mknight[black][57] -= 5;
Mbishop[black][58] -= 5;
Mbishop[black][61] -= 5;
Mknight[black][62] -= 5;
}
for (sq = 0; sq < 64; sq++)
{
wpadv = bpadv = PADVNCM;
Mwpawn[sq] = (wpadv*PawnAdvance[sq]) / 10;
Mbpawn[sq] = (bpadv*PawnAdvance[63-sq]) / 10;
if (distance(sq,wking) < 3 && (col[sq] < 3 || col[sq] > 4))
Mwpawn[sq] += PAWNSHIELD;
if (distance(sq,bking) < 3 && (col[sq] < 3 || col[sq] > 4))
Mbpawn[sq] += PAWNSHIELD;
Mknight[white][sq] += 5 - distance(sq,bking);
Mknight[white][sq] += 5 - distance(sq,wking);
Mknight[black][sq] += 5 - distance(sq,wking);
Mknight[black][sq] += 5 - distance(sq,bking);
Mbishop[white][sq] += stage;
Mbishop[black][sq] += stage;
for (i = 0; i <= PieceCnt[black]; i++)
if (distance(sq,PieceList[black][i]) < 3)
Mknight[white][sq] += KNIGHTPOST;
for (i = 0; i <= PieceCnt[white]; i++)
if (distance(sq,PieceList[white][i]) < 3)
Mknight[black][sq] += KNIGHTPOST;
if (WeakSq[black][sq]) Mknight[white][sq] += KNIGHTSTRONG;
if (WeakSq[white][sq]) Mknight[black][sq] += KNIGHTSTRONG;
if (WeakSq[black][sq]) Mbishop[white][sq] += BISHOPSTRONG;
if (WeakSq[white][sq]) Mbishop[black][sq] += BISHOPSTRONG;
Pd = 0;
for (i = 0; i < 64; i++)
if (board[i] == pawn)
{
if (color[i] == white)
{
r = row[i]+3; pp = true;
if (row[i] == 6) z = i+8; else z = i+16;
for (j = i+8; j < 64; j += 8)
if (!WeakSq[black][j]) pp = false;
}
else
{
r = 10-row[i]; pp = true;
if (row[i] == 1) z = i-8; else z = i-16;
for (j = i-8; j >= 0; j -= 8)
if (!WeakSq[white][j]) pp = false;
}
if (pp) r *= 4;
Pd += r*distance(sq,z);
}
if (tpmtl > 0)
{
val = (Pd*stage2) / (2*tpmtl);
Mking[white][sq] -= (short)val;
Mking[black][sq] -= (short)val;
}
if (distance(sq,wking) == 1) Kfield[black][sq] += KATAK;
if (distance(sq,bking) == 1) Kfield[white][sq] += KATAK;
}
}
int trapped(loc,piece)
short loc,piece;
/*
See if the attacked piece has unattacked squares to move to.
If it is trapped, increment the hung[] array so that the search
will be extended.
*/
{
register short u,m,d;
short i,m0;
m0 = map[loc];
if (sweep[piece])
for (i = Dstart[piece]; i <= Dstop[piece]; i++)
{
d = Dir[i]; m = m0+d; u = unmap[m];
while (u >= 0)
if (color[u] == c1) break;
else if (atak[c2][u] == 0 || board[u] >= piece) return(false);
else if (color[u] == c2) break;
else
{
m += d; u = unmap[m];
}
}
else if (piece == pawn)
{
if (c1 == white) u = loc+8; else u = loc-8;
if (color[u] == neutral && atak[c1][u] >= atak[c2][u])
best = node->score; pbst = pnt;
if (best > alpha) alpha = best;
for (j = ply+1; nxtline[j] > 0; j++) bstline[j] = nxtline[j];
bstline[j] = 0;
bstline[ply] = (node->f<<8) + node->t;
if (ply == 1)
{
if (post) post_move(node);
if (best == alpha)
{
tmp = Tree[pnt];
for (j = pnt-1; j >= 0; j--) Tree[j+1] = Tree[j];
Tree[0] = tmp;
}
if (Sdepth > 2)
if (best > beta) ShowResults('+');
else if (best < alpha) ShowResults('-');
else ShowResults('&');
}
}
if (NodeCnt > ETnodes) ElapsedTime(0);
}
if (ply == 1) node = &Tree[0]; else node = &Tree[pbst];
mv = (node->f<<8) + node->t;
if (ply <= Sdepth && *rpt == 0 && !timeout && hashflag)
PutInTTable(side,best,xdepth,alpha,beta,bstline[ply+1]);
if (depth > 0)
if (history[side-1][node->f][node->t] < 180)
history[side-1][node->f][node->t] += depth;
if (node->t != (GameList[GameCnt].gmove & 0xFF))
if (best <= beta) killr3[ply] = mv;
else if (mv != killr1[ply])
{
killr2[ply] = killr1[ply];
killr1[ply] = mv;
}
if (in_check && best > -9000) Qkillr[ply] = mv;
if (best > 9000) killr0[ply] = mv; else killr0[ply] = 0;
if (timeout || (best < alpha && -Tscore[ply-1] < best))
best = -Tscore[ply-1];
return(best);
}