本文整理汇总了Python中cython.importer.Board类的典型用法代码示例。如果您正苦于以下问题:Python Board类的具体用法?Python Board怎么用?Python Board使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Board类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_queen_at_h8_and_can_move_to_H_and_8_and_diagonal_a1_to_h8
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)
示例2: test_create_board_new_game_true
def test_create_board_new_game_true(self):
board = Board(True)
# Pawn
for x in xrange(8):
self.assertEqual(board.at((x, 6)), BP)
self.assertEqual(board.at((x, 1)), WP)
# Rook
self.assertEqual(board.at((0, 0)), WR)
self.assertEqual(board.at((7, 0)), WR)
self.assertEqual(board.at((0, 7)), BR)
self.assertEqual(board.at((7, 7)), BR)
# Knight
self.assertEqual(board.at((1, 0)), WN)
self.assertEqual(board.at((6, 0)), WN)
self.assertEqual(board.at((1, 7)), BN)
self.assertEqual(board.at((6, 7)), BN)
# Bishop
self.assertEqual(board.at((2, 0)), WB)
self.assertEqual(board.at((5, 0)), WB)
self.assertEqual(board.at((2, 7)), BB)
self.assertEqual(board.at((5, 7)), BB)
# Queen
self.assertEqual(board.at((3, 0)), WQ)
self.assertEqual(board.at((3, 7)), BQ)
# King
self.assertEqual(board.at((4, 0)), WK)
self.assertEqual(board.at((4, 7)), BK)
示例3: test_moves_in_a_new_game
def test_moves_in_a_new_game(self):
board = Board(True)
expected_moves_white = set([
((0, 1), (0, 2)), ((0, 1), (0, 3)),
((1, 1), (1, 2)), ((1, 1), (1, 3)),
((2, 1), (2, 2)), ((2, 1), (2, 3)),
((3, 1), (3, 2)), ((3, 1), (3, 3)),
((4, 1), (4, 2)), ((4, 1), (4, 3)),
((5, 1), (5, 2)), ((5, 1), (5, 3)),
((6, 1), (6, 2)), ((6, 1), (6, 3)),
((7, 1), (7, 2)), ((7, 1), (7, 3)),
((1, 0), (0, 2)), ((1, 0), (2, 2)),
((6, 0), (5, 2)), ((6, 0), (7, 2)),
])
expected_moves_black = set([
((0, 6), (0, 5)), ((0, 6), (0, 4)),
((1, 6), (1, 5)), ((1, 6), (1, 4)),
((2, 6), (2, 5)), ((2, 6), (2, 4)),
((3, 6), (3, 5)), ((3, 6), (3, 4)),
((4, 6), (4, 5)), ((4, 6), (4, 4)),
((5, 6), (5, 5)), ((5, 6), (5, 4)),
((6, 6), (6, 5)), ((6, 6), (6, 4)),
((7, 6), (7, 5)), ((7, 6), (7, 4)),
((1, 7), (0, 5)), ((1, 7), (2, 5)),
((6, 7), (5, 5)), ((6, 7), (7, 5)),
])
self.assertEqual(tuples(board.possible_moves(WHITE)),
expected_moves_white)
self.assertEqual(tuples(board.possible_moves(BLACK)),
expected_moves_black)
示例4: test_queen_at_a1_and_can_move_to_A_and_1_and_diagonal_a1_to_h8
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)
示例5: test_rook_at_a1_with_ally_in_b1_can_move_to_all_A
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)
示例6: test_rook_at_h8_with_allies_in_f8_and_h6_can_move_to_g8_and_h7
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)
示例7: test_knight_can_move_to_protect_the_king2
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)
示例8: test_knight_can_move_if_it_doesnt_protect_the_king
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)
示例9: test_knight_at_a1_and_ally_at_c2_can_move_to_1_position
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)
示例10: test_knight_at_a1_can_move_to_2_positions
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)
示例11: test_knight_at_e5_can_move_to_8_positions
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)
示例12: test_B_at_a1_and_an_b_at_e5_can_move_to_b2_and_c3_and_d4_and_e5
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)
示例13: test_bishop_at_a8_can_move_in_diagonal_a8_to_h1
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)
示例14: test_rook_at_a1_with_ally_in_a2_can_move_to_all_1
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)
示例15: test_bishop_at_h8_can_move_in_diagonal_a1_to_g7
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)