Generates a reasonable bracket for you, based on Ken Pomeroy's college basketball ratings.
This code was a hack when I first wrote it 15 years ago, another hack when I re-wrote it 9 years ago, and even worse today. I use it once a year though, and it works just fine.
For each matchup, it compares the two teams in the game, calculates the odds of the favorite winning the game, and chooses the winner. There are three settings that determine how it does so:
Always picks the favorite
Picks the underdog if they win twice in a row.
If team A has a 75% chance of beating team B, the program will generate two random numbers between 0 and 100; if both of them are greater than 75, team B will advance. Otherwise, team A will advance.
Picks the underdog if they win once
If team A has a 75% chance of beating team B, the program will generate a random number between 0 and 100; if it's greater than 75, team B will advance. Otherwise, team A will advance.
This ipython notebook shows how I fit a very simple exponential curve to kenpom's predictions to reverse-engineer his win percentages. I then use the curve that fitted his predctions to decide how likely one team is to beat another, based on the difference between their kenpom ratings.