Comparing Player Stats

Earlier this week I was curious if I could create a program that would help me make my Fantasy Premier League selections: a list of players with the highest scores for the anticipated gameweek (a set of fixtures). Initially I wanted it to consider form (a player’s average score over the last thirty days) and the difficulty of each fixture. I wrote a first version in a couple of hours [1].

Writing programs that consume APIs in Go usually requires creating a series of structs that mirror the structure of the API. You “unmarshal” JSON onto these. In my first iteration, when I wanted to add my own additional computed values I would just add these as new fields, omitting the json struct tags. When I came to add more features a few days later the code was hard to read so I prefixed my API structs with “api” and then created a series of new types designed on the structure of data I wanted to output. I then iterated over the API values, mapping the data onto the new types. The data was much easier to work with in that way.

My program works like this: Initially I create a selection of “likely winners”: teams whose expected difficulty is less than that of the teams they’re facing. I then take all the players from these teams and sort them by form, their ICT index (a metric created by the league), their average starts and the difficulty of the fixture.

But I encountered an interesting problem. The game requires you to play a certain number of players in each position. Between three and five defenders, two and five midfielders and one and three forwards. There’s always one goalkeeper. These bounds mean that (for example) one week the “ideal” team might consist of four defenders and five midfielders because the midfielders are higher scoring than the defenders and forwards. I attempted various different solutions including maintaining state across an ordered slice and a map of players by position. Even ChatGPT couldn’t produce viable code. Ultimately I ended up calculating the total scores for each combination of players (a formation) and picking the formation with the highest score; though I’m sure this isn’t the most efficient method - if you have a better idea please email me.

I still continue to enjoy writing code with Go. My language (pending name timlang) is still in development and I’ve been adding some new features to my blog. I can’t imagine having worked on this tool any other way, especially when the compiled run time is ~100ms.

Edit: 21st Aug

In studying the API data, today I also decided to include the likelihood of a player starting in a given round as part of their “score”, so as to downgrade injured players. I’m also now displaying the score in the results, an arbitrary number whose meaning is unclear to the uninitiated. Some players seem to rank higher on this score than others in much better form, which might not make sense at first. In some ways the “meaning” of the data, what I’m really trying to convey when I say the “perfect team”, has been distilled; Adding more variables to my ranking order is not as simple as just form on its own nor am I under any illusion that having more variables presents a “complete” picture. That picture may be complex but I suspect that most of my predictions will be wrong.

[1] Latest version:

My internet pulse

My blog is my internet pulse. When I feel motivated I write articles or post updates. When I don’t, my pulse slows; the content dries up.

I own my blog. I own the words I write and the small corner of the internet I’ve carved out. My access to it can’t be revoked.

My blog stays with me. I add new functionality when I see opportunities to. It’s my longest surviving project (the earliest version dating back to 2015, and this current iteration just over a year ago). It having survived so long has allowed me to make incremental updates rather than big sprints; I’ve been able to offer an improved experience for my readers.

My blog is where my ideas establish themselves; some of which I hope others find useful.

What is so timeless?

In one of my favourite “Curb Your Enthusiam” scenes Larry’s assistant gets a tattoo but when he asks her what it means, she says “It’s very personal. I don’t share it with everybody”. He replies, “The whole world can see it but it’s personal.”

I’ve sometimes wondered what idea or symbol is so timeless that I’d want it permanently tattooed on my skin. Perhaps it would be the AFC Bournemouth crest or a pair of cherries, but then lately I’ve felt so disillusioned by the ethics of football: the extortionate sums of money spent on players; the Saudi State; rape allegations, homophobia, racism, drug abuse, CO2 emissions etc.

Football fans it seems, alternate between love and hate for their own players on an almost weekly basis. Overall it feels so transiently insignificant, so fickle.

Masters of our own destinies

I spent years grappling with a feeling of inferiority having not graduated from university. When I finished school at eighteen I studied TV Production in Gloucestershire, despite my only interest having really been film; my father wouldn’t support this in the belief that TV was where the jobs were. My main interest as a teenager had been photography but there was also no possibility my parents would support me in that. Upon reflection, I think photography was one of the only things I was ever truly good at. I left university after a year with ~twelve thousand pounds of debt and depression.

I have no regrets having spent a considerable part of my life programming. I think I’m fairly good at it as well.

