From 8898c638eab94ef84ac6b6c796b376cb5caae16b Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:32:36 -0400 Subject: [PATCH] no cutmon check --- pokemonred_puffer/environment.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index e4dd298..5934453 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -621,6 +621,12 @@ def step(self, action): # self.caught_pokemon[6] == 1 # squirtle ) + # cut mon check + if not self.party_has_cut_capable_mon(): + reset = True + self.first = True + new_reward = -self.progress_reward + return obs, new_reward, reset, False, info def run_action_on_emulator(self, action): @@ -636,6 +642,18 @@ def run_action_on_emulator(self, action): self.teach_cut() self.cut_if_next() + def party_has_cut_capable_mon(self): + # find bulba and replace tackle (first skill) with cut + party_size = self.read_m("wPartyCount") + for i in range(party_size): + # PRET 1-indexes + _, species_addr = self.pyboy.symbol_lookup(f"wPartyMon{i+1}Species") + poke = self.pyboy.memory[species_addr] + # https://github.com/pret/pokered/blob/d38cf5281a902b4bd167a46a7c9fd9db436484a7/constants/pokemon_constants.asm + if poke in CUT_SPECIES_IDS: + return True + return False + def teach_cut(self): # find bulba and replace tackle (first skill) with cut party_size = self.read_m("wPartyCount")