X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=668fd0955687523cd8d8779dccb1c65aea64e6fb;hp=0d1a401c6b715c489426047e308e60490fea203c;hb=b917cd275e6f9825bc860d2fc7b7d67dacef2915;hpb=7b0a2f2a90b63d9e5e092786fbfb54cd8ad3d8e5 diff --git a/src/search.cpp b/src/search.cpp index 0d1a401c..668fd095 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; } @@ -206,10 +206,10 @@ void Search::think() { } } - if (Options["Contempt Factor"] && !Options["UCI_AnalyseMode"]) + if (!Options["UCI_AnalyseMode"]) { - int cf = Options["Contempt Factor"] * PawnValueMg / 100; // From centipawns - cf = cf * Material::game_phase(RootPos) / PHASE_MIDGAME; // Scale down with phase + // Dynamic draw value: try to avoid repetition draws at early midgame + int cf = std::max(70 - RootPos.game_ply(), 0); DrawValue[ RootColor] = VALUE_DRAW - Value(cf); DrawValue[~RootColor] = VALUE_DRAW + Value(cf); } @@ -397,7 +397,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 +432,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 +668,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 +1627,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;