major correction history | bench 1744326
This commit is contained in:
1 parent
194c3d3bc4
commit
4b3e8020fa
3 files changed
+15
-1
No files matched your search
@@ -37,6 +37,7 @@ void Board::Reset() {
|
|||||||
hashKey = 0ULL;
|
hashKey = 0ULL;
|
||||||
pawnKey = 0ULL;
|
pawnKey = 0ULL;
|
||||||
nonPawnKey = 0ULL;
|
nonPawnKey = 0ULL;
|
||||||
|
majorKey = 0ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::SetByFen(std::string_view fen) {
|
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];
|
pawnKey ^= UTILS::zKeys[color][Pawn][square];
|
||||||
} else {
|
} else {
|
||||||
nonPawnKey ^= UTILS::zKeys[color][piece][square];
|
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];
|
pawnKey ^= UTILS::zKeys[color][Pawn][square];
|
||||||
} else {
|
} else {
|
||||||
nonPawnKey ^= UTILS::zKeys[color][piece][square];
|
nonPawnKey ^= UTILS::zKeys[color][piece][square];
|
||||||
|
|
||||||
|
if (piece == King || piece == Rook || piece == Queen) {
|
||||||
|
majorKey ^= UTILS::zKeys[color][piece][square];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public:
|
|||||||
U64 hashKey = 0ULL;
|
U64 hashKey = 0ULL;
|
||||||
U64 pawnKey = 0ULL;
|
U64 pawnKey = 0ULL;
|
||||||
U64 nonPawnKey = 0ULL;
|
U64 nonPawnKey = 0ULL;
|
||||||
|
U64 majorKey = 0ULL;
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
void SetByFen(std::string_view fen);
|
void SetByFen(std::string_view fen);
|
||||||
|
|||||||
+5
-1
@@ -74,6 +74,7 @@ private:
|
|||||||
// indexed by [stm][key]
|
// indexed by [stm][key]
|
||||||
MultiArray<int, 2, CORRHIST_SIZE> pawnHist;
|
MultiArray<int, 2, CORRHIST_SIZE> pawnHist;
|
||||||
MultiArray<int, 2, CORRHIST_SIZE> nonPawnHist;
|
MultiArray<int, 2, CORRHIST_SIZE> nonPawnHist;
|
||||||
|
MultiArray<int, 2, CORRHIST_SIZE> majorHist;
|
||||||
public:
|
public:
|
||||||
void Update(Board& board, int depth, int diff, int* entry) {
|
void Update(Board& board, int depth, int diff, int* entry) {
|
||||||
const int scaledDiff = diff * CORRHIST_GRAIN;
|
const int scaledDiff = diff * CORRHIST_GRAIN;
|
||||||
@@ -86,16 +87,19 @@ public:
|
|||||||
void UpdateAll(Board& board, int depth, int diff) {
|
void UpdateAll(Board& board, int depth, int diff) {
|
||||||
Update(board, depth, diff, &pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]);
|
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, &nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]);
|
||||||
|
Update(board, depth, diff, &majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetAllHist(Board& board) {
|
int GetAllHist(Board& board) {
|
||||||
return pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]
|
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() {
|
void Clear() {
|
||||||
std::fill(&pawnHist[0][0], &pawnHist[0][0] + sizeof(pawnHist) / sizeof(int), 0);
|
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(&nonPawnHist[0][0], &nonPawnHist[0][0] + sizeof(nonPawnHist) / sizeof(int), 0);
|
||||||
|
std::fill(&majorHist[0][0], &majorHist[0][0] + sizeof(majorHist) / sizeof(int), 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user