along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cstring>
+#include <cstring> // For std::memset
#include <iostream>
#include "bitboard.h"
}
-/// 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 {
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;
}