Skip to content

Commit

Permalink
Github CI job failed because pettingzoo update to 1.23 -- changed out…
Browse files Browse the repository at this point in the history
…put of reset() to match new API and set setup.cfg requirement
  • Loading branch information
SynapticSage committed May 29, 2023
1 parent 8e6e2fc commit daa1107
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions ratinabox/contribs/TaskEnvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, *pos, verbose=False,
self.agents:List[str] = [] # pettingzoo variable
# that tracks all agents who are
# still active in an episode
self.info:dict = {} # gymnasium returns info in step()
self.infos:dict = {} # pettingzoo returns infos in step()

# Episode history
self.episodes:dict = {} # Written to upon completion of an episode
Expand Down Expand Up @@ -172,6 +172,7 @@ def add_agents(self, agents:Union[dict, List[Agent], Agent],
agent.t = self.t # agent clock is aligned to environment,
# in case a new agent is placed in the env
# on a later episode
self.infos[name] = {} # pettingzoo requirement

self.reset() # reset the environment with new agent

Expand Down Expand Up @@ -295,6 +296,8 @@ def reset(self, seed=None, return_info=False, options=None):

# Reset goals
self.goal_cache.reset()

return self.get_observation(), self.infos


def update(self, update_agents=False):
Expand Down Expand Up @@ -358,7 +361,7 @@ def step(self, actions:Union[dict,np.array,None]=None, dt=None,
self.get_reward(),
self._dict(self._is_terminal_state()),
self._dict(self._is_truncated_state()),
self._dict([self.info])
self._dict([self.infos])
)

def step1(self, action=None, *pos, **kws):
Expand Down Expand Up @@ -1193,9 +1196,8 @@ def reset(self, goal_locations:Union[np.ndarray,None]=None,
goal_locations)

# Reset the TaskEnvironment parent class (which picks new goals etc)
super().reset(**kws)

return self.get_observation()
# and returns pettingzoo.reset() required objects
return super().reset(**kws)

# --------------------------------------
# Rendering
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ install_requires =
matplotlib
scipy
shapely
pettingzoo
pettingzoo >= 1.23.0
python_requires = >=3.7
include_package_data = False

Expand Down

0 comments on commit daa1107

Please sign in to comment.