我正在使用 python 国际象棋模块。在网站上,它显示您可以通过使用检查移动是否合法
import chess
board = chess.Board()
move = input("Enter a chess move: ")
if move in board.legal_moves:
# Some code to do if the move is a legal move
Run Code Online (Sandbox Code Playgroud)
但是,我希望能够从board.legal_moves. 当我尝试这个时:
print(board.legal_moves[0])
Run Code Online (Sandbox Code Playgroud)
这将返回以下错误:
TypeError: 'LegalMoveGenerator' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)
如何像使用列表一样选择移动?那么,我将如何使用选择作为移动?