diff --git a/src/search.cpp b/src/search.cpp index 97b70b8fefd..5508478862f 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -945,18 +945,17 @@ namespace { if (move == excludedMove) continue; + // Check for legality + if (!pos.legal(move)) + continue; + // At root obey the "searchmoves" option and skip moves not listed in Root - // Move List. As a consequence, any illegal move is also skipped. In MultiPV - // mode we also skip PV moves that have been already searched and those - // of lower "TB rank" if we are in a TB root position. + // Move List. In MultiPV mode we also skip PV moves that have been already + // searched and those of lower "TB rank" if we are in a TB root position. if (rootNode && !std::count(thisThread->rootMoves.begin() + thisThread->pvIdx, thisThread->rootMoves.begin() + thisThread->pvLast, move)) continue; - // Check for legality - if (!rootNode && !pos.legal(move)) - continue; - ss->moveCount = ++moveCount; if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000)