Generate as many NCAA brackets as possible
Filling out an NCAA bracket involves making 63 binary decisions, meaning there are 263 possible entries. That comes out to 9,223,372,036,854,775,808, or "nine quintillion." This program will surely die before we get there, but it can spit out a million possible brackets in a few minutes.
This will continue to append new random brackets to brackets/brackets.csv
until you quit.
npm install
node bracket.js
For each completed game, run the addWinner.js
script with two arguments: The --game_id
and the --winner_id
. The script will politely complain if you select a winner who was not playing in that game.
The games are ordered from 0 to 63 in ascending rounds, always sorted by East, West, South and Midwest. The easiest thing to do is open results/results_2019.csv
and look up the relevant game and the winner's id, also an integer from 0 to 63.
Once the results/results_2019.csv
file is up-to-date, just run this command, then go get coffee for about 15 minutes.
node evaluateResults.js
This script scores each bracket, round by round, and also computes the highest possible score in the frequent case where a predicted winner in a future game is no longer in the bracket.
The only really important function here is choose
, which determines the weight of the randomized selection for each game based on the seeds. You're welcome to fuss with it. The current algo is a linear decline from 50% for each point difference in seeds.
The R project in ./analysis
has a few handy scripts:
sample.R
reduces the contents of./brackets/brackets.csv
to exactly 10M, or however many you wantcheck.R
loads the brackets and tallies them as a sanity check. It can also visualize any given row in a clunky HTML table.results.R
summarizes the scores after you run./evaluateResults.js
.
MIT