public:
static inline constexpr const int16_t unknown = 32500;
static void clear() { memset(table.data(), 0x00, size * sizeof(Hashe)); };
static void clear() {
memset(table.data(), 0x00, size * sizeof(Hashe));
#ifdef USE_STATS
accessed = 0, rewrite = 0, miss = 0;
#endif
};
#ifdef USE_STATS
static void print() {
std::cout << "Transposition table: " << std::endl;
std::cout << "\tSize: " << size << " entries (" << sizeof(Hashe) << "B per entry)" << std::endl;
std::cout << "\tSize: " << std::fixed << std::setprecision(2)
<< (double)size * sizeof(Hashe) / (1 << 20) << "MB" << std::endl;
std::cout << "\tReads: " << accessed << std::endl;
std::cout << "\tMisses: " << miss << "(" << (double)miss / accessed << "%)" << std::endl;
std::cout << "\tRewrite: " << rewrite << std::endl;
std::cout << "\tUsed " << (double)used() / size << "%" << std::endl;
}
static U64 used() {
U64 res = 0;
for (int i = 0; i < size; i++) {
if (table[i].key) res++;
}
return res;
}
#endif
static int16_t read(const Board &board, int ply, Move *best, int16_t alpha, int16_t beta, uint8_t depth) {
U64 hash = board.get_hash();
const Hashe &phashe = table[hash % table.size()];
const Hashe &phashe = table[hash % size];
#ifdef USE_STATS
accessed++;
#endif
if (phashe.key == hash) {
if (phashe.depth >= depth) {
int16_t score = phashe.score;