dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to have a program "think ahead"

  1. #1
    Join Date
    Jul 2007
    Posts
    33

    How to have a program "think ahead"

    Hi all.
    I'm making a chess program (c++). The output of the program is simple: "Your move:" on the player's turn ... "thinking..." (and, of course, a move) on the program's turn.

    My problem is that, while the chess program works pretty well, the player still has to wait about 20 seconds for the program to calculate an answer. However, I figure that, because the player may take a while to choose a move, why not have the program think ahead to its next move so that the player may not have to wait as long. Of course, this would mean that the program would have to account for any move that the player might make, but it might be worth it if it ends up saving time.

    So, is there a way for the program to accept input from the player while simultaneously calculating its own moves?

    Alternatively, is there a way for the program to calculate moves UNTIL the player provides input?

    Anyway...
    Thank you!
    Andy

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: How to have a program "think ahead"

    You should use threads for this. Run the calculation in a separate thread from the user input and then they will not block each other.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)