diff --git a/pokemonred_puffer/environment.py b/pokemonred_puffer/environment.py index ac60f6c..e75164f 100644 --- a/pokemonred_puffer/environment.py +++ b/pokemonred_puffer/environment.py @@ -306,7 +306,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 @@ -668,7 +668,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 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 diff --git a/pokemonred_puffer/global_map.py b/pokemonred_puffer/global_map.py index a8b9118..7ed6c75 100644 --- a/pokemonred_puffer/global_map.py +++ b/pokemonred_puffer/global_map.py @@ -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 0, 0