Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
piece_info_extractor.py
Go to the documentation of this file.
1"""
2No longer used, but keep for reference: PieceReader for converting int to
3PieceType.
4"""
5
6import math
7
8
10 """
11 Converts primitive integer to piece type and color.
12 """
13
14 @staticmethod
15 def get_type(piece: int):
16 return abs(piece)
17
18 @staticmethod
19 def get_color(piece: int):
20 return 0 if piece == 0 else int(math.copysign(1, piece))
21
22 def get_piece_info(self, piece: int):
23 return {
24 "piece_type": self.get_type(piece),
25 "color": self.get_color(piece),
26 }
27
28
29PIECE_READER = PieceReader()
Converts primitive integer to piece type and color.