FreeOrion

Forums for the FreeOrion project
It is currently Thu May 23, 2013 10:39 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: AI causes pause at start of turn
PostPosted: Thu Jun 14, 2012 9:12 pm 
Offline
Space Floater
User avatar

Joined: Tue May 29, 2012 9:15 pm
Posts: 23
I've seen mention on the forum, and experienced myself, the pause at the start of each turn later in a game, apparently caused by all the AI processing.

Does anyone know whether it might be sensible for me to put some timers into the AI script, to cause them to pause for a few tens or hundreds of ms between steps? Would this perhaps free up sufficient CPU time to keep the UI running more smoothly?

I thought I'd ask before spending long mucking about with it, in case it has been tried and failed, or there are specific objections to this approach.

An alternative which had occurred to me, was for the application to call the AI several times instead of just once, to break up the turn processing. This is perhaps less attractive as is would complicate the application code and AI interface.

Trust the above makes some sense, let me know if I'm barking up a wrong tree

_________________
--Steaker--


Top
 Profile  
 
 Post subject: Re: AI causes pause at start of turn
PostPosted: Thu Jun 14, 2012 9:51 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
If you know an easy way to put some delays into a python script that don't just use CPU cycles doing nothing, but actually return CPU time to be used for other things, feel free to try it.

There's also an item on the programming work wiki page about modifying the process class to make the AIs lower priority, which might help make the UI more responsive.

You could possibly also tell the server to only send turn updates to one or two AIs at a time, and wait until the others finish their turns before sending out the current turn's update to the others. That would ensure only one or two are actively processing at any given time.


Top
 Profile  
 
 Post subject: Re: AI causes pause at start of turn
PostPosted: Thu Jun 14, 2012 10:09 pm 
Offline
Space Floater
User avatar

Joined: Tue May 29, 2012 9:15 pm
Posts: 23
I think I have figured out non-busy pauses in Python, will try and report back

_________________
--Steaker--


Top
 Profile  
 
 Post subject: Re: AI causes pause at start of turn
PostPosted: Fri Jun 15, 2012 10:02 am 
Offline
Programmer and Packager
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 766
Location: Sol III
Geoff the Medio wrote:
...There's also an item on the programming work wiki page about modifying the process class to make the AIs lower priority, which might help make the UI more responsive...
This solution suggested on the programming work wiki page would be the most elegant one IMO.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group