X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=62788faac38f0002c2f416cfec421b83d3b76504;hp=08bf90f89845673b79b8197c40e17bab2eccc119;hb=79e3710fd224e6e052f6bc5420a8f8f03bf41e18;hpb=39257509452a81db28538462e6581b05d1a4b7fb diff --git a/src/search.cpp b/src/search.cpp index 08bf90f8..62788faa 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -683,6 +683,10 @@ namespace { TB::ProbeState err; TB::WDLScore wdl = Tablebases::probe_wdl(pos, &err); + // Force check of time on the next occasion + if (thisThread == Threads.main()) + static_cast(thisThread)->callsCnt = 0; + if (err != TB::ProbeState::FAIL) { thisThread->tbHits.fetch_add(1, std::memory_order_relaxed); @@ -944,8 +948,8 @@ moves_loop: // When in check, search starts from here && pos.see_ge(move)) extension = ONE_PLY; - else if ( pos.can_castle(us) // Extension for king moves that change castling rights - && type_of(movedPiece) == KING) + // Extension if castling + else if (type_of(move) == CASTLING) extension = ONE_PLY; // Calculate new depth for this move @@ -1391,21 +1395,15 @@ moves_loop: // When in check, search starts from here if (value > alpha) { + bestMove = move; + if (PvNode) // Update pv even in fail-high case update_pv(ss->pv, move, (ss+1)->pv); if (PvNode && value < beta) // Update alpha here! - { alpha = value; - bestMove = move; - } - else // Fail high - { - tte->save(posKey, value_to_tt(value, ss->ply), BOUND_LOWER, - ttDepth, move, ss->staticEval); - - return value; - } + else + break; // Fail high } } } @@ -1416,7 +1414,8 @@ moves_loop: // When in check, search starts from here return mated_in(ss->ply); // Plies to mate from the root tte->save(posKey, value_to_tt(bestValue, ss->ply), - PvNode && bestValue > oldAlpha ? BOUND_EXACT : BOUND_UPPER, + bestValue >= beta ? BOUND_LOWER : + PvNode && bestValue > oldAlpha ? BOUND_EXACT : BOUND_UPPER, ttDepth, bestMove, ss->staticEval); assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);