Skip to content

Commit

Permalink
fix explore map
Browse files Browse the repository at this point in the history
thatguy11325 committed Jun 28, 2024
1 parent 311339a commit 8a6640d
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ debug:
total_timesteps: 100_000_000
save_checkpoint: True
checkpoint_interval: 4
save_overlay: False
save_overlay: True
overlay_interval: 1
verbose: False
env_pool: False
6 changes: 3 additions & 3 deletions pokemonred_puffer/cleanrl_puffer.py
Original file line number Diff line number Diff line change
@@ -304,14 +304,14 @@ def evaluate(self):
# Moves into models... maybe. Definitely moves.
# You could also just return infos and have it in demo
if "pokemon_exploration_map" in k and self.config.save_overlay is True:
if self.epoch % self.config.overlay_interval == 0:
if True or self.epoch % self.config.overlay_interval == 0:
overlay = make_pokemon_red_overlay(np.stack(self.infos[k], axis=0))
if self.wandb_client is not None:
self.stats["Media/aggregate_exploration_map"] = wandb.Image(
overlay, file_type="jpg"
)
elif "state" in k:
continue
elif "state" in k:
continue

try: # TODO: Better checks on log data types
self.stats[k] = np.mean(v)
4 changes: 2 additions & 2 deletions pokemonred_puffer/eval.py
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
import numpy as np
from numba import jit

from pokemonred_puffer.global_map import MAP_PAD
from pokemonred_puffer.global_map import PAD


KANTO_MAP_PATH = os.path.join(os.path.dirname(__file__), "kanto_map_dsv.png")
BACKGROUND = np.array(cv2.imread(KANTO_MAP_PATH))
BACKGROUND = np.pad(BACKGROUND, MAP_PAD + ((0, 0),))
BACKGROUND = np.pad(BACKGROUND, ((PAD * 16, PAD * 16), (PAD * 16, PAD * 16), (0, 0)))


@jit(nopython=True, nogil=True)
10 changes: 6 additions & 4 deletions pokemonred_puffer/global_map.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
import json

KANTO_MAP_PATH = os.path.join(os.path.dirname(__file__), "kanto_map_dsv.png")

MAP_PATH = os.path.join(os.path.dirname(__file__), "map_data.json")
MAP_PAD = ((20, 20), (20, 20))
GLOBAL_MAP_SHAPE = (444 + MAP_PAD[0][0] + MAP_PAD[0][1], 436 + MAP_PAD[1][0] + MAP_PAD[1][1])
MAP_ROW_OFFSET = MAP_PAD[0][0]
MAP_COL_OFFSET = MAP_PAD[1][0]
PAD = 20
GLOBAL_MAP_SHAPE = (444 + PAD * 2, 436 + PAD * 2)
MAP_ROW_OFFSET = PAD
MAP_COL_OFFSET = PAD

with open(MAP_PATH) as map_data:
MAP_DATA = json.load(map_data)["regions"]

0 comments on commit 8a6640d

Please sign in to comment.