Skip to content

Commit

Permalink
[fix] Fix infos in env.reset()
Browse files Browse the repository at this point in the history
  • Loading branch information
rchaput committed Jul 18, 2024
1 parent 2c8c030 commit 4ac7cb9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions smartgrid/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ def reset(
self.reward_calculator.reset()

obs = self._get_obs()
return obs, {}
# PettingZoo requires the infos to contain a dictionary for each agent,
# even if the dictionary itself is empty.
infos = {agent_name: {} for agent_name in self.agents}
return obs, infos

def render(self, mode='text'):
"""
Expand Down Expand Up @@ -333,10 +336,10 @@ def _get_info(self, rewards: RewardsDict) -> InfoDict:
only the agent's reward, indexed by ``'reward'``.
"""
return {
agent.name: {
'reward': rewards[agent.name]
agent_name: {
'reward': rewards[agent_name]
}
for agent in self.world.agents
for agent_name in self.agents
}

@property
Expand Down

0 comments on commit 4ac7cb9

Please sign in to comment.