Vibe coding an algorithm to select the perfect Wildcard FPL team
I’m a big FPL fan, even to the extent that I launched my own FPL AI Agent to help me play the game.
Before this season started, I had selected a fairly good team with the help of my little cyborg. On Friday morning however, hours before the first kickoff, I threw caution to the wind and made big changes after having listened to one FPL podcast too many.
This may have been a mistake. My team has performed so poorly that I now need to use my wildcard - a special feature in FPL, available only twice per season, which lets you completely rebuild your squad.
This time, I’m not going to trust my instinct. I’ll rely on data. To do that, I need an algorithm.
Framing the problem
I had a vague idea that there were algorithms appropriate for solving this kind of problem, so I started by turning to ChatGPT to ask it to define a solution which I could then feed to Claude Code.
ChatGPT said something along the lines of:
The clean way to frame this is as a 0-1 Integer Linear Program (ILP) - essentially a multi-dimensional knapsack with position, club, and budget constraints.
That sounded great! I had no idea what a multi-dimensional knapsack problem was, but ChatGPT explained, and it made sense. Satisfied that the explanation would fit my needs, I asked it to write me a markdown file that defines the problem.
First run with Claude Code
Next up: Claude Code. I moved the markdown file that defined the problem into the project folder for my FPL AI Agent, since it already has all the FPL data in well-formatted parquet files.
I asked Claude to generate a Python script that solved the problem. After a minute or two it had written a command-line tool, and here’s what it produced on the first run:
The key thing to notice? It gave me three Arsenal defenders. A completely valid mathematical solution - but anyone who’s played FPL knows that tripling up on one defence is a recipe for pain.
Adding constraints
So I asked Claude Code to add another constraint: each position can only have a player from one team. Because I don’t auto-accept everything Claude does, I noticed one of its proposed changes didn’t make any sense. I stepped in:
Does it make sense to have two parameters for the one-per-team position? Surely having just one parameter which defaults to true but can be set to false is enough?
Claude corrected itself, and when I ran the script again, the output was far more balanced. No more triple Arsenal defence.
Beyond the first two gameweeks
Better - but still flawed. The algorithm was only maximising projected points from the last two gameweeks. That’s not enough.
I wanted it to also factor in:
- Fixture difficulty - one of the biggest drivers of FPL performance.
- Last season’s form - proven players don’t stop being good overnight.
Otherwise the solver would happily ditch players like Palmer, Saka, Haaland or Salah, just because they hadn’t scored highly yet this season. I asked Claude to add these parameters, and it did.
Making it visual
Finally, I asked Claude Code to create a dashboard for me with Streamlit. The first iteration was surprisingly good. Only a few minor tweaks later, I had a fully functioning Streamlit app with a team selection algorithm.
👉 You can try it here: wildcard.streamlit.app
Wrapping up
The process looked something like this:
- Frame the problem with ChatGPT.
- Feed that definition into Claude Code.
- Get a first draft of the algorithm (and laugh at triple Arsenal defence).
- Add smarter constraints and real FPL factors like fixtures and last season.
- Package it up into a dashboard you can actually use.
Now I’ve got a Wildcard helper I actually trust.
Will it outsmart my gut instinct this season? We’ll see.