diff --git a/config.yaml b/config.yaml index 58a80cf..5423483 100644 --- a/config.yaml +++ b/config.yaml @@ -11,13 +11,14 @@ debug: state_dir: pyboy_states max_steps: 20480 log_frequency: 1 - disable_wild_encounters: False + disable_wild_encounters: True disable_ai_actions: True use_global_map: False reduce_res: True animate_scripts: True save_state: False auto_next_elevator_floor: True + auto_solve_strength_puzzles: True train: device: cpu compile: False diff --git a/pokemonred_puffer/data/strength_puzzles.py b/pokemonred_puffer/data/strength_puzzles.py index 5d553c8..eba94c2 100644 --- a/pokemonred_puffer/data/strength_puzzles.py +++ b/pokemonred_puffer/data/strength_puzzles.py @@ -38,8 +38,6 @@ # Seafoam 1F right STRENGTH_SOLUTIONS[(63, 11, 30, 26, 8, 192)] = [ - "UP", - "RIGHT", "UP", "RIGHT", "UP", @@ -48,7 +46,6 @@ "LEFT", "LEFT", "LEFT", - "LEFT", ] STRENGTH_SOLUTIONS[(63, 11, 30, 27, 7, 192)] = ["DOWN", "LEFT"] + STRENGTH_SOLUTIONS[ (63, 11, 30, 26, 8, 192) @@ -165,8 +162,6 @@ "UP", "UP", "UP", - "UP", - "UP", "LEFT", "LEFT", "UP", @@ -191,7 +186,6 @@ # 2F Switch 1 STRENGTH_SOLUTIONS[(63, 18, 8, 5, 14, 194)] = [ - "LEFT", "LEFT", "LEFT", "UP", @@ -224,16 +218,6 @@ STRENGTH_SOLUTIONS[(63, 19, 26, 22, 4, 198)] = [ "UP", "UP", - "RIGHT", - "UP", - "UP", - "LEFT", - "DOWN", - "DOWN", - "DOWN", - "LEFT", - "LEFT", - "UP", "UP", "RIGHT", "UP", @@ -274,19 +258,9 @@ "LEFT", "LEFT", "LEFT", - "LEFT", - "LEFT", - "LEFT", - "LEFT", - "LEFT", - "LEFT", - "LEFT", - "LEFT", - "LEFT", "UP", "LEFT", "DOWN", - "DOWN", "RIGHT", "DOWN", "DOWN", diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index aaabb0f..06386fc 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -742,7 +742,6 @@ def run_action_on_emulator(self, action): self.update_seen_coords() while self.read_m("wJoyIgnore"): - self.pyboy.button("a", delay=8) self.pyboy.tick(self.action_freq, render=False) if self.events.get_event("EVENT_GOT_HM01"): @@ -1126,12 +1125,21 @@ def solve_missable_strength_puzzle(self): self.pyboy.memory[wd728] |= 0b0000_0001 # Perform solution current_repel_steps = self.read_m("wRepelRemainingSteps") - for button in solution: + for step in solution: self.pyboy.memory[ self.pyboy.symbol_lookup("wRepelRemainingSteps")[1] ] = 0xFF - self.pyboy.button(button, 8) - self.pyboy.tick(self.action_freq * 1.5, self.animate_scripts) + match step: + case str(button): + self.pyboy.button(button, 8) + self.pyboy.tick(self.action_freq * 2, self.animate_scripts) + case (str(button), int(button_freq), int(action_freq)): + self.pyboy.button(button, button_freq) + self.pyboy.tick(action_freq, self.animate_scripts) + case _: + raise + while self.read_m("wJoyIgnore"): + self.pyboy.tick(self.action_freq, render=False) self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = ( current_repel_steps ) @@ -1156,15 +1164,24 @@ def solve_switch_strength_puzzle(self): self.pyboy.memory[wd728] |= 0b0000_0001 # Perform solution current_repel_steps = self.read_m("wRepelRemainingSteps") - for button in solution: + for step in solution: self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = ( 0xFF ) - self.pyboy.button(button, 8) - self.pyboy.tick(self.action_freq * 2, self.animate_scripts) - self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = ( - current_repel_steps - ) + match step: + case str(button): + self.pyboy.button(button, 8) + self.pyboy.tick(self.action_freq * 2, self.animate_scripts) + case (str(button), int(button_freq), int(action_freq)): + self.pyboy.button(button, button_freq) + self.pyboy.tick(action_freq, self.animate_scripts) + case _: + raise + while self.read_m("wJoyIgnore"): + self.pyboy.tick(self.action_freq, render=False) + self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = ( + current_repel_steps + ) if not self.disable_wild_encounters: self.setup_enable_wild_ecounters() break