diff options
| author | Scott Gasch <[email protected]> | 2026-08-30 18:51:38 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-08-30 18:51:38 -0700 |
| commit | dbf71219abeb51d386b0f7294f1664f2906d2b82 (patch) | |
| tree | 77dc53e1cb3f223ee04a45130b559b08c91991cc /src/searchsup.c | |
| parent | fd1460b2c135f6cef502fd167d1df0edf223e312 (diff) | |
Plumb iImprovement into LMR and futiltiy and parallel search.
Fix a bug (iEval) in HelpSearch
This commit changes the heuristics for: nullmove pruning, LMR, and EFP slightly.
Diffstat (limited to 'src/searchsup.c')
| -rw-r--r-- | src/searchsup.c | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/src/searchsup.c b/src/searchsup.c index d2cbbbd..9ad4303 100644 --- a/src/searchsup.c +++ b/src/searchsup.c @@ -188,15 +188,16 @@ ThreadUnderTerminatingSplit(IN SEARCHER_THREAD_CONTEXT *ctx) INT -GetLMRReduction(IN SCORE iRoughEval, - IN SCORE iAlpha, - IN SCORE iBeta, - IN SEARCHER_THREAD_CONTEXT *ctx, - IN ULONG uRemainingDepth, - IN ULONG uLegalMoves, - IN MOVE mv, - IN ULONG uMoveNum, - IN INT iExtend) +GetLMRReduction(IN SCORE iEval, + IN SCORE iAlpha, + IN SCORE iBeta, + IN SCORE iImprovement, + IN SEARCHER_THREAD_CONTEXT *ctx, + IN ULONG uRemainingDepth, + IN ULONG uLegalMoves, + IN MOVE mv, + IN ULONG uMoveNum, + IN INT iExtend) /** Routine description: @@ -206,6 +207,8 @@ Routine description: counter-move exemption. Kept under the GetLMRReduction name so search.c/split.c's call sites need no changes. + Note: the move has already been made by the time we get here. + Return value: INT : 0 if no reduction, else -ONE_PLY. @@ -215,6 +218,7 @@ Return value: ASSERT(ctx->uPly > 0); ASSERT(mv.uMove); ASSERT((uMoveNum > 0) || (uLegalMoves == 0)); + if ((uRemainingDepth >= TWO_PLY) && (FALSE == ctx->sPlyInfo[ctx->uPly - 1].fPvNode) && (uLegalMoves > 5) && @@ -230,6 +234,9 @@ Return value: (GetMoveFailHighPercentage(mv, NULL) <= 10)) { ASSERT(!InCheck(&ctx->sPosition, ctx->sPosition.uToMove)); + if (iImprovement <= 40) { + return(-(ONE_PLY + QUARTER_PLY)); + } return(-ONE_PLY); } return(0); @@ -369,15 +376,14 @@ Return value: } -void -ComputeMoveExtension(IN SEARCHER_THREAD_CONTEXT *ctx, - IN SCORE iAlpha, - IN SCORE iBeta, - IN ULONG uMoveNum, - IN SCORE iRoughEval, - IN ULONG uDepth, - IN SCORE iCheckSee, - IN OUT INT *piExtend) +void ComputeMoveExtension(IN SEARCHER_THREAD_CONTEXT *ctx, + IN SCORE iAlpha, + IN SCORE iBeta, + IN ULONG uMoveNum, + IN SCORE iRoughEval, + IN ULONG uDepth, + IN SCORE iCheckSee, + IN OUT INT *piExtend) /** Routine description: @@ -482,13 +488,13 @@ Return value: { ASSERT(IS_ESCAPING_CHECK(mv)); iMoveScore = iRoughEval + ComputeMoveScore(ctx, mv, uMoveNum); - + // One legal move in reply to check... if (ONE_LEGAL_MOVE(ctx, ctx->uPly - 1) && - CountKingSafetyDefects(&ctx->sPosition, uColor) > 1) + CountKingSafetyDefects(&ctx->sPosition, uColor) > 1) { *piExtend += (QUARTER_PLY + - HALF_PLY * + HALF_PLY * (iMoveScore + VALUE_KNIGHT > iAlpha)); INC(ctx->sCounters.extension.uOneLegalMove); } @@ -511,7 +517,7 @@ Return value: { // Endgame extension if ((ctx->sPlyInfo[1].uTotalNonPawns > 2) && - ((pos->uNonPawnCount[BLACK][0] + + ((pos->uNonPawnCount[BLACK][0] + pos->uNonPawnCount[WHITE][0]) == 2)) { if ((mv.pCaptured && !IS_PAWN(mv.pCaptured)) || @@ -529,7 +535,7 @@ Return value: if (uDepth <= THREE_PLY) { if ((mv.pCaptured) && !IS_PAWN(mv.pCaptured) && - ((PIECE_VALUE(mv.pCaptured) == + ((PIECE_VALUE(mv.pCaptured) == PIECE_VALUE(mvLast.pCaptured)) || ((mvLast.pPromoted) && (mv.cTo == mvLast.cTo)))) { @@ -1092,11 +1098,11 @@ SelectNullmoveRFactor(SEARCHER_THREAD_CONTEXT *ctx, FLAG WeShouldTryNullmovePruning(SEARCHER_THREAD_CONTEXT *ctx, SCORE iAlpha, SCORE iBeta, - SCORE iRoughEval, - SCORE iImprovement, - ULONG uNullDepth) + SCORE iEval, + SCORE iImprovement, + ULONG uNullDepth) { - static SCORE iSkipNullMargins[] = { + static SCORE iSkipShallowNullIfThisFarBelowAlpha[] = { 700, 950, 1110, 1150, 1190, 1230, 1270, 0 }; POSITION *pos = &ctx->sPosition; @@ -1113,20 +1119,17 @@ FLAG WeShouldTryNullmovePruning(SEARCHER_THREAD_CONTEXT *ctx, (pos->uNonPawnCount[pos->uToMove][0] > 2) && (FALSE == pi->fInCheck) && (iBeta != +INFINITY) && - (FALSE == pi->fPvNode)) // <--- TODO: test this one please... + (FALSE == pi->fPvNode)) { if (uNullDepth <= 6 * ONE_PLY) { u = uNullDepth / ONE_PLY; ASSERT(u <= 6); - SCORE iMargin = iSkipNullMargins[u]; - if (iImprovement > 0) - { - iMargin -= iImprovement; - iMargin = MAX(0, iMargin); - } - if ((iRoughEval + iMargin <= iAlpha) || - ((iRoughEval + iMargin / 2 <= iAlpha) && + SCORE iMargin = iSkipShallowNullIfThisFarBelowAlpha[u]; + iMargin -= iImprovement; // Note: if improving, makes null more likely + iMargin = MAX(0, iMargin); // if not, less likely. + if ((iEval + iMargin <= iAlpha) || + ((iEval + iMargin / 2 <= iAlpha) && (ValueOfMaterialInTroubleAfterNull(ctx, pos->uToMove)))) { return FALSE; |
