#define zoneTab (rawByte + 48*22)
#define sqr2file (rawByte + 59*22)
#define dist (rawByte + 70*22 + 22*10 + 10)
+#define dropBulk (rawByte + 91*22)
#define location (rawLocation + 23)
#define promoGain (rawGain + 1)
int nrRanks, nrFiles, specials, pinCodes, maxDrop, moveSP, pawn, lanceMask, *pvPtr = pvStack, boardEnd, perpLoses, searchNr;
int rawInts[21*22], pieceValues[96], pieceCode[96];
signed char rawChar[32*22], steps[512];
-unsigned char rawByte[91*22], firstDir[64], rawBulk[98], handSlot[97], promoCode[96], aVal[64], vVal[64], rawLocation[96+23];
+unsigned char rawByte[102*22], firstDir[64], rawBulk[98], handSlot[97], promoCode[96], aVal[64], vVal[64], rawLocation[96+23], handBulk[96];
long long int handKey[96], pawnKey;
int handVal[96], rawGain[97];
unsigned int moveStack[500*MAXPLY];
for(r=0; r<nrRanks; r++) for(f=0; f<nrFiles; f++) board[22*r+f] = 0; // playing area
for(f=0; f<11; f++) pawnCount[f] = 0xF0; // Pawn occupancy per file
for(i=0; i<512+20; i++) repKey[i] = 0; // game-history hash
+ promoGain[WHITE+30] = promoGain[BLACK+30] = 0;// danger measure of in-hand pieces
}
char *pieces, *startPos;
for(i=0; i<16; i++) {
int demoted = dropType[handSlot[WHITE+i+16]]-1; // piece type after demotion (could be Pawn, in Chess)
handVal[WHITE+i+16] = handVal[BLACK+i+16] = pieceValues[WHITE+i+16] + handVal[demoted]; // gain by capturing promoted piece
+ handBulk[WHITE+i] = handBulk[BLACK+i] = pieceValues[WHITE+i]/80;
+ handBulk[WHITE+i+16] = handBulk[BLACK+i+16] = pieceValues[demoted]/80;
}
for(i=0; i<16; i++) handVal[WHITE+i] = handVal[BLACK+i] += pieceValues[WHITE+i]; // gain by capturing base piece
for(i=0; i<16; i++) {
}
for(i=0; i<16; i++) { // PST for in-hand pieces. type = -1 only occurs on (all) drops, but true type determined by (off-board) square
PST[-1][handSlot[WHITE+i]] = PST[-1][handSlot[BLACK+i]] = handVal[WHITE+i] - 2*pieceValues[WHITE+i];
+ dropBulk[handSlot[WHITE+i]] = dropBulk[handSlot[BLACK+i]] = pieceValues[WHITE+i]/80;
}
PST[WHITE+2] = PST[BLACK+2] = center; // Bishops
for(f=0; f<11; f++) { // pawn tables
printf("\nfarCode:\n"); for(i=0; i<96; i++) printf(" %2x%s", pieceCode[i]>>8 & 255, (i&15) == 15 ? "\n" : "");
PrintValues("pieceValues:", pieceValues, 0);
PrintValues("handVal:", handVal, 0);
- PrintValues("promoGain:", promoGain, 96);
+ PrintValues("promoGain:", promoGain, 64);
PrintPieces("vVal:", vVal, 64);
PrintPieces("aVal:", aVal, 64);
+ PrintPieces("handBulk:", handBulk, 96);
+ PrintDBoard("dropBulk", dropBulk, " ", 11);
PrintDBoard("hand PST:", PST[-1], " ", 11);
PrintDBoard("Pawn PST:", PST[WHITE], " ", 11);
PrintDBoard("board:", board, " ", 11);
Key hashKey, newKey;
unsigned char fromSqr, toSqr, captSqr, epSqr, rookSqr, rights;
signed char fromPiece, toPiece, victim, savePiece, rook, mutation;
- int pstEval, newEval;
+ int pstEval, newEval, bulk;
int move, depth;
int checker, checkDir, checkDist, xking;
} StackFrame;
int
MakeMove (StackFrame *f, int move)
{
- int to;
+ int to, stm;
f->fromSqr = move >> 8 & 255;
to = move & 255;
f->toSqr = f->captSqr = toDecode[to]; // real to-square for to-encoded special moves
f->newEval += promoGain[f->toPiece] - promoGain[f->mutation] + handVal[f->victim] +
PST[f->toPiece][f->toSqr] - PST[f->mutation][f->fromSqr] + PST[f->victim][f->captSqr];
f->newKey += KEY(f->toPiece, f->toSqr) - KEY(f->mutation, f->fromSqr) - KEY(f->victim, f->captSqr) + handKey[f->victim];
+ stm = f->toPiece & COLOR;
+ f->bulk = promoGain[stm+30]; promoGain[stm+30] += handBulk[f->victim] - dropBulk[f->fromSqr];
location[f->toPiece] = f->toSqr;
return 1;
board[f->captSqr] = f->victim; // differs from toSqr on e.p. (Pawn to-square) and castling, (King to-square) and should be cleared then
board[f->fromSqr] = f->fromPiece; // and the mover
board[handSlot[f->victim]]++;
+ promoGain[(f->toPiece & COLOR)+30] = f->bulk;
location[f->fromPiece] = f->fromSqr;
}
board[sqr]--; // count piece in hand
hashKey += handKey[i ^ COLOR]; // update hash key
pstEval += (color & WHITE ? 1 : -1)*(handVal[i] - pieceValues[i]); // update PST eval (white POV)
+ promoGain[color+30] += handBulk[i];
}
fen++; // skip closing bracket
}