Remove major corrhist

Remove major correction history and slightly increase all other
correction weights.

Passed STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 50080 W: 13171 L: 12959 D: 23950
Ptnml(0-2): 196, 5998, 12462, 6166, 218
https://tests.stockfishchess.org/tests/live_elo/67954526406a4efe9eb7d176

Passed LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 51504 W: 13188 L: 12995 D: 25321
Ptnml(0-2): 54, 5658, 14128, 5865, 47
https://tests.stockfishchess.org/tests/live_elo/67954961406a4efe9eb7d251

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

Bench: 2081366
This commit is contained in:
Martin Novák
2025-01-25 21:09:45 +01:00
committed by Disservin
parent 69be04d38e
commit 831cb01cea
5 changed files with 5 additions and 34 deletions
-5
View File
@@ -54,10 +54,6 @@ inline int pawn_structure_index(const Position& pos) {
return pos.pawn_key() & ((T == Normal ? PAWN_HISTORY_SIZE : CORRECTION_HISTORY_SIZE) - 1); return pos.pawn_key() & ((T == Normal ? PAWN_HISTORY_SIZE : CORRECTION_HISTORY_SIZE) - 1);
} }
inline int major_piece_index(const Position& pos) {
return pos.major_piece_key() & (CORRECTION_HISTORY_SIZE - 1);
}
inline int minor_piece_index(const Position& pos) { inline int minor_piece_index(const Position& pos) {
return pos.minor_piece_key() & (CORRECTION_HISTORY_SIZE - 1); return pos.minor_piece_key() & (CORRECTION_HISTORY_SIZE - 1);
} }
@@ -136,7 +132,6 @@ using PawnHistory = Stats<std::int16_t, 8192, PAWN_HISTORY_SIZE, PIECE_NB, SQUAR
// see https://www.chessprogramming.org/Static_Evaluation_Correction_History // see https://www.chessprogramming.org/Static_Evaluation_Correction_History
enum CorrHistType { enum CorrHistType {
Pawn, // By color and pawn structure Pawn, // By color and pawn structure
Major, // By color and positions of major pieces (Queen, Rook) and King
Minor, // By color and positions of minor pieces (Knight, Bishop) and King Minor, // By color and positions of minor pieces (Knight, Bishop) and King
NonPawn, // By Non-pawn material positions and color NonPawn, // By Non-pawn material positions and color
PieceTo, // By [piece][to] move PieceTo, // By [piece][to] move
+4 -20
View File
@@ -335,7 +335,6 @@ void Position::set_check_info() const {
void Position::set_state() const { void Position::set_state() const {
st->key = st->materialKey = 0; st->key = st->materialKey = 0;
st->majorPieceKey = st->minorPieceKey = 0;
st->nonPawnKey[WHITE] = st->nonPawnKey[BLACK] = 0; st->nonPawnKey[WHITE] = st->nonPawnKey[BLACK] = 0;
st->pawnKey = Zobrist::noPawns; st->pawnKey = Zobrist::noPawns;
st->nonPawnMaterial[WHITE] = st->nonPawnMaterial[BLACK] = VALUE_ZERO; st->nonPawnMaterial[WHITE] = st->nonPawnMaterial[BLACK] = VALUE_ZERO;
@@ -360,16 +359,12 @@ void Position::set_state() const {
{ {
st->nonPawnMaterial[color_of(pc)] += PieceValue[pc]; st->nonPawnMaterial[color_of(pc)] += PieceValue[pc];
if (type_of(pc) >= ROOK) if (type_of(pc) <= BISHOP)
st->majorPieceKey ^= Zobrist::psq[pc][s];
else
st->minorPieceKey ^= Zobrist::psq[pc][s]; st->minorPieceKey ^= Zobrist::psq[pc][s];
} }
else else
{ {
st->majorPieceKey ^= Zobrist::psq[pc][s];
st->minorPieceKey ^= Zobrist::psq[pc][s]; st->minorPieceKey ^= Zobrist::psq[pc][s];
} }
} }
@@ -742,7 +737,6 @@ void Position::do_move(Move m,
do_castling<true>(us, from, to, rfrom, rto); do_castling<true>(us, from, to, rfrom, rto);
k ^= Zobrist::psq[captured][rfrom] ^ Zobrist::psq[captured][rto]; k ^= Zobrist::psq[captured][rfrom] ^ Zobrist::psq[captured][rto];
st->majorPieceKey ^= Zobrist::psq[captured][rfrom] ^ Zobrist::psq[captured][rto];
st->nonPawnKey[us] ^= Zobrist::psq[captured][rfrom] ^ Zobrist::psq[captured][rto]; st->nonPawnKey[us] ^= Zobrist::psq[captured][rfrom] ^ Zobrist::psq[captured][rto];
captured = NO_PIECE; captured = NO_PIECE;
} }
@@ -773,10 +767,7 @@ void Position::do_move(Move m,
st->nonPawnMaterial[them] -= PieceValue[captured]; st->nonPawnMaterial[them] -= PieceValue[captured];
st->nonPawnKey[them] ^= Zobrist::psq[captured][capsq]; st->nonPawnKey[them] ^= Zobrist::psq[captured][capsq];
if (type_of(captured) >= ROOK) if (type_of(captured) <= BISHOP)
st->majorPieceKey ^= Zobrist::psq[captured][capsq];
else
st->minorPieceKey ^= Zobrist::psq[captured][capsq]; st->minorPieceKey ^= Zobrist::psq[captured][capsq];
} }
@@ -858,10 +849,7 @@ void Position::do_move(Move m,
st->materialKey ^= st->materialKey ^=
Zobrist::psq[promotion][pieceCount[promotion] - 1] ^ Zobrist::psq[pc][pieceCount[pc]]; Zobrist::psq[promotion][pieceCount[promotion] - 1] ^ Zobrist::psq[pc][pieceCount[pc]];
if (promotionType >= ROOK) if (promotionType <= BISHOP)
st->majorPieceKey ^= Zobrist::psq[promotion][to];
else
st->minorPieceKey ^= Zobrist::psq[promotion][to]; st->minorPieceKey ^= Zobrist::psq[promotion][to];
// Update material // Update material
@@ -881,14 +869,10 @@ void Position::do_move(Move m,
if (type_of(pc) == KING) if (type_of(pc) == KING)
{ {
st->majorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
st->minorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to]; st->minorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
} }
else if (type_of(pc) >= ROOK) else if (type_of(pc) <= BISHOP)
st->majorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
else
st->minorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to]; st->minorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
} }
-4
View File
@@ -43,7 +43,6 @@ struct StateInfo {
// Copied when making a move // Copied when making a move
Key materialKey; Key materialKey;
Key pawnKey; Key pawnKey;
Key majorPieceKey;
Key minorPieceKey; Key minorPieceKey;
Key nonPawnKey[COLOR_NB]; Key nonPawnKey[COLOR_NB];
Value nonPawnMaterial[COLOR_NB]; Value nonPawnMaterial[COLOR_NB];
@@ -154,7 +153,6 @@ class Position {
Key key() const; Key key() const;
Key material_key() const; Key material_key() const;
Key pawn_key() const; Key pawn_key() const;
Key major_piece_key() const;
Key minor_piece_key() const; Key minor_piece_key() const;
Key non_pawn_key(Color c) const; Key non_pawn_key(Color c) const;
@@ -305,8 +303,6 @@ inline Key Position::pawn_key() const { return st->pawnKey; }
inline Key Position::material_key() const { return st->materialKey; } inline Key Position::material_key() const { return st->materialKey; }
inline Key Position::major_piece_key() const { return st->majorPieceKey; }
inline Key Position::minor_piece_key() const { return st->minorPieceKey; } inline Key Position::minor_piece_key() const { return st->minorPieceKey; }
inline Key Position::non_pawn_key(Color c) const { return st->nonPawnKey[c]; } inline Key Position::non_pawn_key(Color c) const { return st->nonPawnKey[c]; }
+1 -4
View File
@@ -87,7 +87,6 @@ int correction_value(const Worker& w, const Position& pos, const Stack* ss) {
const Color us = pos.side_to_move(); const Color us = pos.side_to_move();
const auto m = (ss - 1)->currentMove; const auto m = (ss - 1)->currentMove;
const auto pcv = w.pawnCorrectionHistory[us][pawn_structure_index<Correction>(pos)]; const auto pcv = w.pawnCorrectionHistory[us][pawn_structure_index<Correction>(pos)];
const auto macv = w.majorPieceCorrectionHistory[us][major_piece_index(pos)];
const auto micv = w.minorPieceCorrectionHistory[us][minor_piece_index(pos)]; const auto micv = w.minorPieceCorrectionHistory[us][minor_piece_index(pos)];
const auto wnpcv = w.nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us]; const auto wnpcv = w.nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us];
const auto bnpcv = w.nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us]; const auto bnpcv = w.nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us];
@@ -95,7 +94,7 @@ int correction_value(const Worker& w, const Position& pos, const Stack* ss) {
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;
return (6922 * pcv + 3837 * macv + 6238 * micv + 7490 * (wnpcv + bnpcv) + 6270 * cntcv); return (7000 * pcv + 6300 * micv + 7550 * (wnpcv + bnpcv) + 6320 * cntcv);
} }
// Add correctionHistory value to raw staticEval and guarantee evaluation // Add correctionHistory value to raw staticEval and guarantee evaluation
@@ -516,7 +515,6 @@ void Search::Worker::clear() {
captureHistory.fill(-631); captureHistory.fill(-631);
pawnHistory.fill(-1210); pawnHistory.fill(-1210);
pawnCorrectionHistory.fill(0); pawnCorrectionHistory.fill(0);
majorPieceCorrectionHistory.fill(0);
minorPieceCorrectionHistory.fill(0); minorPieceCorrectionHistory.fill(0);
nonPawnCorrectionHistory[WHITE].fill(0); nonPawnCorrectionHistory[WHITE].fill(0);
nonPawnCorrectionHistory[BLACK].fill(0); nonPawnCorrectionHistory[BLACK].fill(0);
@@ -1439,7 +1437,6 @@ moves_loop: // When in check, search starts here
-CORRECTION_HISTORY_LIMIT / 4, CORRECTION_HISTORY_LIMIT / 4); -CORRECTION_HISTORY_LIMIT / 4, CORRECTION_HISTORY_LIMIT / 4);
thisThread->pawnCorrectionHistory[us][pawn_structure_index<Correction>(pos)] thisThread->pawnCorrectionHistory[us][pawn_structure_index<Correction>(pos)]
<< bonus * 114 / 128; << bonus * 114 / 128;
thisThread->majorPieceCorrectionHistory[us][major_piece_index(pos)] << bonus * 163 / 128;
thisThread->minorPieceCorrectionHistory[us][minor_piece_index(pos)] << bonus * 146 / 128; thisThread->minorPieceCorrectionHistory[us][minor_piece_index(pos)] << bonus * 146 / 128;
thisThread->nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us] thisThread->nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us]
<< bonus * nonPawnWeight / 128; << bonus * nonPawnWeight / 128;
-1
View File
@@ -288,7 +288,6 @@ class Worker {
PawnHistory pawnHistory; PawnHistory pawnHistory;
CorrectionHistory<Pawn> pawnCorrectionHistory; CorrectionHistory<Pawn> pawnCorrectionHistory;
CorrectionHistory<Major> majorPieceCorrectionHistory;
CorrectionHistory<Minor> minorPieceCorrectionHistory; CorrectionHistory<Minor> minorPieceCorrectionHistory;
CorrectionHistory<NonPawn> nonPawnCorrectionHistory[COLOR_NB]; CorrectionHistory<NonPawn> nonPawnCorrectionHistory[COLOR_NB];
CorrectionHistory<Continuation> continuationCorrectionHistory; CorrectionHistory<Continuation> continuationCorrectionHistory;