MCPcopy Create free account
hub / github.com/YeWR/EfficientZero / TimeLimit

Class TimeLimit

core/utils.py:39–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39class TimeLimit(gym.Wrapper):
40 def __init__(self, env, max_episode_steps=None):
41 super(TimeLimit, self).__init__(env)
42 self._max_episode_steps = max_episode_steps
43 self._elapsed_steps = 0
44
45 def step(self, ac):
46 observation, reward, done, info = self.env.step(ac)
47 self._elapsed_steps += 1
48 if self._elapsed_steps >= self._max_episode_steps:
49 done = True
50 info['TimeLimit.truncated'] = True
51 return observation, reward, done, info
52
53 def get_max_episode_steps(self):
54 return self._max_episode_steps
55
56 def reset(self, **kwargs):
57 self._elapsed_steps = 0
58 return self.env.reset(**kwargs)
59
60
61class NoopResetEnv(gym.Wrapper):

Callers 1

make_atariFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected