diff options
Diffstat (limited to 'src/movesup.c')
| -rwxr-xr-x | src/movesup.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/movesup.c b/src/movesup.c index dec090c..33deae2 100755 --- a/src/movesup.c +++ b/src/movesup.c @@ -1017,11 +1017,36 @@ Return value: SCORE iVal; MOVE mv; MOVE_STACK_MOVE_VALUE_FLAGS mvfTemp; + MOVE mvLast; + ULONG uPrevContKey = 0; + FLAG fHaveContinuation = FALSE; + COOR cEnprise; ASSERT(ctx->sMoveStack.uBegin[ctx->uPly] <= uEnd); ASSERT(u >= ctx->sMoveStack.uBegin[ctx->uPly]); ASSERT(u < uEnd); + // Continuation history: "did a move like this tend to fail high + // right after a move like that?", keyed by (previous move, this + // move) at the same [piece][to] coarseness g_HistoryCounters + // already uses. Same accumulation/decay math as g_HistoryCounters + // (see _IncrementContinuationCounter/_DecrementContinuationCounter, + // dynamic.c) so its magnitude is empirically self-calibrated rather + // than a hand-picked constant -- a pair seen once contributes + // almost nothing, a pair that's fail-highed repeatedly at real + // depth naturally grows to compete with PSQT+history. + if ((ctx->uPly > 0) && (0 != (mvLast = (ctx->sPlyInfo[ctx->uPly - 1]).mv).uMove)) + { + uPrevContKey = MOVE_TO_CONT_KEY(mvLast); + fHaveContinuation = TRUE; + } + + // Flee-to-safety: a small, same-tier selection-time nudge (not a + // GOOD_MOVE promotion -- that class was retired, see generate.c's + // RETIRED comment) for a quiet move whose origin square is + // currently en prise. + cEnprise = FindEnprisePiece(ctx, ctx->sPosition.uToMove); + // // Linear search from u..ctx->sMoveStack.uEnd[ctx->uPly] for the // move with the best value. @@ -1031,6 +1056,16 @@ Return value: if (!IS_CAPTURE_OR_PROMOTION(mv)) { iBestVal += g_HistoryCounters[mv.pMoved][mv.cTo]; + if (TRUE == fHaveContinuation) + { + iBestVal += CONTINUATION_SCALE * + g_ContinuationHistory[(uPrevContKey * CONT_KEY_RANGE) + + MOVE_TO_CONT_KEY(mv)]; + } + if (mv.cFrom == cEnprise) + { + iBestVal += FLEE_BONUS; + } } uLoc = u; @@ -1041,6 +1076,15 @@ Return value: if (!IS_CAPTURE_OR_PROMOTION(mv)) { iVal += g_HistoryCounters[mv.pMoved][mv.cTo]; + if (TRUE == fHaveContinuation) + { + iVal += g_ContinuationHistory[(uPrevContKey * CONT_KEY_RANGE) + + MOVE_TO_CONT_KEY(mv)]; + } + if (mv.cFrom == cEnprise) + { + iVal += FLEE_BONUS; + } } if (iVal > iBestVal) { |
