FreeOrion

Forums for the FreeOrion project
It is currently Thu Jun 20, 2013 7:07 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: AI Production Queue
PostPosted: Mon Jan 09, 2012 5:09 am 
Offline
Space Floater

Joined: Sat Sep 24, 2011 4:39 pm
Posts: 44
I’ve seen a number of odd program behaviors while attempting to improve the ProductionAI module.

It appears that the main, or C++ program, is augmenting/overriding the Python ProductionAI module and is adding ships to the AI Production Queue under certain conditions.

The following are typical of messages that constantly appear in the AI log files:

2012-01-07 01:15:45,791 DEBUG AI : adding new ship to production queue: Troop Ship
2012-01-07 01:15:45,791 DEBUG AI : ProductionQueue::Update: Simulating future turns of production queue
2012-01-07 01:15:45,801 DEBUG AI : ProductionQueue::Update time: 10
2012-01-07 01:15:45,801 DEBUG AI :
2012-01-07 01:15:45,801 DEBUG AI : adding new ship to production queue: Mark I
2012-01-07 01:15:45,801 DEBUG AI : ProductionQueue::Update: Simulating future turns of production queue
2012-01-07 01:15:45,801 DEBUG AI : ProductionQueue::Update time: 0
2012-01-07 01:15:45,801 DEBUG AI :
2012-01-07 01:15:45,811 DEBUG AI : ========= Production Update for empire: 4 ========
2012-01-07 01:15:45,811 DEBUG AI : ProductionQueue::Update: Simulating future turns of production queue
2012-01-07 01:15:45,811 DEBUG AI : ProductionQueue::Update time: 0
2012-01-07 01:15:45,821 DEBUG AI : ========= Production Update for empire: 4 ========
2012-01-07 01:15:45,821 DEBUG AI : ProductionQueue::Update: Simulating future turns of production queue
2012-01-07 01:15:45,821 DEBUG AI : ProductionQueue::Update time: 0

Why is the program “Simulating future turns of production queue”?

Is it, in fact, adding ships to the AI Production Queue based upon the logic of a simulation contained within the main program code?


Top
 Profile  
 
 Post subject: Re: AI Production Queue
PostPosted: Mon Jan 09, 2012 5:23 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 8062
Location: Vancouver, BC
Gray Area wrote:
Why is the program “Simulating future turns of production queue”?
This is done so that estimates of the time it will take to complete the projects (or research) on the queue(s) can be calculated. Those times are found by repeatedly adding the allocated PP to each project until one or more are complete, then removing the completed projects, updating the allocations, and continuing the simulations until all projects are done or a predetermined number of turns (about 500 I think) are simulated.

There may or may not be any use for this in AI clients, but on the human client, it's used to determine the turns to complete projects estimates shown on the research and production queues.


Top
 Profile  
 
 Post subject: Re: AI Production Queue
PostPosted: Mon Jan 09, 2012 6:22 am 
Offline
Space Floater

Joined: Sat Sep 24, 2011 4:39 pm
Posts: 44
Geoff the Medio wrote:
Gray Area wrote:
Why is the program “Simulating future turns of production queue”?
This is done ...

Thanks for the explanation. That information is good to know.

Actually, the ‘turnsLeft’ property may yet prove to be useful to the AI. I’m glad it’s available.

I took another hard, and very careful, look at the ProductionAI module’s code and finally saw what is causing one (1) anomaly. :oops:

Now, if I can only figure out the cause(s) of the other ones …


Top
 Profile  
 
 Post subject: Re: AI Production Queue
PostPosted: Sat Jan 28, 2012 9:11 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 8062
Location: Vancouver, BC
I noticed in the ProductionAI code, you're comparing the names of shipdesigns to human-readable / english text:
Code:
            explorationShipName = "Scout"
            colonyShipName = "Colony Ship"
            outpostShipName = "Outpost Ship"
            troopShipName = "Troop Ship"
            if topPriority == 6 and shipDesign.name(True) == explorationShipName:
                # exploration ship
                print ""
                print "adding new ship to production queue: " + shipDesign.name(True)
This is a bad idea; passing True to the shipDesign name() function tells it to look up the ship's name in the stringtable, and to return the translated version of the name. This means that in languages other than english, the name won't match what you're expecting. Better would be to use the stringtable entry keys, like SD_TROOP_SHIP, SD_SCOUT, SD_COLONY_SHIP, or SD_OUTPOST_SHIP, which won't depend on the user-selected language, and pass false to name(), so that it returns the stringtable entry key without looking it up first.

The only exception is player-created ship designs, which may have only the name they specify in whatever language they're playing in, but this shouldn't be an issue for AI ship designs from the premade ship designs list.


Top
 Profile  
 
 Post subject: Re: AI Production Queue
PostPosted: Mon Jan 30, 2012 10:55 pm 
Offline
Space Floater

Joined: Sat Sep 24, 2011 4:39 pm
Posts: 44
Geoff the Medio wrote:
I noticed in the ProductionAI code, you're comparing the names of shipdesigns to human-readable / english text:

That problem should be easy to correct. I’ll get back to you with an updated module in a day, or so.


Top
 Profile  
 
 Post subject: Re: AI Production Queue
PostPosted: Wed Feb 01, 2012 10:29 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 8062
Location: Vancouver, BC
Gray Area wrote:
I’ll get back to you with an updated module in a day, or so.
Should I be waiting? Presently this is delaying up the v0.4 RC3 release...


Top
 Profile  
 
 Post subject: Re: AI Production Queue
PostPosted: Sun Feb 05, 2012 4:47 pm 
Offline
Programmer and Packager
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 807
Location: Sol III
Looks like Gray Area can't stop by ATM for whatever reasons, so I decided to help out and made the necessary modifications to ProductionAI.py. Run a test game, seems to work. Patch file attached.


Attachments:
ProductionAI_py.patch [2.34 KiB]
Downloaded 8 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group