diff --git a/source/search.cpp b/source/search.cpp index 7433bd1..5072eca 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -690,6 +690,15 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC seenCapturesCount++; } + results.score = std::max(score, results.score); + + if (score > alpha) { + nodeType = PV; + alpha = score; + results.bestMove = currMove; + ctx->pvLine.SetMove(ply, currMove); + } + // Fail high (beta cutoff) if (score >= beta) { int bonus = historyBonusMultiplier * (depth + (!board.InCheck() && staticEval <= alpha)) - historyBonusSub; @@ -775,15 +784,6 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC ctx->TT->WriteEntry(board.hashKey, depth, score, CutNode, currMove, ttpv); return score; } - - results.score = std::max(score, results.score); - - if (score > alpha) { - nodeType = PV; - alpha = score; - results.bestMove = currMove; - ctx->pvLine.SetMove(ply, currMove); - } } if (moveSeen == 0) {