当前位置: 首页>>代码示例>>Python>>正文


Python GameModel.tags['ECO']方法代码示例

本文整理汇总了Python中pychess.Utils.GameModel.GameModel.tags['ECO']方法的典型用法代码示例。如果您正苦于以下问题:Python GameModel.tags['ECO']方法的具体用法?Python GameModel.tags['ECO']怎么用?Python GameModel.tags['ECO']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pychess.Utils.GameModel.GameModel的用法示例。


在下文中一共展示了GameModel.tags['ECO']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadToModel

# 需要导入模块: from pychess.Utils.GameModel import GameModel [as 别名]
# 或者: from pychess.Utils.GameModel.GameModel import tags['ECO'] [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))
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:53,代码来源:pgn.py


注:本文中的pychess.Utils.GameModel.GameModel.tags['ECO']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。