FreeOrion

Forums for the FreeOrion project
It is currently Sun May 19, 2013 6:27 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: the production queue and long AI orders
PostPosted: Sat Mar 15, 2008 6:31 pm 
Offline
Space Floater

Joined: Wed Mar 12, 2008 10:54 am
Posts: 33
Location: Aachen, Germany
Some people complained about the AI orders taking increasingly long times (bug id 1905624), I've experienced the same, but while fiddling about with the AI, I found something. Somewhere in the FreeOrionAI.py is the following code: (the one in the sourceforge Windows release, not the one from svn, I haven't been able to built the game from source yet, so I hope I'm not telling you something you already know)
Code:
    availableShipDesignIDs = empire.availableShipDesigns
    for id in availableShipDesignIDs:
        print "available design id: " + str(id)
        fo.issueEnqueueShipProductionOrder(id, empire.capitolID)

These four lines add all ship designs to the production queue every turn. As I changed it so that it only fills up the production queue if it's empty, the AI orders took nearly no time at all. I also tried filling up my own production queue with ridicoulus amounts of ships and I came to the following conclusion: Putting the first several ships into the production queue takes nearly no time at all, but after about 20 ships inserting anotherone starts to take a long time at the end of a turn, but still nothing like the amount the AI has taken before. I had a hunch and tried to find my way through the AI-clients code and I was unable to find a line that clears the list of orders at the beginning of a turn. Could it be that the AI sends not only the new orders but all old orders as well, which we just don't notice most of the time, because the older move orders are overridden by the new ones all the time? Or am I just wrong? :?


Top
 Profile  
 
 Post subject: Re: the production queue and long AI orders
PostPosted: Sat Mar 15, 2008 8:04 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7887
Location: Vancouver, BC
m_k wrote:
I had a hunch and tried to find my way through the AI-clients code and I was unable to find a line that clears the list of orders at the beginning of a turn.

The orders set is cleared immediately after they are sent:
Code:
void ClientApp::StartTurn()
{
    m_networking.SendMessage(TurnOrdersMessage(m_player_id, m_orders));
    m_orders.Reset();
}

(StartTurn is called client-side to end the client's turn, which "starts" the turn on the server).

On the server, all sets of orders are deleted after being executed:
Code:
    // loop and free all orders
    for (std::map<int, OrderSet*>::iterator it = m_turn_sequence.begin(); it != m_turn_sequence.end(); ++it)
    {
        delete it->second;
        it->second = NULL;
    }

And no orders are sent back with a standard turn update mesasge, so the AI client has no built-in memory of previous turns' sent orders.

Quote:
Could it be that the AI sends not only the new orders but all old orders as well, which we just don't notice most of the time, because the older move orders are overridden by the new ones all the time?

I don't see how this is possible, though I could have missed something and didn't write most of the relevant code once inside the Python-exposing parts.


Top
 Profile  
 
 Post subject: Re: the production queue and long AI orders
PostPosted: Sun Mar 16, 2008 8:42 am 
Offline
Space Floater

Joined: Wed Mar 12, 2008 10:54 am
Posts: 33
Location: Aachen, Germany
Okay, my fault, everything is allright, seems the AIs just were adding ships even faster than I thought, so the bug should be fixed as soon as there is a proper production AI.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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