So, I got this idea to build an MLB simulator. Not one of those crazy detailed ones you see online, just something simple for myself. I’ve always been a baseball nut, you know? And I was sitting around one winter, no games on, feeling kind of bored. I had some time on my hands after wrapping up a freelance gig that went sideways – long story, basically the client kept changing their mind until the project just fizzled out. Left me with a bit of free time and needing something to tinker with.

Getting Started – The Messy Part
First thing I did was look for stats. Man, there’s a ton of baseball data out there. Almost too much. I just wanted the basics to start. I figured I’d grab some batting averages, maybe some pitcher ERAs. Seemed simple enough, right?
Well, getting that data into a format I could actually use was the first headache. Lots of messy websites, tables that didn’t want to be copied nicely. Spent a good while just cleaning up numbers in a spreadsheet. It wasn’t glamorous, felt more like data entry drudgery than cool coding.
Figuring Out the ‘Simulation’ Bit
Okay, got some numbers. Now what? How do you make players ‘play’ in a computer? This is where I kinda hit a wall for a bit. I wanted simple. I decided to use basic probability.
Here’s the rough idea I went with:
- Take a batter’s average.
- Take the pitcher’s opposing average (or something similar).
- Mash ’em together somehow.
- Roll a random number.
- If the number is below a certain threshold, maybe it’s a hit? If it’s higher, an out?
Super crude, I know. I wasn’t trying to reinvent the wheel or model spin rates or anything fancy. I just wanted to see scores change based on some kind of logic tied to player performance. I decided to use Python because I’d messed with it before and it seemed straightforward enough for handling numbers and basic logic. Didn’t want to get bogged down learning a new language for this little side project.

Building It, Step by Step
So I started coding. First, a little function to simulate one at-bat. It took the basic stats, did that random number thing, and decided ‘hit’ or ‘out’. Then I figured, okay, need three outs for an inning. So I made another function that called the at-bat function until three outs happened. Then, wrap that in another layer to do nine innings. It was very step-by-step.
The first version just printed out text like “Out”, “Hit”, “Out”, “Out”, “Inning Over”. Then it would spit out a final score. It was ugly, but it worked. Kinda. The scores were sometimes realistic, sometimes completely wild. Pitcher ERAs were tough to factor in simply, so I mostly focused on the hitter vs. pitcher matchup in a basic way.
Adding a Tiny Bit More Flavor
After getting the basic game sim running, I thought it needed a bit more. It was too predictable, maybe? I added some more randomness.
Things I tried adding:
- A small chance for errors based on nothing, just pure luck.
- A way to differentiate hits (single, double, etc.), again, just random chance after a hit was determined.
- Basic strikeout probability based loosely on pitcher stats.
It didn’t make it super accurate, but it made the text output a little more varied. Still, I kept it simple. Every time I thought about adding something complex, like base running logic or bullpen changes, I reminded myself this was just a garage project. Keep it simple, keep it fun.

What Came Out Of It
So, what’s the end result? It’s a simple command-line thing. You plug in some basic stats for two teams, and it spits out a simulated game score and maybe a very basic box score. It’s not going to predict the World Series winner. It often gives weird results if the input stats are limited.
But you know what? It was a fun process. It kept my brain busy during that down time. I learned that even ‘simple’ simulation is tricky. You have to make tons of assumptions and simplifications. It gave me a new appreciation for the complexity of those fancy sports games and simulation websites. Mine is just a little toy, built piece by piece, figuring it out as I went. And sometimes, that’s the best kind of project.