本文整理匯總了Python中chess.board.Board.pieces_quantity方法的典型用法代碼示例。如果您正苦於以下問題:Python Board.pieces_quantity方法的具體用法?Python Board.pieces_quantity怎麽用?Python Board.pieces_quantity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類chess.board.Board
的用法示例。
在下文中一共展示了Board.pieces_quantity方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_pieces_can_capture_opponent_pieces
# 需要導入模塊: from chess.board import Board [as 別名]
# 或者: from chess.board.Board import pieces_quantity [as 別名]
def test_pieces_can_capture_opponent_pieces():
board = Board(initial_pieces={'a8': King('black'), 'e5': Pawn('black'), 'f3': Knight('white')})
assert board.pieces_quantity() == 3
knight = board.get_piece('f3')
board.move('f3', 'e5')
assert board.get_piece('e5') is knight
assert board.pieces_quantity() == 2
示例2: test_board_has_32_pieces
# 需要導入模塊: from chess.board import Board [as 別名]
# 或者: from chess.board.Board import pieces_quantity [as 別名]
def test_board_has_32_pieces():
board = Board()
assert board.pieces_quantity() == 32
示例3: test_board_can_be_instatiated_with_any_set_of_pieces
# 需要導入模塊: from chess.board import Board [as 別名]
# 或者: from chess.board.Board import pieces_quantity [as 別名]
def test_board_can_be_instatiated_with_any_set_of_pieces():
board = Board(initial_pieces={'a2': Pawn('white'), 'a6': Pawn('black')})
assert board.pieces_quantity() == 2