Skip to content

Commit

Permalink
incorporated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kywch committed Mar 21, 2024
1 parent 14f9169 commit 86ab484
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def init_mem(self):
self.seen_hidden_objs = {}

self.cut_coords = {}
self.cut_tiles = {} # set([])
self.cut_tiles = {}
self.cut_state = deque(maxlen=3)

self.seen_start_menu = 0
Expand Down Expand Up @@ -809,11 +809,7 @@ def update_seen_coords(self):
x_pos, y_pos, map_n = self.get_game_coords()
self.seen_coords[(x_pos, y_pos, map_n)] = 1
self.seen_coords_since_blackout.add((x_pos, y_pos, map_n))
try:
self.explore_map[local_to_global(y_pos, x_pos, map_n)] = 1
except IndexError:
gy, gx = local_to_global(y_pos, x_pos, map_n)
print(f"coord out of bounds! global: ({gx}, {gy}) game: ({x_pos}, {y_pos}, {map_n})")
self.explore_map[local_to_global(y_pos, x_pos, map_n)] = 1
# self.seen_global_coords[local_to_global(y_pos, x_pos, map_n)] = 1
self.seen_map_ids[map_n] = 1
self.seen_map_ids_since_blackout.add(map_n)
Expand All @@ -822,7 +818,7 @@ def get_explore_map(self):
explore_map = np.zeros(GLOBAL_MAP_SHAPE)
for (x, y, map_n), v in self.seen_coords.items():
gy, gx = local_to_global(y, x, map_n)
if gy >= explore_map.shape[0] or gy < 0 or gx >= explore_map.shape[1] or gx < 0:
if 0 > gy >= explore_map.shape[0] or 0 > gx >= explore_map.shape[1]:
print(f"coord out of bounds! global: ({gx}, {gy}) game: ({x}, {y}, {map_n})")
else:
explore_map[gy, gx] = v
Expand Down
2 changes: 1 addition & 1 deletion pokemonred_puffer/global_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def local_to_global(r: int, c: int, map_n: int):
return r + 0, c + 0
except IndexError:
print(f"Coord {map_x}, {map_y} out of bounds for map id {map_n}.")
return -1, -1
return 0, 0

0 comments on commit 86ab484

Please sign in to comment.