Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
OpenAI Gym FlattenAction wrapper
import gym
class FlattenAction(gym.ActionWrapper):
"""Action wrapper that flattens the action."""
def __init__(self, env):
super(FlattenAction, self).__init__(env)
self.action_space = gym.spaces.utils.flatten_space(self.env.action_space)
def action(self, action):
return gym.spaces.utils.unflatten(self.env.action_space, action)
def reverse_action(self, action):
return gym.spaces.utils.flatten(self.env.action_space, action)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment