本文整理汇总了Python中OpenNero.getAppConfig方法的典型用法代码示例。如果您正苦于以下问题:Python OpenNero.getAppConfig方法的具体用法?Python OpenNero.getAppConfig怎么用?Python OpenNero.getAppConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenNero
的用法示例。
在下文中一共展示了OpenNero.getAppConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ModTick
# 需要导入模块: import OpenNero [as 别名]
# 或者: from OpenNero import getAppConfig [as 别名]
def ModTick(dt):
if OpenNero.getAppConfig().rendertype == 'null':
return
script_server = module.getServer()
data = script_server.read_data()
while data:
module.parseInput(data.strip())
data = script_server.read_data()
示例2: __init__
# 需要导入模块: import OpenNero [as 别名]
# 或者: from OpenNero import getAppConfig [as 别名]
def __init__(self):
NERO.module.NeroModule.__init__(self)
if OpenNero.getAppConfig().rendertype != 'null':
self.set_speedup(BATTLE_DEFAULT_SPEEDUP)
print 'setting speedup for on-screen battle'
示例3: step
# 需要导入模块: import OpenNero [as 别名]
# 或者: from OpenNero import getAppConfig [as 别名]
def step(self, agent, action):
"""
2A step for an agent
"""
# make sure RL agents cannot learn in battle mode.
agent.alpha = 0.0
reward = NERO.NeroEnvironment.NeroEnvironment.step(self, agent, action)
live_agents = sum(len(t) for t in self.teams.itervalues())
# wait until all agents have spawned before we keep track of damage.
if self.print_damage < 0 and live_agents < 2 * constants.pop_size:
return reward
# print out damages every loop through the entire population.
self.print_damage += 1
if self.print_damage >= live_agents:
self.print_damage = 0
else:
return reward
damages = {}
winner = None
for team in constants.TEAMS:
damages[team] = 0
agents = self.teams.get(team, set())
agent_damages = [self.get_state(a).total_damage for a in agents]
if any(d < self.hitpoints for d in agent_damages):
damage = sum(agent_damages)
damage += (constants.pop_size - len(agents)) * self.hitpoints
damages[team] = damage
else:
damages[team] = constants.pop_size * self.hitpoints
winner = constants.OBJECT_TYPE_TEAM_0
if team == winner:
winner = constants.OBJECT_TYPE_TEAM_1
if len(damages) == 2:
ss = []
for t, d in sorted(damages.iteritems()):
s = '%s: %d' % (constants.TEAM_LABELS[t], d)
ss.append(s)
ss = tuple(ss)
if self.last_damage != ss:
print 'damages sustained by: ' +' '.join(ss)
self.last_damage = ss
if not constants.getDisplayHint():
OpenNero.setWindowCaption('Damage sustained: ' + ' '.join(ss))
if winner is not None:
s = constants.TEAM_LABELS[winner] + ' team wins!!!'
print s
try:
if OpenNero.getAppConfig().rendertype != 'null':
import tkMessageBox
tkMessageBox.showinfo('NERO Battle Results', s)
except:
pass
if not constants.getDisplayHint():
OpenNero.setWindowCaption(s)
OpenNero.disable_ai()
for a in self.teams[winner]:
self.set_animation(a, self.get_state(a), 'jump')
return reward