|
-
Jun 27th, 2004, 11:47 AM
#1
Thread Starter
Addicted Member
how to make trees?
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".....
-
Jun 27th, 2004, 06:06 PM
#2
Hyperactive Member
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.
-
Jun 27th, 2004, 09:31 PM
#3
-
Jun 27th, 2004, 11:34 PM
#4
Frenzied Member
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?
-
Jun 27th, 2004, 11:41 PM
#5
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?
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.
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.
-
Jun 27th, 2004, 11:57 PM
#6
Frenzied Member
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.
-
Jun 28th, 2004, 02:07 AM
#7
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|