diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index 94aca26..4d548e8 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -647,7 +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 - while self.pyboy.memory[self.pyboy.symbol_lookup("wCurrentMenuItem")[1]] != 1: + for _ in range(24): + if 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)