@@ -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