summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rwxr-xr-xsrc/eval.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/eval.c b/src/eval.c
index b6a7792..48a21e0 100755
--- a/src/eval.c
+++ b/src/eval.c
@@ -5596,7 +5596,7 @@ Return value:
//
// Check the eval hash
//
- iScoreForSideToMove = ProbeEvalHash(ctx);
+ iScoreForSideToMove = ProbeEvalHash(ctx, iAlpha, iBeta);
if (iScoreForSideToMove != INVALID_SCORE)
{
INC(ctx->sCounters.tree.u64EvalHashHits);
@@ -5714,12 +5714,32 @@ Return value:
//
_QuicklyEstimateKingSafetyTerm(pos, &iAlphaMargin, &iBetaMargin);
_QuicklyEstimatePasserBonuses(pos, pHash, &iAlphaMargin, &iBetaMargin);
-
- if ((iScoreForSideToMove + iAlphaMargin <= iAlpha) ||
- (iScoreForSideToMove - iBetaMargin >= iBeta))
+
+ if (iScoreForSideToMove + iAlphaMargin <= iAlpha)
{
ctx->uPositional = MINU(200, ctx->uPositional);
INC(ctx->sCounters.tree.u64LazyEvals);
+#ifdef EVAL_HASH
+ //
+ // The true eval can't reach iAlpha; that's a fact about
+ // the position (not this particular window), so remember
+ // it as a proven upper bound for reuse by later probes.
+ //
+ StoreEvalHash(ctx, iScoreForSideToMove,
+ (SCORE)(iScoreForSideToMove + iAlphaMargin),
+ EVAL_HASH_UPPER);
+#endif
+ goto end;
+ }
+ else if (iScoreForSideToMove - iBetaMargin >= iBeta)
+ {
+ ctx->uPositional = MINU(200, ctx->uPositional);
+ INC(ctx->sCounters.tree.u64LazyEvals);
+#ifdef EVAL_HASH
+ StoreEvalHash(ctx, iScoreForSideToMove,
+ (SCORE)(iScoreForSideToMove - iBetaMargin),
+ EVAL_HASH_LOWER);
+#endif
goto end;
}
}
@@ -6102,7 +6122,7 @@ Return value:
//
// Store in eval hash.
//
- StoreEvalHash(ctx, iScoreForSideToMove);
+ StoreEvalHash(ctx, iScoreForSideToMove, 0, EVAL_HASH_EXACT);
#endif
end: