本文整理匯總了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)