本文整理汇总了Python中gamestate.GameState.setup方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.setup方法的具体用法?Python GameState.setup怎么用?Python GameState.setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gamestate.GameState
的用法示例。
在下文中一共展示了GameState.setup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import setup [as 别名]
def run():
'parse input, update game state and call the bot classes do_turn method'
gamestate = GameState()
bot = MyBot(gamestate)
map_data = ''
while(True):
try:
current_line = sys.stdin.readline().rstrip('\r\n') # string new line char
if current_line.lower() == 'ready':
gamestate.setup(map_data)
bot.do_setup()
gamestate.finish_turn()
map_data = ''
elif current_line.lower() == 'go':
gamestate.update(map_data)
# call the do_turn method of the class passed in
bot.do_turn()
gamestate.finish_turn()
map_data = ''
else:
map_data += current_line + '\n'
except EOFError:
break
except KeyboardInterrupt:
raise
except:
# don't raise error or return so that bot attempts to stay alive
traceback.print_exc(file=sys.stderr)
sys.stderr.flush()