James Stanley


I made an LLM-powered Colonel Blotto game

Sun 21 July 2024
Tagged: software, ai, games

Today I made a Colonel Blotto game where you play against GPT-4o, and after each round you can chat with GPT-4o to get commentary/analysis/coaching. Play with it at blotto.incoherency.co.uk until I run out of OpenAI credit.

I was curious how well it would play the game. I did try a few games by hand in the ChatGPT UI before writing any software, but that's not as good because you have to manually verify that both your and the AI's soldier assignments sum to 100 or less, and manually verify ChatGPT's assessment of who won each round. My UI solves this, and it was fun to make.

It turns out GPT-4o isn't a very good Blotto player. It improves if you feed it a copy-and-paste of Jonathan Partington's Colonel Blotto Page, which I now do, but it's still not great. (Incidentally, if anyone is interested in a 2024 revival of the 1990 tournament, get in touch, we should do it).

I was particularly interested in how you could manipulate the AI into playing bad moves, either by criticising it, or pleading with it, or lying to it about strategy advice. The system prompts tell it not to trust the user, and that mostly seems to be enough. I didn't personally succeed in manipulating it, although a friend claims to have success from directly telling it what allocations to make.

I wrote the backend myself, but I got ChatGPT to write almost the entirety of the user interface code, which would normally be the time-consuming part for me. I gave it a brief description of the WebSocket protocol it needed to implement and how I wanted the page to work, then we did a few iterations of me asking for changes and it rewriting it all, and then when it ran out of steam I manually changed the handful of things it was struggling with.

It felt like a very powerful way to do programming, I've not really worked like this before. Is this what it feels like to be a technical manager? The main downside is it rewrites the entire file every time it needs to make a tiny change, which means you have to wait for it to type it all out, and you have to keep clicking "Continue generation" because OpenAI stop it after a while on long outputs.

It got to a working base loads quicker than I would have done, and I didn't once have to look up any JavaScript or DOM documentation which I normally would.

The page could do with a bit more information on the game, etc., but I think it is already good enough for what I wanted to do with it.

Play with it if you like, let me know what you think.

And the icon of the Colonel was drawn for me by DALL-E:

Zero chance I could draw such a good icon for the game.



If you like my blog, please consider subscribing to the RSS feed or the mailing list: