Skip to content

Commit

Permalink
Simplify agent checking code.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisyeh96 committed Sep 12, 2023
1 parent 0c58438 commit 7c1c597
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pettingzoo/test/parallel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def parallel_api_test(par_env: ParallelEnv, num_cycles=1000):
agent
), "action_space should return the exact same space object (not a copy) for an agent (ensures that action space seeding works as expected). Consider decorating your action_space(self, agent) method with @functools.lru_cache(maxsize=None)"

# we make a copy of live_agents because live_agents changes during iteration
for agent in set(live_agents):
if terminated[agent] or truncated[agent]:
live_agents.remove(agent)
agents_to_remove = {
agent in live_agents if terminated[agent] or truncated[agent]
}
live_agents -= agents_to_remove

assert (
set(par_env.agents) == live_agents
Expand Down

0 comments on commit 7c1c597

Please sign in to comment.