Moderators: Moderators General, Magistrates, Prelates
Explanation of PDF
The PDF accompanying this writeup is not the game tree for tic-tac-toe. The full game tree for tic-tac-toe is very large and would be difficult to represent as a whole in a meaningful way. Therefore, I’ve taken a cheap shortcut by creating a digraph that represents the game tree for tic-tac-toe.
In the digraph, each vertex represents a symmetrically distinct game state of tic-tac-toe. Game states to the left are parent states of their children on the right. Each edge in the graph represents a symmetrically distinct legal move. Red edges with triangular ends represent corner moves. Green edges with half-box ends represent edge moves. Blue edges with circular ends represent center moves.
A single play of tic-tac-toe can be traced from left to right on the digraph, beginning at the empty board on the far left and ending at a game state with no children (which corresponds to a “leaf” vertex in the full game tree.)
Each game state with more than one parent can be viewed as the root vertex of a symmetric equivalence class of subgames. Therefore, the full game tree could be generated by creating a separate copy of each vertex v for each of v’s parents.
There are 765 symmetrically distinct game states in tic-tac-toe. There are 138 “leaves.” (That is, 138 distinct win, loss or draw states.)
Symmetric equivalence between two game states was decided based on applying all eight symmetries of a square (from group theory) to one of the game boards and comparing the results to the other board to see if they were equal.
In the primary data structure I used, I referred to each game state only according to a symmetrically equivalent “master state” for its class. Effectively, I chose one game state from each equivalence class as the “name” of the entire class and used it throughout to refer to that class. This approach was a deliberate tradeoff: I wanted condensed enough output to be able to view as a whole, but the ability to trivially trace a single play of tic-tac-toe was lost (as discussed above.) It’s still possible to trace a given play, but it’s not trivially easy.
ColinMcNulty wrote:What gives with this forum? Can't post an image, can't set a signature, can fill in some profile data?!?![]()
nneonneo wrote:@Wil: That PDF comes up blank for me. Maybe it's too big to view?
redscourge wrote:...I realize that comic is in no way an attempt to present an efficient representation of an optimal tic tac toe strategy, but...
uncivlengr wrote:What is with people thinking this is intended to be a practical tool for playing games of tic-tac-toe?
xero_art wrote:4) Now make one for chess!
djessop wrote:The t-shirt should read "There are 11 types of people in the world, those who understand binary, those who don't and those who insist the number above is pronounced as eleven no matter what base you're in".
You say this, and yet opt to post your own strategy, as if everyone doesn't know how to optimally play tic tac toe before they leave elementary school.redscourge wrote:redscourge wrote:...I realize that comic is in no way an attempt to present an efficient representation of an optimal tic tac toe strategy, but...uncivlengr wrote:What is with people thinking this is intended to be a practical tool for playing games of tic-tac-toe?
That's not actually what I thought, but my post was so damn long I don't blame you for missing one of the sentences. Oddly enough there is actually an eye tracking study on Jakob Nielsen's site ( useit.com/eyetracking ) that shows this happens at about the place that sentence was at!
Patrius wrote:sardia wrote:Alt Text: The only winning move is to play, perfectly, waiting for your opponent to make a mistake.
It's kinda hard to read at first, but I'll get the hang of it.
BTW: For those of you wondering where the comic is, Go to xkcd.com.
Press back to go back one comic, and then press forward twice to get to the newest comic. It's strange like that, but it works when Randall hasn't updated the website fully.
It seems that this graph assumes that X is going to make the first move in the corner, as opposed to the side or middle. Why is this? Are there less available winning scenarios if X's first move isn't in the corner, hence the "Optimal" part of the title?
redscourge wrote:I wish I could enjoy #832, but I fear that somewhere out there in the world is someone smart enough to understand the diagram, yet not smart enough to realize that they should not solve simple problems in this way, which in this case is the very least efficient way. This fear is mainly rooted in the fact that I believe that inevitably, this person will one day work for a company that will eventually want to sell me something. I realize that comic is in no way an attempt to present an efficient representation of an optimal tic tac toe strategy, but the thought still makes me feel like...well...do a search for "Mr. Bean in the museum" and watch the video...like that!
In tic tac toe, I think the simplest way to express the optimal algorithm is basically like this:
while the game is not over yet do the following in order:
-if you see a move that will allow you to immediately win, take that move
-else if you see a move you must take to prevent the other player from immediately winning, take that move
-else if the center square is available take it
-else if any corner square is available take it
-else take any edge square
Basically, if the first player starts by taking the center square and the second player starts by taking an edge square, the first player can win, otherwise it should always be a tie unless someone screws up.
You could come to this same conclusion by discovering two facts about the game:
1) After a certain point, you really have no choice of what square to take next if you wish to avoid immediately losing, so after that point there's not really any need for "strategy". This point is most likely after the other player has chosen two squares, because the earliest one can win is when they choose their third.
2) Due to symmetry, the board can be simplified down to a 1/8th section like a piece of pie (i.e. the top left section would consist of the top left, top center, and center squares). Any move that would fall outside this section can be mirror transposed as though it fell within this section, so basically when not faced with an immediate win or loss situation, you only ever really have 2 (or 3 if the center is not yet taken) truly unique choices of where to move.
redscourge wrote:In tic tac toe, I think the simplest way to express the optimal algorithm is basically like this:
while the game is not over yet do the following in order:
-if you see a move that will allow you to immediately win, take that move
-else if you see a move you must take to prevent the other player from immediately winning, take that move
-else if the center square is available take it
-else if any corner square is available take it
-else take any edge square
uncivlengr wrote:You say this, and yet opt to post your own strategy, as if everyone doesn't know how to optimally play tic tac toe before they leave elementary school.
SEE wrote:
Given the game wasn't solved until 2007, and it took twenty years and hundreds of computers to solve, I expect that most eight-year-olds do not play a deep enough game to actually always win if they went first, but merely that the first move was sufficient advantage to beat other eight-year-olds who also lacked a deep game.
Davidy wrote:SEE wrote:
Given the game wasn't solved until 2007, and it took twenty years and hundreds of computers to solve, I expect that most eight-year-olds do not play a deep enough game to actually always win if they went first, but merely that the first move was sufficient advantage to beat other eight-year-olds who also lacked a deep game.
Shirley, you jest!
I saw "computers" in the 1950's, made of mechanical relays and incandescent lights, that could play perfect games. And, there were chickens in the 1930's that could play and win. I have no doubt that the game was solved pretty much as soon as it was created.
Klear wrote:Davidy wrote:SEE wrote:
Given the game wasn't solved until 2007, and it took twenty years and hundreds of computers to solve, I expect that most eight-year-olds do not play a deep enough game to actually always win if they went first, but merely that the first move was sufficient advantage to beat other eight-year-olds who also lacked a deep game.
Shirley, you jest!
I saw "computers" in the 1950's, made of mechanical relays and incandescent lights, that could play perfect games. And, there were chickens in the 1930's that could play and win. I have no doubt that the game was solved pretty much as soon as it was created.
He was talking about Draughts. Also that was two years ago.
Return to Individual XKCD Comic Threads
Users browsing this forum: ChronosDragon, Farpappestals, FecyEnzync, Lardy Plans, LazyMonk, Majestic-12 [Bot], shealtket, yappobiscuits and 28 guests