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

Docs: update aec_rps.py #1248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions docs/code_examples/aec_rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ def __init__(self, render_mode=None):
)

# optional: we can define the observation and action spaces here as attributes to be used in their corresponding methods
self._action_spaces = {agent: Discrete(3) for agent in self.possible_agents}
self._observation_spaces = {
agent: Discrete(4) for agent in self.possible_agents
}
self.action_spaces = {agent: Discrete(3) for agent in self.possible_agents}
self.observation_spaces = {agent: Discrete(4) for agent in self.possible_agents}
self.render_mode = render_mode

# Observation space should be defined here.
Expand All @@ -88,13 +86,13 @@ def __init__(self, render_mode=None):
@functools.lru_cache(maxsize=None)
def observation_space(self, agent):
# gymnasium spaces are defined and documented here: https://gymnasium.farama.org/api/spaces/
return Discrete(4)
return self.observation_spaces[agent]

# Action space should be defined here.
# If your spaces change over time, remove this line (disable caching).
@functools.lru_cache(maxsize=None)
def action_space(self, agent):
return Discrete(3)
return self.action_spaces[agent]

def render(self):
"""
Expand Down
Loading