当前位置: 首页>>代码示例>>Python>>正文


Python Board.is_legal_movement方法代码示例

本文整理汇总了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)
开发者ID:jdvr,项目名称:RadikalChess,代码行数:10,代码来源:test.py

示例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)
开发者ID:jdvr,项目名称:RadikalChess,代码行数:10,代码来源:test.py

示例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())
开发者ID:jdvr,项目名称:RadikalChess,代码行数:10,代码来源:test.py

示例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)
开发者ID:jdvr,项目名称:RadikalChess,代码行数:12,代码来源:test.py

示例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)
开发者ID:jdvr,项目名称:RadikalChess,代码行数:12,代码来源:test.py

示例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);
开发者ID:jdvr,项目名称:RadikalChess,代码行数:14,代码来源:test.py

示例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)
开发者ID:jdvr,项目名称:RadikalChess,代码行数:15,代码来源:test.py

示例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)
开发者ID:jdvr,项目名称:RadikalChess,代码行数:16,代码来源:test.py


注:本文中的board.Board.is_legal_movement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。