Skip to content

Commit

Permalink
fix intermediate events swarming
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Aug 9, 2024
1 parent 21d74ee commit 972f0fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 8 additions & 4 deletions pokemonred_puffer/cleanrl_puffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ def evaluate(self):
self.config.async_wrapper
and hasattr(self.config, "swarm")
and self.config.swarm
# and self.epoch % self.config.swarm_frequency == 0
and "required_count" in self.infos
and self.states
):
Expand Down Expand Up @@ -325,12 +324,17 @@ def evaluate(self):
# If we do, migrate 100% of states to one of the states
max_event_count = 0
new_state_key = ""
max_state = None
for key in self.states.keys():
if len(key) > max_event_count:
candidate_max_state: deque = self.states[key]
if (
len(key) > max_event_count
and len(candidate_max_state) == candidate_max_state.maxlen
):
max_event_count = len(key)
new_state_key = key
max_state: deque = self.states[key]
if max_event_count > self.max_event_count and len(max_state) == max_state.maxlen:
max_state = candidate_max_state
if max_event_count > self.max_event_count and max_state:
self.max_event_count = max_event_count

# Need a way not to reset the env id counter for the driver env
Expand Down
2 changes: 0 additions & 2 deletions pokemonred_puffer/data/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2645,8 +2645,6 @@ def get_event(self, event_name: str) -> bool:
"EVENT_BILL_SAID_USE_CELL_SEPARATOR",
"EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING",
"EVENT_BEAT_MT_MOON_EXIT_SUPER_NERD",
"EVENT_GOT_DOME_FOSSIL",
"EVENT_GOT_HELIX_FOSSIL",
"EVENT_GOT_HM01",
"EVENT_RUBBED_CAPTAINS_BACK",
"EVENT_ROCKET_HIDEOUT_4_DOOR_UNLOCKED",
Expand Down

0 comments on commit 972f0fe

Please sign in to comment.