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
https://github.com/official-stockfish/Stockfish/pull/5816

closes https://github.com/official-stockfish/Stockfish/pull/5934

No functional change
This commit is contained in:
mstembera
2025-03-20 12:40:27 -07:00
committed by Disservin
parent 0dabf4f3fa
commit 6ceaca4c7b
3 changed files with 12 additions and 7 deletions

View File

@@ -155,6 +155,12 @@ struct CorrHistTypedef<Continuation> {
using type = MultiArray<CorrHistTypedef<PieceTo>::type, PIECE_NB, SQUARE_NB>; using type = MultiArray<CorrHistTypedef<PieceTo>::type, PIECE_NB, SQUARE_NB>;
}; };
template<>
struct CorrHistTypedef<NonPawn> {
using type =
Stats<std::int16_t, CORRECTION_HISTORY_LIMIT, CORRECTION_HISTORY_SIZE, COLOR_NB, COLOR_NB>;
};
} }
template<CorrHistType T> template<CorrHistType T>

View File

@@ -87,8 +87,8 @@ int correction_value(const Worker& w, const Position& pos, const Stack* const ss
const auto m = (ss - 1)->currentMove; const auto m = (ss - 1)->currentMove;
const auto pcv = w.pawnCorrectionHistory[pawn_structure_index<Correction>(pos)][us]; const auto pcv = w.pawnCorrectionHistory[pawn_structure_index<Correction>(pos)][us];
const auto micv = w.minorPieceCorrectionHistory[minor_piece_index(pos)][us]; const auto micv = w.minorPieceCorrectionHistory[minor_piece_index(pos)][us];
const auto wnpcv = w.nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us]; const auto wnpcv = w.nonPawnCorrectionHistory[non_pawn_index<WHITE>(pos)][WHITE][us];
const auto bnpcv = w.nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us]; const auto bnpcv = w.nonPawnCorrectionHistory[non_pawn_index<BLACK>(pos)][BLACK][us];
const auto cntcv = const auto cntcv =
m.is_ok() ? (*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()] m.is_ok() ? (*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()]
: 0; : 0;
@@ -141,9 +141,9 @@ void update_correction_history(const Position& pos,
workerThread.pawnCorrectionHistory[pawn_structure_index<Correction>(pos)][us] workerThread.pawnCorrectionHistory[pawn_structure_index<Correction>(pos)][us]
<< bonus * 111 / 128; << bonus * 111 / 128;
workerThread.minorPieceCorrectionHistory[minor_piece_index(pos)][us] << bonus * 146 / 128; workerThread.minorPieceCorrectionHistory[minor_piece_index(pos)][us] << bonus * 146 / 128;
workerThread.nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us] workerThread.nonPawnCorrectionHistory[non_pawn_index<WHITE>(pos)][WHITE][us]
<< bonus * nonPawnWeight / 128; << bonus * nonPawnWeight / 128;
workerThread.nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us] workerThread.nonPawnCorrectionHistory[non_pawn_index<BLACK>(pos)][BLACK][us]
<< bonus * nonPawnWeight / 128; << bonus * nonPawnWeight / 128;
if (m.is_ok()) if (m.is_ok())
@@ -581,8 +581,7 @@ void Search::Worker::clear() {
pawnHistory.fill(-1262); pawnHistory.fill(-1262);
pawnCorrectionHistory.fill(6); pawnCorrectionHistory.fill(6);
minorPieceCorrectionHistory.fill(0); minorPieceCorrectionHistory.fill(0);
nonPawnCorrectionHistory[WHITE].fill(0); nonPawnCorrectionHistory.fill(0);
nonPawnCorrectionHistory[BLACK].fill(0);
for (auto& to : continuationCorrectionHistory) for (auto& to : continuationCorrectionHistory)
for (auto& h : to) for (auto& h : to)

View File

@@ -289,7 +289,7 @@ class Worker {
CorrectionHistory<Pawn> pawnCorrectionHistory; CorrectionHistory<Pawn> pawnCorrectionHistory;
CorrectionHistory<Minor> minorPieceCorrectionHistory; CorrectionHistory<Minor> minorPieceCorrectionHistory;
CorrectionHistory<NonPawn> nonPawnCorrectionHistory[COLOR_NB]; CorrectionHistory<NonPawn> nonPawnCorrectionHistory;
CorrectionHistory<Continuation> continuationCorrectionHistory; CorrectionHistory<Continuation> continuationCorrectionHistory;
private: private: