@@ -75,6 +75,9 @@ namespace {
7575 int FutilityMoveCounts[2 ][16 ]; // [improving][depth]
7676 int Reductions[2 ][2 ][64 ][64 ]; // [pv][improving][depth][moveNumber]
7777
78+ // Threshold used for countermoves based pruning.
79+ const int CounterMovePruneThreshold = VALUE_ZERO;
80+
7881 template <bool PvNode> Depth reduction (bool i, Depth d, int mn) {
7982 return Reductions[PvNode][i][std::min (d / ONE_PLY, 63 )][std::min (mn, 63 )] * ONE_PLY;
8083 }
@@ -192,6 +195,7 @@ void Search::clear() {
192195 th->counterMoves .clear ();
193196 th->history .clear ();
194197 th->counterMoveHistory .clear ();
198+ th->counterMoveHistory [NO_PIECE][0 ].fill (Value (CounterMovePruneThreshold-1 ));
195199 th->resetCalls = true ;
196200 }
197201
@@ -812,9 +816,6 @@ namespace {
812816 const CounterMoveStats& cmh = *(ss-1 )->counterMoves ;
813817 const CounterMoveStats& fmh = *(ss-2 )->counterMoves ;
814818 const CounterMoveStats& fm2 = *(ss-4 )->counterMoves ;
815- const bool cm_ok = is_ok ((ss-1 )->currentMove );
816- const bool fm_ok = is_ok ((ss-2 )->currentMove );
817- const bool f2_ok = is_ok ((ss-4 )->currentMove );
818819
819820 MovePicker mp (pos, ttMove, depth, ss);
820821 value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
@@ -916,9 +917,8 @@ namespace {
916917
917918 // Countermoves based pruning
918919 if ( lmrDepth < 3
919- && ((cmh[moved_piece][to_sq (move)] < VALUE_ZERO) || !cm_ok)
920- && ((fmh[moved_piece][to_sq (move)] < VALUE_ZERO) || !fm_ok)
921- && ((fm2[moved_piece][to_sq (move)] < VALUE_ZERO) || !f2_ok || (cm_ok && fm_ok)))
920+ && (cmh[moved_piece][to_sq (move)] < CounterMovePruneThreshold)
921+ && (fmh[moved_piece][to_sq (move)] < CounterMovePruneThreshold))
922922 continue ;
923923
924924 // Futility pruning: parent node
@@ -1123,7 +1123,7 @@ namespace {
11231123 // Bonus for prior countermove that caused the fail low
11241124 else if ( depth >= 3 * ONE_PLY
11251125 && !pos.captured_piece ()
1126- && cm_ok )
1126+ && is_ok ((ss- 1 )-> currentMove ) )
11271127 update_cm_stats (ss-1 , pos.piece_on (prevSq), prevSq, stat_bonus (depth));
11281128
11291129 if (!excludedMove)
0 commit comments