@@ -331,34 +331,46 @@ def parse_game_metadata(self) -> GameMetadata:
331331 main_log = main_log_file .read_text () if main_log_file .exists () else "No tournament log found"
332332 main_log_path = str (main_log_file ) if main_log_file .exists () else ""
333333
334- # Parse round directories and their sim logs
334+ # Parse round data - prioritize round_stats from metadata.json
335335 rounds = []
336- rounds_dir = self .log_dir / "rounds"
337- if rounds_dir .exists ():
338- # Get all round directories (sorted numerically)
339- round_dirs = sorted ([d for d in rounds_dir .iterdir () if d .is_dir ()], key = lambda x : int (x .name ))
340-
341- for round_dir in round_dirs :
342- round_num = int (round_dir .name )
343-
344- # Collect all sim logs for this round
345- sim_logs = []
346- sim_files = sorted (round_dir .glob ("sim_*.log" ), key = lambda x : int (x .stem .split ("_" )[1 ]))
347-
348- for sim_file in sim_files :
349- sim_content = sim_file .read_text ()
350- sim_logs .append ({"filename" : sim_file .name , "content" : sim_content , "full_path" : str (sim_file )})
351-
352- # Check for round results
353- results_file = round_dir / "results.json"
354- round_results = None
355- if results_file .exists ():
356- round_results = json .loads (results_file .read_text ())
357- # Get agent info for this round (we'll need to get it from metadata)
358- agent_info = get_agent_info_from_metadata (results ) if results else []
359- round_results = process_round_results (round_results , agent_info )
360-
361- rounds .append ({"round_num" : round_num , "sim_logs" : sim_logs , "results" : round_results })
336+
337+ # First, try to get round data from metadata.json round_stats
338+ if "round_stats" in results :
339+ # Get agent info for processing round results
340+ agent_info = get_agent_info_from_metadata (results ) if results else []
341+
342+ # Process each round from round_stats
343+ for round_key , round_data in results ["round_stats" ].items ():
344+ round_num = int (round_key )
345+
346+ # Process the round results from metadata
347+ round_results = process_round_results (round_data , agent_info )
348+
349+ rounds .append ({"round_num" : round_num , "sim_logs" : [], "results" : round_results })
350+
351+ else :
352+ # Fallback: Parse round directories and their sim logs (for older games)
353+ rounds_dir = self .log_dir / "rounds"
354+ if rounds_dir .exists ():
355+ # Get all round directories (sorted numerically)
356+ round_dirs = sorted ([d for d in rounds_dir .iterdir () if d .is_dir ()], key = lambda x : int (x .name ))
357+
358+ for round_dir in round_dirs :
359+ round_num = int (round_dir .name )
360+
361+ # Check for round results
362+ results_file = round_dir / "results.json"
363+ round_results = None
364+ if results_file .exists ():
365+ round_results = json .loads (results_file .read_text ())
366+ # Get agent info for this round (we'll need to get it from metadata)
367+ agent_info = get_agent_info_from_metadata (results ) if results else []
368+ round_results = process_round_results (round_results , agent_info )
369+
370+ rounds .append ({"round_num" : round_num , "sim_logs" : [], "results" : round_results })
371+
372+ # Sort rounds by round number to ensure consistent ordering
373+ rounds .sort (key = lambda x : x ["round_num" ])
362374
363375 # Extract agent information
364376 agent_info = get_agent_info_from_metadata (results ) if results else []
0 commit comments