Softball Pulp
Auto-generate a winning softball lineup using linear programming and PuLP.

A Fair Lineup in Three Steps
List Who Showed Up
Enter each player's name, gender, and every position they're comfortable playing. A demo button fills in a sample team of 14.
Rank by Skill
Drag players into order from most to least skilled. The ranking only feeds the optimizer and never appears in the results, so nobody's feelings get hurt.
Get the Lineup
Two solvers return a batting order with two women in every five batters, and a fielding chart for every inning with at least four women on the field and nobody sitting out twice in a row.
At a Glance
From Roster to Lineup
- Player InputPug Templating
- ValidationDry Run of Solvers
- Batting OrderPuLP Model, CBC Solver
- Fielding ChartPuLP Model, Nine Innings
- ResultsFlask Page
Built with
Key takeawayLeague rules map cleanly onto linear constraints, so adding a rule means adding a constraint instead of rewriting a custom algorithm.
Build Notes
Challenges, learnings, and what's next
Challenges
- Each step is a full page form POST, so the roster travels between pages as hidden form fields. localStorage keeps the roster and ranking order so a refresh does not wipe them.
- Keeping players in the same position between innings needs extra helper variables to stay linear. The current attempt compares variables with Python
==, which PuLP evaluates to a constant, and adding it with+=replaces the skill objective. The fielding chart is a valid assignment, not an optimized one. - The rule of two women in every five batters applies to each group of five except the last, which is left unconstrained. This lets a roster of up to 15 players with only four women still produce a batting order.
Learnings
- PuLP with the CBC solver handles 20 players × 9 innings × 10 positions fast enough that the solver is never the bottleneck.
- Expressing lineup rules as LP constraints is more maintainable than a custom heuristic.
- Documenting even a simple web app is time consuming. AI can scaffold the writing, but it still needs manual rework to keep your own voice.
- Drawing the field diagram as an SVG in Figma keeps it sharp at any size.
Next
- Move output data into the URL so lineups can be shared directly from the results page.
- Allow configuration before optimization, such as an all-male roster, adjusted gender ratios, or different league rules.
- Lower the minimum player count from 10 to 8 to support smaller rosters.
- Allow a female player to bat multiple times when the roster is short on women.
More Apps

Settlers Journal
A development journal for a Settlers of Catan web application, published as a searchable static site with Astro and Pagefind.

Scratch
A platform for deploying and browsing experimental web apps. Each web app is a collection of static files and an optional backing API implemented in Python.

DuckDB WASM Demo
A full SQL database running inside your browser tab. Walk through a small analysis, then write your own queries.


