Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
from gym import logger
|
2016-04-27 08:00:58 -07:00
|
|
|
import numpy as np
|
|
|
|
|
2016-12-23 16:21:42 -08:00
|
|
|
from gym import error
|
2017-02-26 00:01:00 -08:00
|
|
|
from gym.utils import closer
|
2016-05-27 12:16:35 -07:00
|
|
|
|
|
|
|
env_closer = closer.Closer()
|
2016-04-27 08:00:58 -07:00
|
|
|
|
|
|
|
# Env-related abstractions
|
|
|
|
|
|
|
|
class Env(object):
|
|
|
|
"""The main OpenAI Gym class. It encapsulates an environment with
|
2016-04-28 10:33:37 -07:00
|
|
|
arbitrary behind-the-scenes dynamics. An environment can be
|
|
|
|
partially or fully observed.
|
|
|
|
|
|
|
|
The main API methods that users of this class need to know are:
|
|
|
|
|
|
|
|
step
|
2016-05-29 09:07:09 -07:00
|
|
|
reset
|
2016-04-28 10:33:37 -07:00
|
|
|
render
|
2016-05-15 15:59:02 -07:00
|
|
|
close
|
2016-05-29 09:07:09 -07:00
|
|
|
seed
|
2016-04-27 08:00:58 -07:00
|
|
|
|
|
|
|
And set the following attributes:
|
|
|
|
|
|
|
|
action_space: The Space object corresponding to valid actions
|
|
|
|
observation_space: The Space object corresponding to valid observations
|
2016-05-27 12:16:35 -07:00
|
|
|
reward_range: A tuple corresponding to the min and max possible rewards
|
2016-04-27 08:00:58 -07:00
|
|
|
|
2016-08-24 23:10:58 +02:00
|
|
|
Note: a default reward range set to [-inf,+inf] already exists. Set it if you want a narrower range.
|
|
|
|
|
2016-04-27 08:00:58 -07:00
|
|
|
The methods are accessed publicly as "step", "reset", etc.. The
|
|
|
|
non-underscored versions are wrapper methods to which we may add
|
2016-06-29 01:47:55 -07:00
|
|
|
functionality over time.
|
2016-04-27 08:00:58 -07:00
|
|
|
"""
|
|
|
|
|
|
|
|
# Set this in SOME subclasses
|
|
|
|
metadata = {'render.modes': []}
|
2016-04-30 22:53:10 -04:00
|
|
|
reward_range = (-np.inf, np.inf)
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
spec = None
|
2016-05-15 15:59:02 -07:00
|
|
|
|
2016-04-27 08:00:58 -07:00
|
|
|
# Set these in ALL subclasses
|
|
|
|
action_space = None
|
|
|
|
observation_space = None
|
|
|
|
|
|
|
|
def step(self, action):
|
2016-04-28 10:33:37 -07:00
|
|
|
"""Run one timestep of the environment's dynamics. When end of
|
|
|
|
episode is reached, you are responsible for calling `reset()`
|
|
|
|
to reset this environment's state.
|
2016-04-27 08:00:58 -07:00
|
|
|
|
2016-05-27 12:16:35 -07:00
|
|
|
Accepts an action and returns a tuple (observation, reward, done, info).
|
2016-04-27 08:00:58 -07:00
|
|
|
|
2016-05-27 12:16:35 -07:00
|
|
|
Args:
|
|
|
|
action (object): an action provided by the environment
|
2016-04-27 08:00:58 -07:00
|
|
|
|
2016-05-27 12:16:35 -07:00
|
|
|
Returns:
|
|
|
|
observation (object): agent's observation of the current environment
|
|
|
|
reward (float) : amount of reward returned after previous action
|
|
|
|
done (boolean): whether the episode has ended, in which case further step() calls will return undefined results
|
|
|
|
info (dict): contains auxiliary diagnostic information (helpful for debugging, and sometimes learning)
|
2016-04-27 08:00:58 -07:00
|
|
|
"""
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
raise NotImplementedError
|
2016-04-27 08:00:58 -07:00
|
|
|
|
|
|
|
def reset(self):
|
2017-02-26 00:01:00 -08:00
|
|
|
"""Resets the state of the environment and returns an initial observation.
|
2016-04-27 08:00:58 -07:00
|
|
|
|
2016-09-04 00:38:03 -07:00
|
|
|
Returns: observation (object): the initial observation of the
|
2017-02-26 00:01:00 -08:00
|
|
|
space.
|
2016-04-27 08:00:58 -07:00
|
|
|
"""
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
raise NotImplementedError
|
2016-04-27 08:00:58 -07:00
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def render(self, mode='human'):
|
2016-04-27 08:00:58 -07:00
|
|
|
"""Renders the environment.
|
|
|
|
|
|
|
|
The set of supported modes varies per environment. (And some
|
|
|
|
environments do not support rendering at all.) By convention,
|
|
|
|
if mode is:
|
|
|
|
|
|
|
|
- human: render to the current display or terminal and
|
|
|
|
return nothing. Usually for human consumption.
|
|
|
|
- rgb_array: Return an numpy.ndarray with shape (x, y, 3),
|
|
|
|
representing RGB values for an x-by-y pixel image, suitable
|
|
|
|
for turning into a video.
|
|
|
|
- ansi: Return a string (str) or StringIO.StringIO containing a
|
|
|
|
terminal-style text representation. The text can include newlines
|
|
|
|
and ANSI escape sequences (e.g. for colors).
|
|
|
|
|
|
|
|
Note:
|
|
|
|
Make sure that your class's metadata 'render.modes' key includes
|
|
|
|
the list of supported modes. It's recommended to call super()
|
|
|
|
in implementations to use the functionality of this method.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
mode (str): the mode to render with
|
|
|
|
close (bool): close all open renderings
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
class MyEnv(Env):
|
2016-05-27 12:16:35 -07:00
|
|
|
metadata = {'render.modes': ['human', 'rgb_array']}
|
|
|
|
|
|
|
|
def render(self, mode='human'):
|
|
|
|
if mode == 'rgb_array':
|
|
|
|
return np.array(...) # return RGB frame suitable for video
|
|
|
|
elif mode is 'human':
|
|
|
|
... # pop up a window and render
|
|
|
|
else:
|
|
|
|
super(MyEnv, self).render(mode=mode) # just raise an exception
|
2016-04-27 08:00:58 -07:00
|
|
|
"""
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
raise NotImplementedError
|
2016-04-27 08:00:58 -07:00
|
|
|
|
2016-05-15 15:59:02 -07:00
|
|
|
def close(self):
|
2016-05-27 12:16:35 -07:00
|
|
|
"""Override _close in your subclass to perform any necessary cleanup.
|
|
|
|
|
|
|
|
Environments will automatically close() themselves when
|
|
|
|
garbage collected or when the program exits.
|
2016-05-15 15:59:02 -07:00
|
|
|
"""
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
return
|
2016-05-15 15:59:02 -07:00
|
|
|
|
2016-05-29 09:07:09 -07:00
|
|
|
def seed(self, seed=None):
|
|
|
|
"""Sets the seed for this env's random number generator(s).
|
|
|
|
|
|
|
|
Note:
|
|
|
|
Some environments use multiple pseudorandom number generators.
|
|
|
|
We want to capture all such seeds used in order to ensure that
|
|
|
|
there aren't accidental correlations between multiple generators.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
list<bigint>: Returns the list of seeds used in this env's random
|
|
|
|
number generators. The first value in the list should be the
|
|
|
|
"main" seed, or the value which a reproducer should pass to
|
|
|
|
'seed'. Often, the main seed equals the provided 'seed', but
|
|
|
|
this won't be true if seed=None, for example.
|
|
|
|
"""
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
logger.warn("Could not seed environment %s", self)
|
|
|
|
return
|
2017-06-16 16:35:03 -07:00
|
|
|
|
2016-08-17 15:16:45 -07:00
|
|
|
@property
|
|
|
|
def unwrapped(self):
|
|
|
|
"""Completely unwrap this env.
|
2016-08-11 14:45:52 -07:00
|
|
|
|
|
|
|
Returns:
|
2016-08-17 15:16:45 -07:00
|
|
|
gym.Env: The base non-wrapped gym.Env instance
|
2016-08-11 14:45:52 -07:00
|
|
|
"""
|
2017-02-26 00:01:00 -08:00
|
|
|
return self
|
2016-08-11 14:45:52 -07:00
|
|
|
|
2016-04-27 08:00:58 -07:00
|
|
|
def __str__(self):
|
2017-06-16 16:35:03 -07:00
|
|
|
if self.spec is None:
|
2017-03-09 18:16:26 -08:00
|
|
|
return '<{} instance>'.format(type(self).__name__)
|
2017-06-16 16:35:03 -07:00
|
|
|
else:
|
|
|
|
return '<{}<{}>>'.format(type(self).__name__, self.spec.id)
|
2016-04-27 08:00:58 -07:00
|
|
|
|
|
|
|
# Space-related abstractions
|
|
|
|
|
|
|
|
class Space(object):
|
2016-08-11 14:45:52 -07:00
|
|
|
"""Defines the observation and action spaces, so you can write generic
|
|
|
|
code that applies to any Env. For example, you can choose a random
|
|
|
|
action.
|
2016-04-27 08:00:58 -07:00
|
|
|
"""
|
2018-02-08 16:46:25 -08:00
|
|
|
def __init__(self, shape=None, dtype=None):
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
self.shape = None if shape is None else tuple(shape)
|
|
|
|
self.dtype = None if dtype is None else np.dtype(dtype)
|
2016-04-27 08:00:58 -07:00
|
|
|
|
2017-02-04 23:35:38 -08:00
|
|
|
def sample(self):
|
2016-04-27 08:00:58 -07:00
|
|
|
"""
|
2017-02-04 23:35:38 -08:00
|
|
|
Uniformly randomly sample a random element of this space
|
2016-04-27 08:00:58 -07:00
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def contains(self, x):
|
|
|
|
"""
|
|
|
|
Return boolean specifying if x is a valid
|
|
|
|
member of this space
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def to_jsonable(self, sample_n):
|
|
|
|
"""Convert a batch of samples from this space to a JSONable data type."""
|
|
|
|
# By default, assume identity is JSONable
|
|
|
|
return sample_n
|
|
|
|
|
|
|
|
def from_jsonable(self, sample_n):
|
|
|
|
"""Convert a JSONable data type to a batch of samples from this space."""
|
|
|
|
# By default, assume identity is JSONable
|
|
|
|
return sample_n
|
2016-08-11 14:45:52 -07:00
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
|
|
|
|
warn_once = True
|
|
|
|
|
|
|
|
def deprecated_warn_once(text):
|
|
|
|
global warn_once
|
|
|
|
if not warn_once: return
|
|
|
|
warn_once = False
|
|
|
|
logger.warn(text)
|
|
|
|
|
|
|
|
|
2016-08-11 14:45:52 -07:00
|
|
|
class Wrapper(Env):
|
2016-09-04 00:38:03 -07:00
|
|
|
env = None
|
|
|
|
|
2017-02-26 00:01:00 -08:00
|
|
|
def __init__(self, env):
|
2016-08-13 19:24:48 -07:00
|
|
|
self.env = env
|
2016-09-04 00:38:03 -07:00
|
|
|
self.action_space = self.env.action_space
|
|
|
|
self.observation_space = self.env.observation_space
|
|
|
|
self.reward_range = self.env.reward_range
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
self.metadata = self.env.metadata
|
|
|
|
self._warn_double_wrap()
|
2016-12-23 16:21:42 -08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def class_name(cls):
|
|
|
|
return cls.__name__
|
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def _warn_double_wrap(self):
|
2017-02-26 00:01:00 -08:00
|
|
|
env = self.env
|
|
|
|
while True:
|
2017-03-09 18:16:26 -08:00
|
|
|
if isinstance(env, Wrapper):
|
2017-02-26 00:01:00 -08:00
|
|
|
if env.class_name() == self.class_name():
|
|
|
|
raise error.DoubleWrapperError("Attempted to double wrap with Wrapper: {}".format(self.__class__.__name__))
|
|
|
|
env = env.env
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def step(self, action):
|
|
|
|
if hasattr(self, "_step"):
|
|
|
|
deprecated_warn_once("%s doesn't implement 'step' method, but it implements deprecated '_step' method." % type(self))
|
|
|
|
self.step = self._step
|
|
|
|
return self.step(action)
|
|
|
|
else:
|
|
|
|
deprecated_warn_once("%s doesn't implement 'step' method, " % type(self) +
|
|
|
|
"which is required for wrappers derived directly from Wrapper. Deprecated default implementation is used.")
|
|
|
|
return self.env.step(action)
|
|
|
|
|
|
|
|
def reset(self, **kwargs):
|
|
|
|
if hasattr(self, "_reset"):
|
|
|
|
deprecated_warn_once("%s doesn't implement 'reset' method, but it implements deprecated '_reset' method." % type(self))
|
|
|
|
self.reset = self._reset
|
|
|
|
return self._reset(**kwargs)
|
|
|
|
else:
|
|
|
|
deprecated_warn_once("%s doesn't implement 'reset' method, " % type(self) +
|
|
|
|
"which is required for wrappers derived directly from Wrapper. Deprecated default implementation is used.")
|
|
|
|
return self.env.reset(**kwargs)
|
2016-08-11 14:45:52 -07:00
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def render(self, mode='human'):
|
|
|
|
return self.env.render(mode)
|
2016-08-11 14:45:52 -07:00
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def close(self):
|
2017-09-02 18:10:50 -07:00
|
|
|
if self.env:
|
|
|
|
return self.env.close()
|
2016-08-11 14:45:52 -07:00
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def seed(self, seed=None):
|
2016-08-11 14:45:52 -07:00
|
|
|
return self.env.seed(seed)
|
|
|
|
|
|
|
|
def __str__(self):
|
2016-09-04 00:38:03 -07:00
|
|
|
return '<{}{}>'.format(type(self).__name__, self.env)
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return str(self)
|
2016-08-17 15:16:45 -07:00
|
|
|
|
|
|
|
@property
|
2017-02-26 00:01:00 -08:00
|
|
|
def unwrapped(self):
|
|
|
|
return self.env.unwrapped
|
2016-09-04 00:38:03 -07:00
|
|
|
|
2017-03-09 18:16:26 -08:00
|
|
|
@property
|
|
|
|
def spec(self):
|
|
|
|
return self.env.spec
|
|
|
|
|
2016-09-04 00:38:03 -07:00
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
class ObservationWrapper(Wrapper):
|
|
|
|
def step(self, action):
|
2016-09-04 00:38:03 -07:00
|
|
|
observation, reward, done, info = self.env.step(action)
|
2016-09-04 01:44:20 -07:00
|
|
|
return self.observation(observation), reward, done, info
|
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def reset(self, **kwargs):
|
|
|
|
observation = self.env.reset(**kwargs)
|
|
|
|
return self.observation(observation)
|
|
|
|
|
2016-09-04 01:44:20 -07:00
|
|
|
def observation(self, observation):
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
deprecated_warn_once("%s doesn't implement 'observation' method. Maybe it implements deprecated '_observation' method." % type(self))
|
2016-09-04 01:44:20 -07:00
|
|
|
return self._observation(observation)
|
2016-09-04 00:38:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
class RewardWrapper(Wrapper):
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def reset(self):
|
|
|
|
return self.env.reset()
|
|
|
|
|
|
|
|
def step(self, action):
|
2016-09-04 00:38:03 -07:00
|
|
|
observation, reward, done, info = self.env.step(action)
|
2016-09-04 01:44:20 -07:00
|
|
|
return observation, self.reward(reward), done, info
|
|
|
|
|
|
|
|
def reward(self, reward):
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
deprecated_warn_once("%s doesn't implement 'reward' method. Maybe it implements deprecated '_reward' method." % type(self))
|
2016-09-04 01:44:20 -07:00
|
|
|
return self._reward(reward)
|
2016-09-04 00:38:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
class ActionWrapper(Wrapper):
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def step(self, action):
|
2016-09-04 01:44:20 -07:00
|
|
|
action = self.action(action)
|
2016-09-04 00:38:03 -07:00
|
|
|
return self.env.step(action)
|
|
|
|
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
def reset(self):
|
|
|
|
return self.env.reset()
|
2018-02-08 16:46:25 -08:00
|
|
|
|
2016-09-04 01:44:20 -07:00
|
|
|
def action(self, action):
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
deprecated_warn_once("%s doesn't implement 'action' method. Maybe it implements deprecated '_action' method." % type(self))
|
2016-09-04 01:44:20 -07:00
|
|
|
return self._action(action)
|
|
|
|
|
2016-10-14 22:07:47 -07:00
|
|
|
def reverse_action(self, action):
|
Cleanup, removal of unmaintained code (#836)
* add dtype to Box
* remove board_game, debugging, safety, parameter_tuning environments
* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder
* Improve render("human"), now resizable, closable window.
* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods
* CubeCrash unit test environment
* followup fixes
* MemorizeDigits unit test envrionment
* refactored spaces a bit
fixed indentation
disabled test_env_semantics
* fix unit tests
* fixes
* CubeCrash, MemorizeDigits tested
* gym backwards compatibility patch
* gym backwards compatibility, followup fixes
* changelist, add spaces to main namespaces
* undo_logger_setup for backwards compat
* remove configuration.py
2018-01-25 18:20:14 -08:00
|
|
|
deprecated_warn_once("%s doesn't implement 'reverse_action' method. Maybe it implements deprecated '_reverse_action' method." % type(self))
|
2016-10-14 22:07:47 -07:00
|
|
|
return self._reverse_action(action)
|