本文整理汇总了Python中chess.board.Board._pieces方法的典型用法代码示例。如果您正苦于以下问题:Python Board._pieces方法的具体用法?Python Board._pieces怎么用?Python Board._pieces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chess.board.Board
的用法示例。
在下文中一共展示了Board._pieces方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_check_small
# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import _pieces [as 别名]
def test_check_small():
board = Board()
king = King(BLACK, 0, 0)
rook = Rook(WHITE, 2, 2)
board._pieces = {king, rook}
assert not board.checked(BLACK)
board.move(rook, 2, 0)
assert board.checked(BLACK)
示例2: test_copy
# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import _pieces [as 别名]
def test_copy():
board = Board()
king = King(BLACK, 0, 0)
rook = Rook(WHITE, 2, 2)
board._pieces = {king, rook}
clone = board.copy()
assert len(clone._pieces) == len(board._pieces)
for piece in clone._pieces:
assert piece not in board._pieces
示例3: test_check_medium
# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import _pieces [as 别名]
def test_check_medium():
board = Board()
king = King(BLACK, 0, 0)
rook = Rook(WHITE, 2, 2)
pawn = Pawn(WHITE, 7, 3)
bishop = Bishop(WHITE, 1, 3)
enemy_king = King(WHITE, 6, 6)
board._pieces = {king, rook, pawn, bishop, enemy_king}
assert not board.checked(BLACK)
board.move(rook, 2, 0)
assert board.checked(BLACK)
assert not board.checked(WHITE)
示例4: test_moves_tiny
# 需要导入模块: from chess.board import Board [as 别名]
# 或者: from chess.board.Board import _pieces [as 别名]
def test_moves_tiny():
board = Board()
king = King(BLACK, 0, 0)
r = Rook(WHITE, 4, 0)
board._pieces = {king, r}
assert_equals(board.moves_open(BLACK), True)