The HTML Tic-Tac-Toe Game(noveltheory.com)
noveltheory.com
The HTML Tic-Tac-Toe Game
http://noveltheory.com/tictac/
7 comments
His underlying engine that generated the pages isn't very good because it's easy to beat. Unless that was deliberate, but he doesn't say so.
Yes, interesting. Optimal play should end in a tie every game. He says there are 2 ways for X to win (mirror images of each other). In those cases, O's second move was not optimal.
Spoiler alert! :)
To beat it: X in a corner, O in the centre, X in the opposite corner. O's move of course must not be in the centre or any of the corners; that way the second O can be placed such that the third X is forced to be in a bad spot.
To beat it: X in a corner, O in the centre, X in the opposite corner. O's move of course must not be in the centre or any of the corners; that way the second O can be placed such that the third X is forced to be in a bad spot.
I would have hoped that it uses CSS logic. Should be doable? I am not a CSS wizard (still look up things on the fly), but I think there are rules for "if class x is below class y in the hierarchy then..." and for selected and unselected links. Perhaps that is sufficient to create a much more compressed CSS only Tic Tac Toe?
I suspect this to be between difficult and impossible to do as CSS doesn't have any way of knowing the past; I don't think there's a way to remember moves as such. All I can think of is to somehow have an #anchor for each possible configuration and to select the visible links for the next move depending on which anchor is active. This isn't really any more elegant than having a separate page for each configuration; you're not encoding any actual logic in the CSS, just the graph of possible outcomes.
Not really encoding logic, true - but perhaps a more compressed representation would be possible. I am not sure one would have to list every possible configuration.
Great thing. It reminded me of the time when I used heuristics for developing tic-tac-toe in C. And realized that to make computer play a simple logical game it takes hundreds of lines of code. So I really appreciate the amount of thinking gone in developing such AI entirely from discrete states of HTML pages.
"A strange game. The only winning move is not to play." - Joshua
(Incidentally, that movie sparked my interest in both artificial intelligence and telephony programming.)
(Incidentally, that movie sparked my interest in both artificial intelligence and telephony programming.)
"On a Pentium 133, it requires about 20 seconds to play every game and generate every HTML page!"