diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 5f8db741..69c32785 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -28,8 +28,7 @@ #include "evaluate.h" #include "material.h" #include "pawns.h" - -std::atomic Eval::Contempt; +#include "thread.h" namespace Trace { @@ -844,7 +843,7 @@ namespace { // Initialize score by reading the incrementally updated scores included in // the position object (material + piece square tables) and the material // imbalance. Score is computed internally from the white point of view. - Score score = pos.psq_score() + me->imbalance() + Eval::Contempt; + Score score = pos.psq_score() + me->imbalance() + pos.this_thread()->contempt; // Probe the pawn hash table pe = Pawns::probe(pos); @@ -915,7 +914,7 @@ std::string Eval::trace(const Position& pos) { std::memset(scores, 0, sizeof(scores)); - Eval::Contempt = SCORE_ZERO; // Reset any dynamic contempt + pos.this_thread()->contempt = SCORE_ZERO; // Reset any dynamic contempt Value v = Evaluation(pos).value(); diff --git a/src/evaluate.h b/src/evaluate.h index c3b0b2b9..ccc6d5fa 100644 --- a/src/evaluate.h +++ b/src/evaluate.h @@ -32,8 +32,6 @@ namespace Eval { constexpr Value Tempo = Value(20); // Must be visible to search -extern std::atomic Contempt; - std::string trace(const Position& pos); Value evaluate(const Position& pos); diff --git a/src/search.cpp b/src/search.cpp index af0946ea..66c40693 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -309,8 +309,8 @@ void Thread::search() { multiPV = std::min(multiPV, rootMoves.size()); int ct = Options["Contempt"] * PawnValueEg / 100; // From centipawns - Eval::Contempt = (us == WHITE ? make_score(ct, ct / 2) - : -make_score(ct, ct / 2)); + contempt = (us == WHITE ? make_score(ct, ct / 2) + : -make_score(ct, ct / 2)); // Iterative deepening loop until requested to stop or the target depth is reached while ( (rootDepth += ONE_PLY) < DEPTH_MAX @@ -353,8 +353,8 @@ void Thread::search() { // Adjust contempt based on root move's previousScore (dynamic contempt) ct += int(std::round(48 * atan(float(previousScore) / 128))); - Eval::Contempt = (us == WHITE ? make_score(ct, ct / 2) - : -make_score(ct, ct / 2)); + contempt = (us == WHITE ? make_score(ct, ct / 2) + : -make_score(ct, ct / 2)); } // Start with a small aspiration window and, in the case of a fail diff --git a/src/thread.h b/src/thread.h index 13974497..0d507739 100644 --- a/src/thread.h +++ b/src/thread.h @@ -71,6 +71,7 @@ public: ButterflyHistory mainHistory; CapturePieceToHistory captureHistory; ContinuationHistory contHistory; + Score contempt; };