Skip to content

Commit

Permalink
Only give sprite/sign/hiddenobj rewards for important map ids and add…
Browse files Browse the repository at this point in the history
… a few more map id rewards
  • Loading branch information
thatguy11325 committed Sep 6, 2024
1 parent 5a20c2f commit 9449006
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions pokemonred_puffer/data/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ class MapIds(Enum):
MapIds.SAFARI_ZONE_SECRET_HOUSE: ["EVENT_GOT_HM03", "HS_SAFARI_ZONE_WEST_ITEM_4"],
MapIds.SAFARI_ZONE_WEST: ["EVENT_GOT_HM03", "HS_SAFARI_ZONE_WEST_ITEM_4"],
MapIds.SAFARI_ZONE_WEST_REST_HOUSE: ["EVENT_GOT_HM03", "HS_SAFARI_ZONE_WEST_ITEM_4"],
MapIds.VICTORY_ROAD_1F: ["EVENT_BEAT_CHAMPION_RIVAL"],
MapIds.VICTORY_ROAD_2F: ["EVENT_BEAT_CHAMPION_RIVAL"],
MapIds.VICTORY_ROAD_3F: ["EVENT_BEAT_CHAMPION_RIVAL"],
MapIds.INDIGO_PLATEAU: ["EVENT_BEAT_CHAMPION_RIVAL"],
MapIds.INDIGO_PLATEAU_LOBBY: ["EVENT_BEAT_CHAMPION_RIVAL"],
MapIds.LORELEIS_ROOM: ["EVENT_BEAT_CHAMPION_RIVAL"],
MapIds.BRUNOS_ROOM: ["EVENT_BEAT_CHAMPION_RIVAL"],
MapIds.AGATHAS_ROOM: ["EVENT_BEAT_CHAMPION_RIVAL"],
Expand Down
18 changes: 10 additions & 8 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,17 +1244,19 @@ def insert_guard_drinks(self):
def sign_hook(self, *args, **kwargs):
sign_id = self.read_m("hSpriteIndexOrTextID")
map_id = self.read_m("wCurMap")
self.seen_signs[(map_id, sign_id)] = 1.0
self.seen_signs[(map_id, sign_id)] = 1.0 if self.scale_map_id(map_id) else 0.0

def hidden_object_hook(self, *args, **kwargs):
hidden_object_id = self.pyboy.memory[self.pyboy.symbol_lookup("wHiddenObjectIndex")[1]]
map_id = self.pyboy.memory[self.pyboy.symbol_lookup("wCurMap")[1]]
self.seen_hidden_objs[(map_id, hidden_object_id)] = 1.0
self.seen_hidden_objs[(map_id, hidden_object_id)] = (
1.0 if self.scale_map_id(map_id) else 0.0
)

def sprite_hook(self, *args, **kwargs):
sprite_id = self.pyboy.memory[self.pyboy.symbol_lookup("hSpriteIndexOrTextID")[1]]
map_id = self.pyboy.memory[self.pyboy.symbol_lookup("wCurMap")[1]]
self.seen_npcs[(map_id, sprite_id)] = 1.0
self.seen_npcs[(map_id, sprite_id)] = 1.0 if self.scale_map_id(map_id) else 0.0

def start_menu_hook(self, *args, **kwargs):
if self.read_m("wIsInBattle") == 0:
Expand Down Expand Up @@ -1485,7 +1487,7 @@ def update_seen_coords(self):
self.reward_explore_map[local_to_global(y_pos, x_pos, map_n)] = min(
self.explore_map[local_to_global(y_pos, x_pos, map_n)] + inc,
self.exploration_max,
) * self.map_id_scaling(map_n)
) * (self.map_id_scalefactor if self.scale_map_id(map_n) else 1.0)
# self.seen_global_coords[local_to_global(y_pos, x_pos, map_n)] = 1
self.seen_map_ids[map_n] = 1

Expand Down Expand Up @@ -1712,10 +1714,10 @@ def get_events_sum(self):
0,
)

def map_id_scaling(self, map_n: int) -> float:
def scale_map_id(self, map_n: int) -> float:
map_id = MapIds(map_n)
if map_id not in MAP_ID_COMPLETION_EVENTS:
return 1.0
return False

if all(
event_or_missable.startswith("EVENT_")
Expand All @@ -1726,8 +1728,8 @@ def map_id_scaling(self, map_n: int) -> float:
)
for event_or_missable in MAP_ID_COMPLETION_EVENTS[map_id]
):
return self.map_id_scalefactor
return 1.0
return True
return False

def check_num_bag_items(self):
_, wBagItems = self.pyboy.symbol_lookup("wBagItems")
Expand Down

0 comments on commit 9449006

Please sign in to comment.