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

Make MultiDiscrete a Tuple-like space #2364

Merged
merged 3 commits into from
Sep 11, 2021
Merged

Make MultiDiscrete a Tuple-like space #2364

merged 3 commits into from
Sep 11, 2021

Conversation

XuehaiPan
Copy link
Contributor

@XuehaiPan XuehaiPan commented Aug 27, 2021

Add __getitem__ and __len__ method for MultiDiscrete space.

As exampled in Tuple:

gym/gym/spaces/tuple.py

Lines 5 to 11 in 2bd436b

class Tuple(Space):
"""
A tuple (i.e., product) of simpler spaces
Example usage:
self.observation_space = spaces.Tuple((spaces.Discrete(2), spaces.Discrete(3)))
"""

this PR makes:

t = Tuple((Discrete(2), Discrete(3)))
md = MulitDiscrete([2, 3])

t[0]   # -> Discrete(2)
md[0]  # -> Discrete(2)

@jkterry1
Copy link
Collaborator

jkterry1 commented Sep 2, 2021

@XuehaiPan Can you please add tests?

@XuehaiPan
Copy link
Contributor Author

@XuehaiPan Can you please add tests?

Done.

@jkterry1 jkterry1 merged commit a8f551e into openai:master Sep 11, 2021
@XuehaiPan XuehaiPan deleted the multidiscrete-as-tuple branch September 11, 2021 17:01
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

Successfully merging this pull request may close these issues.

2 participants