"""One chart per figure; all plots are computed from supplied result tables.""" import argparse,csv from pathlib import Path import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt def read(path): with path.open() as f:return list(csv.DictReader(f)) def frame(): fig,ax=plt.subplots(figsize=(7.3,4.25));ax.tick_params(labelsize=10);return fig,ax def save(fig,path):fig.tight_layout();fig.savefig(path,dpi=180,metadata={'Software':'Infinite Players v3'});plt.close(fig) def main(): parser=argparse.ArgumentParser();parser.add_argument('--results',type=Path,default=Path('results'));parser.add_argument('--output',type=Path,default=Path('figures'));a=parser.parse_args();r=a.results;o=a.output;o.mkdir(parents=True,exist_ok=True) data=read(r/'continuous_lag.csv');x=[int(d['lag']) for d in data] fig,ax=frame();ax.plot(x,[float(d['theory_variance']) for d in data],label='Exact overlapping-trajectory variance');ax.plot(x,[float(d['variance']) for d in data],'o',label='Measured: 16,000 trajectories per lag') ax.set(xlabel='Pairing offset (events)',ylabel='Variance of the 64-event identity score',title='Misalignment changes both evidence strength and dependence');ax.legend(fontsize=9);save(fig,o/'01_lag_variance.png') data=read(r/'sequence_inference.csv');fig,ax=frame() for method,label,marker in [('operator_tree','Operator tree = full-sequence HMM Bayes','o'),('paired_product','Paired-product likelihood','s')]: ds=[d for d in data if d['method']==method];xx=np.array([int(d['events']) for d in ds]);yy=np.array([float(d['accuracy']) for d in ds]);lo=np.array([float(d['ci_low']) for d in ds]);hi=np.array([float(d['ci_high']) for d in ds]);ax.errorbar(xx,yy,yerr=[yy-lo,hi-yy],marker=marker,capsize=3,label=label) ax.set(xlabel='Recorded decision-context events',ylabel='Synthetic identity accuracy after world calibration',ylim=(.75,1.015),title='A strong sequence baseline is retained, not surpassed');ax.set_xticks([8,16,32]);ax.legend(fontsize=9);save(fig,o/'02_sequence_inference.png') data=read(r/'retrospective_memory.csv');fig,ax=frame();x=np.array([int(d['retained_prefix_bits']) for d in data]);y=np.array([float(d['accuracy']) for d in data]);ax.plot(x,[float(d['analytic_accuracy']) for d in data],label='Exact expected accuracy for prefix storage');ax.plot(x,y,'o',label='16,000 simulated future queries') ax.set(xlabel='Retained source bits (256-event history)',ylabel='One-bit identity recovery accuracy',ylim=(.45,1.03),title='A one-bit player identity does not imply a one-bit archive');ax.legend(fontsize=9);save(fig,o/'03_retrospective_memory.png') data=read(r/'shield_summary.csv');fig,ax=frame();names={'source_anchor':'Source anchor','path_shield_LP':'Exact path shield','conditional_class_only':'Conditional classes only','unconstrained':'Unconstrained','nullspace_24_updates':'24 nullspace updates'} offsets={'source_anchor':(10,-15),'path_shield_LP':(12,6),'nullspace_24_updates':(12,-4),'conditional_class_only':(-30,-20),'unconstrained':(-100,5)} for d in data: x=float(d['semantic_path_TV_h6']);y=float(d['normalized_value']);ax.scatter([x],[y],s=42);ax.annotate(names[d['method']],(x,y),xytext=offsets[d['method']],textcoords='offset points',fontsize=9) ax.set(xlabel='Semantic six-step trajectory TV (0 = preserved)',ylabel='Normalized discounted return',xlim=(-.04,1),ylim=(.47,.87),title='Performance and whole-session fidelity are different objectives');save(fig,o/'04_style_return_frontier.png') data=read(r/'semantic_horizons.csv');fig,ax=frame() for method in ('path_shield_LP','conditional_class_only','unconstrained'): ds=[d for d in data if d['method']==method];ax.plot([int(d['horizon']) for d in ds],[float(d['semantic_path_TV']) for d in ds],marker='o',label=names[method]) ax.set(xlabel='Semantic trajectory length',ylabel='Exact finite-model trajectory TV',ylim=(-.025,1),title='Conditional action matching does not preserve the path law');ax.legend(fontsize=9);save(fig,o/'05_horizon_fidelity.png') data=read(r/'local_revisions.csv');fig,ax=frame();x=np.array([int(d['events']) for d in data]);dep=np.array([int(d['tree_compositions_per_revision']) for d in data]);ax.loglog(x,32*dep,'o-',label='Tree: H K³ log₂ n');ax.loglog(x,16*x,'s-',label='Full forward replay: H K² n') ax.set(xlabel='Archive events n (H=4, K=2)',ylabel='Dense arithmetic scaling proxy per correction',title='Local reannotation trades retained structure for repair work');ax.legend(fontsize=9);save(fig,o/'06_local_repair_work.png') data=read(r/'nullspace_updates.csv');fig,ax=frame();x=np.arange(1,25);y=np.array([[float(d['mean_value'])*.1 for d in data if int(d['iteration'])==it] for it in x]);mean=y.mean(axis=1);se=y.std(axis=1,ddof=1)/4 ax.plot(x,mean,label='Projected-Q updates, 16 arenas');ax.fill_between(x,mean-1.96*se,mean+1.96*se,alpha=.2,label='Descriptive pointwise ±1.96 standard errors');ceiling=float(next(d['normalized_value'] for d in read(r/'shield_summary.csv') if d['method']=='path_shield_LP'));ax.axhline(ceiling,linestyle='--',label='Mean exact path-shield ceiling') ax.set(xlabel='Accepted analytic policy update',ylabel='Mean normalized discounted value',title='A feasible improving direction need not reach the optimal vertex');ax.legend(fontsize=8);save(fig,o/'07_nullspace_learning.png') if __name__=='__main__':main()