major correction history | bench 1744326 #146

Merged
rektdie merged 1 commits from major-corrhist into main 2026-02-25 16:36:01 +01:00
3 changed files with 15 additions and 1 deletions

No files matched your search

+9
View File
@@ -37,6 +37,7 @@ void Board::Reset() {
hashKey = 0ULL;
pawnKey = 0ULL;
nonPawnKey = 0ULL;
majorKey = 0ULL;
}
void Board::SetByFen(std::string_view fen) {
@@ -295,6 +296,10 @@ void Board::SetPiece(int piece, int square, bool color) {
pawnKey ^= UTILS::zKeys[color][Pawn][square];
} else {
nonPawnKey ^= UTILS::zKeys[color][piece][square];
if (piece == King || piece == Rook || piece == Queen) {
majorKey ^= UTILS::zKeys[color][piece][square];
}
}
}
@@ -309,6 +314,10 @@ void Board::RemovePiece(int piece, int square, bool color) {
pawnKey ^= UTILS::zKeys[color][Pawn][square];
} else {
nonPawnKey ^= UTILS::zKeys[color][piece][square];
if (piece == King || piece == Rook || piece == Queen) {
majorKey ^= UTILS::zKeys[color][piece][square];
}
}
}
+1
View File
@@ -45,6 +45,7 @@ public:
U64 hashKey = 0ULL;
U64 pawnKey = 0ULL;
U64 nonPawnKey = 0ULL;
U64 majorKey = 0ULL;
void Reset();
void SetByFen(std::string_view fen);
+5 -1
View File
@@ -74,6 +74,7 @@ private:
// indexed by [stm][key]
MultiArray<int, 2, CORRHIST_SIZE> pawnHist;
MultiArray<int, 2, CORRHIST_SIZE> nonPawnHist;
MultiArray<int, 2, CORRHIST_SIZE> majorHist;
public:
void Update(Board& board, int depth, int diff, int* entry) {
const int scaledDiff = diff * CORRHIST_GRAIN;
@@ -86,16 +87,19 @@ public:
void UpdateAll(Board& board, int depth, int diff) {
Update(board, depth, diff, &pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]);
Update(board, depth, diff, &nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]);
Update(board, depth, diff, &majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE]);
}
int GetAllHist(Board& board) {
return pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]
+ nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE];
+ nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]
+ majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE];
}
void Clear() {
std::fill(&pawnHist[0][0], &pawnHist[0][0] + sizeof(pawnHist) / sizeof(int), 0);
std::fill(&nonPawnHist[0][0], &nonPawnHist[0][0] + sizeof(nonPawnHist) / sizeof(int), 0);
std::fill(&majorHist[0][0], &majorHist[0][0] + sizeof(majorHist) / sizeof(int), 0);
}
};