Skip to content

Commit

Permalink
Exploration inc parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Jul 25, 2024
1 parent 62bb80c commit 5750ed4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ env:
use_global_map: False
save_state: False
animate_scripts: False
exploration_inc: 0.25
exploration_max: 1.0



Expand Down
14 changes: 11 additions & 3 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def __init__(self, env_config: pufferlib.namespace):
self.use_global_map = env_config.use_global_map
self.save_state = env_config.save_state
self.animate_scripts = env_config.animate_scripts
self.exploration_inc = env_config.exploration_inc
self.exploration_max = env_config.exploration_max
self.action_space = ACTION_SPACE

# Obs space-related. TODO: avoid hardcoding?
Expand Down Expand Up @@ -1274,16 +1276,22 @@ def get_game_coords(self):
return (self.read_m(0xD362), self.read_m(0xD361), self.read_m(0xD35E))

def update_seen_coords(self):
inc = 0.0 if (self.read_m("wd736") & 0b1000_0000) else 1
inc = 0.0 if (self.read_m("wd736") & 0b1000_0000) else self.exploration_inc

x_pos, y_pos, map_n = self.get_game_coords()
# self.seen_coords[(x_pos, y_pos, map_n)] = inc
cur_map_tileset = self.read_m("wCurMapTileset")
if cur_map_tileset not in self.seen_coords:
self.seen_coords[cur_map_tileset] = {}
self.seen_coords[cur_map_tileset][(x_pos, y_pos, map_n)] = inc
self.seen_coords[cur_map_tileset][(x_pos, y_pos, map_n)] = max(
self.seen_coords[cur_map_tileset].get((x_pos, y_pos, map_n), 0.0) + inc,
self.exploration_max,
)
# TODO: Turn into a wrapper?
self.explore_map[local_to_global(y_pos, x_pos, map_n)] = inc
self.explore_map[local_to_global(y_pos, x_pos, map_n)] = max(
self.explore_map.get(local_to_global(y_pos, x_pos, map_n), 0.0) + inc,
self.exploration_max,
)
# self.seen_global_coords[local_to_global(y_pos, x_pos, map_n)] = 1
self.seen_map_ids[map_n] = 1

Expand Down

0 comments on commit 5750ed4

Please sign in to comment.