Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
app_simple.py
Go to the documentation of this file.
1from pathlib import Path
2
3from xiangqipy.command_input import (XiangqiGameCommandLine, build_game_runner,
4 get_output_file_info)
5from xiangqipy.game_output_generator import GameOutputGenerator
6from xiangqipy.game_summary_converter import CoreToPyGameSummaryConverter
7
8
9def run(custom_output_root: Path = None, **kwargs):
10 """
11 Creates xiangqi_bindings.PlayerSpec objects for each player, and runs a
12 xiangqi_bindings.Game
13 """
14 command_line_kwargs = XiangqiGameCommandLine().get_args()
15 run_kwargs = {**command_line_kwargs, **kwargs}
16
17 output_file_info = get_output_file_info(run_kwargs)
18 game_runner = build_game_runner(run_kwargs)
19
20 core_game_summary = game_runner.run_game()
21 py_game_summary = CoreToPyGameSummaryConverter(
22 core_game_summary=core_game_summary
23 ).convert()
24
25 if output_file_info.save_summary:
26 output_generator = GameOutputGenerator(
27 game_summary=py_game_summary,
28 output_dir_suffix=output_file_info.output_dir_suffix,
29 custom_output_root=custom_output_root,
30 )
31 output_generator.generate_output()
32
33
34if __name__ == "__main__":
35 run(red_strength=2, black_strength=3)
Collects info from command line args out outputs as a dictionary.
Outputs GameSummary to .json file, and saves plots to a .png file.
def run(Path custom_output_root=None, **kwargs)
Creates xiangqi_bindings.PlayerSpec objects for each player, and runs a xiangqi_bindings....
Definition: app_simple.py:9
Contains classes for collecting command line input, and converting to a form that will be convenient ...
Definition: command_input.py:1
Contains the GameOutputGenerator class.