No globals #50

Merged
rektdie merged 23 commits from no_globals into main 2025-04-12 13:52:41 +02:00
5 changed files with 9 additions and 12 deletions
Showing only changes of commit dd6f0b94f5 - Show all commits

No files matched your search

-2
View File
@@ -69,7 +69,6 @@ void RunBenchmark() {
// Clearing
TT.Clear();
std::memset(killerMoves, 0, sizeof(killerMoves));
SearchContext ctx;
@@ -82,6 +81,5 @@ void RunBenchmark() {
std::cout << ctx.nodes << " nodes " << int(ctx.nodes/sw.GetElapsedSec()) << " nps" << std::endl;
TT.Clear();
std::memset(killerMoves, 0, sizeof(killerMoves));
positionIndex = 0;
}
-2
View File
@@ -102,8 +102,6 @@ void PlayGame(std::atomic<int>& positions, U64 targetPositions, std::vector<Game
// Since positionIndex is thread-local, no need to protect it
positionIndex = 0;
std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves));
SEARCH::SearchContext ctx;
try {
+4 -4
View File
@@ -40,9 +40,9 @@ static int ScoreMove(Board &board, Move &move, int ply, SearchContext& ctx) {
return moveScoreTable[attackerType][targetType] + 30000;
} else {
if (killerMoves[0][ply] == move) {
if (ctx.killerMoves[0][ply] == move) {
return 20000;
} else if (killerMoves[1][ply] == move) {
} else if (ctx.killerMoves[1][ply] == move) {
return 18000;
} else {
// Max 16384
@@ -328,8 +328,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
// Fail high (beta cutoff)
if (score >= beta) {
if (!currMove.IsCapture()) {
killerMoves[1][ply] = killerMoves[0][ply];
killerMoves[0][ply] = currMove;
ctx.killerMoves[1][ply] = ctx.killerMoves[0][ply];
ctx.killerMoves[0][ply] = currMove;
int bonus = depth * depth;
+3 -3
View File
@@ -22,9 +22,6 @@ constexpr int MAX_HISTORY = 16384;
constexpr int inf = 100000;
// [id][ply]
inline int killerMoves[2][MAX_PLY];
inline int lmrTable[MAX_DEPTH+1][MAX_MOVES];
void InitLMRTable();
@@ -115,12 +112,15 @@ public:
PVLine pvLine;
History history;
std::array<std::array<int, MAX_PLY>, 2> killerMoves{};
Stopwatch sw;
SearchContext(){
pvLine.Clear();
history.Clear();
sw.Restart();
killerMoves = {};
}
};
+2 -1
View File
@@ -136,9 +136,10 @@ void UCILoop(Board &board) {
// Clearing
TT.Clear();
std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves));
ctx.killerMoves = {};
ctx.history.Clear();
positionIndex = 0;
continue;