From 62f70df486cf92d94cfeec1ef2c7963d2302951e Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Sun, 2 Jun 2024 09:09:01 -0400 Subject: [PATCH] Fix crash possibility in script --- pokemonred_puffer/environment.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index 4d548e8..78de5b8 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -581,8 +581,8 @@ def run_action_on_emulator(self, action): self.action_hist[action] += 1 # press button then release after some steps # TODO: Add video saving logic - self.pyboy.send_input(VALID_ACTIONS[action]) - self.pyboy.send_input(VALID_RELEASE_ACTIONS[action], delay=8) + # self.pyboy.send_input(VALID_ACTIONS[action]) + # self.pyboy.send_input(VALID_RELEASE_ACTIONS[action], delay=8) self.pyboy.tick(self.action_freq, render=True) if self.read_bit(0xD803, 0): @@ -647,9 +647,9 @@ def cut_if_next(self): self.pyboy.tick(self.action_freq, render=True) # scroll to pokemon # 1 is the item index for pokemon - for _ in range(24): - if self.pyboy.memory[self.pyboy.symbol_lookup("wCurrentMenuItem")[1]] == 1: - break + # for _ in range(24): + while self.pyboy.memory[self.pyboy.symbol_lookup("wCurrentMenuItem")[1]] != 1: + # break self.pyboy.send_input(WindowEvent.PRESS_ARROW_DOWN) self.pyboy.send_input(WindowEvent.RELEASE_ARROW_DOWN, delay=8) self.pyboy.tick(self.action_freq, render=True) @@ -664,7 +664,7 @@ def cut_if_next(self): self.pyboy.send_input(WindowEvent.RELEASE_ARROW_DOWN, delay=8) self.pyboy.tick(self.action_freq, render=True) party_mon = self.pyboy.memory[self.pyboy.symbol_lookup("wCurrentMenuItem")[1]] - _, addr = self.pyboy.symbol_lookup(f"wPartyMon{party_mon+1}Moves") + _, addr = self.pyboy.symbol_lookup(f"wPartyMon{party_mon%6+1}Moves") if 15 in self.pyboy.memory[addr : addr + 4]: break