1111from codeclash .analysis .viz .scatter_codebase_organization import (
1212 ASSETS_SUBFOLDER ,
1313 DATA_CACHE ,
14+ analyze_filename_redundancy_over_rounds ,
1415)
15- from codeclash .analysis .viz .utils import FONT_BOLD , MODEL_TO_COLOR , MODEL_TO_DISPLAY_NAME
16+ from codeclash .analysis .viz .utils import FONT_BOLD , MARKERS , MODEL_TO_COLOR , MODEL_TO_DISPLAY_NAME
1617
1718
1819def calculate_file_counts_by_extension_at_round (data : list , target_round : int = 15 ) -> pd .DataFrame :
@@ -107,12 +108,13 @@ def filter_outlier_tournaments_by_total_files_99p(created_files_df: pd.DataFrame
107108 return created_files_df .merge (valid_pairs , on = ["player" , "tournament" ], how = "inner" )
108109
109110
110- def plot_total_created_files_over_rounds (created_files_df : pd .DataFrame ):
111+ def plot_total_created_files_over_rounds (created_files_df : pd .DataFrame , redundancy_at_r15 : dict [ str , float ] ):
111112 """Line plot showing cumulative total created files over rounds per model.
112113
113114 - X: Round number
114115 - Y: Total number of files created (cumulative, mean across tournaments)
115116 - One line per model, colored consistently
117+ - Legend includes filename redundancy ratio at round 15
116118 """
117119 # Aggregate by player and round (mean across all tournaments)
118120 print ("------" )
@@ -129,15 +131,20 @@ def plot_total_created_files_over_rounds(created_files_df: pd.DataFrame):
129131 # Figure styling to match other viz
130132 plt .figure (figsize = (6 , 6 ))
131133
132- # Plot one line per model with consistent color & legend label
134+ # Plot one line per model with consistent color, marker & legend label
133135 seen_labels = set ()
134- for player in sorted (agg_created ["player" ].unique ()):
136+ for idx , player in enumerate ( sorted (agg_created ["player" ].unique () )):
135137 player_data = agg_created [agg_created ["player" ] == player ]
136138 color = MODEL_TO_COLOR .get (player , "#333333" )
137139 label = MODEL_TO_DISPLAY_NAME .get (player , player )
140+ marker = MARKERS [idx % len (MARKERS )]
141+
142+ # Get redundancy ratio for this player
143+ redundancy_pct = redundancy_at_r15 .get (player , 0 ) * 100
144+ label_with_redundancy = f"{ label } ($R={ redundancy_pct :.0f} \\ %$)"
138145
139146 # Avoid duplicate legend entries
140- plot_label = label if label not in seen_labels else None
147+ plot_label = label_with_redundancy if label not in seen_labels else None
141148 if plot_label :
142149 seen_labels .add (label )
143150
@@ -146,6 +153,8 @@ def plot_total_created_files_over_rounds(created_files_df: pd.DataFrame):
146153 player_data ["total_files" ],
147154 color = color ,
148155 linewidth = 2.5 ,
156+ marker = marker ,
157+ markersize = 8 ,
149158 label = plot_label ,
150159 alpha = 0.9 ,
151160 )
@@ -187,8 +196,15 @@ def main():
187196 # Apply 99% per-player filtering (mirrors bar chart logic)
188197 created_files_df = filter_outlier_tournaments_by_total_files_99p (created_files_df )
189198
199+ print ("\n === Calculating Filename Redundancy at Round 15 ===" )
200+ redundancy_df = analyze_filename_redundancy_over_rounds (data )
201+ redundancy_at_r15 = (
202+ redundancy_df [redundancy_df ["round" ] == 15 ].groupby ("player" )["redundancy_ratio" ].mean ().to_dict ()
203+ )
204+ print (redundancy_at_r15 )
205+
190206 print ("\n === Plotting Total Created Files Over Rounds ===" )
191- plot_total_created_files_over_rounds (created_files_df )
207+ plot_total_created_files_over_rounds (created_files_df , redundancy_at_r15 )
192208
193209
194210if __name__ == "__main__" :
0 commit comments