Skip to content

Commit

Permalink
If in a dark cave, auto turn on flash
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 6, 2024
1 parent 2c3e8fc commit a252887
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ env:
reduce_res: True
two_bit: True
log_frequency: 2000
auto_flash: True

train:
seed: 1
Expand Down
5 changes: 5 additions & 0 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def __init__(self, env_config: pufferlib.namespace):
self.gb_path = env_config.gb_path
self.log_frequency = env_config.log_frequency
self.two_bit = env_config.two_bit
self.auto_flash = env_config.auto_flash
self.action_space = ACTION_SPACE

# Obs space-related. TODO: avoid hardcoding?
Expand Down Expand Up @@ -582,6 +583,10 @@ def step(self, action):
if self.save_video and self.step_count == 0:
self.start_video()

_, wMapPalOffset = self.pyboy.symbol_lookup("wMapPalOffset")[1]
if self.auto_flash and self.pyboy.memory[wMapPalOffset] == 6:
self.pyboy.memory[wMapPalOffset] = 0

self.run_action_on_emulator(action)
self.update_seen_coords()
self.update_health()
Expand Down

0 comments on commit a252887

Please sign in to comment.