Skip to content

Commit 889fed4

Browse files
xu-shawnAndyGrant
authored andcommitted
Better nonpawn indexing
Improves indexing scheme, by noting that both sides are likely to access the same non_pawn_index nearby. LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 75936 W: 19905 L: 19554 D: 36477 Ptnml(0-2): 190, 7863, 21554, 8128, 233 https://tests.stockfishchess.org/tests/view/67904d0cfc8c306ba6cea332 closes #5816 No functional change Co-authored-by: Andrew Grant <andrew.github@grantnet.us>
1 parent 435ba3d commit 889fed4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/history.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ enum CorrHistType {
138138
Pawn, // By color and pawn structure
139139
Major, // By color and positions of major pieces (Queen, Rook) and King
140140
Minor, // By color and positions of minor pieces (Knight, Bishop) and King
141-
NonPawn, // By color and non-pawn material positions
141+
NonPawn, // By Non-pawn material positions and color
142142
PieceTo, // By [piece][to] move
143143
Continuation, // Combined history of move pairs
144144
};
@@ -150,6 +150,11 @@ struct CorrHistTypedef {
150150
using type = Stats<std::int16_t, CORRECTION_HISTORY_LIMIT, COLOR_NB, CORRECTION_HISTORY_SIZE>;
151151
};
152152

153+
template<>
154+
struct CorrHistTypedef<NonPawn> {
155+
using type = Stats<std::int16_t, CORRECTION_HISTORY_LIMIT, CORRECTION_HISTORY_SIZE, COLOR_NB>;
156+
};
157+
153158
template<>
154159
struct CorrHistTypedef<PieceTo> {
155160
using type = Stats<std::int16_t, CORRECTION_HISTORY_LIMIT, PIECE_NB, SQUARE_NB>;

src/search.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ int correction_value(const Worker& w, const Position& pos, const Stack* ss) {
8989
const auto pcv = w.pawnCorrectionHistory[us][pawn_structure_index<Correction>(pos)];
9090
const auto macv = w.majorPieceCorrectionHistory[us][major_piece_index(pos)];
9191
const auto micv = w.minorPieceCorrectionHistory[us][minor_piece_index(pos)];
92-
const auto wnpcv = w.nonPawnCorrectionHistory[WHITE][us][non_pawn_index<WHITE>(pos)];
93-
const auto bnpcv = w.nonPawnCorrectionHistory[BLACK][us][non_pawn_index<BLACK>(pos)];
92+
const auto wnpcv = w.nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us];
93+
const auto bnpcv = w.nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us];
9494
const auto cntcv =
9595
m.is_ok() ? (*(ss - 2)->continuationCorrectionHistory)[pos.piece_on(m.to_sq())][m.to_sq()]
9696
: 0;
@@ -1442,9 +1442,9 @@ Value Search::Worker::search(
14421442
<< bonus * 114 / 128;
14431443
thisThread->majorPieceCorrectionHistory[us][major_piece_index(pos)] << bonus * 163 / 128;
14441444
thisThread->minorPieceCorrectionHistory[us][minor_piece_index(pos)] << bonus * 146 / 128;
1445-
thisThread->nonPawnCorrectionHistory[WHITE][us][non_pawn_index<WHITE>(pos)]
1445+
thisThread->nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us]
14461446
<< bonus * nonPawnWeight / 128;
1447-
thisThread->nonPawnCorrectionHistory[BLACK][us][non_pawn_index<BLACK>(pos)]
1447+
thisThread->nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us]
14481448
<< bonus * nonPawnWeight / 128;
14491449

14501450
if (m.is_ok())

0 commit comments

Comments
 (0)