2No longer used, but keep for reference: classes for handling piece points.
8from xiangqi_bindings
import PieceColor, PieceType
22 def __init__(self, piece_vals: Dict[int, int]):
35 pts_arrays_black: Dict[int, np.array],
36 pts_arrays_red: Dict[int, np.array] =
None
42 if pts_arrays_red
is None:
43 pts_arrays_red = {piece_type: np.flip(pts_array, axis=0)
for
44 piece_type, pts_array
in pts_arrays_black.items()}
46 PieceColor.kRed: pts_arrays_red,
47 PieceColor.kBlk: pts_arrays_black}
54general_position_icga_2004 = np.zeros(90).reshape((10, 9))
55advisor_position_icga_2004 = np.zeros(90).reshape((10, 9))
56elephant_position_icga_2004 = np.zeros(90).reshape((10, 9))
58chariot_position_icga_2004 = np.array([
59 [-2, 10, 6, 14, 12, 14, 6, 10, -2],
60 [8, 4, 8, 16, 8, 16, 8, 4, 8],
61 [4, 8, 6, 14, 12, 14, 6, 8, 4],
62 [6, 10, 8, 14, 14, 14, 8, 10, 6],
63 [12, 16, 14, 20, 20, 20, 14, 16, 12],
64 [12, 14, 12, 18, 18, 18, 12, 14, 12],
65 [12, 18, 16, 22, 22, 22, 16, 18, 12],
66 [12, 12, 12, 18, 18, 18, 12, 12, 12],
67 [16, 20, 18, 24, 26, 24, 18, 20, 16],
68 [14, 14, 12, 18, 16, 18, 12, 14, 14]
71horse_position_icga_2004 = np.array([
72 [0, -4, 0, 0, 0, 0, 0, -4, 0],
73 [0, 2, 4, 4, -2, 4, 4, 2, 0],
74 [4, 2, 8, 8, 4, 8, 8, 2, 4],
75 [2, 6, 8, 6, 10, 6, 8, 6, 2],
76 [4, 12, 16, 14, 12, 14, 16, 12, 4],
77 [6, 16, 14, 18, 16, 18, 14, 16, 6],
78 [8, 24, 18, 24, 20, 24, 18, 24, 8],
79 [12, 14, 16, 20, 18, 20, 16, 14, 12],
80 [4, 10, 28, 16, 8, 16, 28, 10, 4],
81 [4, 8, 16, 12, 4, 12, 16, 8, 4]
84cannon_position_icga_2004 = np.array([
85 [0, 0, 2, 6, 6, 6, 2, 0, 0],
86 [0, 2, 4, 6, 6, 6, 4, 2, 0],
87 [4, 0, 8, 6, 10, 6, 8, 0, 4],
88 [0, 0, 0, 2, 4, 2, 0, 0, 0],
89 [-2, 0, 4, 2, 6, 2, 4, 0, -2],
90 [0, 0, 0, 2, 8, 2, 0, 0, 0],
91 [0, 0, -2, 4, 10, 4, -2, 0, 0],
92 [2, 2, 0, -10, -8, -10, 0, 2, 2],
93 [2, 2, 0, -4, -14, -4, 0, 2, 2],
94 [6, 4, 0, -10, -12, -10, 0, 4, 6]
97soldier_position_icga_2004 = np.array([
98 [0, 0, 0, 0, 0, 0, 0, 0, 0],
99 [0, 0, 0, 0, 0, 0, 0, 0, 0],
100 [0, 0, 0, 0, 0, 0, 0, 0, 0],
101 [0, 0, -2, 0, 0, 0, -2, 0, 0],
102 [2, 0, 8, 0, 8, 0, 8, 0, 2],
103 [6, 12, 18, 18, 20, 18, 18, 12, 6],
104 [10, 20, 30, 34, 40, 34, 30, 20, 10],
105 [14, 26, 42, 60, 80, 60, 42, 26, 14],
106 [18, 36, 56, 80, 120, 80, 56, 36, 18],
107 [0, 3, 6, 9, 12, 9, 6, 3, 0]
110position_points_icga_2004 = {
111 PieceType.kGen: general_position_icga_2004,
112 PieceType.kAdv: advisor_position_icga_2004,
113 PieceType.kEle: elephant_position_icga_2004,
114 PieceType.kCha: chariot_position_icga_2004,
115 PieceType.kHor: horse_position_icga_2004,
116 PieceType.kCan: cannon_position_icga_2004,
117 PieceType.kSol: soldier_position_icga_2004
121DEFAULT_BASE_POINTS =
BasePoints(piece_vals=base_pts_icga_2004)
123 pts_arrays_black=position_points_icga_2004)
def __init__(self, Dict[int, int] piece_vals)
def __init__(self, Dict[int, np.array] pts_arrays_black, Dict[int, np.array] pts_arrays_red=None)