Python gym.envs.registration.EnvSpec() Examples
The following are 16
code examples of gym.envs.registration.EnvSpec().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gym.envs.registration
, or try the search function
.
Example #1
Source File: gym_env.py From pixelworld with MIT License | 6 votes |
def __init__(self, env, record_video=True, video_schedule=None, log_dir=None, timestep_limit=9999): # Ensure the version saved to disk doesn't monitor into our log_dir locals_no_monitor = dict(locals()) locals_no_monitor['log_dir'] = None locals_no_monitor['record_video'] = False locals_no_monitor['video_schedule'] = None Serializable.quick_init(self, locals_no_monitor) self.env = env self._observation_space = to_rllab_space(env.observation_space) self._action_space = to_rllab_space(env.action_space) self.env.spec = EnvSpec('GymEnv-v0') monitor.logger.setLevel(logging.WARNING) if not record_video: self.video_schedule = NoVideoSchedule() else: if video_schedule is None: self.video_schedule = CappedCubicVideoSchedule() else: self.video_schedule = video_schedule self.set_log_dir(log_dir) self._horizon = timestep_limit
Example #2
Source File: pointmass.py From cs294-112_hws with MIT License | 5 votes |
def __init__(self, max_episode_steps_coeff=1, scale=20, goal_padding=2.0): super(PointMass, self).__init__() # define scale such that the each square in the grid is 1 x 1 self.scale = int(scale) self.grid_size = self.scale * self.scale self.observation_space = gym.spaces.Box( low=np.array([0.0, 0.0]), high=np.array([1.0, 1.0])) self.action_space = gym.spaces.Box( low=np.array([-np.inf, -np.inf]), high=np.array([np.inf, np.inf])) self.goal_padding = goal_padding self.spec = EnvSpec(id='PointMass-v0', max_episode_steps=int(max_episode_steps_coeff*self.scale))
Example #3
Source File: __init__.py From adversarial-policies with MIT License | 5 votes |
def register(id, **kwargs): """Idempotent version of gym.envs.registration.registry. Needed since aprl.envs can get imported multiple times, e.g. when deserializing policies. """ try: existing_spec = registration.spec(id) new_spec = registration.EnvSpec(id, **kwargs) assert existing_spec.__dict__ == new_spec.__dict__ except gym.error.UnregisteredEnv: # not previously registered registration.register(id, **kwargs) # Low-dimensional multi-agent environments
Example #4
Source File: random_robots.py From EPG with MIT License | 5 votes |
def meta_reset(self, seed): np.random.seed(seed) env = RandomWeightHopperEnv(rand_mass=self.rand_mass, rand_gravity=self.rand_gravity, rand_friction=self.rand_friction, rand_thickness=self.rand_thickness) # Based on Hopper-v2 spec = EnvSpec( 'RandomWeightHopperEnv-v0', entry_point='generic_rl.envs.mujoco:RandomWeightHopperEnv', max_episode_steps=1000, reward_threshold=3800.0 ) env._spec = spec env.seed(seed) # Wrap the env as needed env = TimeLimit( env, max_episode_steps=spec.max_episode_steps, max_episode_seconds=spec.max_episode_seconds ) self.env = env # Fix for done flags. self.env.reset() self.step = env.step self.render = env.render self.reset = env.reset
Example #5
Source File: random_robots.py From EPG with MIT License | 5 votes |
def meta_reset(self, seed): np.random.seed(seed) env = NormalHopperEnv() # Based on Hopper-v2 spec = EnvSpec( 'NormalHopperEnv-v0', entry_point='generic_rl.envs.mujoco:NormalHopperEnv', max_episode_steps=1000, reward_threshold=3800.0 ) env._spec = spec env.seed(seed) # Wrap the env as needed env = TimeLimit( env, max_episode_steps=spec.max_episode_steps, max_episode_seconds=spec.max_episode_seconds ) self.env = env # Fix for done flags. self.env.reset() self.step = env.step self.render = env.render self.reset = env.reset
Example #6
Source File: random_robots.py From EPG with MIT License | 5 votes |
def meta_reset(self, seed): np.random.seed(seed) env = RandomWeightHopperDirEnv() # Based on Hopper-v2 spec = EnvSpec( 'DirHopperEnv-v0', entry_point='generic_rl.envs.mujoco:DirHopperEnv', max_episode_steps=1000, reward_threshold=3800.0 ) env._spec = spec env.seed(seed) # Wrap the env as needed env = TimeLimit( env, max_episode_steps=spec.max_episode_steps, max_episode_seconds=spec.max_episode_seconds ) self.env = env # Fix for done flags. self.env.reset() self.step = env.step self.render = env.render self.reset = env.reset
Example #7
Source File: test_nested_observation_spaces.py From ray with Apache License 2.0 | 5 votes |
def __init__(self): self.action_space = spaces.Discrete(2) self.observation_space = DICT_SPACE self._spec = EnvSpec("NestedDictEnv-v0") self.steps = 0
Example #8
Source File: test_nested_observation_spaces.py From ray with Apache License 2.0 | 5 votes |
def __init__(self): self.action_space = spaces.Discrete(2) self.observation_space = TUPLE_SPACE self._spec = EnvSpec("NestedTupleEnv-v0") self.steps = 0
Example #9
Source File: test_nested_observation_spaces.py From ray with Apache License 2.0 | 5 votes |
def __init__(self): self.action_space = spaces.Discrete(2) self.observation_space = REPEATED_SPACE self._spec = EnvSpec("RepeatedSpaceEnv-v0") self.steps = 0
Example #10
Source File: test_nested_observation_spaces.py From ray with Apache License 2.0 | 5 votes |
def __init__(self): self.action_space = spaces.Discrete(2) self.observation_space = DICT_SPACE self._spec = EnvSpec("NestedDictEnv-v0") self.steps = 0
Example #11
Source File: test_nested_observation_spaces.py From ray with Apache License 2.0 | 5 votes |
def __init__(self): self.action_space = spaces.Discrete(2) self.observation_space = TUPLE_SPACE self._spec = EnvSpec("NestedTupleEnv-v0") self.steps = 0
Example #12
Source File: env_base.py From vel with MIT License | 5 votes |
def specification(self) -> EnvSpec: """ Return environment specification """ raise NotImplementedError
Example #13
Source File: classic_control.py From vel with MIT License | 5 votes |
def specification(self) -> EnvSpec: """ Return environment specification """ return gym.spec(self.envname)
Example #14
Source File: mujoco.py From vel with MIT License | 5 votes |
def specification(self) -> EnvSpec: """ Return environment specification """ return gym.spec(self.envname)
Example #15
Source File: classic_atari.py From vel with MIT License | 5 votes |
def specification(self) -> EnvSpec: """ Return environment specification """ return gym.spec(self.envname)
Example #16
Source File: pendulum_with_goals.py From coach with Apache License 2.0 | 4 votes |
def __init__(self, goal_reaching_thresholds=np.array([0.075, 0.075, 0.75]), goal_not_reached_penalty=-1, goal_reached_reward=0, terminate_on_goal_reaching=True, time_limit=1000, frameskip=1, random_goals_instead_of_standing_goal=False, polar_coordinates: bool=False): super().__init__() dir = os.path.dirname(__file__) model = load_model_from_path(dir + "/pendulum_with_goals.xml") self.sim = MjSim(model) self.viewer = None self.rgb_viewer = None self.frameskip = frameskip self.goal = None self.goal_reaching_thresholds = goal_reaching_thresholds self.goal_not_reached_penalty = goal_not_reached_penalty self.goal_reached_reward = goal_reached_reward self.terminate_on_goal_reaching = terminate_on_goal_reaching self.time_limit = time_limit self.current_episode_steps_counter = 0 self.random_goals_instead_of_standing_goal = random_goals_instead_of_standing_goal self.polar_coordinates = polar_coordinates # spaces definition self.action_space = spaces.Box(low=-self.sim.model.actuator_ctrlrange[:, 1], high=self.sim.model.actuator_ctrlrange[:, 1], dtype=np.float32) if self.polar_coordinates: self.observation_space = spaces.Dict({ "observation": spaces.Box(low=np.array([-np.pi, -15]), high=np.array([np.pi, 15]), dtype=np.float32), "desired_goal": spaces.Box(low=np.array([-np.pi, -15]), high=np.array([np.pi, 15]), dtype=np.float32), "achieved_goal": spaces.Box(low=np.array([-np.pi, -15]), high=np.array([np.pi, 15]), dtype=np.float32) }) else: self.observation_space = spaces.Dict({ "observation": spaces.Box(low=np.array([-1, -1, -15]), high=np.array([1, 1, 15]), dtype=np.float32), "desired_goal": spaces.Box(low=np.array([-1, -1, -15]), high=np.array([1, 1, 15]), dtype=np.float32), "achieved_goal": spaces.Box(low=np.array([-1, -1, -15]), high=np.array([1, 1, 15]), dtype=np.float32) }) self.spec = EnvSpec('PendulumWithGoals-v0') self.spec.reward_threshold = self.goal_not_reached_penalty * self.time_limit self.reset()