13 std::shared_ptr<SpaceInfoProviderBase> game_board,
14 std::unordered_map<gameboard::PieceColor, PlayerSpec> player_specs,
17 std::shared_ptr<GameReporterInterface> game_reporter,
18 bool report_during_game,
21 : game_board_{game_board}
22 , player_specs_{player_specs}
23 , move_evaluators_{std::move(move_evaluators)}
24 , game_reporter_{game_reporter}
25 , report_during_game_{report_during_game}
27 , whose_turn_{whose_turn}
29 , game_id_{GenerateGameID()}
30 , stop_requested_{false}
31 , stop_signal_received_{std::nullopt} {}
44 auto now = std::chrono::system_clock::now();
45 auto time_now = std::chrono::system_clock::to_time_t(now);
46 auto duration = now.time_since_epoch();
48 std::chrono::duration_cast<std::chrono::microseconds>(duration).count() % 1000000;
50 std::ostringstream oss;
51 oss << std::put_time(std::localtime(&time_now),
"%Y%m%d%H%M%S");
52 oss << std::setw(3) << std::setfill(
'0') << musec;
58 bool obtained_valid_move =
false;
61 while (not obtained_valid_move) {
64 result = proposed_move;
65 obtained_valid_move =
true;
76 auto executed_move =
game_board_->ExecuteMove(valid_move);
82 std::unordered_map<gameboard::PieceColor, moveselection::SearchSummaries>
85 auto red_search_summaries =
87 if (red_search_summaries.has_value()) {
91 auto black_search_summaries =
93 if (black_search_summaries.has_value()) {
129 if (available_moves.Size() == 0) {
155 std::cout <<
"Game terminated early." << std::endl;
std::unordered_map< gameboard::PieceColor, PlayerSpec > player_specs_
gameboard::Move GetValidMove(const gameboard::MoveCollection &available_moves)
std::shared_ptr< GameReporterInterface > game_reporter_
gameboard::PieceColor whose_turn_
void PlayerTurn(const gameboard::MoveCollection &available_moves)
void SetWinner(gameboard::PieceColor color)
std::optional< int > stop_signal_received_
std::optional< int > stop_signal_received()
std::unordered_map< gameboard::PieceColor, std::unique_ptr< MoveEvaluatorBase > > move_evaluators_
std::atomic_bool stop_requested_
std::vector< gameboard::ExecutedMove > move_log_
std::string GenerateGameID()
std::shared_ptr< SpaceInfoProviderBase > game_board_
void RequestStop(int signal)
Game(std::shared_ptr< SpaceInfoProviderBase > game_board, std::unordered_map< gameboard::PieceColor, PlayerSpec > player_specs, std::unordered_map< gameboard::PieceColor, std::unique_ptr< MoveEvaluatorBase > > move_evaluators, std::shared_ptr< GameReporterInterface > game_reporter, bool report_during_game=true, gameboard::PieceColor whose_turn=gameboard::PieceColor::kRed)
GameSummary GenerateGameSummary()
PieceColor opponent_of(PieceColor color)
A container for multiple gameboard::Move objects.
bool ContainsMove(const Move &move) const
A gameboard::BoardSpace pair (start and end).