From 972f0fe1cd25859382d156a8031ba0449b6eec76 Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:16:53 -0400 Subject: [PATCH] fix intermediate events swarming --- pokemonred_puffer/cleanrl_puffer.py | 12 ++++++++---- pokemonred_puffer/data/events.py | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pokemonred_puffer/cleanrl_puffer.py b/pokemonred_puffer/cleanrl_puffer.py index 9030541..f9da495 100644 --- a/pokemonred_puffer/cleanrl_puffer.py +++ b/pokemonred_puffer/cleanrl_puffer.py @@ -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 ): @@ -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 diff --git a/pokemonred_puffer/data/events.py b/pokemonred_puffer/data/events.py index 3c335d7..033343f 100644 --- a/pokemonred_puffer/data/events.py +++ b/pokemonred_puffer/data/events.py @@ -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",