diff options
Diffstat (limited to 'src/search.c')
| -rwxr-xr-x | src/search.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/search.c b/src/search.c index 870951b..31220e1 100755 --- a/src/search.c +++ b/src/search.c @@ -275,15 +275,23 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, VERIFY(MakeMove(ctx, mvHash)); fIsDraw = IsDraw(ctx); UnmakeMove(ctx, mvHash); - if ((FALSE == fIsDraw) || (iScore == 0) || - ((u == HASH_FLAG_LOWER) && (iScore >= iBeta) && (0 >= iBeta)) || - ((u == HASH_FLAG_UPPER) && (iScore <= iAlpha) && (0 <= iAlpha))) + if ((FALSE == fIsDraw) || (iScore == g_iDrawScore[pos->uToMove]) || + ((u == HASH_FLAG_LOWER) && (iScore >= iBeta) && (g_iDrawScore[pos->uToMove] >= iBeta)) || + ((u == HASH_FLAG_UPPER) && (iScore <= iAlpha) && (g_iDrawScore[pos->uToMove] <= iAlpha))) { - if ((iAlpha < iScore) && (iScore < iBeta)) + // If the hash move leads to a draw, the score actually + // produced by playing it is g_iDrawScore[pos->uToMove] + // (from the mover's point of view), not the stale iScore + // recorded along whatever non-repeating path originally + // stored this entry -- the checks above only established + // that the draw score clears the same bound iScore does, + // not that iScore itself is an accurate value to return. + SCORE iRetScore = fIsDraw ? g_iDrawScore[pos->uToMove] : iScore; + if ((iAlpha < iRetScore) && (iRetScore < iBeta)) { UpdatePV(ctx, HASHMOVE); } - iBestScore = iScore; + iBestScore = iRetScore; goto end; } } @@ -949,7 +957,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, } else { - iBestScore = 0; + iBestScore = g_iDrawScore[pos->uToMove]; if ((iAlpha < iBestScore) && (iBestScore < iBeta)) { INC(ctx->sCounters.tree.u64LeafCount); |
