View Single Post
Old 29-Mar-2007, 03:53 AM   #2 (permalink)
Iphone
Fixed Error!
 
Iphone's Avatar

Posts: 4,202
Join Date: Mar 2007
Rep Power: 6 Iphone is on a distinguished road

IM:
Default Re: Depth First / Breadth First Searching

Alright... (Sorry about my lag in my reply but life has been overly hectic and busy)

You will have to create your tree sort of like this:
root(All open moves)
0,1,2,3,4,5,6,7,8
then move down the tree (If you are familiar with trees you can point each leaf to the parent node and to each side by side leaf.

So then you point root to it's leaves aka 0,1,2,... Your linking of the tree is entirely up to you.

then move down a node:
0: then link all of it's leaves aka 1,2,3,4...

So you can travel down the tree from root to 0 then to any of the child leaves 1,2,3,4...

And the process repeats.

The other idea is you can link rows together too...
0
/ / | \ \
1-2-3-4-5....

You generate this with an array of moves, and as you move down a leaf. You toggle the array index to false so it can't be listed again. And generate your list that way.
Aka:
int row = 0;
parent = root;
//making row + 1
array[9] = {true, true, true...}
current = makenode(link up parent)
current set value(loop first true index of array)
update parent(link down current)
repeat for all true values
reset array move to first leaf, toggle leaf value to false and repeat with parent of leaf.

Do this for all of the leaves and nodes.

I hoped this helped out a lil.

I don't know how much you need help with the tree itself but that is the idea.
Iphone is offline   Reply With Quote