2Contains PlayerSummary class.
5from dataclasses
import dataclass
6from typing
import Dict, List
10import xiangqi_bindings
as xb
22 @param color xiangi_xb.PieceColoar: color of Player the summary belongs to.
23 @param player_type xiangipy.enums.PlayerType: type of the Player.
25 @param max_search_depth int: maximum depth that a Minimax move evaluator will search.
27 container
with summary data of each Move selected by Player.
31 player_type: PlayerType
32 move_evaluator_type: EvaluatorType = EvaluatorType.NULL
33 max_search_depth: int = None
34 zobrist_key_size: int =
None
35 zkeys_seed: int =
None
36 search_summaries: cdm.SearchSummaries =
None
41 Property indicating if PlayerSummary object has search summaries.
43 Expect to be
True for MinimaxMoveEvaluators,
False otherwise.
50 Number of moves selected by Player during Game.
57 Converts Players' move numbers in to overall Game Move numbers
58 (red = odd ints, black = even ints).
68 ) -> Dict[str, pd.DataFrame] | None:
70 Dictionary with strings corresponding to
71 xiangqi_xb.MinimaxResultType values
as keys,
and DataFrame of
72 result type counts
as values.
74 Each row of data frame -> move number, each col -> a value of
75 remaining search depth when result was obtained.
80 for name, value
in xb.MinimaxResultType.__members__.items():
81 new_df = pd.DataFrame(
83 search_summary.result_depth_counts[value, :]
88 new_df.index.name =
"game_move_numbers"
90 f
"remaining_depth={col_idx}"
91 for col_idx
in range(new_df.shape[1])
100 Dataframe with row -> move number, col -> xiangqi_xb.MinimaxResultType.
102 Named
'first_searches...' in constrast to
'extra_searches...' or
103 'second_searches...' which would occur
if first_search of
104 MinimaxMoveEvaluator.select_move returns an illegal move. After fixing bug
105 that was allowing moves that violated repeated move rule to be returned
106 by first search, have never recorded any second searches.
112 result_type_names = list(xb.MinimaxResultType.__members__.keys())
113 num_result_types = len(result_type_names)
119 (num_first_searches, num_result_types), dtype=np.int64
122 columns=result_type_names,
124 df.index.name =
"game_move_numbers"
127 for idx, (name, value)
in enumerate(
128 xb.MinimaxResultType.__members__.items()
130 for search_idx, search_summary
in enumerate(
134 df.iloc[search_idx, idx] = sum(
135 search_summary.result_depth_counts[value][:]
138 assert df[
"Unknown"].sum() == 0
139 df.drop(columns=[
"Unknown"], inplace=
True)
148 Transposition table size the first time any illegal move was returned
149 by first search. This has been NaN after fixing first search's repeat
155 ].tr_table_size_initial
160 Size of transposition table at end of game.
168 Transposition table size at first illegal move and end of game wrapped
169 into single convenience property.
171 return cdm.TranspositionTableSizesAtEvents(
179 Dataframe with row -> move number; cols -> number of nodes explored,
180 total time
for move selection, average time per node,
and minimax
181 evaluation score of the selected move.
186 num_nodes = np.array(
188 search_summary.num_nodes
193 search_time_s = np.array(
195 search_summary.time.total_seconds()
200 mean_time_per_node_ns = np.array(
202 search_summary.mean_time_per_node_ns
207 eval_score = np.array(
209 search_summary.equal_score_moves.shared_score
216 search_summary.tr_table_size_final
220 returned_illegal_move = np.array(
222 search_summary.returned_illegal_move
227 num_collisions = np.array(
229 search_summary.num_collisions
238 "num_nodes": num_nodes,
239 "search_time_s": search_time_s,
240 "mean_time_per_node_ns": mean_time_per_node_ns,
241 "eval_score": eval_score,
242 "tr_table_size": tr_table_size,
244 "returned_illegal_move": returned_illegal_move,
245 "num_collisions": num_collisions,
250 df.index.name =
"game_move_numbers"
257 Pandas Series with mean & max nodes per move, mean & max time per move,
258 and number of illegal move requests.
265 "mean_time_per_node_ns"
267 num_illegal_move_requests = len(
271 collisions_per_move = (
274 collisions_per_node = (
287 num_illegal_move_requests,
303 "num_illegal_move_requests",
305 "collisions_per_move",
306 "collisions_per_node",
308 "tr_table_size_first_illegal_move_request",
310 "tr_table_size_end_game",
A Python SearchSummaries.
Enum indicating type of core MoveEvaluator used for a Player.
Can take a turn in a Game.
Data container for data from one xiangqipy.game_interfaces.Player in a Game.
cdm.TranspositionTableSizesAtEvents tr_table_sizes_at_events(self)
Transposition table size at first illegal move and end of game wrapped into single convenience proper...
int|None tr_table_size_first_illegal_move_request(self)
Transposition table size the first time any illegal move was returned by first search.
pd.Series|None selection_stats(self)
Pandas Series with mean & max nodes per move, mean & max time per move, and number of illegal move re...
int|None tr_table_size_end_game(self)
Size of transposition table at end of game.
pd.DataFrame|None first_search_stats(self)
Dataframe with row -> move number; cols -> number of nodes explored, total time for move selection,...
pd.DataFrame|None first_searches_by_type(self)
Dataframe with row -> move number, col -> xiangqi_xb.MinimaxResultType.
int player_move_count(self)
Number of moves selected by Player during Game.
bool has_search_summaries(self)
Property indicating if PlayerSummary object has search summaries.
List[int] game_move_numbers(self)
Converts Players' move numbers in to overall Game Move numbers (red = odd ints, black = even ints).
Dict[str, pd.DataFrame]|None first_searches_by_type_and_depth(self)
Dictionary with strings corresponding to xiangqi_xb.MinimaxResultType values as keys,...
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.