diff options
Diffstat (limited to 'src/search.c')
| -rwxr-xr-x | src/search.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/search.c b/src/search.c index 61fa428..ab7d122 100755 --- a/src/search.c +++ b/src/search.c @@ -358,7 +358,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, if (iScore > iBeta) { StoreLowerBound(mvHash, pos, iScore, uDepth, FALSE); } - iBestScore = iScore; // TODO: try just beta here + iBestScore = iScore; goto end; } } @@ -516,8 +516,8 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, (ctx->uPly >= 2) && (ctx->sPlyInfo[ctx->uPly - 2].iExtensionAmount <= 0)) { - if ((uDepth > THREE_QUARTERS_PLY) && - (uDepth <= ONE_PLY + THREE_QUARTERS_PLY) && + ASSERT(uDepth >= THREE_QUARTERS_PLY); + if ((uDepth <= ONE_PLY + THREE_QUARTERS_PLY) && (iRoughEval + VALUE_KNIGHT <= iAlpha)) { uFutilityMargin = (iAlpha - iRoughEval) / 2; @@ -762,9 +762,9 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, (uFutilityMargin) && (TRUE == fIsLeftoverMove) && (iExtend <= 0) && - (!IS_ESCAPING_CHECK(mv)) && + (!IS_ESCAPING_CHECK(mv)) && (!IS_CAPTURE_OR_PROMOTION(mv)) && - (!IS_CHECKING_MOVE(mv)) && + (!IS_CHECKING_MOVE(mv)) && (!fThreat) && (ComputeMoveScore(ctx, mv, (x - 1)) < uFutilityMargin)) { @@ -843,7 +843,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, iBestScore = iScore; mvBest = mv; pi->mvBest = mv; - + if (iScore > iAlpha) { if (iScore >= iBeta) @@ -919,6 +919,11 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, ASSERT(IS_CHECKING_MOVE(mvLast)); ASSERT(InCheck(pos, pos->uToMove)); iBestScore = MATED_SCORE(ctx->uPly); + if ((iAlpha < iBestScore) && (iBestScore < iBeta)) + { + INC(ctx->sCounters.tree.u64LeafCount); + UpdatePV(ctx, MATEMOVE); + } ASSERT(iBestScore <= -NMATE); goto end; } @@ -927,6 +932,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, iBestScore = 0; if ((iAlpha < iBestScore) && (iBestScore < iBeta)) { + INC(ctx->sCounters.tree.u64LeafCount); UpdatePV(ctx, DRAWMOVE); } goto end; @@ -1460,7 +1466,6 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx, // If we see a move whose value is zero, the rest of the moves // in this ply can be tossed. ASSERT(SanityCheckMoves(ctx, x, VERIFY_BEFORE | VERIFY_AFTER)); - ASSERT(iBestScore > -NMATE); goto end; } mv = ctx->sMoveStack.mvf[x].mv; @@ -1522,7 +1527,6 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx, mv.cTo); } KEEP_TRACK_OF_FIRST_MOVE_FHs(uLegalMoves == 1); - ASSERT(iBestScore > -NMATE); ASSERT(SanityCheckMoves(ctx, x, VERIFY_BEFORE)); goto end; } @@ -1546,7 +1550,6 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx, } } } - ASSERT(iBestScore > -NMATE); ASSERT(SanityCheckMoves(ctx, x, VERIFY_BEFORE)); end: @@ -1554,5 +1557,10 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx, ASSERT(PositionsAreEquivalent(pos, &pi->sPosition)); ASSERT(IS_VALID_SCORE(iBestScore) || WE_SHOULD_STOP_SEARCHING); DTLeaveNode(ctx, TRUE, iBestScore, pi->mvBest); + + // Note: iBestScore can be +INFINITY or -INFINITY here even in the + // absence of a legitimate mate detected if we disallowed stand + // pat due to perceived danger early on, when the a..b window had + // an extreme bound. This is "legitimate" but weird. return(iBestScore); } |
