本文整理汇总了Python中pychess.Utils.GameModel.GameModel.tags['BlackElo']方法的典型用法代码示例。如果您正苦于以下问题:Python GameModel.tags['BlackElo']方法的具体用法?Python GameModel.tags['BlackElo']怎么用?Python GameModel.tags['BlackElo']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pychess.Utils.GameModel.GameModel
的用法示例。
在下文中一共展示了GameModel.tags['BlackElo']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadToModel
# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import tags['BlackElo'] [as 别名]
def loadToModel (self, gameno, position=-1, model=None, quick_parse=True):
if not model:
model = GameModel()
model.tags['Event'] = self._getTag(gameno, 'Event')
model.tags['Site'] = self._getTag(gameno, 'Site')
model.tags['Date'] = self._getTag(gameno, 'Date')
model.tags['Round'] = self._getTag(gameno, 'Round')
model.tags['White'], model.tags['Black'] = self.get_player_names(gameno)
model.tags['WhiteElo'] = self._getTag(gameno, 'WhiteElo')
model.tags['BlackElo'] = self._getTag(gameno, 'BlackElo')
model.tags['Result'] = reprResult[self.get_result(gameno)]
model.tags['ECO'] = self._getTag(gameno, "ECO")
fenstr = self._getTag(gameno, "FEN")
variant = self._getTag(gameno, "Variant")
if variant and ("fischer" in variant.lower() or "960" in variant):
from pychess.Variants.fischerandom import FRCBoard
model.variant = FischerRandomChess
model.boards = [FRCBoard(fenstr)]
else:
if fenstr:
model.boards = [Board(fenstr)]
else:
model.boards = [Board(setup=True)]
del model.moves[:]
model.status = WAITING_TO_START
model.reason = UNKNOWN_REASON
error = None
if quick_parse:
movstrs = self._getMoves (gameno)
for i, mstr in enumerate(movstrs):
if position != -1 and model.ply >= position:
break
try:
move = parseAny (model.boards[-1], mstr)
except ParsingError, e:
notation, reason, boardfen = e.args
ply = model.boards[-1].ply
if ply % 2 == 0:
moveno = "%d." % (i/2+1)
else: moveno = "%d..." % (i/2+1)
errstr1 = _("The game can't be read to end, because of an error parsing move %(moveno)s '%(notation)s'.") % {
'moveno': moveno, 'notation': notation}
errstr2 = _("The move failed because %s.") % reason
error = LoadingError (errstr1, errstr2)
break
model.moves.append(move)
model.boards.append(model.boards[-1].move(move))