views:

72

answers:

2

I read this answer, and it just confused me: http://stackoverflow.com/questions/1869096/tictactoe-ai-making-incorrect-decisions#answer-1869226

Could somebody help me understand how I could apply this to Tictactoe?

1) How would I "work my way up through the tree? 2) How do I even create a tree of moves?

Note: I currently have a Board class which stores state about the game (e.g. Is the game complete with the current moves?, Is there a winner?, etc.) Each move on the current board is stored as 1 - 9 (top left to bottom right in rows). I can make copies of the current board state with ease. I can return a list of current moves for "X" and "O", as well as available moves from a Board.

+4  A: 

Solving Tic-Tac-Toe: Game Tree Basics
Category: Game Theory
Posted on: July 30, 2008 11:38 AM, by Mark C. Chu-Carroll

alt text

The picture pretty much says it all, but here is a link to the blog post: http://scienceblogs.com/goodmath/2008/07/solving_tictactoe_game_tree_ba.php

Robert Harvey
+1  A: 

I can answer your question "2", and hopefully this should help you figure out question "1":

Every node in the tree represents the current state of the game after some number of moves. So the root of the tree represents the game at the start (i.e. no pieces played so far). It has nine children (one for each possible first move). Each child in turn has 8 children (one for each possible second move). And so on, until you reach points where the game has been won or drawn. These are the leaf nodes.

Oli Charlesworth