multiPV = std::min(multiPV, rootMoves.size());
// Iterative deepening loop until requested to stop or the target depth is reached
- while ( (rootDepth += ONE_PLY) < DEPTH_MAX
+ while ( (rootDepth = rootDepth + ONE_PLY) < DEPTH_MAX
&& !Signals.stop
&& (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth))
{
{
bestValue = ::search<PV>(rootPos, ss, alpha, beta, rootDepth, false, false);
+ this->tbHits = rootPos.tb_hits();
+ this->nodes = rootPos.nodes_searched();
+
// Bring the best move to the front. It is critical that sorting
// is done with a stable algorithm because all the values but the
// first and eventually the new best one are set to -VALUE_INFINITE
Depth extension, newDepth;
Value bestValue, value, ttValue, eval;
bool ttHit, inCheck, givesCheck, singularExtensionNode, improving;
- bool captureOrPromotion, doFullDepthSearch, moveCountPruning, skipQuiets;
+ bool captureOrPromotion, doFullDepthSearch, moveCountPruning, skipQuiets, ttCapture;
Piece moved_piece;
int moveCount, quietCount;
{
thisThread->resetCalls = false;
+ thisThread->tbHits = pos.tb_hits();
+ thisThread->nodes = pos.nodes_searched();
+
// At low node count increase the checking rate to about 0.1% of nodes
// otherwise use a default value.
thisThread->callsCnt = Limits.nodes ? std::min(4096, int(Limits.nodes / 1024))
if (err != TB::ProbeState::FAIL)
{
- thisThread->tbHits++;
+ pos.increment_tbHits();
int drawScore = TB::UseRule50 ? 1 : 0;
&& (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 3 * ONE_PLY;
skipQuiets = false;
+ ttCapture = false;
// Step 11. Loop through moves
// Loop through all pseudo-legal moves until no moves remain or a beta cutoff occurs
ss->moveCount = --moveCount;
continue;
}
+
+ if (move == ttMove && captureOrPromotion)
+ ttCapture = true;
// Update the current move (this must be done after singular extension search)
ss->currentMove = move;
r -= r ? ONE_PLY : DEPTH_ZERO;
else
{
+
+ // Increase reduction if ttMove is a capture
+ if (ttCapture)
+ r += ONE_PLY;
+
// Increase reduction for cut nodes
if (cutNode)
r += 2 * ONE_PLY;
{
assert(is_ok(move));
- // Speculative prefetch as early as possible
- prefetch(TT.first_entry(pos.key_after(move)));
-
givesCheck = type_of(move) == NORMAL && !pos.discovered_check_candidates()
? pos.check_squares(type_of(pos.piece_on(from_sq(move)))) & to_sq(move)
: pos.gives_check(move);
&& !pos.see_ge(move))
continue;
+ // Speculative prefetch as early as possible
+ prefetch(TT.first_entry(pos.key_after(move)));
+
// Check for legality just before making the move
if (!pos.legal(move))
{
void check_time() {
- static TimePoint lastInfoTime = now();
+ static std::atomic<TimePoint> lastInfoTime = { now() };
int elapsed = Time.elapsed();
TimePoint tick = Limits.startTime + elapsed;