2Contains a single function, run(), that does everything needed to play a Game.
4from pathlib
import Path
7import xiangqi_bindings
as bindings
10 XiangqiGameCommandLine,
19def run(custom_output_root: Path =
None, **kwargs: Dict) -> GameSummary:
21 Collects command line args, instantiates everything needed for a Game, runs the Game,
22 and optionally saves GameSummary info.
24 @param custom_output_root: optional Path of output parent dir;
if not specified,
25 defaults to ./data/game_summaries/<timestamp-based-dirname>
26 @param **kwargs: optional key value pairs that can supplement
or override
33 run_kwargs = {**command_line_kwargs, **kwargs}
36 xiangqi_command = run_kwargs_interpreter.interpret_command()
38 game_board = bindings.GameBoard()
41 xiangqi_command=xiangqi_command, game_board=game_board
43 my_game =
Game(players=players, game_board=game_board)
45 game_summary = my_game.play()
48 if xiangqi_command.save_summary:
50 game_summary=game_summary,
51 output_dir_suffix=xiangqi_command.output_dir_suffix,
52 custom_output_root=custom_output_root,
55 output_generator.generate_output()
60if __name__ ==
"__main__":
Runs a game between two Players.
Outputs GameSummary to .json file, and saves plots to a .png file.
Builds two Player objects for a GameBoard based on XiangqiGameCommand.
GameSummary run(Path custom_output_root=None, **Dict kwargs)
Collects command line args, instantiates everything needed for a Game, runs the Game,...
Contains the GameOutputGenerator class.
GameSummary class and its component classes.
Handlers for signals received when Game is running in terminal UI.
Classes for building Player objects.