diff options
Diffstat (limited to 'src/searchsup.c')
| -rw-r--r-- | src/searchsup.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/searchsup.c b/src/searchsup.c index 585bcc6..efdde67 100644 --- a/src/searchsup.c +++ b/src/searchsup.c @@ -239,7 +239,7 @@ Return value: SCORE ComputeMoveScore(IN SEARCHER_THREAD_CONTEXT *ctx, IN MOVE mv, - IN ULONG uMoveNum) + IN ULONG uMoveNum) { SCORE iMoveScore = (PIECE_VALUE(mv.pCaptured) + PIECE_VALUE(mv.pPromoted)); @@ -247,8 +247,25 @@ ComputeMoveScore(IN SEARCHER_THREAD_CONTEXT *ctx, { ASSERT(uMoveNum < MAX_MOVE_STACK); ASSERT(IS_SAME_MOVE(mv, ctx->sMoveStack.mvf[uMoveNum].mv)); + ASSERT(ctx->uPly > 0); iMoveScore = ctx->sMoveStack.mvf[uMoveNum].iValue; - if ((iMoveScore >= SORT_THESE_FIRST) && IS_CAPTURE_OR_PROMOTION(mv)) + // Every current caller (search.c's EFP check, and + // ComputeMoveExtension's two ComputeMoveScore() call sites) only + // reaches here after MakeMove(ctx, mv) has already succeeded, so + // ctx->uPly is always the *child's* ply here -- uMoveNum indexes + // the parent's move list, i.e. ctx->uPly - 1, not ctx->uPly. That's + // the ply RescoreMovesViaSearch (if it ran) would have rescored, + // so that's the flag to check. + if (TRUE == ctx->sPlyInfo[ctx->uPly - 1].fMovesRescoredByIID) + { + // RescoreMovesViaSearch already put a real, searched eval-axis + // score here -- better than SEE/MVV-LVA, since it reflects an + // entire subtree, not just the immediate exchange. Trust it + // exactly as-is; don't run it through the capture-bias + // subtraction or collapse it via MIN0, both of which assume + // generate.c's ordering-encoded format, which this isn't. + } + else if ((iMoveScore >= SORT_THESE_FIRST) && IS_CAPTURE_OR_PROMOTION(mv)) { ASSERT(iMoveScore > 0); iMoveScore &= STRIP_OFF_FLAGS; @@ -668,7 +685,15 @@ Return value: ctx->sMoveStack.mvf[x].iValue = -INFINITY; x++; } - ctx->sMoveStack.mvf[uBest].iValue |= SORT_THESE_FIRST; + // uBest already holds the largest real score in the list (iBestScore + // tracked the running max as we went) -- SelectBest{With,No}History + // just compare raw magnitude, so it naturally sorts first without + // needing a flag. OR-ing in SORT_THESE_FIRST here used to corrupt + // that real score into looking like generate.c's biased-capture- + // ordering format to any later ComputeMoveScore() caller; removed. + // fMovesRescoredByIID (below) is the correct, non-destructive way to + // signal "trust this ply's iValue as a real eval-axis score." + ctx->sPlyInfo[ctx->uPly].fMovesRescoredByIID = TRUE; ASSERT(IS_VALID_SCORE(iBestScore)); return(iBestScore); } |
