Login  Register
 



Post new topicReply to topic
 
Author Message
 PostPosted: 29 Jun, 2010 
 

Joined: 10 Apr, 2007
Posts: 322
Location: Philippines
Offline
 I was looking at the Sempf ai thread and was going to post there but then I started wandering all over on various issues with the Ai so I decided to start a new thread so I do not derail his
.
Sonsalt wrote:
Results Test games Sempf AIX vs. Sorian AIX (latest version)
Con Sempf:
- Builds too few bombers too late
- Wastes its Fighters over the enemies base
- Commander is moving too far out of the base
- Uses T1 Fighters and Bombers too long into the game
- Building template for forward bases is faulty. It should start with defences instead of factories.



Most of these seem to be common problems that carry over from the stock AI. There used to be a commander leashing code but that seems to have been left out of the single player AI. I remember seeing it somewhere in the OPAI though. The fighter over enemy bases is actually something that all the units will do if given the opportunity. If a unit locks on a target it follow the target all the way back to its base or if the target is destroyed and a new target is available close by then it will lock on that getting closer and closer to the enemy base.

There is an avoid bases function in the Guard marker ai in Platoon lua. I have not had time to check that out properly but I was planning on seeing if that could be used to keep designated platoons from running into enemy bases.

T1 units will be used in late game if the the economy can not support building T2 or T3 units.

Same with the defenses. If you are calling for an expensive weapon like T2 artillery and you have the priority at 1000 but the economy is low it is going to build a cheaper factory instead even if that factory priority is set at 300.
If you try to use the build conditions to make the AI build that T2 artillery first then it may not build that expansion base at all.

The biggest problem I see with the commanders is the lock up bug. This happens when the commander is called to defend the base. He goes from being a builder unit to a combat unit. Part of the problem at least seems to be here in the commander thread function found in AI behaviors,

Code:
#call platoon resume building deal...
if not cdr:IsDead() and cdr:IsIdleState() then
if not cdr.EngineerBuildQueue or table.getn(cdr.EngineerBuildQueue) == 0 then
local pool = aiBrain:GetPlatoonUniquelyNamed('ArmyPool')
aiBrain:AssignUnitsToPlatoon( pool, {cdr}, 'Unassigned', 'None' )
elseif cdr.EngineerBuildQueue and table.getn(cdr.EngineerBuildQueue) != 0 then
if not cdr.NotBuildingThread then
cdr.NotBuildingThread = cdr:ForkThread(platoon.WatchForNotBuilding)
end
end
end
end
end

Even if the commander does return to the base most of the time he does not get reassigned to a build platoon. I tried changing the 'Unassigned' and 'None' to various specific commander support platoons but still he does not reassign and the WatchForNotBuilding Thread does not even notice it. I opened all the debug comments in both the Sorian and the GPG and it does not matter if it is Sorian or GPG code the results are the same. Occasionally the commander will actually fork back to support and go about assisting and building but then another attack comes and he goes back into combat mode and sooner or later he will get stuck in combat mode and not come out of it.

Using the Sorian ai the commander is not actually idle. He goes into the commander hiding which keeps looping and he just sits there in the base until he is called to go fight again. I never followed up completely on this because I decided to actually play all the factions in campaign mode because I wanted to see how well the commander Ai worked in that AI and found another weird bug in the campaign totally unrelated to the commander and I have been trying to figure that out ever since. Keep getting side tracked trying to figure out one problem I always find another problem somewhere else :mrgreen:

Moe


Top
 Profile  
 PostPosted: 29 Jun, 2010 
 

Joined: 12 Apr, 2010
Posts: 33
Offline
moe at the moment im fixing the things sonsalt said and ill look into avoiding bases. about commander freezing, can you set a global flag inside the commander behaviour thread, and respawn the thread so it starts like the commander has just spawned. if you can fix this i can change the builders so it wont start with the start build order. also both the sorian ai and my ai wont build t1 units when it has no t1 factories.


Top
 Profile  
 PostPosted: 29 Jun, 2010 
 

Joined: 10 Apr, 2007
Posts: 322
Location: Philippines
Offline
Hey Sempf

Not sure about the respawn thing. Sorians ai I believe is set through build conditions not to build t1 after a certain point in the game. Such as if you have greater than two T3 factories, less than two T2 factories etc. Same with the economy build conditions. Economy greater than or less than 0.5 0.2 build or do not build. I am not at home right now and probably will not be for several more days but I will try to look into some things when I am able from my lap top. I do have a bunch of resources here on my laptop for the game. Early AI's had the problem of building pretty much nothing but t1 units late game because basically from mid to late the T3 structures, Nukes and anti nukes, and building T4 units sucked all the juice out of the economy. Thus most Ai modders were focusing on economy and getting more T3 units late game.

You can tell the Ai to build T1 platoons late game by using the greater than or less than type build conditions but generally t1 from mid to late game are of little use. To weak to be any real use and the available resources are better spent building more powerful units and defenses. It is all in the economy really and balancing out the economy is much easier said than done.

Moe


Top
 Profile  
 PostPosted: 29 Jun, 2010 
 

Joined: 12 Apr, 2010
Posts: 33
Offline
my ai builds t1 units when it has greater than 1 t1 factory( land for land units, air for air units). sorian does it to be honest a bit bad, but that is personall taste, i dont like to see my ai with 7 idle factories waiting to be upgraded since he has 2 t3 factories, my ai is more agressive with spending resources on units on less than 20x20 maps.(promotion!! :P).

