Skip to content

Commit

Permalink
Fix autorepel
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 9, 2024
1 parent 4d34bfd commit e5d05a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ debug:
env:
headless: False
stream_wrapper: False
init_state: cut
init_state: Bulbasaur
max_steps: 1_000_000
disable_wild_encounters: True
disable_ai_actions: True
Expand Down
13 changes: 6 additions & 7 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,11 @@ def register_hooks(self):
# self.pyboy.hook_register(None, "UsedCut.nothingToCut", self.cut_hook, context=True)
# self.pyboy.hook_register(None, "UsedCut.canCut", self.cut_hook, context=False)
if self.disable_wild_encounters:
print("registering")
bank, addr = self.pyboy.symbol_lookup("TryDoWildEncounter.gotWildEncounterType")
self.pyboy.hook_register(
None,
"TryDoWildEncounter.gotWildEncounterType",
bank,
addr + 8,
self.disable_wild_encounter_hook,
None,
)
Expand Down Expand Up @@ -884,9 +886,6 @@ def step(self, action):
if self.save_video and self.step_count == 0:
self.start_video()

if self.disable_wild_encounters:
self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = 100

_, wMapPalOffset = self.pyboy.symbol_lookup("wMapPalOffset")
if self.auto_flash and self.pyboy.memory[wMapPalOffset] == 6:
self.pyboy.memory[wMapPalOffset] = 0
Expand Down Expand Up @@ -1131,8 +1130,8 @@ def cut_hook(self, context):
self.cut_tiles[wTileInFrontOfPlayer] = 1

def disable_wild_encounter_hook(self, *args, **kwargs):
self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = 100
self.pyboy.memory[self.pyboy.symbol_lookup("wCurEnemyLVL")[1] + 1] = 1
self.pyboy.memory[self.pyboy.symbol_lookup("wRepelRemainingSteps")[1]] = 0xFFFF
self.pyboy.memory[self.pyboy.symbol_lookup("wCurEnemyLVL")[1]] = 1

def agent_stats(self, action):
levels = [self.read_m(f"wPartyMon{i+1}Level") for i in range(self.read_m("wPartyCount"))]
Expand Down

0 comments on commit e5d05a4

Please sign in to comment.