Skip to content

Commit

Permalink
Return of the hidden obj npc reward
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Mar 22, 2024
1 parent 5470b7c commit b25b3c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ rewards:
stats_menu: 0.1
bag_menu: 0.1
taught_cut: 10.0
explore_npcs: 0.02
explore_hidden_objs: 0.02


policies:
Expand Down
11 changes: 2 additions & 9 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def reset(self, seed: Optional[int] = None):
self.explore_map = np.zeros(GLOBAL_MAP_SHAPE, dtype=np.float32)
self.cut_explore_map = np.zeros(GLOBAL_MAP_SHAPE, dtype=np.float32)
self.init_mem()
# We only init seen hidden objs once cause they can only be found once!
self.seen_hidden_objs = {}
self.reset_count = 0
with open(self.init_state_path, "rb") as f:
self.pyboy.load_state(f)
Expand All @@ -266,7 +268,6 @@ def reset(self, seed: Optional[int] = None):
self.read_m(i).bit_count()
for i in range(EVENT_FLAGS_START, EVENT_FLAGS_START + EVENTS_FLAGS_LENGTH)
)

else:
self.reset_count += 1

Expand Down Expand Up @@ -311,14 +312,10 @@ def init_mem(self):
self.seen_coords = {}
# self.seen_global_coords = np.zeros(GLOBAL_MAP_SHAPE)
self.seen_map_ids = np.zeros(256)

self.seen_npcs = {}

self.seen_hidden_objs = {}

self.cut_coords = {}
self.cut_tiles = {}
self.cut_state = deque(maxlen=3)

self.seen_start_menu = 0
self.seen_pokemon_menu = 0
Expand All @@ -329,13 +326,9 @@ def init_mem(self):
def reset_mem(self):
self.seen_coords.update((k, 0) for k, _ in self.seen_coords.items())
self.seen_map_ids *= 0

self.seen_npcs.update((k, 0) for k, _ in self.seen_npcs.items())

self.seen_hidden_objs.update((k, 0) for k, _ in self.seen_hidden_objs.items())

self.cut_coords.update((k, 0) for k, _ in self.cut_coords.items())
self.cut_state = deque(maxlen=3)

self.seen_start_menu = 0
self.seen_pokemon_menu = 0
Expand Down
3 changes: 3 additions & 0 deletions pokemonred_puffer/rewards/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def get_game_state_reward(self):
"hm_count": self.reward_config["hm_count"] * self.get_hm_count(),
"badges": self.reward_config["badges"] * self.get_badges(),
"exploration": self.reward_config["exploration"] * sum(self.seen_coords.values()),
"explore_npcs": self.reward_config["explore_npcs"] * sum(self.seen_npcs.values()),
"explore_hidden_objs": self.reward_config["explore_hidden_objs"]
* sum(self.seen_hidden_objs.values()),
"cut_coords": self.reward_config["cut_coords"] * sum(self.cut_coords.values()),
"cut_tiles": self.reward_config["cut_tiles"] * sum(self.cut_tiles),
"start_menu": self.reward_config["start_menu"] * self.seen_start_menu,
Expand Down

0 comments on commit b25b3c7

Please sign in to comment.