當前位置: 首頁>>代碼示例>>Python>>正文


Python Board.from_notation方法代碼示例

本文整理匯總了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)
開發者ID:kbuzsaki,項目名稱:restchess,代碼行數:15,代碼來源:board_test.py

示例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]
開發者ID:kbuzsaki,項目名稱:restchess,代碼行數:16,代碼來源:rook_test.py

示例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)
開發者ID:kbuzsaki,項目名稱:restchess,代碼行數:4,代碼來源:piece_test.py

示例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
開發者ID:kbuzsaki,項目名稱:restchess,代碼行數:6,代碼來源:client.py

示例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
開發者ID:kbuzsaki,項目名稱:restchess,代碼行數:6,代碼來源:client.py


注:本文中的chess.Board.from_notation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。