Skip to content

Commit 6ceaca4

Browse files
mstemberaDisservin
authored andcommitted
Change layout of CorrectionHistory<NonPawn>
https://tests.stockfishchess.org/tests/view/67da5b158c7f315cc372a9d2 LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 150368 W: 38874 L: 38401 D: 73093 Ptnml(0-2): 424, 16821, 40262, 17212, 465 Make CorrectionHistory\<NonPawn\> handle both black and white internally. A follow up to #5816 closes #5934 No functional change
1 parent 0dabf4f commit 6ceaca4

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/history.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ struct CorrHistTypedef<Continuation> {
155155
using type = MultiArray<CorrHistTypedef<PieceTo>::type, PIECE_NB, SQUARE_NB>;
156156
};
157157

158+
template<>
159+
struct CorrHistTypedef<NonPawn> {
160+
using type =
161+
Stats<std::int16_t, CORRECTION_HISTORY_LIMIT, CORRECTION_HISTORY_SIZE, COLOR_NB, COLOR_NB>;
162+
};
163+
158164
}
159165

160166
template<CorrHistType T>

src/search.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ int correction_value(const Worker& w, const Position& pos, const Stack* const ss
8787
const auto m = (ss - 1)->currentMove;
8888
const auto pcv = w.pawnCorrectionHistory[pawn_structure_index<Correction>(pos)][us];
8989
const auto micv = w.minorPieceCorrectionHistory[minor_piece_index(pos)][us];
90-
const auto wnpcv = w.nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us];
91-
const auto bnpcv = w.nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us];
90+
const auto wnpcv = w.nonPawnCorrectionHistory[non_pawn_index<WHITE>(pos)][WHITE][us];
91+
const auto bnpcv = w.nonPawnCorrectionHistory[non_pawn_index<BLACK>(pos)][BLACK][us];
9292
const auto cntcv =
9393
m.is_ok() ? (*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()]
9494
: 0;
@@ -141,9 +141,9 @@ void update_correction_history(const Position& pos,
141141
workerThread.pawnCorrectionHistory[pawn_structure_index<Correction>(pos)][us]
142142
<< bonus * 111 / 128;
143143
workerThread.minorPieceCorrectionHistory[minor_piece_index(pos)][us] << bonus * 146 / 128;
144-
workerThread.nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us]
144+
workerThread.nonPawnCorrectionHistory[non_pawn_index<WHITE>(pos)][WHITE][us]
145145
<< bonus * nonPawnWeight / 128;
146-
workerThread.nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us]
146+
workerThread.nonPawnCorrectionHistory[non_pawn_index<BLACK>(pos)][BLACK][us]
147147
<< bonus * nonPawnWeight / 128;
148148

149149
if (m.is_ok())
@@ -581,8 +581,7 @@ void Search::Worker::clear() {
581581
pawnHistory.fill(-1262);
582582
pawnCorrectionHistory.fill(6);
583583
minorPieceCorrectionHistory.fill(0);
584-
nonPawnCorrectionHistory[WHITE].fill(0);
585-
nonPawnCorrectionHistory[BLACK].fill(0);
584+
nonPawnCorrectionHistory.fill(0);
586585

587586
for (auto& to : continuationCorrectionHistory)
588587
for (auto& h : to)

src/search.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class Worker {
289289

290290
CorrectionHistory<Pawn> pawnCorrectionHistory;
291291
CorrectionHistory<Minor> minorPieceCorrectionHistory;
292-
CorrectionHistory<NonPawn> nonPawnCorrectionHistory[COLOR_NB];
292+
CorrectionHistory<NonPawn> nonPawnCorrectionHistory;
293293
CorrectionHistory<Continuation> continuationCorrectionHistory;
294294

295295
private:

0 commit comments

Comments
 (0)