本文整理汇总了Python中board.Board.is_legal_movement方法的典型用法代码示例。如果您正苦于以下问题:Python Board.is_legal_movement方法的具体用法?Python Board.is_legal_movement怎么用?Python Board.is_legal_movement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.is_legal_movement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_is_legal_movement_rook_left
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_is_legal_movement_rook_left(self):
board = Board (20, 20)
piece_king_white = Piece(Piece.KING, Piece.WHITE)
piece_rook_black = Piece(Piece.ROOK, Piece.BLACK)
board.add(piece_king_white, 15, 7)
board.add(piece_rook_black, 15, 10)
available_positions = [[15, 9], [15, 8], [15, 7]]
self.assertEqual(board.is_legal_movement(15, 10), available_positions)
示例2: test_is_legal_movement_queen
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_is_legal_movement_queen(self):
board = Board(6, 6)
piece_king_white = Piece(Piece.KING, Piece.WHITE)
piece_queen_black = Piece(Piece.QUEEN, Piece.BLACK)
board.add(piece_king_white, 0, 2)
board.add(piece_queen_black, 3, 3)
available_positions = [[3, 2], [2, 3], [1, 3], [0, 3], [2, 2], [1, 1], [0, 0], [2, 4]]
self.assertEqual(board.is_legal_movement(3, 3), available_positions)
示例3: test_is_legal_movement_king
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_is_legal_movement_king(self):
board = Board(20, 20)
piece_king_white = Piece(Piece.KING, Piece.WHITE)
piece_king_black = Piece(Piece.KING, Piece.BLACK)
board.add(piece_king_white, 10, 10)
board.add(piece_king_black, 15, 10)
available_positions = [[11, 11], [11, 10], [11, 9]]
self.assertEqual(board.is_legal_movement(10, 10).sort(), available_positions.sort())
示例4: test_is_legal_movement_rook_all
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_is_legal_movement_rook_all(self):
board = Board (20, 20)
piece_king_white = Piece(Piece.KING, Piece.WHITE)
piece_rook_black = Piece(Piece.ROOK, Piece.BLACK)
piece_pawn_black = Piece(Piece.PAWN, Piece.BLACK)
board.add(piece_king_white, 12, 8)
board.add(piece_rook_black, 18, 10)
board.add(piece_pawn_black, 17, 10)
available_positions = [[18, 9], [18, 8], [18, 7]]
self.assertEqual(board.is_legal_movement(18, 10), available_positions)
示例5: test_another_is_legal_movement_rook_up
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_another_is_legal_movement_rook_up(self):
board = Board(6, 6)
piece_king_white = Piece(Piece.KING, Piece.WHITE)
piece_rook_black = Piece(Piece.ROOK, Piece.BLACK)
piece_pawn_black = Piece(Piece.PAWN, Piece.BLACK)
board.add(piece_king_white, 0, 2)
board.add(piece_rook_black, 3, 3)
board.add(piece_pawn_black, 3, 2)
available_positions = [[2, 3], [1, 3], [0, 3]]
self.assertEqual(board.is_legal_movement(3, 3), available_positions)
示例6: test_is_legal_movement_pawn
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_is_legal_movement_pawn(self):
board = Board(6, 4)
piece_pawn = Piece(Piece.PAWN, Piece.BLACK)
piece_pawn_two = Piece(Piece.PAWN, Piece.BLACK)
piece_king = Piece(Piece.KING, Piece.WHITE)
piece_white_pawn = Piece(Piece.PAWN, Piece.WHITE)
board.add(piece_king, 5, 2)
board.add(piece_pawn, 3, 2)
board.add(piece_pawn_two, 4, 3)
board.add(piece_white_pawn, 4, 1)
available_positions = [[4, 2], [4, 1]]
self.assertEquals(board.is_legal_movement(3, 2), available_positions);
示例7: test_is_legal_movement_bishop_rigth_up
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_is_legal_movement_bishop_rigth_up(self):
board = Board (20, 20)
piece_king_white = Piece(Piece.KING, Piece.WHITE)
piece_bishop_black = Piece(Piece.BISHOP, Piece.BLACK)
piece_pawn_black = Piece(Piece.PAWN, Piece.BLACK)
piece_pawn_black_two = Piece(Piece.PAWN, Piece.BLACK)
piece_pawn_black_three = Piece(Piece.PAWN, Piece.BLACK)
board.add(piece_king_white, 15, 13)
board.add(piece_bishop_black, 18, 10)
board.add(piece_pawn_black, 17, 19)
board.add(piece_pawn_black_two, 14 , 14)
available_positions = [[17, 11],[16, 12], [15, 13]]
self.assertEqual(board.is_legal_movement(18, 10), available_positions)
示例8: test_is_legal_movement_bishop_left_down
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import is_legal_movement [as 别名]
def test_is_legal_movement_bishop_left_down(self):
board = Board (20, 20)
piece_king_white = Piece(Piece.KING, Piece.WHITE)
piece_bishop_black = Piece(Piece.BISHOP, Piece.BLACK)
piece_pawn_black = Piece(Piece.PAWN, Piece.BLACK)
piece_pawn_black_two = Piece(Piece.PAWN, Piece.BLACK)
piece_pawn_black_three = Piece(Piece.PAWN, Piece.BLACK)
board.add(piece_king_white, 19, 8)
board.add(piece_bishop_black, 18, 10)
board.add(piece_pawn_black, 17, 9)
board.add(piece_pawn_black_two, 16 , 11)
board.add(piece_pawn_black_three, 17 , 11)
available_positions = [[19, 9]]
self.assertEqual(board.is_legal_movement(18, 10), available_positions)