Takes matchup probabilities between teams as input, exactly simulates the swiss bracket and solves for top N optimal pickems either in probability to pass (at least 5 correct), or in highest expected number of correct points.
Both simulator and solver should not take more than a minute or two to run on CPU, even on single core. Need to generate precomputed.hpp before compiling the solvers.
Algorithms are brain-made (about 2 years old now actually), most code is AI.
g++ -O3 -std=c++20 generate_precomp.cpp -o generate_precomp
./generate_precomp precomputed.hpp
g++ -O3 -std=c++20 generate_example_input.cpp -o generate_example_input
g++ -O3 -std=c++20 solver.cpp -o solver
g++ -O3 -std=c++20 ev_solver.cpp -o ev_solversimulate_bracket computes the exact probability of every Swiss outcome by driven by two hardcoded 16x16 matrices P_bo1 / P_bo3 (edit build_probabilities() to plug in real numbers). Output matches format used by solvers.
g++ -O3 -std=c++20 generate_precomp.cpp -o generate_precomp
./generate_precomp precomputed.hpp # emits the bracket pairing tables too
g++ -O3 -std=c++20 -pthread simulate_bracket.cpp -o simulate_bracket
./simulate_bracket simulated_outcomes.csv # all hardware threads
./simulate_bracket simulated_outcomes.csv 1 # optional thread-count overrideFind only the best pickem:
./solver example_outcomes.csvWrite all pickem pass probabilities as CSV:
./solver example_outcomes.csv --all all_scores.csvFind the top N pickems, ranked best first:
./solver example_outcomes.csv --top 10Find the maximum expected-correct pickem, is very fast in comparison.
./ev_solver example_outcomes.csvWrite every pickem expected-correct value as CSV:
./ev_solver example_outcomes.csv --all all_ev.csvFind the top N pickems, ranked best first:
./ev_solver example_outcomes.csv --top 10Note: --top N with N > 1 disables the greedy single-C shortcut and
enumerates every middle choice, so it runs slower than the default search.
Let one full pickem choice be
-
$E$ : excluded-location set (the 3-0 / 0-3 teams), -
$r$ : A/B role split on$E$ , -
$C$ : middle set (mask$m_C$ ).
why
For fixed
Here
Write the score in outcome
where extr_roles), qual_mask), and
If we build
Then:
which is roughly
To reduce this, first compute a shared table for each excluded-location set
Then derive each role-specific table by remapping
Now the same final pass expression applies:
and the dominant outcome pass drops to around
For EV we write one pickem as
-
$A$ : predicted 3-0 teams, -
$B$ : predicted 0-3 teams, -
$C$ : predicted middle teams.
For outcome
Expand cardinalities as team sums (over teams
Reorder so team indices are outermost, and collect the outcome sums:
So EV reduces to collected team terms times membership indicators:
So after computing
Enumerates all
- round-3 boundary factorization: expand each post-round-3 state through all
$2^9$ round-4/5 suffixes in one pass, keeping write area small/cached. - compact hot tables (
ROW_MASK,ROW_PARTNER,MID_INDEX, colex-rankBINOM); - bitmask state with fixed-size loops for low per-path overhead;
- thread-local aggregation (
G,Gc) with compensated summation, then one reduction.