Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Threads and AI

This topic is 5995 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have to evaluate AI in a specific time frame. It is quite similar to chess programs that can be forced to make a move, where they will pick the best move they have thought of yet. Problem is, I''m not sure how to do this. I thought about using threads, but I''m not very familiar with them yet. I need to create a thread that will be killed after a hundredth of a second. Is this possible, or are Windows timer functions too imprecise for this? Cédric

Share this post

Link to post
Share on other sites
No, that''s not what you want to do. Creating and destroying threads takes time and resources.

You want to create a thread, and have it response to either messages or events that tell it to start figuring out a move. You also need to tell it how long to take searching, and while searching you maintain the current-best move. Every once in a while, you check the elapsed time, and if it exceeds the time limit, you stop searching and return the current-best, and go back to a sleep state.

Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]

[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ ]

Shamelessly ripped from Oluseyi

Share this post

Link to post
Share on other sites
Ok, but it''s kind of hard for me to check if the time has been elapsed inside my AI instructions. I''m trying to create a "random" AI; one that reads random instructions. That''s why being able to kill the thread if it hasn''t returned is important; otherwise, I might get into an infinite loop. I''ll see what I can do.



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!