本文整理汇总了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()