stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE |
game.hpp (1716B)
0 #ifndef STELLAR_ARENA_GAME_H 1 #define STELLAR_ARENA_GAME_H 2 3 #include "movelist.hpp" 4 5 class Game { 6 public: 7 static const std::string startPosition; 8 enum Terminate { 9 Deatch, 10 Timeout, 11 Illegal, 12 Repetition, 13 }; 14 15 Game(const uint16_t match_id, const std::string &white, const std::string &black, const std::string &fen); 16 ~Game(); 17 18 void play(const Move move) { list.push(move); } 19 20 [[nodiscard]] const std::string get_moves() const; 21 [[nodiscard]] const std::string &get_white() const { return white; } 22 [[nodiscard]] const std::string &get_black() const { return black; } 23 [[nodiscard]] const Terminate get_terminate() const { return terminate; } 24 25 [[nodiscard]] const bool is_win_white() const { return !draw && winner == WHITE; } 26 [[nodiscard]] const bool is_win_black() const { return !draw && winner == BLACK; } 27 [[nodiscard]] const bool is_draw() const { return draw; } 28 [[nodiscard]] const Color get_winner() const { return winner; } 29 30 void set_terminate(const Terminate terminate) { this->terminate = terminate; } 31 void set_winner(const Color winner) { this->winner = winner; } 32 void set_draw(const bool draw) { this->draw = draw; } 33 34 static void set_san(bool san) { Game::san = san; } 35 36 friend std::ostream &operator<<(std::ostream &os, const Game &game); 37 38 private: 39 static const std::string to_san(const Board &board, const Move move); 40 41 static uint16_t id_t; 42 uint16_t id = id_t++; 43 uint16_t match_id; 44 45 const std::string white, black; 46 const std::string fen; 47 MoveList list; 48 49 bool draw = false; 50 Color winner; 51 Terminate terminate = Terminate::Deatch; 52 53 static bool san; 54 }; 55 56 #endif