Merge pull request #75 from rektdie/SE

minor rework in tt | bench 3415609
This commit was merged in pull request #75.
This commit is contained in:
rektdie authored and GitHub committed 2025-06-06 09:58:43 +02:00
commit bec0f3275f
3 files changed
+18 -11

No files matched your search

+5 -4
View File
@@ -316,12 +316,13 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
if (ply && (IsDraw(board, ctx))) return 0;
TTEntry entry = ctx->TT.ReadEntry(board.hashKey, depth, alpha, beta);
const bool ttHit = entry.score != invalidEntry;
// if NOT PV node then we try to hit the TTable
if constexpr (!isPV) {
SearchResults entry = ctx->TT.ReadEntry(board.hashKey, depth, alpha, beta);
if (entry.score != invalidEntry) {
return entry;
}
if (ttHit)
return SearchResults(entry.score, entry.bestMove);
}
if (depth <= 0) return Quiescence<mode>(board, alpha, beta, ply, ctx);
+5 -5
View File
@@ -1,16 +1,16 @@
#include "tt.h"
SearchResults TTable::ReadEntry(U64 &hashKey, int depth, int alpha, int beta) {
TTEntry TTable::ReadEntry(U64 &hashKey, int depth, int alpha, int beta) {
TTEntry *current = &table[hashKey % table.size()];
if (current->hashKey == hashKey) {
if (current->depth >= depth) {
if (current->nodeType == PV){
return {current->score, current->bestMove};
return *current;
} else if (current->nodeType == AllNode && current->score <= alpha) {
return current->score;
return *current;
} else if (current->nodeType == CutNode && current->score >= beta) {
return current->score;
return *current;
}
}
}
@@ -27,4 +27,4 @@ void TTable::WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move b
current->score = score;
current->depth = depth;
current->bestMove = bestMove;
}
}
+8 -2
View File
@@ -27,6 +27,12 @@ public:
uint8_t depth = 0;
uint8_t nodeType = 0;
TTEntry() {}
TTEntry(int16_t score) {
this->score = score;
}
operator U64() {
return hashKey;
}
@@ -37,7 +43,7 @@ constexpr U64 maxHash = (1024 * 1000000) / sizeof(TTEntry);
// 5 MB
constexpr U64 defaultHash = (8 * 1000000) / sizeof(TTEntry);
constexpr int invalidEntry = 111111;
constexpr int16_t invalidEntry = 111111;
class TTable {
private:
@@ -71,7 +77,7 @@ public:
return count;
}
SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta);
TTEntry ReadEntry(U64 &hashKey, int depth, int alpha, int beta);
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move besteMove);
};