• Advertisement
Sign in to follow this  

Firing "interrupts" every second..ack!

This topic is 3634 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

Hi, Here is my problem: I have a group of entities that I want to interact with each other. However, I would like to be able to track their movement and watch as the "simulation" progresses. (The goal is that I eventually control an entity and do interactions). The computation time of the actions may be variant - ie, as I tune up the AI, it could be increasingly computationally intensive. Or I could tune it down and have each step happen in a few cycles. My desire at the moment is to have something that will fire each second(or some multiple thereof). I'm not quite sure how to do this - a delay() function does not account for the time spent in computation. Currently I'm using a pthreads implementation and the controller will be in its own thread. Comments/nomenclature clarifications/links/help? Thank you

Share this post


Link to post
Share on other sites
Advertisement
Instead of only doing the AI update once a second, why don't you just break it up into entities? For example, if you have 100 entities, every update frame, update the AI for 10 of them.

Share this post


Link to post
Share on other sites
The key here isn't the "time" of it, it's doing the operations, then "pausing"/suspending/etc.
Right now I'm banging on a while loop and waiting for time() to change. That's cycles happening pointlessly. If I knew how to trigger it every *n* timeslices, that'd be fantabulous. :)

Or, restated, I want a "thread_suspend(ms_to_wait)" concept, and I'm not sure how to implement that.

Share this post


Link to post
Share on other sites
Sleep(1000) perhaps?

To adjust for time spent in computation, obtain time before and after computation, then decrease the sleep time by that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement