2GameSummary class and its component classes.
5from dataclasses
import dataclass
6from typing
import Dict, List
10import xiangqi_bindings
as bindings
20 A data container for holding one PlayerSummary
for each player
in a Game.
22 @param kRed PlayerSummary: summary data
for red player
23 @param kBlk PlayerSummary: summary data
for black player
34 Attributes are all either primitives
or from core_data_class_mirrors to
35 minimize need
for enc_hook
's in msgspec IO.
37 @param game_id str: unique ID of the Game, typically based on timestamp when Game
is instantiated.
39 @param whose_turn xianqi_bindings.PieceColor: color of Player to execute next move.
47 whose_turn: bindings.PieceColor
48 move_log: List[cdm.ExecutedMove]
49 player_summaries: PlayerSummaries
54 Number of moves executed in the Game.
61 Dictionary with list of move ID numbers executed by each player;
62 normally Red player
's list has odd integers, and Black's has even integers.
65 bindings.PieceColor.kBlk: [
66 val
for val
in range(1, self.
move_counts + 1)
if (val % 2) == 0
68 bindings.PieceColor.kRed: [
69 val
for val
in range(self.
move_counts + 1)
if (val % 2) == 1
77 @param player xiangqi_bindings.PieceColor of player that PlayerSummary
is being retrieved
for.
83 basic_game_stats = pd.Series(
85 index=[
"move_counts",
"game_state"],
87 for player
in [bindings.PieceColor.kRed, bindings.PieceColor.kBlk]:
89 if player_summary.has_search_summaries:
90 player_stats = player_summary.selection_stats
91 player_stats.index = [
92 f
"{player.name}_{idx}"
93 for idx
in player_stats.index
96 basic_game_stats = pd.concat([basic_game_stats, player_stats])
98 return basic_game_stats
Enum indicating state of game: is either unfinished, or a particular player has won.
Runs a game between two Players.
Holds summary info of a xiangqipy.game.Game; implements msgspec.Struct for json IO.
Dict[bindings.PieceColor, List[int]] move_numbers(self)
Dictionary with list of move ID numbers executed by each player; normally Red player's list has odd i...
int move_counts(self)
Number of moves executed in the Game.
PlayerSummary get_player_summary(self, bindings.PieceColor player)
Gets the xiangqipy.player_summary.PlayerSummary for a particular xiangqi_bindings....
pd.Series basic_stats(self)
PlayerSummaries player_summaries
A data container for holding one PlayerSummary for each player in a Game.
Data container for data from one xiangqipy.game_interfaces.Player in a Game.
Proposed moves selected using an implementation of core MoveEvaluator.
Contains classes that mirror the structure of some core C++ classes, primarily to facilitate easy IO ...
Enums that are only used on the Python side of the app.
Contains PlayerSummary class.