Skip to content

Commit a00a336

Browse files
locutus2snicolet
authored andcommitted
Prune before extension
Switch execution order in search: do move pruning before extension detection. STC: LLR: 2.96 (-2.94,2.94) [-1.50,4.50] Total: 5762 W: 1307 L: 1181 D: 3274 http://tests.stockfishchess.org/tests/view/5dcc56e90ebc59025bcbb833 LTC: LLR: 2.96 (-2.94,2.94) [0.00,3.50] Total: 72956 W: 11959 L: 11585 D: 49412 http://tests.stockfishchess.org/tests/view/5dcc62840ebc59025bcbb96f Closes #2413 Bench: 4532366
1 parent a131975 commit a00a336

File tree

2 files changed

+42
-40
lines changed

2 files changed

+42
-40
lines changed

src/evaluate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace {
125125
constexpr Score PassedRank[RANK_NB] = {
126126
S(0, 0), S(10, 28), S(17, 33), S(15, 41), S(62, 72), S(168, 177), S(276, 260)
127127
};
128-
128+
129129
// OutpostRank[Rank] contains a bonus according to the rank of the outpost
130130
constexpr Score OutpostRank[RANK_NB] = {
131131
S(0, 0), S(0, 0), S(0, 0), S(28, 18), S(30, 24), S(32, 19)

src/search.cpp

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,45 @@ namespace {
955955
movedPiece = pos.moved_piece(move);
956956
givesCheck = pos.gives_check(move);
957957

958-
// Step 13. Extensions (~70 Elo)
958+
// Calculate new depth for this move
959+
newDepth = depth - 1;
960+
961+
// Step 13. Pruning at shallow depth (~170 Elo)
962+
if ( !rootNode
963+
&& pos.non_pawn_material(us)
964+
&& bestValue > VALUE_MATED_IN_MAX_PLY)
965+
{
966+
// Skip quiet moves if movecount exceeds our FutilityMoveCount threshold
967+
moveCountPruning = moveCount >= futility_move_count(improving, depth);
968+
969+
if ( !captureOrPromotion
970+
&& !givesCheck
971+
&& (!PvNode || !pos.advanced_pawn_push(move) || pos.non_pawn_material(~us) > BishopValueMg))
972+
{
973+
// Reduced depth of the next LMR search
974+
int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount), 0);
975+
976+
// Countermoves based pruning (~20 Elo)
977+
if ( lmrDepth < 4 + ((ss-1)->statScore > 0 || (ss-1)->moveCount == 1)
978+
&& (*contHist[0])[movedPiece][to_sq(move)] < CounterMovePruneThreshold
979+
&& (*contHist[1])[movedPiece][to_sq(move)] < CounterMovePruneThreshold)
980+
continue;
981+
982+
// Futility pruning: parent node (~2 Elo)
983+
if ( lmrDepth < 6
984+
&& !inCheck
985+
&& ss->staticEval + 250 + 211 * lmrDepth <= alpha)
986+
continue;
987+
988+
// Prune moves with negative SEE (~10 Elo)
989+
if (!pos.see_ge(move, Value(-(31 - std::min(lmrDepth, 18)) * lmrDepth * lmrDepth)))
990+
continue;
991+
}
992+
else if (!pos.see_ge(move, Value(-199) * depth)) // (~20 Elo)
993+
continue;
994+
}
995+
996+
// Step 14. Extensions (~70 Elo)
959997

960998
// Singular extension search (~60 Elo). If all moves but one fail low on a
961999
// search of (alpha-s, beta-s), and just one fails high on (alpha, beta),
@@ -1009,44 +1047,8 @@ namespace {
10091047
if (type_of(move) == CASTLING)
10101048
extension = 1;
10111049

1012-
// Calculate new depth for this move
1013-
newDepth = depth - 1 + extension;
1014-
1015-
// Step 14. Pruning at shallow depth (~170 Elo)
1016-
if ( !rootNode
1017-
&& pos.non_pawn_material(us)
1018-
&& bestValue > VALUE_MATED_IN_MAX_PLY)
1019-
{
1020-
// Skip quiet moves if movecount exceeds our FutilityMoveCount threshold
1021-
moveCountPruning = moveCount >= futility_move_count(improving, depth);
1022-
1023-
if ( !captureOrPromotion
1024-
&& !givesCheck
1025-
&& (!PvNode || !pos.advanced_pawn_push(move) || pos.non_pawn_material(~us) > BishopValueMg))
1026-
{
1027-
// Reduced depth of the next LMR search
1028-
int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount), 0);
1029-
1030-
// Countermoves based pruning (~20 Elo)
1031-
if ( lmrDepth < 4 + ((ss-1)->statScore > 0 || (ss-1)->moveCount == 1)
1032-
&& (*contHist[0])[movedPiece][to_sq(move)] < CounterMovePruneThreshold
1033-
&& (*contHist[1])[movedPiece][to_sq(move)] < CounterMovePruneThreshold)
1034-
continue;
1035-
1036-
// Futility pruning: parent node (~2 Elo)
1037-
if ( lmrDepth < 6
1038-
&& !inCheck
1039-
&& ss->staticEval + 250 + 211 * lmrDepth <= alpha)
1040-
continue;
1041-
1042-
// Prune moves with negative SEE (~10 Elo)
1043-
if (!pos.see_ge(move, Value(-(31 - std::min(lmrDepth, 18)) * lmrDepth * lmrDepth)))
1044-
continue;
1045-
}
1046-
else if ( !(givesCheck && extension)
1047-
&& !pos.see_ge(move, Value(-199) * depth)) // (~20 Elo)
1048-
continue;
1049-
}
1050+
// Add extension to new depth
1051+
newDepth += extension;
10501052

10511053
// Speculative prefetch as early as possible
10521054
prefetch(TT.first_entry(pos.key_after(move)));

0 commit comments

Comments
 (0)