At several stages in adulthood I’ve looked into the possibility of returning to university in some capacity. Firstly, I feel I missed out on the opportunity to study. It was only as an adult that I discovered how much I really enjoy learning new things; any kind of passion I’d had for learning at school was thoroughly drummed out of me during GCSE & A-Level study; I read hundreds of books in my early teenage years before having to answer inane essay questions about which “literary techniques Bronte employed in Jane Eyre”. Incidentally, novelists don’t consciously employ techniques as if ticking off items on a shopping list, they read.

Secondly, graduating from university has always felt like a club I wasn’t part of. My parents, my sister, most of friends. Most of them describe it as a total waste of time, but a walled garden I may never have access to nonetheless.

The barriers to attending university seem too great: I would have to study A-Levels relevant to the subjects I want to learn about, which might take years with a full-time job. And what would it lead to if not another job? Why would I forgo gainful employment for the possibility of something else? It’s not as though I hate what I do currently.

At the weekend I finished reading “Masters of Doom” which follows “The Two Johns” (Romero and Carmack) (founders of id Software) who would make games like Wolfenstein 3-D, Doom and Quake and bring about vast cultural change in the process. Neither of the Johns graduated from university. Carmack, who was largely self-taught, would conduct his own research so that he could solve difficult graphics problems. It was incredibly humbling to read about the two prodigious programmers, who later went on to become hugely successful (in every sense of that word).

I hope I'm right (to be care-free) about AI

While out drinking with my programmer friends at the weekend, naturally the subject of ChatGPT arose. We laughed about it, comparing the way you can ask it to generate random pictures to Celery Man. While I laugh, there’s a slightly eerie feeling at the back of my mind that perhaps I shouldn’t be. That at some point in time it might not seem so funny.

Often as someone “in the know” I feel differently on hot-button technology subjects to how my non-technical friends and family feel. Take WhatsApp being asked to create backdoors to make it easier for government agencies to hunt down terrorists and child abusers; I can totally see why you’d be concerned by those things, but knowing what I do about the benefits of encryption I’m aware of the other risks. I’m not very knowledgeable about AI or what it’s capable of, other than that I know its current limitation is that it requires human input, so we’re still some way away from something that “thinks” for itself.

One of my programmer friends thinks there is nothing to stop the proliferation of AI. “It’s unstoppable. It’s inevitable that some people will lose their jobs”, he says. He also works in tech and makes good money. The people working on the cutting edge of AI (and with vested interests in it) are hugely wealthy and have likely spent most of their lives in the belief that their work will push humanity forward. I wonder how much sympathy they have for the working classes, sympathy for the Customer Service Representative with no university education. Attempts to automate entry-level jobs (that our economy thrives on) like these with bots might seem silly now, but I’d hazard a guess they soon won’t be. Those of us who work in tech are all incredibly lucky; I think about this every day.

I don’t think I have any reason to be worried about my job. The application I work on is highly complex and configurable. By the time you’d explained what it does to a machine in English, you’d have built the entire thing from scratch anyway. English might not even be the ideal way to explain it but at least it’s how us humans think (and dream) about applications now. Perhaps I could describe a service and some endpoints to ChatGPT and it could probably produce an Echo server with working code, but the limit to how accurate it’s going to be is how much detail I’m willing to go into.

There’s a subculture that seems to have appeared on some parts of Reddit and Hacker News recently: choosing the prompts that your AI art is created from. I find it totally absurd that anyone would think this could be considered a “skill” but people already do, as though choosing 10 words requires anything like the level of skill required to draw or paint well. Thankfully we do consider skill when we think about the quality of art, which is why a Rembrandt knockoff doesn’t cost you anywhere near as much as the real thing.

I imagine the future (at least for programmers) will be some augmentation of what we currently do: auto generated code snippets. I can’t imagine a self-checking, self-moderating machine that turns Jira tickets into an application you never touch or see. There will still be code, edited and validated by humans.

But I don’t see people losing their jobs in the face of this technology as an “inevitability” either. It certainly doesn’t have to be, unless those in charge let it be. We’ve developed a much better understanding of how to live with technology than ~170 years ago. I only hope that we don’t give in to the lazy, big tech optimism that got us into so much trouble in the past. Let’s stop pretending the big-tech CEOs and SV investors of this world care about the interests of the common person like they say they do; they don’t.