Page 3 of 3

Re: MogulAI

Posted: 13 Nov 2010 16:10
by Zuu
Hmm, yea now I see Selling an aircraft causes a DoCommand which is not allowed in a Valuator call. So your loop is still needed, but you can use a foreach loop whenever you don't need the extra power of a regular loop.

Code: Select all

function AIAI::DeleteVehiclesInDepots()
{
   local list = AIVehicleList();
   list.Valuate(AIVehicle.IsStoppedInDepot);
   list.KeepValue(1);
   foreach(q, _ in list)
   {
       AIVehicle.SellVehicle(q);
   }
   return list.Count();
}
Note that the ", _" is absolutely needed in order for the foreach to work as wanted. The underscore is a second looping variable that will contain the AIList values. If only one looping variable is provided, it will contain the values, not the keys.

An alternative in case you're desire is to minimize the amount of code:

Code: Select all

function AIAI::DeleteVehiclesInDepots()
{
   local list = AIVehicleList();
   foreach(q, _ in list)
   {
       AIVehicle.IsStoppedInDepot(q) && AIVehicle.SellVehicle(q);
   }
   return list.Count();
}

Re: MogulAI

Posted: 16 Sep 2016 14:19
by Kogut
I returned to playing with AIs and started from comparing startup performance. In my tests (flat terrain, infrastructure maintemance killing aircraft) MogulAI was wonderfully quick. I will look around to check is it possible to reuse your ideas/code in my AI.

Re: MogulAI

Posted: 21 Dec 2017 16:33
by xarick
When distant join is turned off, the AI builds roads like in this screenshot.

Image