stellar

UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

repetition.hpp (972B)


0 #ifndef STELLAR_REPETITION_H
1 #define STELLAR_REPETITION_H
3 #include <iostream>
4 #include <vector>
6 #include "utils.hpp"
8 namespace repetition {
10 class Table {
11 public:
12 Table() = default;
14 [[nodiscard]] bool is_repetition(const U64 hash) const {
15 for (int i = repetitions.size() - 1; i >= 0; i--) {
16 if (repetitions[i] == hash) return true;
17 if (repetitions[i] == hashNull) return false;
18 }
19 return false;
20 }
22 void pop() { repetitions.pop_back(); }
23 void clear() { repetitions.clear(); }
24 void push_null() { repetitions.push_back(hashNull); }
25 void push_hash(U64 hash) { repetitions.push_back(hash); }
27 friend std::ostream &operator<<(std::ostream &os, const Table &rtable) {
28 for (const U64 hash : rtable.repetitions)
29 os << hash << " ";
30 return os;
31 }
33 private:
34 std::vector<U64> repetitions;
36 const static int hashNull = 0;
37 };
39 } // namespace repetition
41 #endif