From 310406812e57ac969da3ce2f86fc834751e22992 Mon Sep 17 00:00:00 2001 From: liuzhaoze <1045954863@qq.com> Date: Mon, 9 Dec 2024 16:36:52 +0800 Subject: [PATCH] Docs: update aec_rps.py --- docs/code_examples/aec_rps.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/code_examples/aec_rps.py b/docs/code_examples/aec_rps.py index 7272f75bd..59d44768d 100644 --- a/docs/code_examples/aec_rps.py +++ b/docs/code_examples/aec_rps.py @@ -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. @@ -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): """