minimalistic OXO

When you're up against a master it is very noble to let him/her pick both the battleground and the battle. You're going to get beaten though. And while you might learn some important lessons along the way (watch Karate Kid for full list) ... you're still going to get beaten.

Of course I could not refuse to pick up the gauntlet on the Tic-Tac-Toe (or noughts and crosses or oxo as we call it) challenge. But it was with a bit of despair. Sure, I might point out that it looks more like a matrix with elements than a set with cells and that there are in fact 5 diagonals and 5 antidiagonals (only two of those counting for a "Winning Set", that is true), but I might then get slapped around the head with my own weapons. I'm not a mathematician and I'm challenging a PhD in Quantum Physics.

And then I remembered something. I used to play a text MUD (try them, I haven't seen anything graphical that beats them for depth of involvement and gameplay ... once you get used to the interface). Inside the game you could play chess against other players. Yes, really. It was minimalistic. I mean, you had to know the shorthand codes for moving a piece and only newbies would occasionally request a visual (ascii art) view of the board (the rest of us did it all in the head). The only thing the game itself knew was what the valid moves were at a given state for the board.

Did the chess game know about the victory conditions ? Of course not. Only a computer needs to be told what the victory conditions are !

A smile crossed my face when I remembered that. For I can not beat Peter at his own game and I'll be devouring his upcoming newsletter(s) that explain his solution (and no doubt learn lots from them). But a minimalistic OXO in under two hours ? Yes, I can do that.

You find my solution here
  • It has no concept of rows, columns or diagonals other than is needed for the interface (which is REST, using most of the verbs to get the job done).
  • There is a little bit of code, the biggest part going to showing the board (like the ascii art for the chess game).
  • The game has no concept of a victory condition, the players can decide what that is.
  • It comes with documentation, search for "oxo" after you deploy the module. 
  • There is no computer player or any other AI (you can add those as a layer on top if you want them, it's easy to find the rules for a perfect game on wikipedia).
Let the games begin !