本文整理匯總了Python中chess.Board.from_notation方法的典型用法代碼示例。如果您正苦於以下問題:Python Board.from_notation方法的具體用法?Python Board.from_notation怎麽用?Python Board.from_notation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類chess.Board
的用法示例。
在下文中一共展示了Board.from_notation方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: from chess import Board [as 別名]
# 或者: from chess.Board import from_notation [as 別名]
def setUp(self):
self.notation = [["WR", "WN", "WB", "WQ", "WK", "WB", "WN", "WR"],
["WP", "WP", "WP", "WP", "", "WP", "WP", "WP"],
[ "", "", "", "", "", "", "", ""],
[ "", "", "", "", "WP", "", "", ""],
[ "", "", "", "", "BP", "", "", ""],
[ "", "", "", "", "", "", "", ""],
["BP", "BP", "BP", "BP", "", "BP", "BP", "BP"],
["BR", "BN", "BB", "BQ", "BK", "BB", "BN", "BR"]]
self.flat_notation = list(itertools.chain(*self.notation))
self.num_pieces = len([square for square in self.flat_notation if square != ""])
self.empty_board = Board()
self.board = Board.from_notation(self.notation)
示例2: setUp
# 需要導入模塊: from chess import Board [as 別名]
# 或者: from chess.Board import from_notation [as 別名]
def setUp(self):
self.board = Board.from_notation([[ "", "", "", "", "", "", "", ""],
[ "", "WR", "", "", "", "", "", ""],
[ "", "", "", "", "", "", "", ""],
[ "", "", "", "", "", "", "", ""],
[ "", "WR", "", "BR", "", "WR", "", ""],
[ "", "", "", "", "", "", "", ""],
[ "", "", "", "", "", "", "", "BR"],
[ "", "", "", "", "", "", "", ""]])
self.upper_rook = self.board[1][1]
self.left_rook = self.board[4][1]
self.right_rook = self.board[4][5]
self.middle_rook = self.board[4][3]
self.lower_rook = self.board[6][7]
示例3: setUp
# 需要導入模塊: from chess import Board [as 別名]
# 或者: from chess.Board import from_notation [as 別名]
def setUp(self):
self.board = Board.from_notation(chess.STARTING_NOTATION)
示例4: _reset
# 需要導入模塊: from chess import Board [as 別名]
# 或者: from chess.Board import from_notation [as 別名]
def _reset(self):
self._board = Board.from_notation(chess.STARTING_NOTATION)
self.turn_count = 1
self.cur_player = Color.white
示例5: _load_from_response
# 需要導入模塊: from chess import Board [as 別名]
# 或者: from chess.Board import from_notation [as 別名]
def _load_from_response(self, resp):
next_turn = {"turn": resp["turn"], "current_player": resp["current_player"]}
self._cached_board = Board.from_notation(resp["board"])
return next_turn