stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE |
repetition.hpp (909B)
0 #ifndef STELLAR_REPETITION_H
1 #define STELLAR_REPETITION_H
3 namespace repetition {
5 class Table {
6 public:
7 Table() = default;
9 bool is_repetition(const U64 hash) const {
10 for (int i = repetitions.size() - 1; i >= 0; i--) {
11 if (repetitions[i] == hash) return true;
12 if (repetitions[i] == hashNull) return false;
13 }
14 return false;
15 }
17 void pop(void) { repetitions.pop_back(); }
18 void clear(void) { repetitions.clear(); }
19 void push_null(void) { repetitions.push_back(hashNull); }
20 void push_hash(U64 hash) { repetitions.push_back(hash); }
22 friend std::ostream &operator<<(std::ostream &os, const Table &rtable) {
23 for (const U64 hash : rtable.repetitions)
24 os << hash << " ";
25 return os;
26 }
28 private:
29 std::vector<U64> repetitions;
31 const static int hashNull = 0;
32 };
34 } // namespace repetition
36 #endif