Skip to content

Commit ced2924

Browse files
vondelezamar
authored andcommitted
simplify logic for history based pruning
STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 34255 W: 6292 L: 6194 D: 21769 LTC LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 89914 W: 11769 L: 11739 D: 66406 Bench: 6581936 Closes #1066
1 parent 2d96e8f commit ced2924

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/movepick.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct Stats {
6666
const T* operator[](Piece pc) const { return table[pc]; }
6767
T* operator[](Piece pc) { return table[pc]; }
6868
void clear() { std::memset(table, 0, sizeof(table)); }
69+
void fill(const Value& v) { std::fill(&table[0][0], &table[PIECE_NB-1][SQUARE_NB-1]+1, v); };
6970
void update(Piece pc, Square to, Move m) { table[pc][to] = m; }
7071
void update(Piece pc, Square to, Value v) {
7172

src/search.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)