tt aging | bench 1743358
This commit is contained in:
1 parent
855e5c2377
commit
5ca125e336
3 files changed
+40
-4
No files matched your search
@@ -896,6 +896,7 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext* ctx) {
|
||||
template <searchMode mode>
|
||||
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext* ctx) {
|
||||
searchStopped = false;
|
||||
ctx->TT->IncreaseAge();
|
||||
ctx->seldepth = 0;
|
||||
ctx->nodesTable = {};
|
||||
if constexpr (mode != bench) {
|
||||
|
||||
+27
-4
@@ -10,18 +10,41 @@ void TTable::WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move b
|
||||
current = &bucket->depthPreferred;
|
||||
} else if (bucket->alwaysReplace && bucket->alwaysReplace.hashKey == hashKey) {
|
||||
current = &bucket->alwaysReplace;
|
||||
} else if (!bucket->alwaysReplace) {
|
||||
current = &bucket->alwaysReplace;
|
||||
} else if (!bucket->depthPreferred) {
|
||||
current = &bucket->depthPreferred;
|
||||
} else if (ttpv) {
|
||||
current = &bucket->depthPreferred;
|
||||
} else if (!bucket->depthPreferred || bucket->depthPreferred.depth <= depth) {
|
||||
current = &bucket->depthPreferred;
|
||||
} else {
|
||||
current = &bucket->alwaysReplace;
|
||||
const int depthPreferredValue = GetReplacementValue(bucket->depthPreferred);
|
||||
const int alwaysReplaceValue = GetReplacementValue(bucket->alwaysReplace);
|
||||
|
||||
if (depthPreferredValue <= alwaysReplaceValue) {
|
||||
current = &bucket->depthPreferred;
|
||||
} else {
|
||||
current = &bucket->alwaysReplace;
|
||||
}
|
||||
}
|
||||
|
||||
const bool samePosition = current->hashKey == hashKey;
|
||||
const bool exactBound = nodeType == PV;
|
||||
const bool entryFromCurrentAge = current->age == age;
|
||||
const int writeDepth = depth + 4 + ttpv * 2;
|
||||
|
||||
if (samePosition && !exactBound && entryFromCurrentAge && writeDepth <= current->depth) {
|
||||
return;
|
||||
}
|
||||
|
||||
current->hashKey = hashKey;
|
||||
current->nodeType = nodeType;
|
||||
current->score = score;
|
||||
current->depth = depth;
|
||||
current->bestMove = bestMove;
|
||||
|
||||
if (bestMove || !samePosition) {
|
||||
current->bestMove = bestMove;
|
||||
}
|
||||
|
||||
current->age = age;
|
||||
current->ttpv = ttpv;
|
||||
}
|
||||
+12
@@ -26,6 +26,7 @@ public:
|
||||
Move bestMove = Move();
|
||||
uint8_t depth = 0;
|
||||
uint8_t nodeType = 0;
|
||||
uint8_t age = 0;
|
||||
bool ttpv = false;
|
||||
|
||||
TTEntry() {}
|
||||
@@ -55,6 +56,13 @@ constexpr int16_t invalidEntry = 11111;
|
||||
class TTable {
|
||||
private:
|
||||
std::vector<TTBucket> table;
|
||||
|
||||
uint8_t age = 0;
|
||||
|
||||
int GetReplacementValue(const TTEntry& entry) const {
|
||||
const int ageDelta = uint8_t(age - entry.age);
|
||||
return entry.depth - ageDelta * 4 + entry.ttpv * 2;
|
||||
}
|
||||
public:
|
||||
TTable() : table(defaultHash) {};
|
||||
|
||||
@@ -72,6 +80,10 @@ public:
|
||||
__builtin_prefetch(&table[hashKey % table.size()]);
|
||||
}
|
||||
|
||||
void IncreaseAge() {
|
||||
age++;
|
||||
}
|
||||
|
||||
TTEntry GetEntry(U64 &hashKey) {
|
||||
TTBucket *current = &table[hashKey % table.size()];
|
||||
if (current->depthPreferred.hashKey == hashKey) {
|
||||
|
||||
Reference in new issue
Block a user