def gym_core_action_space(gym_core_id):
spec = gym.spec(gym_core_id)
if spec.id == 'CartPole-v0':
return spaces.Hardcoded([[spaces.KeyEvent.by_name('left', down=True)],
[spaces.KeyEvent.by_name('left', down=False)]])
elif spec._entry_point.startswith('gym.envs.atari:'):
actions = []
env = spec.make()
for action in env.unwrapped.get_action_meanings():
z = 'FIRE' in action
left = 'LEFT' in action
right = 'RIGHT' in action
up = 'UP' in action
down = 'DOWN' in action
translated = atari_vnc(up=up, down=down, left=left, right=right, z=z)
actions.append(translated)
return spaces.Hardcoded(actions)
else:
raise error.Error('Unsupported env type: {}'.format(spec.id))
评论列表
文章目录