@@ -72,6 +72,7 @@ Value qsearch(Position &board, Value alpha, Value beta, search::Session &session
7272 session.qnodes ++;
7373 session.seldepth = std::max (session.seldepth , ply);
7474 if (((session.nodes & 2047 ) == 0 && session.tm .elapsed () >= session.tm .optimum ()) ||
75+ (session.tc .nodes > 0 && session.nodes >= session.tc .nodes ) ||
7576 stopSearch.load (std::memory_order_relaxed))
7677 return VALUE_NONE ;
7778
@@ -187,6 +188,7 @@ Value doSearch(
187188 if (depth <= 0 )
188189 return qsearch (board, alpha, beta, session, ply);
189190 if (((session.nodes & 2047 ) == 0 && session.tm .elapsed () >= session.tm .optimum ()) ||
191+ (session.tc .nodes > 0 && session.nodes >= session.tc .nodes ) ||
190192 stopSearch.load (std::memory_order_relaxed))
191193 return VALUE_NONE ;
192194
@@ -417,7 +419,8 @@ Value doSearch(
417419 } else if (movesSearched >= 6 ) {
418420 reduction = 1 + movesSearched / 8 ;
419421 }
420- reduction = std::clamp (reduction, 1 , depth - 2 );
422+ if (reduction > 0 )
423+ reduction = std::clamp (reduction, 1 , depth - 2 );
421424 }
422425
423426 int ext = 0 ;
@@ -569,7 +572,10 @@ void search(const chess::Position &board, const timeman::LimitsType timecontrol)
569572 Position board_ = board;
570573 Move best = Move::none ();
571574 Value bestScore = -VALUE_INFINITE ;
572- Session tmpSession{};
575+ double unusedTimeAdjust = -1 ;
576+ Session tmpSession;
577+ tmpSession.tc = session.tc ;
578+ tmpSession.tm .init (session.tc , board.side_to_move (), board.ply (), unusedTimeAdjust);
573579 for (Move move : moves) {
574580 if (!session.tc .searchmoves .empty () &&
575581 std::find (session.tc .searchmoves .begin (),
@@ -669,7 +675,10 @@ void search(const chess::Position &board, const timeman::LimitsType timecontrol)
669675 Position board_ = board;
670676 Move best = Move::none ();
671677 Value bestScore = -VALUE_INFINITE ;
672- Session tmpSession{};
678+ double unusedTimeAdjust = -1 ;
679+ Session tmpSession;
680+ tmpSession.tc = session.tc ;
681+ tmpSession.tm .init (session.tc , board.side_to_move (), board.ply (), unusedTimeAdjust);
673682 for (Move move : moves) {
674683 if (!session.tc .searchmoves .empty () &&
675684 std::find (session.tc .searchmoves .begin (),
0 commit comments