stellar

UCI 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
3 #include "movelist.hpp"
5 class Game {
6 public:
7 static const std::string startPosition;
8 enum Terminate {
9 Deatch,
10 Timeout,
11 Illegal,
12 Repetition,
13 };
15 Game(const uint16_t match_id, const std::string &white, const std::string &black, const std::string &fen);
16 ~Game();
18 void play(const Move move) { list.push(move); }
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; }
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; }
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; }
34 static void set_san(bool san) { Game::san = san; }
36 friend std::ostream &operator<<(std::ostream &os, const Game &game);
38 private:
39 static const std::string to_san(const Board &board, const Move move);
41 static uint16_t id_t;
42 uint16_t id = id_t++;
43 uint16_t match_id;
45 const std::string white, black;
46 const std::string fen;
47 MoveList list;
49 bool draw = false;
50 Color winner;
51 Terminate terminate = Terminate::Deatch;
53 static bool san;
54 };
56 #endif