diff options
Diffstat (limited to 'src/eval.c')
| -rw-r--r--[-rwxr-xr-x] | src/eval.c | 86 |
1 files changed, 33 insertions, 53 deletions
diff --git a/src/eval.c b/src/eval.c index 5522d2d..26b7ace 100755..100644 --- a/src/eval.c +++ b/src/eval.c @@ -1261,10 +1261,12 @@ Return value: { COOR c1, cSquare; PIECE pSentry, pHelper; - ULONG uPawnFile = FILE(c) + 1; + ULONG ucFile = FILE(c); + ULONG uPawnFile = ucFile + 1; BITBOARD bb; ULONG uSentries, uHelpers; ULONG uColor; + ULONG xColor; int d1; #ifdef DEBUG COOR cVerifySquare; @@ -1278,54 +1280,49 @@ Return value: ASSERT(IS_PAWN(pHelper)); uColor = GET_COLOR(pHelper); ASSERT(IS_VALID_COLOR(uColor)); + xColor = FLIP(uColor); - if (pHash->uCountPerFile[FLIP(uColor)][uPawnFile] != 0) + // The only way a pawn can be a passer/candidate if the other + // side has a pawn on its same file is if that enemy pawn is + // behind it. This is a corner case but it is important to + // detect all passers. + if (pHash->uCountPerFile[xColor][uPawnFile] != 0) { - ASSERT((pos->bbPawns[FLIP(uColor)] & BBFILE[FILE(c)]) != 0); - - // - // The only way a pawn can be a passer/candidate if the other - // side has a pawn on its same file is if that enemy pawn is - // behind it. This is a corner case but it is important to - // detect all passers. - // + ASSERT((pos->bbPawns[xColor] & BBFILE[ucFile]) != 0); switch(uColor) { case WHITE: - bb = pos->bbPawns[BLACK] & BBFILE[FILE(c)]; + bb = pos->bbPawns[BLACK] & BBFILE[ucFile]; ASSERT(bb); while(IS_ON_BOARD(c1 = CoorFromBitBoardRank8ToRank1(&bb))) { - ASSERT(FILE(c1) == FILE(c)); + ASSERT(FILE(c1) == ucFile); if (c1 < c) return; } break; case BLACK: - bb = pos->bbPawns[WHITE] & BBFILE[FILE(c)]; + bb = pos->bbPawns[WHITE] & BBFILE[ucFile]; ASSERT(bb); while(IS_ON_BOARD(c1 = CoorFromBitBoardRank1ToRank8(&bb))) { - ASSERT(FILE(c1) == FILE(c)); + ASSERT(FILE(c1) == ucFile); if (c1 > c) return; } break; } } - // - // Count FLIP(uColor)'s sentries and determine the location of the - // critical square. Note if there are no sentries then this - // pawn (on square c) is a passer already, not a candidate. - // - bb = pos->bbPawns[FLIP(uColor)] & BBADJACENT_FILES[FILE(c)]; + // Count xColor's sentry pawns and determine the location of the + // critical square for the pawn at c to become a passer. Note if + // there are no sentries then this pawn (on square c) is a passer + // already, not a candidate. + bb = pos->bbPawns[xColor] & BBADJACENT_FILES[ucFile]; bb &= BBPRECEEDING_RANKS[(c & 0x70) >> 4][uColor]; if (!bb) { ASSERT(CountBits(bb) == 0); - // - // There are no sentries so this pawn is a passer. - // + // There are no enemy sentries so this pawn is a passer. pHash->bbPasserLocations[uColor] |= COOR_TO_BB(c); ASSERT(CountBits(pHash->bbPasserLocations[uColor]) > 0); ASSERT(CountBits(pHash->bbPasserLocations[uColor]) <= 8); @@ -1336,9 +1333,7 @@ Return value: PASSER_BY_RANK[uColor][RANK(c)], "passed pawn"); - // // However, don't give doubled passers such a big bonus. - // if (IS_PAWN(pos->rgSquare[c - 16 * g_iAhead[uColor]].pPiece)) { EVAL_TERM(uColor, @@ -1352,10 +1347,10 @@ Return value: } uSentries = CountBits(bb); - // - // There's one or more sentry pawns so we'll look for helpers to - // decide if this pawn is a candidate passer. - // + // There's one or more sentry pawns so we'll look for friendly + // helpers to decide if this pawn is a candidate passer. First + // figure out the critical square we need to get the passer + // through. if (uColor == WHITE) { pSentry = BLACK_PAWN; @@ -1369,9 +1364,9 @@ Return value: cSquare -= 0x10; } cSquare &= 0xF0; - cSquare |= FILE(c); + cSquare |= ucFile; ASSERT(IS_ON_BOARD(cSquare)); - ASSERT(FILE(cSquare) == FILE(c)); + ASSERT(FILE(cSquare) == ucFile); #ifdef DEBUG uVerifySentries = 0; @@ -1443,26 +1438,21 @@ Return value: if ((IS_ON_BOARD(c1)) && (pHash->uCountPerFile[uColor][FILE(c1) + 1])) { ASSERT(pos->bbPawns[uColor] & BBFILE[FILE(c1)]); - if (!(pos->bbPawnAttacks[FLIP(uColor)] & COOR_TO_BB(c1)) || + if (!(pos->bbPawnAttacks[xColor] & COOR_TO_BB(c1)) || (pos->bbPawnAttacks[uColor] & COOR_TO_BB(c1))) { - // - // The square c1 the place a helper pawn must get to in - // order to aide the candidate past a sentry. - // + // Friend helper pawn there? if (pos->rgSquare[c1].pPiece == pHelper) { uHelpers = 1; goto do_left; } - // // There is no helper pawn in the support position yet. // See if one can get there. - // c1 = c1 - d1; while (IS_ON_BOARD(c1) && - ((!(pos->bbPawnAttacks[FLIP(uColor)] & COOR_TO_BB(c1))) || + ((!(pos->bbPawnAttacks[xColor] & COOR_TO_BB(c1))) || (pos->bbPawnAttacks[uColor] & COOR_TO_BB(c1)))) { if (pos->rgSquare[c1].pPiece == pHelper) @@ -1485,26 +1475,21 @@ Return value: { ASSERT(pos->bbPawns[uColor] & BBFILE[FILE(c1)]); - if (!(pos->bbPawnAttacks[FLIP(uColor)] & COOR_TO_BB(c1)) || + if (!(pos->bbPawnAttacks[xColor] & COOR_TO_BB(c1)) || (pos->bbPawnAttacks[uColor] & COOR_TO_BB(c1))) { - // - // The square c1 is the place a helper pawn must get to in - // order to aide the candidate. - // + // Already a helper there? if (pos->rgSquare[c1].pPiece == pHelper) { uHelpers++; goto done_helpers; } - // // There is no pawn in the left support position yet. See // if one can get there. - // c1 -= d1; while (IS_ON_BOARD(c1) && - ((!(pos->bbPawnAttacks[FLIP(uColor)] & COOR_TO_BB(c1))) || + ((!(pos->bbPawnAttacks[xColor] & COOR_TO_BB(c1))) || (pos->bbPawnAttacks[uColor] & COOR_TO_BB(c1)))) { if (pos->rgSquare[c1].pPiece == pHelper) @@ -1536,14 +1521,12 @@ Return value: CANDIDATE_PASSER_BY_RANK[uColor][RANK(c)], "candidate passer"); - // // If the other side has no pieces then give this candidate an // extra bonus -- used to be a second full copy of the same // CANDIDATE_PASSER_BY_RANK value (an exact duplicate of the // term just added above, not a different angle on it), now a // fractional modifier. - // - if (pos->uNonPawnCount[FLIP(uColor)][0] == 1) + if (pos->uNonPawnCount[xColor][0] == 1) { EVAL_TERM(uColor, PAWN, @@ -1588,7 +1571,6 @@ Return value: FOREACH_COLOR(uColor) { ASSERT(IS_VALID_COLOR(uColor)); - if (pHash->bbPasserLocations[uColor]) { ASSERT(pos->uPawnCount[uColor] > 0); @@ -1602,10 +1584,8 @@ Return value: ASSERT(pHash->uCountPerFile[uColor][u+1] != 0); while(IS_ON_BOARD(c = CoorFromBitBoardRank8ToRank1(&bb))) { - // // Keep track of leftmost/rightmost passer for // outside passer code later on. - // ASSERT(FILE(c) == u); ASSERT(RANK(c) > 1); ASSERT(RANK(c) < 8); |
