# Tic-Tac-Toe Game Tree

• 08-26-2006
gL_nEwB
Tic-Tac-Toe Game Tree
Ok. I've come off about a 2 month break from programming all together, and I'm going to try at making an effective Tic-Tac-Toe game first with just 2 players, then later on to AI using the minimax game tree... or if any others that would be good for this type of game. Now, could someone explain to me how this game tree would go about in code? I've read about it's theory and nodes... but I've never practiced linked lists or what not. So this is my first try at nodes, children... all that stuff. How would code logic go with the tree below?

So far, I've learned the minimax tree uses a point system to determine the winner of the game. The max player, usually the human player, tries to get the points from the tree to a positive number? Then the min player, usually the computer, tries to get the overall point total to a negative number? Each node represents a certain number total in the game?

Any help would be appreciated...along with some code examples.
Thank you.
• 08-27-2006
Kurisu33
I know nothing about Minmax tree, but a linked list is just a series of nodes basically. A tree structure is based on this same principle, but instead of sequential items in a list/queue fashion each node can point to multiple children.

Example of a combo:
Code:

```#include <list> using std::list; struct node // Will represent each tree node. {   // Put data variables here that would go in each node. Ex:   int value;   list <node> children; // Contains a list of all this node's children. } class Tree {   public:     Tree()   {     treeRoot.value = 5;     node tempChild;     tempChild.value = 3;      treeRoot.children.push_back(tempChild);  // Add this node to the children of treeRoot.     tempChild.value = 1;     treeRoot.children.push_back(tempChild);   };   private:     node treeRoot; // Base of your tree. }```
I believe the above code as is would make the following tree:
Code:

```              5             / \             3  1```
• 08-28-2006
dwks
You might be able to find some information on aihorizon.com, such as google(&quot;site:aihorizon.com tic tac toe=&quot;=).