def control_update(self):
''' Uses input from the keyboard to control the player. '''
keys_pressed = pygame.key.get_pressed()
action_map = {
pygame.K_SPACE: ('hop', INITIAL_HOP),
pygame.K_l: ('leap', INITIAL_LEAP),
pygame.K_d: ('run', 2),
}
action = ('run', 0)
for key in action_map:
if keys_pressed[key]:
action = action_map[key]
break
reward, end_episode = self.simulator.update(action, DT, True)
self.total += reward
if end_episode:
print 'Episode Reward:', self.total
self.total = 0.0
self.simulator = Simulator()
评论列表
文章目录