Merge pull request #24 from rektdie/gravity
Gravity bench 412557
This commit was merged in pull request #24.
This commit is contained in:
4 files changed
+35
-7
No files matched your search
@@ -69,7 +69,8 @@ void RunBenchmark() {
|
||||
// Clearing
|
||||
TT.Clear();
|
||||
std::memset(killerMoves, 0, sizeof(killerMoves));
|
||||
std::memset(historyMoves, 0, sizeof(historyMoves));
|
||||
|
||||
history.Clear();
|
||||
|
||||
nodes = 0;
|
||||
|
||||
|
||||
+2
-3
@@ -38,7 +38,7 @@ static int ScoreMove(Board &board, Move &move, int ply) {
|
||||
return 18000;
|
||||
} else {
|
||||
// Max 16384
|
||||
return historyMoves[board.sideToMove][move.MoveFrom()][move.MoveTo()];
|
||||
return history[board.sideToMove][move.MoveFrom()][move.MoveTo()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,8 +265,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
|
||||
killerMoves[1][ply] = killerMoves[0][ply];
|
||||
killerMoves[0][ply] = currMove;
|
||||
|
||||
historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] =
|
||||
std::min(16384, historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] + depth * depth);
|
||||
history.Update(board.sideToMove, currMove, depth * depth);
|
||||
}
|
||||
|
||||
TT.WriteEntry(board.hashKey, depth, score, CutNode, Move());
|
||||
|
||||
+29
-2
@@ -3,8 +3,10 @@
|
||||
#include "uci.h"
|
||||
#include <vector>
|
||||
#include "move.h"
|
||||
#include <algorithm>
|
||||
|
||||
constexpr int maxDepth = 64;
|
||||
constexpr int maxHistory = 16384;
|
||||
|
||||
extern U64 nodes;
|
||||
extern bool benchStarted;
|
||||
@@ -15,8 +17,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 +35,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] = {};
|
||||
|
||||
+2
-1
@@ -119,7 +119,8 @@ void UCILoop(Board &board) {
|
||||
// Clearing
|
||||
TT.Clear();
|
||||
std::memset(killerMoves, 0, sizeof(killerMoves));
|
||||
std::memset(historyMoves, 0, sizeof(historyMoves));
|
||||
|
||||
history.Clear();
|
||||
positionIndex = 0;
|
||||
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user