Skip to content

Commit

Permalink
Fix strength puzzles
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Aug 27, 2024
1 parent 9093d3a commit a47c4ef
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 37 deletions.
3 changes: 2 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 0 additions & 26 deletions pokemonred_puffer/data/strength_puzzles.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

# Seafoam 1F right
STRENGTH_SOLUTIONS[(63, 11, 30, 26, 8, 192)] = [
"UP",
"RIGHT",
"UP",
"RIGHT",
"UP",
Expand All @@ -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)
Expand Down Expand Up @@ -165,8 +162,6 @@
"UP",
"UP",
"UP",
"UP",
"UP",
"LEFT",
"LEFT",
"UP",
Expand All @@ -191,7 +186,6 @@

# 2F Switch 1
STRENGTH_SOLUTIONS[(63, 18, 8, 5, 14, 194)] = [
"LEFT",
"LEFT",
"LEFT",
"UP",
Expand Down Expand 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",
Expand Down Expand Up @@ -274,19 +258,9 @@
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"LEFT",
"UP",
"LEFT",
"DOWN",
"DOWN",
"RIGHT",
"DOWN",
"DOWN",
Expand Down
37 changes: 27 additions & 10 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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
)
Expand All @@ -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
Expand Down

0 comments on commit a47c4ef

Please sign in to comment.