本文整理汇总了Python中pychess.Utils.GameModel.GameModel.moves方法的典型用法代码示例。如果您正苦于以下问题:Python GameModel.moves方法的具体用法?Python GameModel.moves怎么用?Python GameModel.moves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pychess.Utils.GameModel.GameModel
的用法示例。
在下文中一共展示了GameModel.moves方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadToModel
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import moves [as 别名]
def loadToModel(self, rec, position, model=None):
if not model:
model = GameModel()
if self.fen_is_string:
rec = self.games[0]
if isinstance(rec, dict) and "Variant" in rec:
model.variant = FischerandomBoard
fen = self.games[0]["FEN"]
try:
board = model.variant(setup=fen)
except SyntaxError as err:
board = model.variant()
raise LoadingError(
_("The game can't be loaded, because of an error parsing FEN"),
err.args[0])
model.boards = [board]
model.variations = [model.boards]
model.moves = []
if model.status == WAITING_TO_START:
status, reason = getStatus(model.boards[-1])
if status in (BLACKWON, WHITEWON, DRAW):
model.status, model.reason = status, reason
return model
示例2: loadToModel
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import moves [as 别名]
def loadToModel(self, gameno, position, model=None):
if not model:
model = GameModel()
# We have to set full move number to 1 to make sure LBoard and GameModel
# are synchronized.
#fenlist = self.games[gameno].split(" ")
#if len(fenlist) == 6:
# fen = " ".join(fenlist[:5]) + " 1"
fen = self.games[gameno]
try:
board = model.variant(setup=fen)
except SyntaxError as err:
board = model.variant()
raise LoadingError(
_("The game can't be loaded, because of an error parsing FEN"),
err.args[0])
model.boards = [board]
model.variations = [model.boards]
model.moves = []
if model.status == WAITING_TO_START:
status, reason = getStatus(model.boards[-1])
if status in (BLACKWON, WHITEWON, DRAW):
model.status, model.reason = status, reason
return model