本文整理汇总了Python中pychess.Utils.GameModel.GameModel.variations方法的典型用法代码示例。如果您正苦于以下问题:Python GameModel.variations方法的具体用法?Python GameModel.variations怎么用?Python GameModel.variations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pychess.Utils.GameModel.GameModel
的用法示例。
在下文中一共展示了GameModel.variations方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadToModel
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import variations [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 variations [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
示例3: loadToModel
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import variations [as 别名]
def loadToModel(self, rec, position, model=None):
if not model:
model = GameModel()
if "Variant" in rec:
model.variant = FischerandomBoard
fieldlist = rec["FEN"].split(" ")
if len(fieldlist) == 4:
fen = rec["FEN"]
opcodestr = ""
elif len(fieldlist) > 4:
fen = " ".join(fieldlist[:4])
opcodestr = " ".join(fieldlist[4:])
else:
raise LoadingError("EPD string can not have less than 4 field")
opcodes = {}
for opcode in map(str.strip, opcodestr.split(";")):
space = opcode.find(" ")
if space == -1:
opcodes[opcode] = True
else:
opcodes[opcode[:space]] = opcode[space + 1:]
if "hmvc" in opcodes:
fen += " " + opcodes["hmvc"]
else:
fen += " 0"
if "fmvn" in opcodes:
fen += " " + opcodes["fmvn"]
else:
fen += " 1"
model.boards = [model.variant(setup=fen)]
model.variations = [model.boards]
model.status = WAITING_TO_START
# rc is kinda broken
# if "rc" in opcodes:
# model.boards[0].board.rc = int(opcodes["rc"])
if "resign" in opcodes:
if fieldlist[1] == "w":
model.status = BLACKWON
else:
model.status = WHITEWON
model.reason = WON_RESIGN
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
示例4: loadToModel
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import variations [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]
model.boards = [model.variant.board(setup=fen)]
model.variations = [model.boards]
if model.status == WAITING_TO_START:
model.status, model.reason = getStatus(model.boards[-1])
return model
示例5: loadToModel
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import variations [as 别名]
def loadToModel(self, rec, position, model=None):
if not model:
model = GameModel()
model.tags['Event'] = rec["Event"]
model.tags['Site'] = rec["Site"]
model.tags['Date'] = self.get_date(rec)
model.tags['Round'] = ""
model.tags['White'] = "?"
model.tags['Black'] = "?"
model.tags['Termination'] = rec["Termination"]
fen = rec["FEN"]
model.boards = [model.variant(setup=fen)]
model.variations = [model.boards]
model.status = WAITING_TO_START
return model