Skip to content

Commit

Permalink
Docs: update aec_rps.py
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhaoze committed Dec 9, 2024
1 parent 67ecdb2 commit 3104068
Showing 1 changed file with 4 additions and 6 deletions.
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

0 comments on commit 3104068

Please sign in to comment.