2Contains classes that mirror the structure of some core C++ classes,
3primarily to facilitate easy IO of a GameSummary with msgspec.
8from dataclasses
import dataclass
9from typing
import Dict, List, TypeAlias
12import xiangqi_bindings
as bindings
17 Determines the integer type used for Points int the C++ core,
and provides
18 a numpy integer type
with the same size
and signed-ness.
27 (
False, 2): np.uint16,
28 (
False, 4): np.uint32,
29 (
False, 8): np.uint64,
34 bindings.is_signed_points_type(),
35 bindings.size_of_points_type(),
45 Enum indicating the type of result obtained from Minimax analysis
49 Unknown = int(bindings.MinimaxResultType.Unknown)
50 TrTableHit = int(bindings.MinimaxResultType.TrTableHit)
51 EvaluatorLoses = int(bindings.MinimaxResultType.EvaluatorLoses)
52 EvaluatorWins = int(bindings.MinimaxResultType.EvaluatorWins)
53 FullyEvaluatedNode = int(bindings.MinimaxResultType.FullyEvaluatedNode)
54 StandardLeaf = int(bindings.MinimaxResultType.StandardLeaf)
55 AlphaPrune = int(bindings.MinimaxResultType.AlphaPrune)
56 BetaPrune = int(bindings.MinimaxResultType.BetaPrune)
65 piece_color: bindings.PieceColor
66 piece_type: bindings.PieceType
71 piece_color=core_game_piece.piece_color,
72 piece_type=core_game_piece.piece_type,
87 return cls(rank=core_board_space.rank, file=core_board_space.file)
101 start = BoardSpace.from_core_board_space(core_move.start)
102 end = BoardSpace.from_core_board_space(core_move.end)
103 return cls(start=start, end=end)
109 A Python MoveCollection.
116 cls, core_move_collection: bindings.MoveCollection
119 Move.from_core_move(core_move=core_move)
120 for core_move
in core_move_collection.moves
122 return cls(moves=moves)
126 return len(self.
moves)
132 A Python EqualScoreMoves.
135 shared_score: PointsT
136 move_collection: MoveCollection
140 cls, core_equal_score_moves: bindings.EqualScoreMoves
143 shared_score=core_equal_score_moves.shared_score,
144 move_collection=MoveCollection.from_core_move_collection(
145 core_move_collection=core_equal_score_moves.move_collection
152 first_illegal_move_request: int |
None
159 A Python ExecutedMove
162 moving_piece: GamePiece
163 destination_piece: GamePiece
168 cls, core_executed_move: bindings.ExecutedMove
171 moving_piece=GamePiece.from_core_game_piece(
172 core_game_piece=core_executed_move.moving_piece
174 destination_piece=GamePiece.from_core_game_piece(
175 core_game_piece=core_executed_move.destination_piece
177 spaces=Move.from_core_move(core_move=core_executed_move.spaces),
184 A Python SearchSummary.
188 time: datetime.timedelta
189 result_depth_counts: np.ndarray
190 transposition_table_hits: np.ndarray
191 equal_score_moves: EqualScoreMoves
193 returned_illegal_move: bool
195 tr_table_size_initial: int
196 tr_table_size_final: int
200 cls, core_search_summary: bindings.SearchSummary
203 num_nodes=core_search_summary.num_nodes,
204 time=core_search_summary.time,
205 result_depth_counts=np.array(
206 core_search_summary.get_result_depth_counts()
208 transposition_table_hits=np.array(
209 core_search_summary.get_transposition_table_hits()
211 equal_score_moves=EqualScoreMoves.from_core_equal_score_moves(
212 core_equal_score_moves=core_search_summary.equal_score_moves
214 selected_move=Move.from_core_move(
215 core_move=core_search_summary.selected_move
217 returned_illegal_move=core_search_summary.returned_illegal_move,
218 num_collisions=core_search_summary.num_collisions,
219 tr_table_size_initial=core_search_summary.tr_table_size_initial,
220 tr_table_size_final=core_search_summary.tr_table_size_final,
231 A Python SearchSummaries.
234 first_searches: List[SearchSummary]
235 extra_searches: Dict[int, SearchSummary]
239 cls, core_search_summaries: bindings.SearchSummaries
243 SearchSummary.from_core_search_summary(item)
244 for item
in core_search_summaries.first_searches
247 key: SearchSummary.from_core_search_summary(val)
248 for key, val
in core_search_summaries.extra_searches.items()
def from_core_board_space(cls, bindings.BoardSpace core_board_space)
A Python EqualScoreMoves.
def from_core_equal_score_moves(cls, bindings.EqualScoreMoves core_equal_score_moves)
def from_core_executed_move(cls, bindings.ExecutedMove core_executed_move)
def from_core_game_piece(cls, bindings.GamePiece core_game_piece)
Enum indicating the type of result obtained from Minimax analysis of a single node.
def from_core_move_collection(cls, bindings.MoveCollection core_move_collection)
def from_core_move(cls, bindings.Move core_move)
Determines the integer type used for Points int the C++ core, and provides a numpy integer type with ...
type get_points_type(self)
A Python SearchSummaries.
def from_core_search_summaries(cls, bindings.SearchSummaries core_search_summaries)
float mean_time_per_node_ns(self)
def from_core_search_summary(cls, bindings.SearchSummary core_search_summary)