Skip to content

Commit

Permalink
Remove risk of infinite while
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 2, 2024
1 parent aabe87a commit 13f16ca
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 13f16ca

Please sign in to comment.