本文整理汇总了Python中cython.importer.Board.piece_moves方法的典型用法代码示例。如果您正苦于以下问题:Python Board.piece_moves方法的具体用法?Python Board.piece_moves怎么用?Python Board.piece_moves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cython.importer.Board
的用法示例。
在下文中一共展示了Board.piece_moves方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_queen_at_a1_and_can_move_to_A_and_1_and_diagonal_a1_to_h8
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_queen_at_a1_and_can_move_to_A_and_1_and_diagonal_a1_to_h8(self):
board = Board(False)
board.load_fen("8/8/8/8/8/8/8/Q7 w kQkq - 0 1")
pos = (0, 0)
possible_moves = moves(
pos,
[
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
(7, 7),
(0, 1),
(0, 2),
(0, 3),
(0, 4),
(0, 5),
(0, 6),
(0, 7),
(1, 0),
(2, 0),
(3, 0),
(4, 0),
(5, 0),
(6, 0),
(7, 0),
],
)
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例2: test_queen_at_h8_and_can_move_to_H_and_8_and_diagonal_a1_to_h8
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_queen_at_h8_and_can_move_to_H_and_8_and_diagonal_a1_to_h8(self):
board = Board(False)
board.load_fen("7Q/8/8/8/8/8/8/8 w kQkq - 0 1")
pos = (7, 7)
possible_moves = moves(
pos,
[
(0, 0),
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
(7, 0),
(7, 1),
(7, 2),
(7, 3),
(7, 4),
(7, 5),
(7, 6),
(0, 7),
(1, 7),
(2, 7),
(3, 7),
(4, 7),
(5, 7),
(6, 7),
],
)
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例3: test_black_pawn_at_e2_with_enemy_at_f1_should_be_promoted_at_f1
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_black_pawn_at_e2_with_enemy_at_f1_should_be_promoted_at_f1(self):
board = Board(False)
board.load_fen("8/8/8/8/8/8/4p3/5P2 b kQkq f3 0 1")
pos = (4, 1)
possible_moves = moves(pos, [(4, 0), (5, 0)])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
board.move((4, 1), (5, 0), 5)
self.assertEqual(board.at((5, 0)), "black queen")
示例4: test_white_pawn_at_e7_with_enemy_at_f8_should_be_promoted_at_f8
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_white_pawn_at_e7_with_enemy_at_f8_should_be_promoted_at_f8(self):
board = Board(False)
board.load_fen("5p2/4P3/8/8/8/8/8/8 w kQkq f3 0 1")
pos = (4, 6)
possible_moves = moves(pos, [(4, 7), (5, 7)])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
board.move((4, 6), (5, 7), 5)
self.assertEqual(board.at((5, 7)), "white queen")
示例5: test_knight_can_move_to_protect_the_king2
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_knight_can_move_to_protect_the_king2(self):
board = Board(False)
board.load_fen("8/8/8/4N3/2q1K3/8/8/8 w kQkq - 0 1")
pos = (4, 4)
possible_moves = moves(pos, [
(2, 3)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例6: test_knight_can_move_if_it_doesnt_protect_the_king
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_knight_can_move_if_it_doesnt_protect_the_king(self):
board = Board(False)
board.load_fen("8/8/8/4N3/8/8/3K4/8 w kQkq - 0 1")
pos = (4, 4)
possible_moves = moves(pos, [
(3, 2), (5, 2), (6, 3), (6, 5), (5, 6), (3, 6), (2, 5), (2, 3)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例7: test_knight_at_a1_and_ally_at_c2_can_move_to_1_position
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_knight_at_a1_and_ally_at_c2_can_move_to_1_position(self):
board = Board(False)
board.load_fen("8/8/8/8/8/8/2N5/N7 w kQkq - 0 1")
pos = (0, 0)
possible_moves = moves(pos, [
(1, 2)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例8: test_knight_at_a1_can_move_to_2_positions
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_knight_at_a1_can_move_to_2_positions(self):
board = Board(False)
board.load_fen("8/8/8/8/8/8/8/N7 w kQkq - 0 1")
pos = (0, 0)
possible_moves = moves(pos, [
(2, 1), (1, 2)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例9: test_knight_at_e5_can_move_to_8_positions
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_knight_at_e5_can_move_to_8_positions(self):
board = Board(False)
board.load_fen("8/8/8/4N3/8/8/8/8 w kQkq - 0 1")
pos = (4, 4)
possible_moves = moves(pos, [
(3, 2), (5, 2), (6, 3), (6, 5), (5, 6), (3, 6), (2, 5), (2, 3)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例10: test_rook_at_h8_with_allies_in_f8_and_h6_can_move_to_g8_and_h7
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_rook_at_h8_with_allies_in_f8_and_h6_can_move_to_g8_and_h7(self):
board = Board(False)
board.load_fen("5R1R/8/7R/8/8/8/8/8 w kQkq - 0 1")
pos = (7, 7)
possible_moves = moves(pos, [
(6, 7), (7, 6)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例11: test_bishop_at_a8_can_move_in_diagonal_a8_to_h1
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_bishop_at_a8_can_move_in_diagonal_a8_to_h1(self):
board = Board(False)
board.load_fen("B7/8/8/8/8/8/8/8 w kQkq - 0 1")
pos = (0, 7)
possible_moves = moves(pos, [
(1, 6), (2, 5), (3, 4), (4, 3), (5, 2), (6, 1), (7, 0)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例12: test_bishop_at_h8_can_move_in_diagonal_a1_to_g7
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_bishop_at_h8_can_move_in_diagonal_a1_to_g7(self):
board = Board(False)
board.load_fen("7B/8/8/8/8/8/8/8 w kQkq - 0 1")
pos = (7, 7)
possible_moves = moves(pos, [
(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6),
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例13: test_rook_at_a1_with_ally_in_a2_can_move_to_all_1
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_rook_at_a1_with_ally_in_a2_can_move_to_all_1(self):
board = Board(False)
board.load_fen("8/8/8/8/8/8/R7/R7 w kQkq - 0 1")
pos = (0, 0)
possible_moves = moves(pos, [
(1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0),
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例14: test_rook_at_a1_with_ally_in_b1_can_move_to_all_A
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_rook_at_a1_with_ally_in_b1_can_move_to_all_A(self):
board = Board(False)
board.load_fen("8/8/8/8/8/8/8/RR6 w kQkq - 0 1")
pos = (0, 0)
possible_moves = moves(pos, [
(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7),
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)
示例15: test_B_at_a1_and_an_b_at_e5_can_move_to_b2_and_c3_and_d4_and_e5
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import piece_moves [as 别名]
def test_B_at_a1_and_an_b_at_e5_can_move_to_b2_and_c3_and_d4_and_e5(self):
board = Board(False)
board.load_fen("8/8/8/4b3/8/8/8/B7 w kQkq - 0 1")
pos = (0, 0)
possible_moves = moves(pos, [
(1, 1), (2, 2), (3, 3), (4, 4)
])
self.assertEqual(tuples(board.piece_moves(pos)), possible_moves)