Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
piece_info_extractor.py
Go to the documentation of this file.
1
"""
2
No longer used, but keep for reference: PieceReader for converting int to
3
PieceType.
4
"""
5
6
import
math
7
8
9
class
PieceReader
:
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
29
PIECE_READER =
PieceReader
()
xiangqipy.piece_info_extractor.PieceReader
Converts primitive integer to piece type and color.
Definition:
piece_info_extractor.py:9
xiangqipy.piece_info_extractor.PieceReader.get_type
def get_type(int piece)
Definition:
piece_info_extractor.py:15
xiangqipy.piece_info_extractor.PieceReader.get_color
def get_color(int piece)
Definition:
piece_info_extractor.py:19
xiangqipy.piece_info_extractor.PieceReader.get_piece_info
def get_piece_info(self, int piece)
Definition:
piece_info_extractor.py:22
src
xiangqipy
piece_info_extractor.py
Generated on Sun Dec 29 2024 02:10:05 for Xiangiqgame by
1.9.6