X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=6cab3f6cf7496713c1ac033bd3866ea2a9d22323;hp=62948590a494c6fc48968abdd0aa3db810006a92;hb=d53c928261a3a1b50304ec0a69312b6c2c338ccb;hpb=bc8f5fe0bfd2690d1fcfe3541b54193a05322102;ds=sidebyside diff --git a/src/search.cpp b/src/search.cpp index 62948590..6cab3f6c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -528,7 +528,7 @@ namespace { Bound bt; Value bestValue, value, oldAlpha, ttValue; Value refinedValue, nullValue, futilityBase, futilityValue; - bool isPvMove, inCheck, singularExtensionNode, givesCheck; + bool pvMove, inCheck, singularExtensionNode, givesCheck; bool captureOrPromotion, dangerous, doFullDepthSearch; int moveCount = 0, playedMoveCount = 0; Thread* thisThread = pos.this_thread(); @@ -818,12 +818,12 @@ split_point_start: // At split points actual search starts from here if (RootNode && !std::count(RootMoves.begin() + PVIdx, RootMoves.end(), move)) continue; - // At PV and SpNode nodes we want all moves to be legal since the beginning - if ((PvNode || SpNode) && !pos.pl_move_is_legal(move, ci.pinned)) - continue; - if (SpNode) { + // Shared counter cannot be decremented later if move turns out to be illegal + if (!pos.pl_move_is_legal(move, ci.pinned)) + continue; + moveCount = ++sp->moveCount; sp->mutex.unlock(); } @@ -840,7 +840,6 @@ split_point_start: // At split points actual search starts from here << " currmovenumber " << moveCount + PVIdx << sync_endl; } - isPvMove = (PvNode && moveCount <= 1); captureOrPromotion = pos.is_capture_or_promotion(move); givesCheck = pos.move_gives_check(move, ci); dangerous = givesCheck || is_dangerous(pos, move, captureOrPromotion); @@ -929,6 +928,7 @@ split_point_start: // At split points actual search starts from here continue; } + pvMove = PvNode ? moveCount <= 1 : false; ss->currentMove = move; if (!SpNode && !captureOrPromotion && playedMoveCount < 64) movesSearched[playedMoveCount++] = move; @@ -939,7 +939,7 @@ split_point_start: // At split points actual search starts from here // Step 15. Reduced depth search (LMR). If the move fails high will be // re-searched at full depth. if ( depth > 3 * ONE_PLY - && !isPvMove + && !pvMove && !captureOrPromotion && !dangerous && ss->killers[0] != move @@ -955,7 +955,7 @@ split_point_start: // At split points actual search starts from here ss->reduction = DEPTH_ZERO; } else - doFullDepthSearch = !isPvMove; + doFullDepthSearch = !pvMove; // Step 16. Full depth search, when LMR is skipped or fails high if (doFullDepthSearch) @@ -968,7 +968,7 @@ split_point_start: // At split points actual search starts from here // Only for PV nodes do a full PV search on the first move or after a fail // high, in the latter case search only if value < beta, otherwise let the // parent node to fail low with value <= alpha and to try another move. - if (PvNode && (isPvMove || (value > alpha && (RootNode || value < beta)))) + if (PvNode && (pvMove || (value > alpha && (RootNode || value < beta)))) value = newDepth < ONE_PLY ? -qsearch(pos, ss+1, -beta, -alpha, DEPTH_ZERO) : - search(pos, ss+1, -beta, -alpha, newDepth); @@ -994,7 +994,7 @@ split_point_start: // At split points actual search starts from here RootMove& rm = *std::find(RootMoves.begin(), RootMoves.end(), move); // PV move or new best move ? - if (isPvMove || value > alpha) + if (pvMove || value > alpha) { rm.score = value; rm.extract_pv_from_tt(pos); @@ -1002,7 +1002,7 @@ split_point_start: // At split points actual search starts from here // We record how often the best move has been changed in each // iteration. This information is used for time management: When // the best move changes frequently, we allocate some more time. - if (!isPvMove && MultiPV == 1) + if (!pvMove && MultiPV == 1) BestMoveChanges++; } else