I’ve been working on a little project for a couple months now and it’s about time I write something about it.
So here it is. Give it a play.
“Wow, your AI is really bad,” I hear you say. “No matter what I do it always makes terrible moves.”
And I would respond, “Depends on your definition of ‘terrible’.”
I was thinking one day about how, if there’s an algorithm to never lose tic tac toe, is there an algorithm that never wins? Or, even further, always loses?
Although I have not definitively answered either of those questions, the code I linked to above is more of the start of an attempt to do so. It will lose in many of the games you play, but there are known sets of moves that will either force a draw or even a player 2 (AI) victory.
As it exists, it uses an algorithm that I put together based on a bunch of pen-and-paper games with friends and colleagues. (Perhaps I’ll write about it later, if I can make it fully work). I found a couple ways that break my system, so it’s time for a new approach.
At this point, I’m confident that player 2 can always force a draw, and am pretty sure player 2 can force a player 1 win. I just haven’t proven it yet.
(pretty picture because pictures are better than just words)