Open MarcoMeter opened 5 years ago
Hi @MarcoMeter
This is currently not possible, unless you manually keep a tracker that increments every time a +1 reward is received. It makes a lot of sense though to have this more easily available. We can ensure that it is available as part of the observations in the Round 2 release.
Here's the wrapper I use for this. It adds the current floor to the info
dictionary.
class FloorTrackEnv(gym.Wrapper):
def __init__(self, env):
super().__init__(env)
self.floor = 0
def reset(self, **kwargs):
self.floor = 0
return self.env.reset(**kwargs)
def step(self, action):
obs, rew, done, info = self.env.step(action)
if rew == 1.0:
self.floor += 1
info['floor'] = self.floor
return obs, rew, done, info
The above wrapper does not work if you manually change the starting floor. In that case, you can make a slight modification to the reset()
method:
class FloorTrackEnv(gym.Wrapper):
def __init__(self, env):
super().__init__(env)
self.floor = 0
def reset(self, **kwargs):
obs = self.env.reset(**kwargs)
self.floor = self.unwrapped._floor
return obs
def step(self, action):
obs, rew, done, info = self.env.step(action)
if rew == 1.0:
self.floor += 1
info['floor'] = self.floor
return obs, rew, done, info
Is there a possibiity to print the current floor? I'd like to track the mean floor for my training statistics. The property _floor is set to None as long as floor() is not called.