/
tt.h
52 lines (40 loc) · 980 Bytes
/
tt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef TT_H_GAURD
#define TT_H_GAURD
#include <stdint.h>
#include "types.h"
enum TTBound {
LOW_BOUND,
HIGH_BOUND,
EXACT_BOUND
};
class TTable;
class TTEntry {
friend TTable;
public:
Move best_move() const { return static_cast<Move>(move); }
Score score() const { return static_cast<Score>(value); }
TTBound bound() const { return TTBound(gen_bound & 0x3); }
uint16_t gen() const { return gen_bound >> 2; }
uint64_t allowance;
uint64_t key;
Score value;
uint16_t move;
uint16_t gen_bound;
};
class TTable {
public:
TTable() : current_generation(4) {};
TTable(const TTable&) = delete;
TTable& operator=(const TTable&) = delete;
void resize(size_t size);
TTEntry* probe(Key zkey);
void prefetch(Key zkey);
void save(const Position& pos, Move move, TTBound bound, Score val, uint64_t allowance);
void age();
void clear();
private:
std::vector<TTEntry> entries;
uint16_t current_generation;
};
extern TTable TT;
#endif