Skip to content

Commit

Permalink
Refactor previous patch
Browse files Browse the repository at this point in the history
No functional change.
  • Loading branch information
mcostalba committed Sep 8, 2016
1 parent 38428ad commit d909d10
Showing 1 changed file with 33 additions and 38 deletions.
71 changes: 33 additions & 38 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,52 +920,47 @@ namespace {
newDepth = depth - ONE_PLY + extension;

// Step 13. Pruning at shallow depth
if ( !rootNode
&& !captureOrPromotion
&& !inCheck
&& !givesCheck
&& bestValue > VALUE_MATED_IN_MAX_PLY
&& !pos.advanced_pawn_push(move))
if ( !rootNode
&& !inCheck
&& bestValue > VALUE_MATED_IN_MAX_PLY)
{
// Move count based pruning
if (moveCountPruning)
continue;
if ( !captureOrPromotion
&& !givesCheck
&& !pos.advanced_pawn_push(move))
{
// Move count based pruning
if (moveCountPruning)
continue;

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

// Countermoves based pruning
if ( predictedDepth < 3 * ONE_PLY
&& (!cmh || (*cmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
&& (!fmh || (*fmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
&& (!fmh2 || (*fmh2)[moved_piece][to_sq(move)] < VALUE_ZERO || (cmh && fmh)))
continue;
// Countermoves based pruning
if ( predictedDepth < 3 * ONE_PLY
&& (!cmh || (*cmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
&& (!fmh || (*fmh )[moved_piece][to_sq(move)] < VALUE_ZERO)
&& (!fmh2 || (*fmh2)[moved_piece][to_sq(move)] < VALUE_ZERO || (cmh && fmh)))
continue;

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

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

if (pos.see_sign(move) < see_v)
continue;
if (pos.see_sign(move) < see_v)
continue;
}
}
else if ( depth < 3 * ONE_PLY
&& pos.see_sign(move) < VALUE_ZERO)
continue;
}
else if ( depth < 3 * ONE_PLY
&& !inCheck
&& bestValue > VALUE_MATED_IN_MAX_PLY
&& !rootNode
&& ( captureOrPromotion
|| givesCheck
|| pos.advanced_pawn_push(move))
&& pos.see_sign(move) < VALUE_ZERO
)
continue;

// Speculative prefetch as early as possible
prefetch(TT.first_entry(pos.key_after(move)));
Expand Down

2 comments on commit d909d10

@Kingdefender
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations to Ajith!

I had one small comment on the indents here 923-925 Marco

+      if (  !rootNode
+         && !inCheck
+         &&  bestValue > VALUE_MATED_IN_MAX_PLY)

I think the && are one space too far to the left.. Can you still correct it?

@mcostalba
Copy link
Author

@mcostalba mcostalba commented on d909d10 Sep 8, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.