Results 1 to 7 of 7

Thread: how to make trees?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    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".....

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    San Jose, Ca. - USA
    Posts
    302
    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.

  3. #3

  4. #4
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    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?

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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.

  6. #6
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    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.

  7. #7
    Lively Member
    Join Date
    Jun 2004
    Location
    Dubai, UAE
    Posts
    64
    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
  •  



Click Here to Expand Forum to Full Width