本文整理汇总了Python中gym.error.ResetNeeded方法的典型用法代码示例。如果您正苦于以下问题:Python error.ResetNeeded方法的具体用法?Python error.ResetNeeded怎么用?Python error.ResetNeeded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gym.error
的用法示例。
在下文中一共展示了error.ResetNeeded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: step
# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import ResetNeeded [as 别名]
def step(self, action):
if not self.episode_number or self.timesteps is self.horizon:
raise error.ResetNeeded()
state = self._get_new_state()
self._take_action(action)
reward = self._get_reward()
message = "Timestep {}:==: Action: {} ; Reward: {}".format(
self.timesteps, CryptoEnv.action_space.lookup[action], reward
)
self.logger.debug(message)
self.timesteps = self.timesteps + 1
if self.timesteps is not self.horizon:
self.current = self.current + 1
return state, reward, False, np.array([float(self.horizon - self.timesteps) / self.horizon])
else:
return state, reward, True, np.array([0.0])
示例2: before_step
# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import ResetNeeded [as 别名]
def before_step(self, action):
assert not self.closed
if self.done:
raise error.ResetNeeded("Trying to step environment which is currently done. While the monitor is active for {}, you cannot step beyond the end of an episode. Call 'env.reset()' to start the next episode.".format(self.env_id))
elif self.steps is None:
raise error.ResetNeeded("Trying to step an environment before reset. While the monitor is active for {}, you must call 'env.reset()' before taking an initial step.".format(self.env_id))
示例3: _before_env_step
# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import ResetNeeded [as 别名]
def _before_env_step(self, action):
# Do not execute if the environment was not stepped or reset from this monitor
if not self._active:
# Remember that env was not stepped via the monitor and require reset next time
self.stats_recorder.env_done = None
return
if self.done is None:
raise ResetNeeded("Trying to step environment {}, before calling 'env.reset()'.".format(self.env_id))
if self.done:
raise ResetNeeded("Trying to step environment {}, which is done. You cannot step beyond the "
"end of an episode. Call 'env.reset()' to start the next episode.".format(self.env_id))