Skip to content

Commit

Permalink
[Update registration.py]: Clean-up of unused arguments (#1626)
Browse files Browse the repository at this point in the history
* Update registration.py

* Update registration.py
  • Loading branch information
zuoxingdong authored and pzhokhov committed Dec 6, 2019
1 parent 3ee7e67 commit a99e8d1
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions gym/envs/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,24 @@ class EnvSpec(object):
id (str): The official environment ID
entry_point (Optional[str]): The Python entrypoint of the environment class (e.g. module.name:Class)
reward_threshold (Optional[int]): The reward threshold before the task is considered solved
kwargs (dict): The kwargs to pass to the environment class
nondeterministic (bool): Whether this environment is non-deterministic even after seeding
tags (dict[str:any]): A set of arbitrary key-value tags on this environment, including simple property=True tags
max_episode_steps (Optional[int]): The maximum number of steps that an episode can consist of
kwargs (dict): The kwargs to pass to the environment class
Attributes:
id (str): The official environment ID
"""

def __init__(self, id, entry_point=None, reward_threshold=None, kwargs=None, nondeterministic=False, tags=None, max_episode_steps=None):
def __init__(self, id, entry_point=None, reward_threshold=None, nondeterministic=False, max_episode_steps=None, kwargs=None):
self.id = id
# Evaluation parameters
self.entry_point = entry_point
self.reward_threshold = reward_threshold
# Environment properties
self.nondeterministic = nondeterministic
self.entry_point = entry_point

if tags is None:
tags = {}
self.tags = tags

tags['wrapper_config.TimeLimit.max_episode_steps'] = max_episode_steps

self.max_episode_steps = max_episode_steps
self._kwargs = {} if kwargs is None else kwargs

# We may make some of these other parameters public if they're
# useful.
match = env_id_re.search(id)
if not match:
raise error.Error('Attempted to register malformed environment ID: {}. (Currently all IDs must be of the form {}.)'.format(id, env_id_re.pattern))
self._env_name = match.group(1)
self._kwargs = {} if kwargs is None else kwargs
self._env_name = match.group(1)

def make(self, **kwargs):
"""Instantiates an instance of the environment with appropriate kwargs"""
Expand Down Expand Up @@ -105,7 +91,7 @@ def make(self, path, **kwargs):
# compatibility code to be invoked.
if hasattr(env, "_reset") and hasattr(env, "_step") and not getattr(env, "_gym_disable_underscore_compat", False):
patch_deprecated_methods(env)
if (env.spec.max_episode_steps is not None) and not spec.tags.get('vnc'):
if env.spec.max_episode_steps is not None:
from gym.wrappers.time_limit import TimeLimit
env = TimeLimit(env, max_episode_steps=env.spec.max_episode_steps)
return env
Expand Down

1 comment on commit a99e8d1

@2twentytwo2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great

Please sign in to comment.