Skip to content

Commit d909d10

Browse files
committed
Refactor previous patch
No functional change.
1 parent 38428ad commit d909d10

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

src/search.cpp

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -920,52 +920,47 @@ namespace {
920920
newDepth = depth - ONE_PLY + extension;
921921

922922
// Step 13. Pruning at shallow depth
923-
if ( !rootNode
924-
&& !captureOrPromotion
925-
&& !inCheck
926-
&& !givesCheck
927-
&& bestValue > VALUE_MATED_IN_MAX_PLY
928-
&& !pos.advanced_pawn_push(move))
923+
if ( !rootNode
924+
&& !inCheck
925+
&& bestValue > VALUE_MATED_IN_MAX_PLY)
929926
{
930-
// Move count based pruning
931-
if (moveCountPruning)
932-
continue;
927+
if ( !captureOrPromotion
928+
&& !givesCheck
929+
&& !pos.advanced_pawn_push(move))
930+
{
931+
// Move count based pruning
932+
if (moveCountPruning)
933+
continue;
933934

934-
predictedDepth = std::max(newDepth - reduction<PvNode>(improving, depth, moveCount), DEPTH_ZERO);
935+
predictedDepth = std::max(newDepth - reduction<PvNode>(improving, depth, moveCount), DEPTH_ZERO);
935936

936-
// Countermoves based pruning
937-
if ( predictedDepth < 3 * ONE_PLY
938-
&& (!cmh || (*cmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
939-
&& (!fmh || (*fmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
940-
&& (!fmh2 || (*fmh2)[moved_piece][to_sq(move)] < VALUE_ZERO || (cmh && fmh)))
941-
continue;
937+
// Countermoves based pruning
938+
if ( predictedDepth < 3 * ONE_PLY
939+
&& (!cmh || (*cmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
940+
&& (!fmh || (*fmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
941+
&& (!fmh2 || (*fmh2)[moved_piece][to_sq(move)] < VALUE_ZERO || (cmh && fmh)))
942+
continue;
942943

943-
// Futility pruning: parent node
944-
if ( predictedDepth < 7 * ONE_PLY
945-
&& ss->staticEval + 256 + 200 * predictedDepth / ONE_PLY <= alpha)
946-
continue;
944+
// Futility pruning: parent node
945+
if ( predictedDepth < 7 * ONE_PLY
946+
&& ss->staticEval + 256 + 200 * predictedDepth / ONE_PLY <= alpha)
947+
continue;
947948

948-
// Prune moves with negative SEE at low depths and below a decreasing
949-
// threshold at higher depths.
950-
if (predictedDepth < 8 * ONE_PLY)
951-
{
952-
Value see_v = predictedDepth < 4 * ONE_PLY ? VALUE_ZERO
953-
: -PawnValueMg * 2 * int(predictedDepth - 3 * ONE_PLY) / ONE_PLY;
949+
// Prune moves with negative SEE at low depths and below a decreasing
950+
// threshold at higher depths.
951+
if (predictedDepth < 8 * ONE_PLY)
952+
{
953+
Value see_v = predictedDepth < 4 * ONE_PLY ? VALUE_ZERO
954+
: -PawnValueMg * 2 * int(predictedDepth - 3 * ONE_PLY) / ONE_PLY;
954955

955-
if (pos.see_sign(move) < see_v)
956-
continue;
956+
if (pos.see_sign(move) < see_v)
957+
continue;
958+
}
957959
}
960+
else if ( depth < 3 * ONE_PLY
961+
&& pos.see_sign(move) < VALUE_ZERO)
962+
continue;
958963
}
959-
else if ( depth < 3 * ONE_PLY
960-
&& !inCheck
961-
&& bestValue > VALUE_MATED_IN_MAX_PLY
962-
&& !rootNode
963-
&& ( captureOrPromotion
964-
|| givesCheck
965-
|| pos.advanced_pawn_push(move))
966-
&& pos.see_sign(move) < VALUE_ZERO
967-
)
968-
continue;
969964

970965
// Speculative prefetch as early as possible
971966
prefetch(TT.first_entry(pos.key_after(move)));

0 commit comments

Comments
 (0)