Skip to content

Commit

Permalink
restore cut coords to its former glory
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Dec 17, 2024
1 parent 1e910ba commit 22c9d23
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ rewards:
explore_signs: 0.015025767686371013
explore_warps: 0.010135211705238394
hm_count: 7.5
invalid_cut_coords: 0.0001
level: 1.05
moves_obtained: 4.0
pokecenter_heal: 0.47
Expand Down
21 changes: 10 additions & 11 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ def register_hooks(self):
)
self.pyboy.hook_register(None, "HandleBlackOut", self.blackout_hook, None)
self.pyboy.hook_register(None, "SetLastBlackoutMap.done", self.blackout_update_hook, None)
# self.pyboy.hook_register(None, "UsedCut.nothingToCut", self.cut_hook, context=True)
# self.pyboy.hook_register(None, "UsedCut.canCut", self.cut_hook, context=False)
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:
self.setup_disable_wild_encounters()
self.pyboy.hook_register(None, "AnimateHealingMachine", self.pokecenter_heal_hook, None)
Expand Down Expand Up @@ -420,8 +420,8 @@ def init_mem(self):
]
}

self.cut_coords = {}
self.cut_tiles = {}
self.valid_cut_coords = {}
self.invalid_cut_coords = {}

self.seen_hidden_objs = {}
self.seen_signs = {}
Expand Down Expand Up @@ -1348,7 +1348,7 @@ def update_warps_hook(self, *args, **kwargs):
if key[-1] != 0xFF:
self.seen_warps[key] = 1

def cut_hook(self, context):
def cut_hook(self, context: bool):
player_direction = self.pyboy.memory[
self.pyboy.symbol_lookup("wSpritePlayerStateData1FacingDirection")[1]
]
Expand All @@ -1367,14 +1367,13 @@ def cut_hook(self, context):
]
if context:
if wTileInFrontOfPlayer in [0x3D, 0x50]:
self.cut_coords[coords] = 10
self.valid_cut_coords[coords] = 1
else:
self.cut_coords[coords] = 0.001
self.invalid_cut_coords[coords] = 1
else:
self.cut_coords[coords] = 0.001
self.invalid_cut_coords[coords] = 1

self.cut_explore_map[local_to_global(y, x, map_id)] = 1
self.cut_tiles[wTileInFrontOfPlayer] = 1

def disable_wild_encounter_hook(self, *args, **kwargs):
if (
Expand Down Expand Up @@ -1428,8 +1427,8 @@ def agent_stats(self, action):
"taught_cut": int(self.check_if_party_has_hm(TmHmMoves.CUT.value)),
"taught_surf": int(self.check_if_party_has_hm(TmHmMoves.SURF.value)),
"taught_strength": int(self.check_if_party_has_hm(TmHmMoves.STRENGTH.value)),
# "cut_coords": sum(self.cut_coords.values()),
# "cut_tiles": len(self.cut_tiles),
"valid_cut_coords": len(self.valid_cut_coords),
"invalid_cut_coords": len(self.invalid_cut_coords),
"menu": {
"start_menu": self.seen_start_menu,
"pokemon_menu": self.seen_pokemon_menu,
Expand Down
5 changes: 4 additions & 1 deletion pokemonred_puffer/rewards/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ def get_game_state_reward(self):
"hm_count": self.reward_config["hm_count"] * self.get_hm_count(),
"level": self.reward_config["level"] * self.get_levels_reward(),
"badges": self.reward_config["badges"] * self.get_badges(),
"cut_coords": self.reward_config["cut_coords"] * sum(self.cut_coords.values()),
"valid_cut_coords": self.reward_config["valid_cut_coords"]
* len(self.cut_coords.values()),
"invalid_cut_coords": self.reward_config["invalid_cut_coords"]
* len(self.cut_coords.values()),
"cut_tiles": self.reward_config["cut_tiles"] * sum(self.cut_tiles.values()),
"start_menu": self.reward_config["start_menu"] * self.seen_start_menu,
"pokemon_menu": self.reward_config["pokemon_menu"] * self.seen_pokemon_menu,
Expand Down
5 changes: 5 additions & 0 deletions sweep-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ rewards:
min: 1.0e-3
max: 10.0
scale: 1.0
invalid_cut_coords:
carbs.utils.LinearSpace:
min: 1.0e-5
max: 1.0e-3
scale: 5e-5
moves_obtained:
carbs.utils.LinearSpace:
min: 1.0e-3
Expand Down

0 comments on commit 22c9d23

Please sign in to comment.