stellar

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

game.hpp (1716B)


      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     [[nodiscard]] const std::string get_moves() const;
     22     [[nodiscard]] const std::string &get_white() const { return white; }
     23     [[nodiscard]] const std::string &get_black() const { return black; }
     24     [[nodiscard]] const Terminate get_terminate() const { return terminate; }
     25 
     26     [[nodiscard]] const bool is_win_white() const { return !draw && winner == WHITE; }
     27     [[nodiscard]] const bool is_win_black() const { return !draw && winner == BLACK; }
     28     [[nodiscard]] const bool is_draw() const { return draw; }
     29     [[nodiscard]] const Color get_winner() const { return winner; }
     30 
     31     void set_terminate(const Terminate terminate) { this->terminate = terminate; }
     32     void set_winner(const Color winner) { this->winner = winner; }
     33     void set_draw(const bool draw) { this->draw = draw; }
     34 
     35     static void set_san(bool san) { Game::san = san; }
     36 
     37     friend std::ostream &operator<<(std::ostream &os, const Game &game);
     38 
     39   private:
     40     static const std::string to_san(const Board &board, const Move move);
     41 
     42     static uint16_t id_t;
     43     uint16_t id = id_t++;
     44     uint16_t match_id;
     45 
     46     const std::string white, black;
     47     const std::string fen;
     48     MoveList list;
     49 
     50     bool draw = false;
     51     Color winner;
     52     Terminate terminate = Terminate::Deatch;
     53 
     54     static bool san;
     55 };
     56 
     57 #endif