mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 01:56:58 +08:00
Coding style in TT code
In particular seems more natural to return bool and TTEntry on the same line, actually we should pass and return them as a pair, but due to limitations of C++ and not wanting to use std::pair this can be an acceptable compromise. No functional change. Resolves #157
This commit is contained in:
committed by
Joona Kiiski
parent
0edb6348d2
commit
413b243809
24
src/tt.cpp
24
src/tt.cpp
@@ -63,12 +63,12 @@ void TranspositionTable::clear() {
|
||||
}
|
||||
|
||||
|
||||
/// TranspositionTable::probe() looks up the current position in the
|
||||
/// transposition table. It returns true and a pointer to the TTEntry if
|
||||
/// the position is found. Otherwise, it returns false and a pointer to an empty or
|
||||
/// least valuable TTEntry to be replaced later. A TTEntry t1 is considered
|
||||
/// to be more valuable than a TTEntry t2 if t1 is from the current search and t2
|
||||
/// is from a previous search, or if the depth of t1 is bigger than the depth of t2.
|
||||
/// TranspositionTable::probe() looks up the current position in the transposition
|
||||
/// table. It returns true and a pointer to the TTEntry if the position is found.
|
||||
/// Otherwise, it returns false and a pointer to an empty or least valuable TTEntry
|
||||
/// to be replaced later. A TTEntry t1 is considered to be more valuable than a
|
||||
/// TTEntry t2 if t1 is from the current search and t2 is from a previous search,
|
||||
/// or if the depth of t1 is bigger than the depth of t2.
|
||||
|
||||
TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
|
||||
|
||||
@@ -79,20 +79,18 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
|
||||
if (!tte[i].key16 || tte[i].key16 == key16)
|
||||
{
|
||||
if (tte[i].key16)
|
||||
tte[i].genBound8 = uint8_t(generation | tte[i].bound()); // Refresh
|
||||
tte[i].genBound8 = uint8_t(generation8 | tte[i].bound()); // Refresh
|
||||
|
||||
found = (bool)tte[i].key16;
|
||||
return &tte[i];
|
||||
return found = (bool)tte[i].key16, &tte[i];
|
||||
}
|
||||
|
||||
// Find an entry to be replaced according to the replacement strategy
|
||||
TTEntry* replace = tte;
|
||||
for (unsigned i = 1; i < TTClusterSize; ++i)
|
||||
if ( (( tte[i].genBound8 & 0xFC) == generation || tte[i].bound() == BOUND_EXACT)
|
||||
- ((replace->genBound8 & 0xFC) == generation)
|
||||
if ( (( tte[i].genBound8 & 0xFC) == generation8 || tte[i].bound() == BOUND_EXACT)
|
||||
- ((replace->genBound8 & 0xFC) == generation8)
|
||||
- (tte[i].depth8 < replace->depth8) < 0)
|
||||
replace = &tte[i];
|
||||
|
||||
found = false;
|
||||
return replace;
|
||||
return found = false, replace;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user