game tree design problem

I have a tree node class, which holds a game board, and which can plot possible next moves, and functions which produce the next n rows of moves for a node. Each time a move is generated a new node is created, the game board is copied to this new node, and then the move is taken, leaving the original node's board untouched.

This however, is very slow. Is there a way that, perhaps using a static game board in the node class, I could just take moves as I create children, and then undo the moves as when returning to the original node. I keep a stack full of previous moves and can undo moves, but I'm not sure whether what I'm thinking of is possible since I would later need to search the tree and assess the board states, which would involve retaking the moves at each node. Another concern is whether this would even be any faster.

Your thoughts would be greatly appreciated.
Hmmm... in general for game board, we uses 1 or 2D array to hold the positions. Waste space you may say but for small game board, the trade-off is worth it. Accessing 1, 2D array elements will be very much faster than you use a tree node class.

You can also use another array to store the position that has been occupied or vacant-ed. The contents of this array contain indexes to the above game board array.

Above is my opinion. I welcome others to post alternative data structure for game board :P
Topic archived. No new replies allowed.