Skip to content

Commit

Permalink
Fix surf in plateau
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jun 15, 2024
1 parent e82493e commit efdd5d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 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: victory_road_5
init_state: victory_road
max_steps: 1_000_000
disable_wild_encounters: True
disable_ai_actions: True
Expand Down
32 changes: 6 additions & 26 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ def surf_if_attempt(self, action: WindowEvent):
return

in_overworld = self.read_m("wCurMapTileset") == Tilesets.OVERWORLD.value
if in_overworld:
in_plateau = self.read_m("wCurMapTileset") == Tilesets.PLATEAU.value
if in_overworld or in_plateau:
_, wTileMap = self.pyboy.symbol_lookup("wTileMap")
tileMap = self.pyboy.memory[wTileMap : wTileMap + 20 * 18]
tileMap = np.array(tileMap, dtype=np.uint8)
Expand All @@ -828,30 +829,10 @@ def surf_if_attempt(self, action: WindowEvent):
direction = self.read_m("wSpritePlayerStateData1FacingDirection")

if not (
(
direction == 0x4
and action == WindowEvent.PRESS_ARROW_UP
and in_overworld
and 0x14 in up
)
or (
direction == 0x0
and action == WindowEvent.PRESS_ARROW_DOWN
and in_overworld
and 0x14 in down
)
or (
direction == 0x8
and action == WindowEvent.PRESS_ARROW_LEFT
and in_overworld
and 0x14 in left
)
or (
direction == 0xC
and action == WindowEvent.PRESS_ARROW_RIGHT
and in_overworld
and 0x14 in right
)
(direction == 0x4 and action == WindowEvent.PRESS_ARROW_UP and 0x14 in up)
or (direction == 0x0 and action == WindowEvent.PRESS_ARROW_DOWN and 0x14 in down)
or (direction == 0x8 and action == WindowEvent.PRESS_ARROW_LEFT and 0x14 in left)
or (direction == 0xC and action == WindowEvent.PRESS_ARROW_RIGHT and 0x14 in right)
):
return

Expand Down Expand Up @@ -960,7 +941,6 @@ def solve_switch_strength_puzzle(self):
picture_id = self.read_m(f"wSprite{sprite_id:02}StateData1PictureID")
mapY = self.read_m(f"wSprite{sprite_id:02}StateData2MapY")
mapX = self.read_m(f"wSprite{sprite_id:02}StateData2MapX")
print((picture_id, mapY, mapX) + self.get_game_coords())
if solution := STRENGTH_SOLUTIONS.get(
(picture_id, mapY, mapX) + self.get_game_coords(), []
):
Expand Down

0 comments on commit efdd5d1

Please sign in to comment.