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

Retrieve the number of the current floor #82

Open
MarcoMeter opened this issue Apr 17, 2019 · 2 comments
Open

Retrieve the number of the current floor #82

MarcoMeter opened this issue Apr 17, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@MarcoMeter
Copy link
Contributor

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.

@awjuliani awjuliani self-assigned this Apr 17, 2019
@awjuliani awjuliani added the enhancement New feature or request label Apr 17, 2019
@awjuliani
Copy link
Contributor

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.

@unixpickle
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants