Skip to content

Commit

Permalink
Two small bugfixes (#5589)
Browse files Browse the repository at this point in the history
1. Add the missing `_cumulative_rewards` property
2. Update `agent_selection` to not error out when an agent finishes an episode.
  • Loading branch information
Henry Peteet authored Nov 10, 2021
1 parent 0a2f57f commit ad9282b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pettingzoo-unity/pettingzoo_unity/pettingzoo_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ def _create_empty_actions(self, behavior_name, num_agents):
np.zeros((num_agents, len(a_spec.discrete_branches)), dtype=np.int32),
)

@property
def _cumulative_rewards(self):
return self._cumm_rewards

def reset(self):
"""
Resets the environment.
Expand Down Expand Up @@ -399,6 +403,9 @@ def infos(self):

@property
def agent_selection(self):
if not self._live_agents:
# If we had an agent finish then return that agent even though it isn't alive.
return self._agents[0]
return self._agents[self._agent_index]

@property
Expand Down

0 comments on commit ad9282b

Please sign in to comment.