mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Introduce and use TranspositionTable::refresh()
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
ff95bbd41f
commit
c416133e2f
2 changed files with 15 additions and 9 deletions
|
@ -1001,10 +1001,8 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2. Check for aborted search and immediate draw
|
// Step 2. Check for aborted search and immediate draw
|
||||||
if (AbortSearch || ThreadsMgr.thread_should_stop(threadID))
|
if ( AbortSearch || ThreadsMgr.thread_should_stop(threadID)
|
||||||
return VALUE_DRAW;
|
|| pos.is_draw() || ply >= PLY_MAX - 1)
|
||||||
|
|
||||||
if (pos.is_draw() || ply >= PLY_MAX - 1)
|
|
||||||
return VALUE_DRAW;
|
return VALUE_DRAW;
|
||||||
|
|
||||||
// Step 3. Mate distance pruning
|
// Step 3. Mate distance pruning
|
||||||
|
@ -1021,7 +1019,7 @@ namespace {
|
||||||
posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key();
|
posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key();
|
||||||
|
|
||||||
tte = TT.retrieve(posKey);
|
tte = TT.retrieve(posKey);
|
||||||
ttMove = (tte ? tte->move() : MOVE_NONE);
|
ttMove = tte ? tte->move() : MOVE_NONE;
|
||||||
|
|
||||||
// At PV nodes, we don't use the TT for pruning, but only for move ordering.
|
// At PV nodes, we don't use the TT for pruning, but only for move ordering.
|
||||||
// This is to avoid problems in the following areas:
|
// This is to avoid problems in the following areas:
|
||||||
|
@ -1030,12 +1028,9 @@ namespace {
|
||||||
// * Fifty move rule detection
|
// * Fifty move rule detection
|
||||||
// * Searching for a mate
|
// * Searching for a mate
|
||||||
// * Printing of full PV line
|
// * Printing of full PV line
|
||||||
|
|
||||||
if (!PvNode && tte && ok_to_use_TT(tte, depth, beta, ply))
|
if (!PvNode && tte && ok_to_use_TT(tte, depth, beta, ply))
|
||||||
{
|
{
|
||||||
// Refresh tte entry to avoid aging
|
TT.refresh(tte);
|
||||||
TT.store(posKey, tte->value(), tte->type(), tte->depth(), ttMove, tte->static_value(), tte->static_value_margin());
|
|
||||||
|
|
||||||
ss->bestMove = ttMove; // Can be MOVE_NONE
|
ss->bestMove = ttMove; // Can be MOVE_NONE
|
||||||
return value_from_tt(tte->value(), ply);
|
return value_from_tt(tte->value(), ply);
|
||||||
}
|
}
|
||||||
|
|
11
src/tt.h
11
src/tt.h
|
@ -64,6 +64,7 @@ public:
|
||||||
staticValue = int16_t(statV);
|
staticValue = int16_t(statV);
|
||||||
staticValueMargin = int16_t(kd);
|
staticValueMargin = int16_t(kd);
|
||||||
}
|
}
|
||||||
|
void set_generation(int g) { data = move() | (type() << 21) | (g << 23); }
|
||||||
|
|
||||||
uint32_t key() const { return key32; }
|
uint32_t key() const { return key32; }
|
||||||
Depth depth() const { return Depth(depth16); }
|
Depth depth() const { return Depth(depth16); }
|
||||||
|
@ -114,6 +115,7 @@ public:
|
||||||
TTEntry* retrieve(const Key posKey) const;
|
TTEntry* retrieve(const Key posKey) const;
|
||||||
void new_search();
|
void new_search();
|
||||||
TTEntry* first_entry(const Key posKey) const;
|
TTEntry* first_entry(const Key posKey) const;
|
||||||
|
void refresh(const TTEntry* tte) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -133,4 +135,13 @@ inline TTEntry* TranspositionTable::first_entry(const Key posKey) const {
|
||||||
return entries[uint32_t(posKey) & (size - 1)].data;
|
return entries[uint32_t(posKey) & (size - 1)].data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// TranspositionTable::refresh updates the 'generation' value of the TTEntry
|
||||||
|
/// to avoid aging. Normally called after a TT hit, before to return.
|
||||||
|
|
||||||
|
inline void TranspositionTable::refresh(const TTEntry* tte) const {
|
||||||
|
|
||||||
|
const_cast<TTEntry*>(tte)->set_generation(generation);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !defined(TT_H_INCLUDED)
|
#endif // !defined(TT_H_INCLUDED)
|
||||||
|
|
Loading…
Add table
Reference in a new issue