Skip to content
Best of Challenge 1: Wild Card

Historic Matchup Simulator

Imagine creating matchups between any MLB teams throughout baseball history. With MLB StatsAPI data and Google Gemini, you can.

Core trick

Normalizes stats across eras, then simulates each pitch from outcome probabilities while tracking base and out state.

Tags

Built with

flaskgeminigooglehtmljavascriptpythontailwind

Description

Inspiration My curiosity and love of statistics drove me to create a tool that could answer the age-old question: "What if Team X from Year Y played Team Z from Year W?" The project combines advanced statistics, machine learning, and real-time simulation to bring historical matchups to life. What it does The MLB Historical Matchup Simulator creates pitch-by-pitch baseball games between any MLB teams from 1920 to present. It: Normalizes statistics across different eras for fair matchups Simulates realistic pitch sequences and outcomes Tracks detailed game states including baserunners and fielding Generates AI-powered game analysis and commentary Provides comprehensive post-game statistics and highlights How we built it The simulator was developed using: Python/Flask backend for game logic and statistical processing Socket.IO for real-time updates Hosted via Google Cloud Run Google Gemini API for natural language generation Advanced statistical models for era normalization MLB Stats API for historical data Custom algorithms for: Exit velocity calculations Hit distance estimation Pitch selection and outcomes Defensive positioning Challenges we ran into Normalizing statistics across vastly different eras of baseball Creating realistic pitch sequences that reflect historical tendencies Implementing real-time game state management Balancing simulation speed with detail Handling edge cases in baserunning and scoring situations Developing accurate physics models for hit outcomes Accomplishments that we're proud of Created a statistically accurate simulation engine Successfully normalized player performance across 100+ years Implemented realistic physics-based hit outcomes Developed natural language game summaries Built an engaging real-time interface Maintained historical accuracy while ensuring entertaining gameplay What we learned Advanced baseball statistics and sabermetrics Real-time web application architecture Historical data normalization techniques Physics modeling for sports simulation Natural language processing integration Complex state management in simulations What's next for Historic Matchup Simulator Season simulation mode Custom team creation Historical playoff brackets Player career trajectory modeling Advanced weather effects
msamylea/mlbhackathon★ 03 forksPythonMITCreated Jan 31, 2025 · last push Feb 1, 2025

README excerpt



# MLB Historical Matchup Simulator

[![Python](https://img.shields.io/badge/Python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Flask](https://img.shields.io/badge/Flask-2.0+-green.svg)](https://flask.palletsprojects.com/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

A web application that allows users to simulate baseball games between teams from different eras, powered by advanced statistics and natural language processing.

- **MLB StatsAPI** for historical data
- **Google's Gemini API** for natural language processing
- **Flask** and **Socket.IO** for real-time web functionality

# Navigation

[Features](#Features)

[Prerequisites](#Prerequisites)

[Installation](#Installation)

[Project Structure](#Structure)

## Screenshots

![collage](https://github.com/user-attachments/assets/412365a0-560d-424d-a649-23fe20f3bc76)


## 🎮 Features

### ⚾ Core Gameplay
- **Historical Matchups**: Simulate games between any MLB teams from 1920 to present
- **Real-time Simulation**: Watch pitch-by-pitch with detailed statistics
- **Live Scoreboard**: Track inning-by-inning scoring and game state
- **Base Runner System**: Visual tracking of runners and scoring plays
- **Pitch Sequences**: Detailed pitch information including type, velocity, and outcome
- **Batting Lineups**: Batter lineup optimized using OBP, SLG, OPS and tracked and maintained for consistent batting order between innings.
- **Google Gemini Analysis**: Statistical analysis of era norma

Team