From 57572835748804aec429892f7539b06a775f81aa Mon Sep 17 00:00:00 2001 From: Mouhssine Rifaki Date: Tue, 28 Apr 2026 23:45:37 -0400 Subject: [PATCH] fix: render different maps in render_human_replay_videos loop Greptile suggestion on PR #28: the loop reused the same cmd every iteration so it rendered the same map repeatedly. Add --map-name per iteration that cycles through map_NNN.bin in the training dir. Tries both 0-indexed and 1-indexed naming patterns to match different dataset conventions. --- pufferlib/utils.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pufferlib/utils.py b/pufferlib/utils.py index 2bb240e485..ba57663741 100644 --- a/pufferlib/utils.py +++ b/pufferlib/utils.py @@ -480,8 +480,8 @@ def render_human_replay_videos(config, policy_bin_path, output_dir, num_maps=5, env_config = config.get("env_config", config.get("env", {})) k_scenarios = env_config.get("k_scenarios", 2) - # Build command for human replay rendering - cmd = [ + # Base command for human replay rendering (per-map --map-name added inside loop) + base_cmd = [ "xvfb-run", "-a", "-s", @@ -511,7 +511,20 @@ def render_human_replay_videos(config, policy_bin_path, output_dir, num_maps=5, videos_to_log_world = [] videos_to_log_agent = [] + # Greptile fix: vary --map-name per iteration so the loop renders different maps + # rather than the same one repeatedly. Try both map_NNN.bin naming patterns + # (some datasets start at 000, others at 001). + map_dir = "resources/drive/binaries/training" for map_idx in range(num_maps): + map_path_a = os.path.join(map_dir, f"map_{map_idx:03d}.bin") + map_path_b = os.path.join(map_dir, f"map_{map_idx + 1:03d}.bin") + if os.path.exists(map_path_a): + cmd = base_cmd + ["--map-name", map_path_a] + elif os.path.exists(map_path_b): + cmd = base_cmd + ["--map-name", map_path_b] + else: + print(f"No map binary found for index {map_idx} in {map_dir}, skipping") + continue result = subprocess.run(cmd, cwd=os.getcwd(), capture_output=True, text=True, timeout=600, env=env_vars) vids_exist = os.path.exists("resources/drive/output_topdown.mp4") and os.path.exists(