← All work

Deadball: a data-driven baseball simulation engine

A full baseball league simulator whose rules live in data, not code, tested by an AI that plays thousands of games.

Independent2026built with Claude Code✓ passed

Based on the tabletop game Deadball by W. M. Akers. This is a personal, non-commercial engine; the game's rules and design belong to its author.

The ballpark view during a live game: the scoreboard, the batter and pitcher cards, runners moving on the diamond, and a play-by-play feed. In the third inning the game pauses to ask whether to steal second, the manager sends the runner, and he steals the base.
The ballpark view: a live game that pauses for your calls. Here, a steal of second.

context

Deadball is a tabletop baseball game played with dice. I built a full league simulator around it: generated teams and players, schedules, full seasons, a championship series, an offseason with aging and a draft, a daily newspaper of standings, box scores and league leaders, and a "ballpark view" where you manage your own club's game live.

problem

Two problems, one on each side of the code.

  • Rules change constantly. The base game plus its expansions is a lot of rules, and I wanted to grow the sim by editing data, not by rebuilding code every time a rule changed.
  • A table game and a league simulator have different jobs. The game is built for play at the table. A simulator running full seasons and decades needs its numbers to track modern MLB: run scoring, stolen bases, and how players develop and age.

build

The league app on top: a CLI, a daily newspaper, the ballpark view for live play, and an MCP server that an AI tester uses to run thousands of games, all stored in SQLite. Every play runs through the engine underneath, where each rule is a model in a TOML file: inputs, formula steps ordered by a topological sort, and outputs. Models call sub-models with cycle detection, and dice are seedable so tests repeat.
Two layers: the league on top, and an engine whose rules live in data.
  • A data-driven engine. A "model" is a TOML file: inputs, then formula steps, then outputs. The game's rules live in models, so changing a rule means editing data.
  • Engine internals.
    • Formula evaluation sits behind an interface, so the library can be swapped.
    • A topological sort orders each model's steps.
    • Models can call other models, with cycle detection.
    • Dice and random sources sit behind traits, so tests are seedable and deterministic.
  • The league on top: SQLite persistence, a CLI, the daily newspaper, and the ballpark view. In the ballpark view your game runs on its own thread, the browser paces the plays, and the game pauses for your calls (steal, bunt, pinch-hit, pitching change), then records the result so it shows up in the newspaper.
  • A test harness for an AI. An MCP server lets an AI generate leagues, play thousands of games and read aggregate stats.
The league's daily newspaper, the Deadball Association Daily Register: standings for two leagues, yesterday's results and today's games, full box scores with batting and pitching lines, and league leaders in batting average, home runs, runs batted in, ERA and wins.
The daily newspaper: standings, box scores and league leaders, generated after every simulated day.

decisions hypothesis → measured → decided

  • Let the AI hunt for anomalies. Aggregate stats from AI-run simulations showed a caught-stealing rate of about 38%, far above real baseball. There were two causes: a bug in my engine that let slow runners attempt steals, and steal settings that sat above modern MLB rates. I fixed the bug and tuned two values in the league's TOML. The rate came down to about 24%, with about 1.2 attempts per team per game.
  • Tuned to track modern MLB. I adjusted player generation, pitcher usage and the run environment so long simulations follow modern MLB trends, and checked every change against simulated seasons. Because the rules live in data, each adjustment is a TOML change, not a code change.
  • Measure every rule before trusting it. Ballpark quirks were wired in one at a time and each one verified in simulation. A short porch roughly doubled home runs (3.2 vs 1.5 per game), and a high mound dropped batting average from .220 to .178.
  • Calibrate aging over decades. Running many seasons back to back is a different job from a season at the table, so I shaped the growth curve to track MLB's: a peak in the mid-20s and decline from 30. I also removed the point carry-over, so the aged population matches the generated one.

results

  • About 25,900 lines of Rust, 34 TOML models and 293 tests.
  • 262 commits since July 2026.
  • Seasons, championships and offseasons run end to end, and a decade-long dynasty sim runs unattended.

how I worked with AI

Two ways. Claude Code was the implementation partner: I owned the design and the rules, and reviewed the changes. Then the AI became the tester: through the MCP server it ran simulations and surfaced anomalies a human would miss, and every tuning decision was made on measured output, not guesses.

Code: the repository is private. A code walkthrough is available on request.

RustTOMLSQLiteevalexprtiny_httpMCPHTML/CSS/JS