X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsearch.cpp;h=f0c1bdd978e14fdc661c2a4041bb220fce343055;hb=926f215061311392bc26c7bc4bde5b719dbab4e5;hp=4590bd4a1905c6f3e0baa5931f3284487565fe68;hpb=df722521ba7027df394ed6370571cb5dc2ed6da1;p=stockfish diff --git a/src/search.cpp b/src/search.cpp index 4590bd4a..f0c1bdd9 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -129,7 +129,6 @@ namespace { }; size_t PVIdx; - TimeManagement Time; EasyMoveManager EasyMove; double BestMoveChanges; Value DrawValue[COLOR_NB]; @@ -218,11 +217,12 @@ template uint64_t Search::perft(Position& pos, Depth depth); void Search::think() { - Time.init(Limits, RootPos.side_to_move(), RootPos.game_ply(), now()); + Color us = RootPos.side_to_move(); + Time.init(Limits, us, RootPos.game_ply(), now()); int contempt = Options["Contempt"] * PawnValueEg / 100; // From centipawns - DrawValue[ RootPos.side_to_move()] = VALUE_DRAW - Value(contempt); - DrawValue[~RootPos.side_to_move()] = VALUE_DRAW + Value(contempt); + DrawValue[ us] = VALUE_DRAW - Value(contempt); + DrawValue[~us] = VALUE_DRAW + Value(contempt); TB::Hits = 0; TB::RootInTB = false; @@ -291,6 +291,11 @@ void Search::think() { Threads.timer->run = false; } + // When playing in 'nodes as time' mode, subtract the searched nodes from + // the available ones before to exit. + if (Limits.npmsec) + Time.availableNodes += Limits.inc[us] - RootPos.nodes_searched(); + // When we reach the maximum depth, we can arrive here without a raise of // Signals.stop. However, if we are pondering or in an infinite search, // the UCI protocol states that we shouldn't print the best move before the