Skip to content

Commit

Permalink
fixed local_to_global index error
Browse files Browse the repository at this point in the history
  • Loading branch information
kywch committed Mar 17, 2024
1 parent 043096e commit 7ef770f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pokemonred_puffer/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,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 gx >= explore_map.shape[1]:
if gy >= explore_map.shape[0] or gy < 0 or gx >= explore_map.shape[1] or gx < 0:
print(f"coord out of bounds! global: ({gx}, {gy}) game: ({x}, {y}, {map_n})")
else:
explore_map[gy, gx] = v
Expand Down
3 changes: 3 additions & 0 deletions pokemonred_puffer/global_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ def local_to_global(r: int, c: int, map_n: int):
except KeyError:
print(f"Map id {map_n} not found in map_data.json.")
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

0 comments on commit 7ef770f

Please sign in to comment.