diff --git a/src/search.cpp b/src/search.cpp index 0f2ab238..f316f749 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -466,7 +466,7 @@ Value Worker::search( if (!is_in_check) { correction = m_td.history.get_correction(pos); raw_eval = tt_data && !is_mate_score(tt_data->eval) ? tt_data->eval : evaluate(pos); - ss->static_eval = raw_eval + correction; + ss->static_eval = adj_shuffle(pos, raw_eval) + correction; improving = (ss - 2)->static_eval != -VALUE_INF && ss->static_eval > (ss - 2)->static_eval; if (!tt_data) { @@ -952,7 +952,7 @@ Value Worker::quiesce(const Position& pos, Stack* ss, Value alpha, Value beta, i if (!is_in_check) { correction = m_td.history.get_correction(pos); raw_eval = tt_data && !is_mate_score(tt_data->eval) ? tt_data->eval : evaluate(pos); - static_eval = raw_eval + correction; + static_eval = adj_shuffle(pos, raw_eval) + correction; if (!tt_data) { m_searcher.tt.store(pos, ply, raw_eval, Move::none(), -VALUE_INF, 0, ttpv, Bound::None); @@ -1045,5 +1045,19 @@ Value Worker::evaluate(const Position& pos) { return -VALUE_INF; // Not implemented in tune mode #endif } + +Value Worker::adj_shuffle(const Position& pos, Value value) { + // During datagen, use raw evals only. + // source: chef. + if (m_searcher.settings.datagen) { + return value; + } + + // Scale down the value when the fifty-move counter is high. + i32 clock = pos.get_50mr_counter(); + value = value * (200 - clock) / 200; + + return value; +} } // namespace Search } // namespace Clockwork diff --git a/src/search.hpp b/src/search.hpp index 8f1764fc..dff28fbb 100644 --- a/src/search.hpp +++ b/src/search.hpp @@ -193,6 +193,7 @@ class alignas(128) Worker { template Value quiesce(const Position& pos, Stack* ss, Value alpha, Value beta, i32 ply); Value evaluate(const Position& pos); + Value adj_shuffle(const Position& pos, Value value); bool check_tm_hard_limit(); };