From: Fabian Fichter Date: Wed, 11 Nov 2020 19:17:25 +0000 (+0100) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=8817da450b91bfc2bb0fdab8e286c2c7d8566f38;p=fairystockfish.git Merge official-stockfish/master bench: 3828292 --- 8817da450b91bfc2bb0fdab8e286c2c7d8566f38 diff --cc src/position.cpp index f970b4b,5ce7da2..017382a --- a/src/position.cpp +++ b/src/position.cpp @@@ -99,8 -77,10 +99,10 @@@ std::ostream& operator<<(std::ostream& && !pos.can_castle(ANY_CASTLING)) { StateInfo st; + ASSERT_ALIGNED(&st, Eval::NNUE::kCacheLineSize); + Position p; - p.set(pos.fen(), pos.is_chess960(), &st, pos.this_thread()); + p.set(pos.variant(), pos.fen(), pos.is_chess960(), &st, pos.this_thread()); Tablebases::ProbeState s1, s2; Tablebases::WDLScore wdl = Tablebases::probe_wdl(p, &s1); int dtz = Tablebases::probe_dtz(p, &s2); diff --cc src/search.cpp index 0878a93,66ef504..3f58f09 --- a/src/search.cpp +++ b/src/search.cpp @@@ -549,38 -521,14 +551,42 @@@ void Thread::search() } double bestMoveInstability = 1 + 2 * totBestMoveChanges / Threads.size(); - double totalTime = rootMoves.size() == 1 ? 0 : - Time.optimum() * fallingEval * reduction * bestMoveInstability; + double totalTime = Time.optimum() * fallingEval * reduction * bestMoveInstability; + + // Cap used time in case of a single legal move for a better viewer experience in tournaments + // yielding correct scores and sufficiently fast moves. + if (rootMoves.size() == 1) + totalTime = std::min(500.0, totalTime); + if (completedDepth >= 8 && rootPos.two_boards() && Options["Protocol"] == "xboard") + { + if (Limits.time[us]) + Partner.ptell("time " + std::to_string((Limits.time[us] - Time.elapsed()) / 10)); + if (Limits.time[~us]) + Partner.ptell("otim " + std::to_string(Limits.time[~us] / 10)); + if (!Partner.weDead && bestValue <= VALUE_MATED_IN_MAX_PLY) + { + Partner.ptell("dead"); + Partner.weDead = true; + } + else if (Partner.weDead && bestValue > VALUE_MATED_IN_MAX_PLY) + { + Partner.ptell("x"); + Partner.weDead = false; + } + else if (!Partner.weWin && bestValue >= VALUE_MATE_IN_MAX_PLY && Limits.time[~us] < Partner.time * 10) + { + Partner.ptell("sit"); + Partner.weWin = true; + } + else if (Partner.weWin && (bestValue < VALUE_MATE_IN_MAX_PLY || Limits.time[~us] > Partner.time * 10)) + { + Partner.ptell("x"); + Partner.weWin = false; + } + } + - // Stop the search if we have exceeded the totalTime, at least 1ms search + // Stop the search if we have exceeded the totalTime if (Time.elapsed() > totalTime) { // If we are allowed to ponder do not stop the search now but @@@ -1603,11 -1529,8 +1617,11 @@@ moves_loop: // When in check, search st moveCount++; // Futility pruning - if ( !ss->inCheck + if ( bestValue > VALUE_TB_LOSS_IN_MAX_PLY && !givesCheck + && !( pos.extinction_value() == -VALUE_MATE + && pos.piece_on(to_sq(move)) + && pos.extinction_piece_types().find(type_of(pos.piece_on(to_sq(move)))) != pos.extinction_piece_types().end()) && futilityBase > -VALUE_KNOWN_WIN && !pos.advanced_pawn_push(move)) { @@@ -1656,9 -1579,9 +1670,9 @@@ // CounterMove based pruning if ( !captureOrPromotion - && moveCount + && bestValue > VALUE_TB_LOSS_IN_MAX_PLY - && (*contHist[0])[pos.moved_piece(move)][to_sq(move)] < CounterMovePruneThreshold - && (*contHist[1])[pos.moved_piece(move)][to_sq(move)] < CounterMovePruneThreshold) + && (*contHist[0])[history_slot(pos.moved_piece(move))][to_sq(move)] < CounterMovePruneThreshold + && (*contHist[1])[history_slot(pos.moved_piece(move))][to_sq(move)] < CounterMovePruneThreshold) continue; // Make and search the move @@@ -1691,7 -1614,11 +1705,11 @@@ // All legal moves have been searched. A special case: if we're in check // and no legal moves were found, it is checkmate. if (ss->inCheck && bestValue == -VALUE_INFINITE) + { + assert(!MoveList(pos).size()); + - return mated_in(ss->ply); // Plies to mate from the root + return pos.checkmate_value(ss->ply); // Plies to mate from the root + } tte->save(posKey, value_to_tt(bestValue, ss->ply), pvHit, bestValue >= beta ? BOUND_LOWER :