encapsulated TT | bench 1857933

This commit is contained in:
rektdie committed 2025-04-12 22:43:39 +02:00
1 parent c08c545335
commit 53f6ae17bc
7 files changed
+43 -49

No files matched your search

+22 -9
View File
@@ -1,8 +1,24 @@
#pragma once
#include "board.h"
#include "search.h"
#include <vector>
class SearchResults {
public:
int score = 0;
Move bestMove = Move();
SearchResults(){}
SearchResults(int pScore, Move pMove) {
score = pScore;
bestMove = pMove;
}
SearchResults(int pScore) {
score = pScore;
}
};
class TTEntry {
public:
U64 hashKey;
@@ -21,27 +37,26 @@ constexpr U64 maxHash = (64* 1000000) / sizeof(TTEntry);
// 5 MB
constexpr U64 defaultHash = (5 * 1000000) / sizeof(TTEntry);
inline U64 hashSize = defaultHash;
constexpr int invalidEntry = 111111;
class TTable {
private:
std::vector<TTEntry> table;
public:
TTable() : table(hashSize) {};
TTable() : table(defaultHash) {};
void Resize(U64 size) {
table.resize(size);
}
void Clear() {
U64 size = table.size();
table.clear();
table.resize(hashSize);
table.resize(size);
}
TTEntry* GetRawEntry(U64 &hashKey) {
TTEntry *current = &table[hashKey % hashSize];
TTEntry *current = &table[hashKey % table.size()];
return current;
}
@@ -56,9 +71,7 @@ public:
return count;
}
SEARCH::SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta);
SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta);
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move besteMove);
};
inline TTable TT;