From bd3fd8ba790b32efe040d6c49257a37037c0046a Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 2 Jan 2026 09:24:56 +0100 Subject: [PATCH] Extract bestMove and ponderMove after the PV. Extracting ponderMove may have the unintentional effect of extending the PV by one move (which should not be displayed), so we need to extract it after we've extracted the PV. We still need to both before the MPI exchange, though. Patch by vondele, merely committed by me. --- src/search.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index fd9151407..bc5c3c3a5 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -246,12 +246,6 @@ void Search::Worker::start_searching() { main_manager()->bestPreviousScore = bestThread->rootMoves[0].score; main_manager()->bestPreviousAverageScore = bestThread->rootMoves[0].averageScore; - Move bestMove = bestThread->rootMoves[0].pv[0]; - Move ponderMove = Move::none(); - if (bestThread->rootMoves[0].pv.size() > 1 - || bestThread->rootMoves[0].extract_ponder_from_tt(tt, rootPos)) - ponderMove = bestThread->rootMoves[0].pv[1]; - // Temporarily switch out onUpdateFull to capture the PV information that we need, // so that we can exchange it through MPI. (We may end up not actually printing // it out.) @@ -264,6 +258,12 @@ void Search::Worker::start_searching() { assert(!serializedInfo.empty()); main_manager()->updates.onUpdateFull = std::move(oldOnUpdateFull); + Move bestMove = bestThread->rootMoves[0].pv[0]; + Move ponderMove = Move::none(); + if (bestThread->rootMoves[0].pv.size() > 1 + || bestThread->rootMoves[0].extract_ponder_from_tt(tt, rootPos)) + ponderMove = bestThread->rootMoves[0].pv[1]; + // Exchange info as needed Distributed::MoveInfo mi{bestMove.raw(), ponderMove.raw(), bestThread->completedDepth, bestThread->rootMoves[0].score, Distributed::rank()};