1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Store only unchanged static evaluations in TT

A recent commit introduced a decrease of the static evaluation of
an inner node dependent on the previous stat score, which finally
was also stored in the transposition table. Now only the unchanged
static evaluation are stored there.

Remark:
For the case that a static evaluation can be retrieved from the
transposition table the value is now used unchanged. Another test
which also applies the modification in this case failed:
http://tests.stockfishchess.org/tests/view/5b7af6df0ebc5902bdbae2f6

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 6707 W: 1547 L: 1383 D: 3777
http://tests.stockfishchess.org/tests/view/5b7a92df0ebc5902bdbadcf3

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 36203 W: 6046 L: 5781 D: 24376
http://tests.stockfishchess.org/tests/view/5b7abaa10ebc5902bdbadfa9

Closes https://github.com/official-stockfish/Stockfish/pull/1742

Bench: 4457440
This commit is contained in:
Stefan Geschwentner 2018-08-20 12:06:52 +02:00 committed by Stéphane Nicolet
parent f3b8a69919
commit 28543cddc6

View file

@ -556,7 +556,7 @@ namespace {
Key posKey; Key posKey;
Move ttMove, move, excludedMove, bestMove; Move ttMove, move, excludedMove, bestMove;
Depth extension, newDepth; Depth extension, newDepth;
Value bestValue, value, ttValue, eval, maxValue; Value bestValue, value, ttValue, eval, maxValue, pureStaticEval;
bool ttHit, inCheck, givesCheck, improving; bool ttHit, inCheck, givesCheck, improving;
bool captureOrPromotion, doFullDepthSearch, moveCountPruning, skipQuiets, ttCapture, pvExact; bool captureOrPromotion, doFullDepthSearch, moveCountPruning, skipQuiets, ttCapture, pvExact;
Piece movedPiece; Piece movedPiece;
@ -705,15 +705,15 @@ namespace {
// Step 6. Static evaluation of the position // Step 6. Static evaluation of the position
if (inCheck) if (inCheck)
{ {
ss->staticEval = eval = VALUE_NONE; ss->staticEval = pureStaticEval = eval = VALUE_NONE;
improving = false; improving = false;
goto moves_loop; // Skip early pruning when in check goto moves_loop; // Skip early pruning when in check
} }
else if (ttHit) else if (ttHit)
{ {
// Never assume anything on values stored in TT // Never assume anything on values stored in TT
if ((ss->staticEval = eval = tte->eval()) == VALUE_NONE) if ((ss->staticEval = pureStaticEval = eval = tte->eval()) == VALUE_NONE)
eval = ss->staticEval = evaluate(pos) - 10 * ((ss-1)->statScore > 0); eval = ss->staticEval = (pureStaticEval = evaluate(pos)) - 10 * ((ss-1)->statScore > 0);
// Can ttValue be used as a better position evaluation? // Can ttValue be used as a better position evaluation?
if ( ttValue != VALUE_NONE if ( ttValue != VALUE_NONE
@ -726,10 +726,10 @@ namespace {
int malus = p > 0 ? (p + 5000) / 1024 : int malus = p > 0 ? (p + 5000) / 1024 :
p < 0 ? (p - 5000) / 1024 : 0; p < 0 ? (p - 5000) / 1024 : 0;
ss->staticEval = eval = (ss-1)->currentMove != MOVE_NULL ? evaluate(pos) - malus ss->staticEval = eval = (ss-1)->currentMove != MOVE_NULL ? (pureStaticEval = evaluate(pos)) - malus
: -(ss-1)->staticEval + 2 * Eval::Tempo; : (pureStaticEval = -(ss-1)->staticEval + 2 * Eval::Tempo);
tte->save(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, ss->staticEval); tte->save(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, pureStaticEval);
} }
// Step 7. Razoring (~2 Elo) // Step 7. Razoring (~2 Elo)
@ -1179,7 +1179,7 @@ moves_loop: // When in check, search starts from here
tte->save(posKey, value_to_tt(bestValue, ss->ply), tte->save(posKey, value_to_tt(bestValue, ss->ply),
bestValue >= beta ? BOUND_LOWER : bestValue >= beta ? BOUND_LOWER :
PvNode && bestMove ? BOUND_EXACT : BOUND_UPPER, PvNode && bestMove ? BOUND_EXACT : BOUND_UPPER,
depth, bestMove, ss->staticEval); depth, bestMove, pureStaticEval);
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE); assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);