You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Behavioral prediction engine for experimental game theory. Given round-by-round
observations of a human subject in a cooperation game, predict their future
contributions and punishment decisions using a library of previously-fitted
behavioral profiles and a cognitive dynamics model.
Current engine: v5 (22 parameters, 17 free during fitting).
Library: ~548 profiles (212 N-experiment + 196 P-experiment + 140 Fischbacher).
Evaluation standard: next-round predictive accuracy (MAE 2.10, 74% hit rate within ±2).
Note: The file map and architecture sections below are from the v4 era and have not been fully updated. The v5 codebase is described in the documents above.
Architecture
Guess Who Elimination Protocol — three steps per round:
Observe — Record the subject's actual contribution/punishment at round t.
Eliminate — Score every library candidate by behavioral distance to the
subject's trajectory so far. Hard-eliminate beyond an adaptive threshold
(3x best distance, 0.5 floor).
Predict — Run the v4 engine with each surviving candidate's fitted
parameters on the current subject's actual environment. Ensemble prediction =
inverse-distance-weighted average of survivor outputs.
Forward shadow: the elimination curve E(t) and its second derivative E''(t)
predict behavioral transitions 1 round ahead.
Current Files (actively used)
Engine
File
What it does
vcms_engine_v4.py
The engine. 22-parameter state machine with GameConfig adapter pattern. Supports PGG (with/without punishment) and IPD. Normalized game time, latent strain accumulator, self-exploitation strain. Exports DEFAULTS (all 22 params), make_vcms_params(x, free_names, fixed), and vcms_objective(x, rounds, free_names, game_config) for fitting pipelines. Punishment normalizer uses gc.max_punish / 2 (generalizes across game types). Pure Python, no numpy.
pgg_p_loader.py
Loads Herrmann et al. PGG CSV data. Returns {subject_id: [PRoundData]}. Used by all PGG scripts.
Main predictor. Guess Who elimination protocol with precomputed response matrix. LOO cross-validation over 140 Fischbacher subjects. Traj-only and drift prediction modes.
fischbacher_adapter.py
Builds the 140-profile Fischbacher board. Validates engine against conditional cooperation schedules (Fischbacher & Gachter 2010).
nottingham_ood_test.py
OOD test harness. Accepts any city CSV via argv[1]. Runs traj-only + drift predictions against the full 576-profile board. Reports per-horizon MAE, correlation, coverage.
Fitting & Library Construction
File
What it does
refit_oscillators.py
Targeted re-fit for subjects with multi-round cycling. Adds s_latent_rate/s_latent_thresh as free parameters. Only updates if RMSE improves.
normalized_fit.py
Shared fitting infrastructure for normalized-time scripts. Provides fit_subject_de() (Differential Evolution + Nelder-Mead polish), predict_fast_normalized(), params_array_to_dict(), FIT_PARAM_NAMES (15 free), FIXED_PARAMS (5 fixed). Used by all refit/fit scripts below.
refit_p_normalized.py
Re-fit 196 P-experiment subjects with v4 normalized-time engine. Uses vcms_report for run output.
refit_n_normalized.py
Re-fit 212 N-experiment subjects (7 cities) with v4 normalized-time engine. Per-city breakdown via vcms_report.
refit_ipd_normalized.py
Re-fit 188 IPD subjects (SP + FP) with v4 normalized-time engine. Per-treatment and per-type breakdown via vcms_report.
fit_nottingham.py
Fit 16 Nottingham N-experiment subjects. Uses vcms_report for run output, keeps custom per-subject detail table.
fit_minsk.py
Fit 32 Minsk N-experiment subjects. Same structure as fit_nottingham.py.
Auditing & reporting module. Section A: per-subject trace interpretation (interpret_trace, format_audit_report, format_audit_summary) — decodes engine decisions (dominant strain channel, budget trajectory shape, routing). Section B: run summary reporting (format_run_header, format_progress_line, collect_run_stats, format_run_summary, format_comparison_table, format_group_breakdown, format_param_scale_comparison, format_run_footer). Used by all 5 fitting scripts for consistent output. Stdlib-only (no numpy).
Analysis & Diagnostics
File
What it does
knockout_v4.py
Channel knockout analysis. Disables each of 10 behavioral channels, measures RMSE impact. Populates active_channels/null_channels on all library entries.