Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
game.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
13#include <iostream>
14#include <memory>
15#include <optional>
16#include <string>
17#include <unordered_map>
18
19namespace game {
20class Game {
21 std::shared_ptr<SpaceInfoProviderBase> game_board_;
22 std::unordered_map<gameboard::PieceColor, PlayerSpec> player_specs_;
23 std::unordered_map<gameboard::PieceColor, std::unique_ptr<MoveEvaluatorBase>>
26 std::shared_ptr<GameReporterInterface> game_reporter_;
28 std::vector<gameboard::ExecutedMove> move_log_;
30 std::string game_id_;
31 std::atomic_bool stop_requested_;
32 std::optional<int> stop_signal_received_;
33
34public:
35 Game(
36 std::shared_ptr<SpaceInfoProviderBase> game_board,
37 std::unordered_map<gameboard::PieceColor, PlayerSpec> player_specs,
38 std::unordered_map<gameboard::PieceColor, std::unique_ptr<MoveEvaluatorBase>>
39 move_evaluators,
40 std::shared_ptr<GameReporterInterface> game_reporter,
41 bool report_during_game = true,
43 );
44
46 void RequestStop(int signal);
47 std::optional<int> stop_signal_received();
48
49private:
50 std::string GenerateGameID();
52 void PlayerTurn(const gameboard::MoveCollection &available_moves);
53 void ChangeWhoseTurn();
56};
57
58} // namespace game
Constants, typedefs, and simple structs used by gameboard::GameBoard.
std::unordered_map< gameboard::PieceColor, PlayerSpec > player_specs_
Definition: game.hpp:22
gameboard::Move GetValidMove(const gameboard::MoveCollection &available_moves)
Definition: game.cpp:57
GameState game_state_
Definition: game.hpp:25
std::shared_ptr< GameReporterInterface > game_reporter_
Definition: game.hpp:26
bool report_during_game_
Definition: game.hpp:29
gameboard::PieceColor whose_turn_
Definition: game.hpp:27
void PlayerTurn(const gameboard::MoveCollection &available_moves)
Definition: game.cpp:74
void SetWinner(gameboard::PieceColor color)
Definition: game.cpp:35
std::optional< int > stop_signal_received_
Definition: game.hpp:32
void ChangeWhoseTurn()
Definition: game.cpp:33
std::optional< int > stop_signal_received()
Definition: game.cpp:108
std::unordered_map< gameboard::PieceColor, std::unique_ptr< MoveEvaluatorBase > > move_evaluators_
Definition: game.hpp:24
std::atomic_bool stop_requested_
Definition: game.hpp:31
std::vector< gameboard::ExecutedMove > move_log_
Definition: game.hpp:28
std::string GenerateGameID()
Definition: game.cpp:43
std::string game_id_
Definition: game.hpp:30
GameSummary Play()
Definition: game.cpp:110
std::shared_ptr< SpaceInfoProviderBase > game_board_
Definition: game.hpp:21
void RequestStop(int signal)
Definition: game.cpp:103
GameSummary GenerateGameSummary()
Definition: game.cpp:80
Defines GamePiece and supporting constants and free functions.
Definition: game.hpp:19
A container for multiple gameboard::Move objects.
A gameboard::BoardSpace pair (start and end).