stellar

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

repetition.hpp (909B)


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