stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE | |
game.hpp (1603B)
1 #ifndef STELLAR_ARENA_GAME_H 2 #define STELLAR_ARENA_GAME_H 3 4 #include "movelist.hpp" 5 6 class Game { 7 public: 8 static const std::string startPosition; 9 enum Terminate { 10 Deatch, 11 Timeout, 12 Illegal, 13 Repetition, 14 }; 15 16 Game(const uint16_t match_id, const std::string white, const std::string black, const std::string fen); 17 ~Game(); 18 19 void play(const Move move) { list.push(move); } 20 21 const std::string get_moves(void) const; 22 const std::string &get_white(void) const { return white; } 23 const std::string &get_black(void) const { return black; } 24 const Terminate get_terminate(void) const { return terminate; } 25 26 const bool is_win_white(void) const { return !draw && winner == color::WHITE; } 27 const bool is_win_black(void) const { return !draw && winner == color::BLACK; } 28 const bool is_draw(void) const { return draw; } 29 30 void set_terminate(const Terminate terminate) { this->terminate = terminate; } 31 void set_winner(const color::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::Color winner; 51 Terminate terminate = Terminate::Deatch; 52 53 static bool san; 54 }; 55 56 #endif