Tuesday, April 24, 2018

March Madness brackets in PHP (scores)

To get ready for this year's March Madness, I updated my Bash script that filled out basketball game brackets. The new version is a PHP page that generates a bracket in a nice, formatted form that you can print out and hang on your office wall.

This made it really easy for me to participate in the office March Madness pool, even though I don't follow basketball. I'm not really a sports guy, but I like to engage with my office colleagues. It's entertaining! My script gives me a stake to follow the games, but without the emotional investment if my bracket doesn't perform well. And that's good enough for me!

But how did my March Madness brackets fare this year?

Following the standard method for How to score March Madness brackets, each round has 320 possible points, regardless of number of games. In round one, you assign ten points for each correctly selected outcome. That's eight games in each of four regions, so 8 × 4 = 32, times ten points for each contest gives 32 × 10 = 320 in each round. In round two, assign twenty points for each correct outcome. And so on. From that, the math is pretty simple.

Round 1

My Midwest bracket did really well in the first round, predicting 7 of 8 games correctly. My East region was off, only predicting 4 games correctly. West did well, with 6 games correct. My South bracket had 5 correct predictions. So that's (7 + 4 + 6 + 5) × 10 = 220.

Round 2

Things fell apart pretty quickly in my second round. My Midwest bracket had 2 correct predictions, and East had 2. My West bracket also predicted 2 games correctly, but my South had only 1 correct. Total for this round was (2 + 2 + 2 + 1) × 20 = 140.

Round 3

I was almost completely knocked out in the third round. Of all my teams, my PHP script only correctly predicted one game (Villanova). In this round, my score was 1 x 40 = 40.

Rounds 4–6

If you followed March Madness this year, you know Villanova went the distance to win the NCAA. Fortunately, my PHP script also predicted Villanova all the way to the end. For the Final Four and the championship round, I made to make my own guesses (Villanova). That makes the math very easy:

round 4: 1 × 80 = 80
round 5: 1 × 160 = 160
round 6: 1 × 320 = 320


Overall, my PHP script did pretty well. Across all rounds, my final score was 220 + 140 + 40 + 80 + 160 + 320 = 960. That's great!

Compared to an earlier version of my Bash script to fill out March Madness brackets, 960 points is excellent! In that previous iteration, I had two runs of the script, with 530 and 490 points each. In an improved version of that Bash script, a sample run netted 390 points. My 960 compares well!

Of course, the outcome of my PHP script is based on weighted guesses, so things could have gone the other way very easily. Without Villanova, my brackets would have been completely out in the third round, resulting in only 220 + 140 = 360 points. So don't use my PHP script to bet with. But my script did keep up my interest in this year's March Madness basketball games, and that's a good thing.

No comments:

Post a Comment