i'm writing a chess program in vb.
is there anyway to make trees (for future moves)?
in C++, there is a type of data structure called "Trees".....
Printable View
i'm writing a chess program in vb.
is there anyway to make trees (for future moves)?
in C++, there is a type of data structure called "Trees".....
there is no intrinsic binary tree data structure in vb. the closest thing would be the intrinsic "collection" object or the Microsoft Scripting Runtime "dictionary" object.
if you search the forum for "binary tree", you'll find a couple of different people have created tree sturctures and posted the code in here.
Or look for linked list.
As far as I know, you really don't need to use trees with chess or checker programs.
Can you explain what you need it for?
Since you can have several possible moves and combinations (and future consequenes of a move) in a chess game, it helps if you have a tree.Quote:
Originally posted by ae_jester
As far as I know, you really don't need to use trees with chess or checker programs.
Can you explain what you need it for?
If he went for a depth first traversal, that would be too large and consuming. I'd suggest a breadth-first traversal so that the program can go for only a certain number of future moves, and give the opposing player a chance to win.
I am assuming you are using the 'tree' idea because you want the computer to be able to 'think' for itself.
With today's search algorithms there is no need to store each possible position in memory. You simply need to store the current position, and you need a method of generating all possible moves from that position.
Sure, the search routine will search the 'tree' of legal moves, but this tree is generated during the search and not before.
I don't really know how to explain this, but if you look at some sample source code it will become more obvious. I have made a checkers program in both VB and C++ so if you need any help, PM me.
Hi
I would go with Mr. ae_jester's logic. You can go for trees data structure, when you want to keep track of the moves and there's a possibility of search backward etc. I would recommend you to use a User-Defined Type Array, to keep track of you moves, using
Type <TypeName>
Members....
End Type
Hope you got some clues.
Gs