Bill Mill web site logo

The Bill Mill NCAA Bracket Randomizer

Each year, when the NCAA basketball tournament comes around, I end up in four or five pools, with a separate bracket filled out for each. I love the games, and I love having teams to root for, but I really hate the process of guessing to fill out my brackets. I inevitably pick too many upsets, just because I want to have fun rooting for underdogs; instead I end up bored after the first two rounds.

This year, I thought I could write some software to help me pick out my brackets. If I let the computer pick reasonably but randomly for each pool, I figure that I stand a better chance of having one decent bracket instead of the assortment of crappy ones I normally end up with.

So the last two nights, I wrote myself a bracket randomizer; just push the "randomize" button at the top and watch it go.

In order to pick what team will win a given game, it first calculates the chance each team will win by plugging Ken Pomeroy's ratings into the log5 formula. Then it picks a random number and compares it to the probability of the favorite winning; if the number is lower than that, it advances the favorite. Otherwise, it advances the underdog. Rinse and repeat, and you should have a reasonable random bracket for the whole tournament.

The Output

Next to each team in the bracket, you'll see three numbers in parentheses. These numbers represent, respectively, the team's Pythagorean rating, adjusted offensive efficiency, and adjusted defensive efficiency.

If that's Greek to you (groan), go check out Ken's explanation of what that means.

The color of each team, once you've randomized, represents their odds of winning. Brighter green is more of a favorite, deeper red more of an underdog. It should update the colors if you manually change the teams, but it won't; I just didn't have time to get everything done that I wanted to. Similarly, it won't update future games if you change the winner of an early one.

The Code

The surprisingly difficult part of this project was creating a simple HTML bracket that looked reasonable and allowed you to click to advance a team. I didn't get everything into the page that I wanted to, simply because I spent so much time just getting that done. (Keep in mind we're talking about a 2-night hack here).

The code to generate the bracket is contained in one super-ugly python file.

If you've got ideas for stuff to add, or want to generate a cooler looking bracket, or just check out the code, you can go get it at github. Feel free to fork and enjoy!