Inspiration

Watching the World Series this year, I noticed that the managers of the Houston Astros and Philadelphia Phillies made several decisions that seemingly worsened their odds of winning the game. For example, manager Rob Thomson's decision to bat right fielder Nick Castellanos in the 5th spot of his lineup seemed rather questionable. Given that Castellanos was a poor hitter this season, it made for sense to me to place him at the bottom of the lineup. To determine the validity of my observations and theories, I created this simulator to determine whether certain lineup and/or game decisions would help the World Series teams win more games.

What it does

Presents the user with a choice between three options:

  1. Simulate one game and receive a game recap. A game recap consists of a box score and succinct summary of all scoring plays in the game.
  2. Simulate one game and receive a detailed play-by-play description of the game. This option also provides a box score following the play-by-play description.
  3. Simulate many games (determined by user input). Prints to the console the winning percentages of both teams in the amount of games specified by the user.

How we built it

The program was built in repl.it with Python.

Challenges we ran into

One major challenge was incorporating all possible outcomes of an at-bat in a baseball game. In a given at-bat, the hitter could strike out, single, double, triple, homer, walk, ground out, fly out, etc. Additionally, the program had to account for the advancement of runners on base and scoring plays.

Another challenge was determining the odds that a specific play occurs in an at-bat given the stats of the pitcher and hitter. Unfortunately, I was not able to sufficiently accomplish this task in the time limit. Currently, the odds are weighted too much in favor of the hitter's stats.

Accomplishments that we're proud of

I'm proud of the program's ability to simulate a Major League Baseball game in a highly realistic manner.

What we learned

I learned that the game of baseball is very complex and difficult to represent in a computer program.

What's next for MLB Game Simulator

  • Incorporation of relief pitchers -Improvement of play odds for a given at-bat -Addition of all teams and players in the MLB -The ability to simulate an entire season and postseason

Built With

Share this project:

Updates