Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve closer implementation and docstrings #126

Merged
merged 6 commits into from
May 27, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve docstrings in core
  • Loading branch information
gdb committed May 27, 2016
commit 8444e8c29d40889003d818546c041862bf63956e
45 changes: 21 additions & 24 deletions gym/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,16 @@ def step(self, action):
episode is reached, you are responsible for calling `reset()`
to reset this environment's state.

Input
-----
action : an action provided by the environment

Outputs
-------
(observation, reward, done, info)

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)
Accepts an action and returns a tuple (observation, reward, done, info).

Args:
action (object): an action provided by the environment

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)
"""
if not self.action_space.contains(action):
logger.warn("Action '{}' is not contained within action space '{}'.".format(action, self.action_space))
Expand All @@ -108,9 +106,8 @@ def reset(self):
"""
Resets the state of the environment and returns an initial observation.

Outputs
-------
observation (object): the initial observation of the space. (Initial reward is assumed to be 0.)
Returns:
observation (object): the initial observation of the space. (Initial reward is assumed to be 0.)
"""
self.monitor._before_reset()
observation = self._reset()
Expand Down Expand Up @@ -145,15 +142,15 @@ def render(self, mode='human', close=False):
Example:

class MyEnv(Env):
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
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
"""
if close:
return self._render(close=close)
Expand Down