added history class + gravity formula | bench 405930

This commit is contained in:
rektdie committed 2025-03-19 09:36:25 +01:00
1 parent cfce80cb43
commit 25f793339f
4 files changed
+34 -7

No files matched your search

+28 -2
View File
@@ -5,6 +5,7 @@
#include "move.h"
constexpr int maxDepth = 64;
constexpr int maxHistory = 16384;
extern U64 nodes;
extern bool benchStarted;
@@ -15,8 +16,6 @@ inline bool searchStopped = false;
// [id][ply]
inline int killerMoves[2][64];
// [stm][from][to]
inline int historyMoves[2][64][64];
class SearchResults {
public:
@@ -35,6 +34,33 @@ public:
}
};
class History {
private:
int historyMoves[2][64][64];
public:
void Update(bool stm, Move move, int bonus) {
int clampedBonus = std::clamp(bonus, -maxHistory, maxHistory);
historyMoves[stm][move.MoveFrom()][move.MoveTo()] +=
clampedBonus - historyMoves[stm][move.MoveFrom()][move.MoveTo()] * std::abs(clampedBonus) / maxHistory;
}
void Clear() {
for (auto &side : historyMoves) {
for (auto &from : side) {
for (auto &to : from) {
to = 0;
}
}
}
}
auto& operator[](int index) {
return historyMoves[index];
}
};
inline History history;
class PVLine {
private:
int length[maxDepth] = {};