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?
AI Production Queue
Moderator: Committer
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: AI 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.Gray Area wrote:Why is the program “Simulating future turns of production queue”?
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.
Re: AI Production Queue
Thanks for the explanation. That information is good to know.Geoff the Medio wrote:This is done ...Gray Area wrote:Why is the program “Simulating future turns of production queue”?
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.
Now, if I can only figure out the cause(s) of the other ones …
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: AI Production Queue
I noticed in the ProductionAI code, you're comparing the names of shipdesigns to human-readable / english text:
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.
Code: Select all
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)
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.
Re: AI Production Queue
That problem should be easy to correct. I’ll get back to you with an updated module in a day, or so.Geoff the Medio wrote:I noticed in the ProductionAI code, you're comparing the names of shipdesigns to human-readable / english text:
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: AI Production Queue
Should I be waiting? Presently this is delaying up the v0.4 RC3 release...Gray Area wrote:I’ll get back to you with an updated module in a day, or so.
Re: AI Production Queue
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
-
[The extension patch has been deactivated and can no longer be displayed.]