else if (n == NOTATION_XIANGQI_WXF && popcount(pos.pieces(us, pt) & file_bb(from)) > 2)
return std::to_string(popcount(forward_file_bb(us, from) & pos.pieces(us, pt)) + 1);
// Moves of promoted pieces
- else if (type_of(m) != DROP && pos.unpromoted_piece_on(from))
+ else if (is_shogi(n) && type_of(m) != DROP && pos.unpromoted_piece_on(from))
return "+" + std::string(1, toupper(pos.piece_to_char()[pos.unpromoted_piece_on(from)]));
// Promoted drops
- else if (type_of(m) == DROP && dropped_piece_type(m) != in_hand_piece_type(m))
+ else if (is_shogi(n) && type_of(m) == DROP && dropped_piece_type(m) != in_hand_piece_type(m))
return "+" + std::string(1, toupper(pos.piece_to_char()[in_hand_piece_type(m)]));
else if (pos.piece_to_char_synonyms()[pc] != ' ')
return std::string(1, toupper(pos.piece_to_char_synonyms()[pc]));
if (type_of(m) == PROMOTION)
san += std::string("=") + pos.piece_to_char()[make_piece(WHITE, promotion_type(m))];
else if (type_of(m) == PIECE_PROMOTION)
- san += std::string("+");
+ san += is_shogi(n) ? std::string("+") : std::string("=") + pos.piece_to_char()[make_piece(WHITE, pos.promoted_piece_type(type_of(pos.moved_piece(m))))];
else if (type_of(m) == PIECE_DEMOTION)
- san += std::string("-");
+ san += is_shogi(n) ? std::string("-") : std::string("=") + std::string(1, pos.piece_to_char()[pos.unpromoted_piece_on(from)]);
else if (type_of(m) == NORMAL && is_shogi(n) && pos.pseudo_legal(make<PIECE_PROMOTION>(from, to)))
san += std::string("=");
if (is_gating(m))
def test_get_san_moves(self):
UCI_moves = ["e2e4", "e7e5", "g1f3", "b8c6h", "f1c4", "f8c5e"]
SAN_moves = ["e4", "e5", "Nf3", "Nc6/H", "Bc4", "Bc5/E"]
-
result = sf.get_san_moves("seirawan", SEIRAWAN, UCI_moves)
self.assertEqual(result, SAN_moves)
UCI_moves = ["c3c4", "g7g6", "b2h8"]
SAN_moves = ["P-7f", "P-3d", "Bx2b="]
-
result = sf.get_san_moves("shogi", SHOGI, UCI_moves)
self.assertEqual(result, SAN_moves)
UCI_moves = ["h3e3", "h10g8", "h1g3", "c10e8", "a1a3", "i10h10"]
SAN_moves = ["C2=5", "H8+7", "H2+3", "E3+5", "R9+2", "R9=8"]
-
result = sf.get_san_moves("xiangqi", XIANGQI, UCI_moves, False, sf.NOTATION_XIANGQI_WXF)
self.assertEqual(result, SAN_moves)
+ UCI_moves = ["e2e4", "d7d5", "f1a6+", "d8d6"]
+ SAN_moves = ["e4", "d5", "Ba6=A", "Qd6"]
+ result = sf.get_san_moves("shogun", SHOGUN, UCI_moves)
+ self.assertEqual(result, SAN_moves)
+
def test_gives_check(self):
result = sf.gives_check("capablanca", CAPA, [])
self.assertFalse(result)