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

The max_obs of observation range may not correct #11

Closed
GoingMyWay opened this issue Mar 23, 2022 · 2 comments
Closed

The max_obs of observation range may not correct #11

GoingMyWay opened this issue Mar 23, 2022 · 2 comments

Comments

@GoingMyWay
Copy link
Contributor

GoingMyWay commented Mar 23, 2022

Dear authors, after checking the code, I found that in https://github.com/semitable/lb-foraging/blob/master/lbforaging/foraging/environment.py#L125

            field_x = self.field.shape[1]
            field_y = self.field.shape[0]
            # field_size = field_x * field_y

            max_food = self.max_food
            max_food_level = self.max_player_level * len(self.players)

            min_obs = [-1, -1, 0] * max_food + [-1, -1, 0] * len(self.players)
            max_obs = [field_x, field_y, max_food_level] * max_food + [
                field_x,
                field_y,
                self.max_player_level,
            ] 

and

return gym.spaces.Box(np.array(min_obs), np.array(max_obs), dtype=np.float32)

For 8x8 grid, the field_x and field_y are 8. However, the positions of the grids are within the range of [0, 7]. In gym.spaces.Box (https://github.com/openai/gym/blob/master/gym/spaces/box.py#L26), it is [0, 8]. I guess it will out of range. It will not cause any error if you do not predict the obs and modify the obs.

Could you please check it? If so, I will make a PR.

@semitable
Copy link
Owner

Thanks @GoingMyWay
Yes, that makes sense to me. I didn't really bother much with the observation space since it doesn't appear to cause any issues when the observation space (is a superset of) contains the actual observations. I am happy to merge a PR if this fixes some use case you have in mind.

@GoingMyWay
Copy link
Contributor Author

Thanks @GoingMyWay Yes, that makes sense to me. I didn't really bother much with the observation space since it doesn't appear to cause any issues when the observation space (is a superset of) contains the actual observations. I am happy to merge a PR if this fixes some use case you have in mind.

Thanks. I encountered this problem when I tried to predict x and y. The grid size is 8x8. I got x=8 and it was out of the bound.

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

No branches or pull requests

2 participants