From 08691ed07918ba75d5e88929c20f175ac4821bcd Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sat, 14 Jan 2017 11:30:20 +0100 Subject: [PATCH] Keep track of total hand values With the aidof two new tables, handBulk[] (piece-list size) and dropBulk[] (board sized), we now keep track of the total value of pieces in the hands. This is stored in the promoGain for piece type 30, (which is not used in any variant), to easily index it with the side to move. --- dropper.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dropper.c b/dropper.c index 8087bf5..d0e9a35 100644 --- a/dropper.c +++ b/dropper.c @@ -54,6 +54,7 @@ int moveNr; // part of game state; incremented by MakeMove #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) @@ -61,7 +62,7 @@ int pvStack[MAXPLY*MAXPLY/2]; 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]; @@ -421,6 +422,7 @@ ClearBoard () for(r=0; r>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); @@ -669,7 +676,7 @@ typedef struct { 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; @@ -938,7 +945,7 @@ NonEvade (StackFrame *f) 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 @@ -990,6 +997,8 @@ MakeMove (StackFrame *f, int move) 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; @@ -1003,6 +1012,7 @@ UnMake (StackFrame *f) 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; } @@ -1347,6 +1357,7 @@ Setup (char *fen) 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 } -- 1.7.0.4