This folder contains the simulation script and Marimo notebooks for analyzing court assignment algorithms.
Dependencies are declared in analysis/pyproject.toml.
cd analysis
uv venv
./.venv/bin/uv pip install .The simulation compares all four court assignment algorithms (Random Baseline, Monte Carlo, Simulated Annealing, and Conflict Graph) and generates comprehensive metrics.
Create or edit analysis/data/config.json:
{
"runs": 100,
"rounds": 10,
"playerCounts": [20],
"numCourts": 4
}- runs: Number of simulation sessions per algorithm
- rounds: Number of rounds per session
- playerCounts: Array of player counts to test (e.g.,
[17, 18, 19, 20]) - numCourts: Number of available courts
cd analysis
npx tsx ./simulation/index.tsThe simulation generates data in analysis/data/:
random_baseline/,mc_algo/,sa_algo/,cg_algo/: Per-engine resultssummary.csv: Repeat pair statistics per simulationpair_events.csv: Individual repeat pair occurrencesmatch_events.csv: Match outcomes with team strengthsbench_stats.csv: Bench fairness metricsmatch_pair_summary.csv: Player pair interaction countsplayer_stats.csv: Win/loss records per playerconfig.json: Configuration and aggregate statistics
comparison_summary.csv: Side-by-side engine comparison
- Repeat pairs: How often the same team plays together across rounds
- Balance: Team strength matching (based on simulated skill levels)
- Bench fairness: Distribution of bench time and gaps between benches
- Win distribution: Player win rates relative to skill levels
cd analysis
./.venv/bin/marimo edit ./engine_analysis.pycd analysis
./.venv/bin/marimo run ./engine_analysis.py --host 127.0.0.1 --port 2786Serves all notebooks with automatic refresh on file changes:
cd analysis
uv run serve.pyThen open:
- http://localhost:8765/algorithm_docs
- http://localhost:8765/engine_analysis
- http://localhost:8765/level_tracker_analysis
Export all notebooks without code cells (output only):
cd analysis
uv run export-htmlThen prerender for the main app (from project root):
npx tsx script/prerender-notebooks.tsThis generates static HTML files in public/analysis/ that render without JavaScript execution.