From 6ceaca4c7b2cc1fa87617b1b9e83d38d8e880924 Mon Sep 17 00:00:00 2001 From: mstembera Date: Thu, 20 Mar 2025 12:40:27 -0700 Subject: [PATCH] Change layout of CorrectionHistory 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\ 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 --- src/history.h | 6 ++++++ src/search.cpp | 11 +++++------ src/search.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/history.h b/src/history.h index fd9b98b9..ec245230 100644 --- a/src/history.h +++ b/src/history.h @@ -155,6 +155,12 @@ struct CorrHistTypedef { using type = MultiArray::type, PIECE_NB, SQUARE_NB>; }; +template<> +struct CorrHistTypedef { + using type = + Stats; +}; + } template diff --git a/src/search.cpp b/src/search.cpp index 2da19f32..0c543c30 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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 pcv = w.pawnCorrectionHistory[pawn_structure_index(pos)][us]; const auto micv = w.minorPieceCorrectionHistory[minor_piece_index(pos)][us]; - const auto wnpcv = w.nonPawnCorrectionHistory[WHITE][non_pawn_index(pos)][us]; - const auto bnpcv = w.nonPawnCorrectionHistory[BLACK][non_pawn_index(pos)][us]; + const auto wnpcv = w.nonPawnCorrectionHistory[non_pawn_index(pos)][WHITE][us]; + const auto bnpcv = w.nonPawnCorrectionHistory[non_pawn_index(pos)][BLACK][us]; const auto cntcv = m.is_ok() ? (*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()] : 0; @@ -141,9 +141,9 @@ void update_correction_history(const Position& pos, workerThread.pawnCorrectionHistory[pawn_structure_index(pos)][us] << bonus * 111 / 128; workerThread.minorPieceCorrectionHistory[minor_piece_index(pos)][us] << bonus * 146 / 128; - workerThread.nonPawnCorrectionHistory[WHITE][non_pawn_index(pos)][us] + workerThread.nonPawnCorrectionHistory[non_pawn_index(pos)][WHITE][us] << bonus * nonPawnWeight / 128; - workerThread.nonPawnCorrectionHistory[BLACK][non_pawn_index(pos)][us] + workerThread.nonPawnCorrectionHistory[non_pawn_index(pos)][BLACK][us] << bonus * nonPawnWeight / 128; if (m.is_ok()) @@ -581,8 +581,7 @@ void Search::Worker::clear() { pawnHistory.fill(-1262); pawnCorrectionHistory.fill(6); minorPieceCorrectionHistory.fill(0); - nonPawnCorrectionHistory[WHITE].fill(0); - nonPawnCorrectionHistory[BLACK].fill(0); + nonPawnCorrectionHistory.fill(0); for (auto& to : continuationCorrectionHistory) for (auto& h : to) diff --git a/src/search.h b/src/search.h index cd3b6ad9..071773f8 100644 --- a/src/search.h +++ b/src/search.h @@ -289,7 +289,7 @@ class Worker { CorrectionHistory pawnCorrectionHistory; CorrectionHistory minorPieceCorrectionHistory; - CorrectionHistory nonPawnCorrectionHistory[COLOR_NB]; + CorrectionHistory nonPawnCorrectionHistory; CorrectionHistory continuationCorrectionHistory; private: