本文整理汇总了Python中cython.importer.Board.possible_moves方法的典型用法代码示例。如果您正苦于以下问题:Python Board.possible_moves方法的具体用法?Python Board.possible_moves怎么用?Python Board.possible_moves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cython.importer.Board
的用法示例。
在下文中一共展示了Board.possible_moves方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_moves_in_a_new_game
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import possible_moves [as 别名]
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)
示例2: test_moves_that_keeps_check_are_not_allowed
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import possible_moves [as 别名]
def test_moves_that_keeps_check_are_not_allowed(self):
board = Board(False)
board.load_fen("8/8/8/8/8/8/4P3/r3K3 w kQkq - 0 1")
expected_moves_white = set([
((4, 0), (3, 1)),
((4, 0), (5, 1)),
])
self.assertEqual(tuples(board.possible_moves(WHITE)),
expected_moves_white)
示例3: test_moves_in_a_board_with_just_a_knight
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import possible_moves [as 别名]
def test_moves_in_a_board_with_just_a_knight(self):
board = Board(False)
board.load_fen("8/8/8/4N3/8/8/8/8 w kQkq - 0 1")
expected_moves_white = set([
((4, 4), (3, 2)),
((4, 4), (5, 2)),
((4, 4), (6, 3)),
((4, 4), (6, 5)),
((4, 4), (5, 6)),
((4, 4), (3, 6)),
((4, 4), (2, 5)),
((4, 4), (2, 3)),
])
expected_moves_black = set()
self.assertEqual(tuples(board.possible_moves(WHITE)),
expected_moves_white)
self.assertEqual(tuples(board.possible_moves(BLACK)),
expected_moves_black)
示例4: test_moves_that_allows_check_are_not_allowed
# 需要导入模块: from cython.importer import Board [as 别名]
# 或者: from cython.importer.Board import possible_moves [as 别名]
def test_moves_that_allows_check_are_not_allowed(self):
board = Board(False)
board.load_fen("8/8/8/8/7b/8/5P2/4K3 w - - 0 1")
expected_moves_white = set([
((4, 0), (3, 0)),
((4, 0), (3, 1)),
((4, 0), (5, 0)),
((4, 0), (4, 1)),
])
self.assertEqual(tuples(board.possible_moves(WHITE)),
expected_moves_white)