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


Python Settings.parseSetting方法代码示例

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


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

示例1: piece

# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import parseSetting [as 别名]
class GameState:

    #update game round i	-> The number of the current round
    #update game this_piece_type s	-> The type of the piece that has just spawned on the field
    #update game next_piece_type s	-> The type of the piece that will spawn the next round
    #update game this_piece_position i,i	-> The starting position in the field for the current piece (top left corner of the piece bounding box)

    def __init__(self):
        self.round = 0
        self.this_piece_type = 'n'
        self.next_piece_type = 'n'
        self.this_piece_position = {"x":1 , "y":2}
        self.players = {"me":PlayerState(), "opponent":PlayerState()}
        self.settings = Settings()

    def parseSettingsMessage(self, parts):
        self.settings.parseSetting(parts)

    def parseGameMessage(self, parts):
        if parts[0] == "game":
            gameStateMessage = parts[1]

            if gameStateMessage== 'round':
                #update game round i
                self.round = int(parts[2])

            elif gameStateMessage == 'this_piece_type':
                #update game this_piece_type s
                self.this_piece_type = parts[2]

            elif gameStateMessage == 'next_piece_type':
                #update game next_piece_type s
                self.next_piece_type = parts[2]

            elif gameStateMessage == 'this_piece_position':
                #update game this_piece_position i,i
                position = parts[2].split(',')
                self.this_piece_position["x"] = int(position[0])
                self.this_piece_position["y"] = int(position[1])

            else:
                stderr.write('Unknown gameStateMessage: %s\n' % (parts[1]))
                stderr.flush()

        elif parts[0] == self.settings.bots["me"]:
            self.players["me"].parsePlayerState(parts[1:])

        elif parts[0] == self.settings.bots["opponent"]:
            self.players["opponent"].parsePlayerState(parts[1:])

        else:
            stderr.write('Unknown gameStateMessage: %s\n' % (parts[0]))
            stderr.flush()
开发者ID:raduangelescu,项目名称:theaigames_blocks_pythonstarterbot,代码行数:55,代码来源:GameState.py


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