ps can any of the more experienced ai modders look into this respawning? this is a workaround for the problem though.


Top
 Profile  
 PostPosted: 02 Jul, 2010 
 

Joined: 26 Feb, 2007
Posts: 336
Location: Toronto
Offline
In my own work, I found that much of the problem related to the Commander centres around those tasks he's allowed to perform (he has custom platoons) most of them being assist jobs. Apart from his initial starting build, you'll find his specific tasks in the ACUBuilders group. Aside with some issues with the assisting code, the key things that were required to get the commander doing what I wished, and not just floundering around otherwise, involved making sure that each of his tasks had the following entries in the BuiderData.Assist section;

AssistRange (usually about 70 to 90)
AssisteeType (either Engineer or Structure)
AssistCategory (the unit he's assisting ie. ENGINEER or MASSEXTRACTION)
AssistLocation = 'MAIN' (always since he rarely leaves home)
BeingBuiltCategories (the category of what it is he's assisting on)
Time (length of time he'll do this function from the time platoon is created)

Once I made sure that those entries were present, and properly set, his behavior became very predictable and reliable. Most of those entries insure that he's not trying to assist units far from the base, for too long and making sure he's helping the right target. Initially some, or most of those were missing and it often resulted in him forming into a platoon and then almost instantly abandoning it. This was a root cause of much of the 'lock up' since he was frequently being formed into platoons that didn't work correctly.

If you look at the function (ManagerEngineerAssistAI and it's partner EconAssistBody) in the platoon.lua file, you can follow the effect each of those settings has. By the way - following that code path was VERY informative for me when I first began work.

In the end, I simply allow Bob (my pet name for all Commanders) to do the following;

Build T1 Power
Repair
Assist Engineers building T2/T3 Power
Assist Experimentals (for short periods)
Assist Mass Extractor Upgrades (within a short radius)

I also make him the primary factory builder at the MAIN base.


Top
 Profile  
 PostPosted: 02 Jul, 2010 
 

Joined: 10 Apr, 2007
Posts: 322
Location: Philippines
Offline
Thanks sprouto.

I was wondering about build conditions etc because the while loop in the aibehaviors Commander thread seems to be doing exactly what it is supposed to do. I have the debug comments opened and watch how the loop executes and in the watch for not building and process threads in platoon lua to see how it works. What seemed odd though is it will work perfectly several times. The commander goes into fight mode and transfers back to build mode and then all of a sudden it just stops working. The loop still executes and the watch and process threads are working but they just keep looping forever. I have been using drakes ravine for tests with all 4 factions. all the commanders pretty much stop at the same time usually around the 10 minute mark. I figured that maybe there were no available platoons to assign him to or perhaps that even though the going home debug showed that he was home that maybe he had not actually hit the sweet spot to get him to clear commands for the next move. I will try your suggestions and see how it goes. Again thanks for the tips.
:D
Moe


Top
 Profile  
 PostPosted: 02 Jul, 2010 
 

Joined: 26 Feb, 2007
Posts: 336
Location: Toronto
Offline
That sounds like the behavior Moe.

If you open up the EngineerManager code you'll see a LOG entry in the AssignEngineerTask function, which is commented out. Removing the comment will allow you to see Bob (and the other Engineers) being assigned to build platoons. You'll quickly come to realize that a lot of the standard engineer platoons are flawed in some minor respect and are frequently created and then destroyed - often due to missing, incomplete or contradictory data. Cleaning them up and getting them to behave consistently was quite an editing chore - but well worth it.

For my own purposes, and to make things visual, I added the value unit.Sync.id to the LOG output so that I could easily follow the behaviour of a single engineer even when lots else was going on. As follows;

Code:
LOG('*AI DEBUG: ARMY ', repr(self.Brain:GetArmyIndex()),': Engineer Manager Forming - ',repr(builder.BuilderName),' - Priority: ', builder:GetPriority(), " - Engineer: " .. unit.Sync.id)


I combined this with a function which will 'name' each engineer on the screen with that value. Here is the function, which I inserted into platoon.lua;

Code:
    NameEngineerUnits = function(self)
        local units = self:GetPlatoonUnits()
      local eng = self:GetPlatoonUnits()[1]
      
        if units and table.getn(units) > 0 then
            for k, v in units do
            if EntityCategoryContains( categories.ENGINEER - categories.SUBCOMMANDER, v ) then
               v:SetCustomName("Engineer " .. eng.Sync.id)

            elseif EntityCategoryContains( categories.SUBCOMMANDER, v) then
               v:SetCustomName("SubCommander " .. eng.Sync.id)
            end
            end
        end
    end,


By putting the following code into each engineer platoon as part of the Builder data;

Code:
   PlatoonAddPlans = { 'NameEngineerUnits' },


You'll soon have named engineers running around that correspond to the log entries. This makes it very easy to follow engineers and see what they're up to.


Top
 Profile  
 PostPosted: 02 Jul, 2010 
 

Joined: 10 Apr, 2007
Posts: 322
Location: Philippines
Offline
Hey sprouto,

That is exactly what I need for a ton of things! Much much thanks for those codes.

Moe


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



Quick Tools

Search for:
Jump to:  

© 2002-2010 Gas Powered Games Corp. All Rights Reserved. Gas Powered Games is the exclusive trademark of Gas Powered Games Corp.
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
 
Home| Games | Company | News & Press | Support
  Terms of Use   |    Copyright Information   |    Privacy Policy