From 1bacdb3128497343a621d9cf1856d7241ab56573 Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Sat, 27 Jul 2024 23:31:52 -0400 Subject: [PATCH] Add max for loop --- config.yaml | 2 +- pokemonred_puffer/environment.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/config.yaml b/config.yaml index f6092a9..32a93b8 100644 --- a/config.yaml +++ b/config.yaml @@ -11,7 +11,7 @@ debug: max_steps: 16 log_frequency: 1 disable_wild_encounters: True - disable_ai_actions: True + disable_ai_actions: False use_global_map: False reduce_res: False animate_scripts: True diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index b6e3d36..a9d22a4 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -677,15 +677,13 @@ def run_action_on_emulator(self, action): if not self.disable_ai_actions: self.pyboy.send_input(VALID_ACTIONS[action]) + self.pyboy.send_input(VALID_RELEASE_ACTIONS[action], delay=8) # TODO: Function-ize this self.user_control = False - while not self.user_control: - self.pyboy.tick(1, render=False) - - self.user_control = False - self.pyboy.send_input(VALID_RELEASE_ACTIONS[action]) - while not self.user_control: + count = 0 + while not self.user_control and count < self.action_freq: self.pyboy.tick(1, render=False) + count += 1 else: self.pyboy.tick(self.action_freq, render=True)