X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=72ec79e71f3e95539d0b05776147d3d51a040d41;hp=0d1a401c6b715c489426047e308e60490fea203c;hb=bbd69c0260a12cedf2b4d32b9ec3d478270533ce;hpb=7b0a2f2a90b63d9e5e092786fbfb54cd8ad3d8e5 diff --git a/src/search.cpp b/src/search.cpp index 0d1a401c..72ec79e7 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -43,7 +43,7 @@ namespace Search { std::vector RootMoves; Position RootPos; Color RootColor; - Time::point SearchTime, IterationTime; + Time::point SearchTime; StateStackPtr SetupStates; } @@ -185,6 +185,10 @@ void Search::think() { RootColor = RootPos.side_to_move(); TimeMgr.init(Limits, RootPos.game_ply(), RootColor); + int cf = Options["Contempt Factor"] * PawnValueMg / 100; // From centipawns + DrawValue[ RootColor] = VALUE_DRAW - Value(cf); + DrawValue[~RootColor] = VALUE_DRAW + Value(cf); + if (RootMoves.empty()) { RootMoves.push_back(MOVE_NONE); @@ -206,16 +210,6 @@ void Search::think() { } } - if (Options["Contempt Factor"] && !Options["UCI_AnalyseMode"]) - { - int cf = Options["Contempt Factor"] * PawnValueMg / 100; // From centipawns - cf = cf * Material::game_phase(RootPos) / PHASE_MIDGAME; // Scale down with phase - DrawValue[ RootColor] = VALUE_DRAW - Value(cf); - DrawValue[~RootColor] = VALUE_DRAW + Value(cf); - } - else - DrawValue[WHITE] = DrawValue[BLACK] = VALUE_DRAW; - if (Options["Write Search Log"]) { Log log(Options["Search Log Filename"]); @@ -397,7 +391,7 @@ namespace { sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; } - IterationTime = Time::now() - SearchTime; + Time::point iterationTime = Time::now() - SearchTime; // If skill levels are enabled and time is up, pick a sub-optimal best move if (skill.enabled() && skill.time_to_pick(depth)) @@ -432,7 +426,7 @@ namespace { // Stop the search if only one legal move is available or all // of the available time has been used. if ( RootMoves.size() == 1 - || IterationTime > TimeMgr.available_time() ) + || iterationTime > TimeMgr.available_time() ) stop = true; if (stop) @@ -668,7 +662,7 @@ namespace { && !ss->skipNullMove && abs(beta) < VALUE_MATE_IN_MAX_PLY) { - Value rbeta = beta + 200; + Value rbeta = std::min(beta + 200, VALUE_INFINITE); Depth rdepth = depth - ONE_PLY - 3 * ONE_PLY; assert(rdepth >= ONE_PLY); @@ -1627,8 +1621,7 @@ void check_time() { Time::point elapsed = Time::now() - SearchTime; bool stillAtFirstMove = Signals.firstRootMove && !Signals.failedLowAtRoot - && elapsed > TimeMgr.available_time() - && elapsed > IterationTime * 1.4; + && elapsed > TimeMgr.available_time() * 75 / 100; bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerThread::Resolution || stillAtFirstMove;