Sign in to follow this  

need advice for AI Iterations

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

hello, i already programmed some little turn-based strategy hex games with more or less AI. Now i plan something bigger(lota more hex fields) and im not sure wheres the limit(in sense of user-friendly) of processing the ai for the hexfields or what other techniques i can use to make it work. In my little games i had no problems with a procession time of 1-5 secs per round. But what if, for example, i plan with 600*600 fields, each field with its own AI, kings and counts managing them, wars, fights, and most important what about path finding. I programmed linear(w/o threads) in c++ until today and as i told, it works fine for my games. Would threads be a way to pass the problem? I have to admit that i dont have any ideas how to program threads or any other technique that could help me. thanks for your advice :)

Share this post


Link to post
Share on other sites
Well, I haven`t played hex-based strategy games, so I don`t know what is considered "normal", but those games have been made some 15 yrs ago when we had 386DX 40 MHz machines. So if it takes you 5 seconds now, it would take up to hour on that machine, while maintaining similar gameplay.

So, you should change the process completely. Probably precompute as much as possible and find a way to reuse this data when some parameters change along the way.

Also, you should have profiled it by now and know what takes most time and optimize it. If it`s pathfinding routine - well, there`s lot of info all around the net regarding this issue. Maybe you`re recomputing everything from scratch each turn, whereas just few parameters change ? I don`t really know, since you haven`t shared more details with us.

Generally, throwing more cores at the problem doesn`t change the fundamental issue which is that it takes >5 seconds on a modern PC. Then again, it might be normal in this genre, I don`t really know.

You could however use the free CPU time while it`s player`s turn. In worst case, you`d recompute something already computed, if player changed his mind and took his actions back through "Undo" feature (I suppose, it`s common in this genre, at least it seems like this from screenshots).

Also, if you`re heating CPU for 5 seconds, there surely are things that could be optimized in the code (as soon as the more effective algorithm is chosen), but for this you really need to profile.

Share this post


Link to post
Share on other sites
Really it's a question of how efficient your algorithm is and what you're doing. Consider as a starting point that modern RTS games can handle several hundred units on big maps in real-time.

What are you doing that takes 5 seconds? That's a vast amount of time to be doing anything other than fluid dynamics or giant particle simulations. How many units do you have? What algorithms are you using for AI processing?

Have you profiled your code to see what the performance bottle-necks are? If not that's an absolute first step you need to take.

[EDIT: and threads don't buy you added performance on a single core machine. They could certainly help on multi-core machines but your system has to be designed for multi-threading to begin with.]

-me

Share this post


Link to post
Share on other sites

This topic is 3778 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this