summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rwxr-xr-xsrc/eval.c126
1 files changed, 69 insertions, 57 deletions
diff --git a/src/eval.c b/src/eval.c
index 1ca2beb..84e001e 100755
--- a/src/eval.c
+++ b/src/eval.c
@@ -1475,23 +1475,23 @@ Return value:
// IDEA: scale the candidate passer bonus based on rank AND on
// the distance the helper(s) have to go to get into position.
//
- // KNOWN BUG, found 2026-09-05 while removing rgSquare[c|8].bvAttacks
- // entirely (board_representation/EVAL.md section 9), NOT fixed
- // here -- flagged for its own separate investigation instead of
- // being bundled into a mechanical cleanup commit. This function
- // runs from _EvalPawns, which is the *first* piece type evaluated
- // each Eval() call -- every non-pawn piece (and, since commit
- // 57502d6, pawns themselves) writes its attack bits later in the
- // same call, so the "is c1 safe to advance a helper pawn into"
- // check below has read an always-zero attack table for as long as
- // bvAttacks has existed in its post-57502d6 form. The condition
- // this used to gate on (skip a candidate passer if its helper
- // square isn't actually safe to advance into) has therefore been
- // unconditionally true -- a silent no-op -- since that commit,
- // not something introduced by today's cleanup. Preserved exactly
- // as that already-dead behavior (unconditional) rather than
- // "fixed" here, since a real fix changes eval scoring and deserves
- // its own before/after check, not one buried in a rename commit.
+ // FIXED 2026-09-05 (found while removing rgSquare[c|8].bvAttacks
+ // entirely, board_representation/EVAL.md section 9; landed as its
+ // own change with its own before/after check, not bundled into
+ // that mechanical cleanup commit). This function runs from
+ // _EvalPawns, which is the *first* piece type evaluated each
+ // Eval() call, so the only attack data that actually exists yet is
+ // pos->bbPawnAttacks -- every non-pawn piece, and (since commit
+ // 57502d6) pawns' own old bvAttacks write, happens later in the
+ // same call. The original condition here read the old combined
+ // bvAttacks word (all piece types), which had been silently
+ // always-zero -- and this gate silently always-true -- since
+ // 57502d6; narrowed to what's actually valid at this point:
+ // pos->bbPawnAttacks only. This is narrower than the original
+ // presumably intended (any piece type, not just pawns), but it's
+ // a real, correct check instead of a fake one, and pawns are the
+ // dominant real-world case for contesting a helper-pawn square
+ // anyway.
//
uHelpers = 0;
d1 = 16 * g_iAhead[uColor];
@@ -1500,33 +1500,39 @@ Return value:
if ((IS_ON_BOARD(c1)) && (pHash->uCountPerFile[uColor][FILE(c1) + 1]))
{
ASSERT(pos->bbPawns[uColor] & BBFILE[FILE(c1)]);
- //
- // The square c1 the place a helper pawn must get to in
- // order to aide the candidate past a sentry.
- //
- 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))
+ if (!(pos->bbPawnAttacks[FLIP(uColor)] & 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.
+ //
if (pos->rgSquare[c1].pPiece == pHelper)
{
uHelpers = 1;
- break;
+ goto do_left;
}
- else if (pos->rgSquare[c1].pPiece == pSentry)
+
+ //
+ // 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[uColor] & COOR_TO_BB(c1))))
{
- break;
+ if (pos->rgSquare[c1].pPiece == pHelper)
+ {
+ uHelpers = 1;
+ break;
+ }
+ else if (pos->rgSquare[c1].pPiece == pSentry)
+ {
+ break;
+ }
+ c1 = c1 - d1;
}
- c1 = c1 - d1;
}
}
@@ -1536,33 +1542,39 @@ Return value:
{
ASSERT(pos->bbPawns[uColor] & BBFILE[FILE(c1)]);
- //
- // The square c1 is the place a helper pawn must get to in
- // order to aide the candidate.
- //
- 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))
+ if (!(pos->bbPawnAttacks[FLIP(uColor)] & 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.
+ //
if (pos->rgSquare[c1].pPiece == pHelper)
{
uHelpers++;
- break;
+ goto done_helpers;
}
- else if (pos->rgSquare[c1].pPiece == pSentry)
+
+ //
+ // 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[uColor] & COOR_TO_BB(c1))))
{
- break;
+ if (pos->rgSquare[c1].pPiece == pHelper)
+ {
+ uHelpers++;
+ break;
+ }
+ else if (pos->rgSquare[c1].pPiece == pSentry)
+ {
+ break;
+ }
+ c1 -= d1;
}
- c1 -= d1;
}
}