Jump to content


Photo

chaos generator problem since v1.0


7 replies to this topic

#1 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 16 February 2005 - 08:13 PM

Thudo did change chaos generator function to be worse.

chaosbuildbasestrategy.ai
--Thudmeizer: Added to force Chaos to build Generators which he seems relunctant to do so!
function ChaosBuildBaseStrategy:DoBuildGenerators()

                if resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Requisition ) > 350 and
  resource_manager:GetNumOwnedPowerGenerators() < 6 then
  
  local build_type = CpuBuildType()
  build_type.btype = CpuPrerequisites.BT_Building
  build_type.name = self.generator_name
  self:TryBuild( build_type )

end

end

Default is this in buildbasestrategy.ai

function BuildBaseStrategy:DoBuildGenerators()

	--aitrace("num strategic pts owned: "..tostring(resource_manager:GetNumOwnedStrategicPoints()))
	
	local min_power = self.info.min_power
	
	if self:IsInSecondTier() then
  min_power = self.info.min_power*2
	elseif resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Requisition ) < 500 then --only build one in tier one
  --return
	end
	
	
	if resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Power ) < min_power then
	
  if resource_manager:GetNumOwnedPowerGenerators() < 6 then
  
 	 dbAssert(self.generator_name ~= nil)
  
 	 local build_type = CpuBuildType()
 	 build_type.btype = CpuPrerequisites.BT_Building
 	 build_type.name = self.generator_name
 	 self:TryBuild( build_type )
  
  else
  
 	 aitrace("trying to build bigger generator")
 	 
 	 --try to build a bigger generator
 	 dbAssert( self.bigger_generator_id ~= nil )
 	 
 	 if not self:PlanExists( "Build Building Plan", self.bigger_generator_id ) then
 	 
    --update where the free slag heaps are
    resource_manager:UpdateFreeSlagHeaps( self.bigger_generator_id )
    
    --look for the closest generator
    local base_pos = cpu_manager.cpu_player:GetStartingPosition() 
    
    local prev_distance = 0
    local chosen_slag_heap = nil
    
    for slag_heap in resource_manager:GetSlagHeaps() do
    
   	 if chosen_slag_heap == nil then
      chosen_slag_heap = slag_heap
      prev_distance = distance_sqr( slag_heap:GetPosition(), base_pos )
   	 else
   	 
      local cur_distance = distance_sqr( slag_heap:GetPosition(), base_pos )
      if cur_distance < prev_distance then
     	 chosen_slag_heap = slag_heap
     	 prev_distance = cur_distance
      end
   	 
   	 end
    
    end
 	 
    --add the plan to build it if it isn't any where near danger
    if chosen_slag_heap ~= nil and not cpu_manager.terrain_analyzer:HasThreat( chosen_slag_heap:GetPosition(), 50 ) then
    
   	 self:AddPlan( BuildBuildingPlan( self.bigger_generator_id, chosen_slag_heap:GetPosition() ) )	
    
    else
    
   	 aitrace("no bigger generators to find")

    end
    
 	 end
 	 
  end
  
	end
	
end

Problem 1 : Chaos won't build big generators

Problem 2 : Standard requirement is that power is < 100 (min_power for hard AI) but now req must be > 350. This is bad IMO and harder to achieve so it will build even less generators. Better idea is to use default function and increase self.info.min_power for chaos in advanced/buildbasestrategyinfo.ai.

Please be carefull in your changes Thudo and document them more clearly so I can have a look and evaluate them.

#2 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,164 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 16 February 2005 - 11:25 PM

I was fiddling with that all last night and found the good compromise.

Its now made more universal in the buildbasestrategy.ai:
function BuildBaseStrategy:DoBuildGenerators()

	--aitrace("num strategic pts owned: "..tostring(resource_manager:GetNumOwnedStrategicPoints()))
	
	--local min_power = self.info.min_power
	
	--if self:IsInSecondTier() then
  --min_power = self.info.min_power*2
	--elseif resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Requisition ) < 500 then --only build one in tier one
  --return
	--end
	
         if resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Requisition ) > 250 and
  resource_manager:GetNumOwnedPowerGenerators() < 6 then
  
  local build_type = CpuBuildType()
  build_type.btype = CpuPrerequisites.BT_Building
  build_type.name = self.generator_name
  self:TryBuild( build_type )

  else
  
 	 aitrace("trying to build bigger generator")
 	 
 	 --try to build a bigger generator
 	 --dbAssert( self.bigger_generator_id ~= nil )
 	 
 	 --if not self:PlanExists( "Build Building Plan", self.bigger_generator_id ) then

                if resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Requisition ) > 500 and
       	 resource_manager:GetNumOwnedPowerGenerators() > 3 then
 	 
    --update where the free slag heaps are
    resource_manager:UpdateFreeSlagHeaps( self.bigger_generator_id )
    
    --look for the closest generator
    local base_pos = cpu_manager.cpu_player:GetStartingPosition() 
    
    local prev_distance = 0
    local chosen_slag_heap = nil
    
    for slag_heap in resource_manager:GetSlagHeaps() do
    
   	 if chosen_slag_heap == nil then
      chosen_slag_heap = slag_heap
      prev_distance = distance_sqr( slag_heap:GetPosition(), base_pos )
   	 else
   	 
      local cur_distance = distance_sqr( slag_heap:GetPosition(), base_pos )
      if cur_distance < prev_distance then
     	 chosen_slag_heap = slag_heap
     	 prev_distance = cur_distance
      end
   	 
   	 end
    
    end
 	 
    --add the plan to build it if it isn't any where near danger
    if chosen_slag_heap ~= nil and not cpu_manager.terrain_analyzer:HasThreat( chosen_slag_heap:GetPosition(), 50 ) then
    
   	 self:AddPlan( BuildBuildingPlan( self.bigger_generator_id, chosen_slag_heap:GetPosition() ) )	
    
    else
    
   	 aitrace("no bigger generators to find")

    end
    
 	 end
 	 
  end
  
	end
Comments? I find all sides now build Generators and Big Generators better. I could drop the Regular Generator Req requirement to 200 but if I do then he'll likely build quickly to his max of six.

I removed the sections in both Marine and Chaos.. I had figured it was causing an issue by overwriting the buildbasestrategy.ai when I noticed no Large Gens were built. All fixed now.

In essence, I want to make it **AS EASY** for the AI to build both regular and Large Thermo Generators even when they are destroyed. The above now makes that possible. Other than now making a script so that the AI places 2-3 turrets around the Large Generator, I think its accomplished now! :umad:

Edited by thudo, 16 February 2005 - 11:43 PM.

Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#3 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 17 February 2005 - 07:13 AM

I'll find the old idea (building while power is low) better. Just increase min_power.

#4 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,164 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 17 February 2005 - 08:35 AM

Doesn't work for Chaos.. it was broken and broken bad. Just tried my way on 6p_Bloodshed Alley where the Chaos AI on StartPoint3 was super-notorious for never ever building more than 2-3 Generators. Well.. he built all 6 and it showed! Now on all maps he builds them 100% of the time now. Before he would 50% of the time. Weird. All factions, with those new Generator scripts, reliably build generators when they can. Hated the fact the AI never built them when he SO NEED 'EM mid-to-late game.

Plus.. the best result? The new Generator scripts don't effect the AI's offensive preformance. He such a saucy bastard now. Ugh!

Edited by thudo, 17 February 2005 - 08:35 AM.

Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#5 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 17 February 2005 - 07:32 PM

I bet you play with shared resources. I tested same map with all chaos AI without shared resources and min_power = 100 and it build enough generators to max its vehicles. Only AI player 4 had problems cause he never build machine pit and ended game with 2000+ power with just two generators.

To get a better understanding I'd suggest you do this. Play the game, add

function Plan:SetState( statename, state )
	dbAssert( state ~= nil )
	self.state = state
	self.statename = statename
	req = resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Requisition )
	pow = resource_manager:GetResourceAmount():Get( ResourceAmount.RT_Power )
	ailog("d:\\b"..player_id..".log", statename)
	ailog("d:\\b"..player_id..".log","at "..cpu_manager.cpu_player:GetGameTime().." r "..tostring(req).." p "..tostring(pow) )
end


to plan.ai and watch the replay switching to AI players often while looking at the debug files. It will give you a good impression why the AI is acting/building few/lots of gens and where it gets stuck.

I did set min_power to 100 for each race (will be 200 in tier2) and only allowed secondary buildinds at tier2.

It all boils down to this for the AI to fail :

1. AI chooses bad SquadLinits in advanced/buildbasestrategyinfo.ai for its race. We have to check that squad limits choosen for a given race is not identical for all AI teams of the same race. Just fought with 5 chaos AI and all seemed to only build defilers.

2. AI is handicaped by starting position unable to build the complete structure tree due to unknown reasons

3. I never watched AI building uber units. Had a game on lost hope where I was the last player of my side with maxed units (6 lasor predators, rest marine squads) defending my base entrance with 8+ turrets. The remaining 4 AI enemies idled around some points, never attacked me but also were unable to build uber units as well. I left the game after some time (making breakfest first) and the situation was static. I had 30000 req/power and the AI must have had same amount at least.

4. AI often will defend its base when its too late. Wandering out with its main force too far to be back in time. We have to add retreat to base if nearest LP in front of base is under attack.

Conclusion : AI will loose to good players cause its often not at critical locations which will decide the outcome of the battle

Edited by LarkinVB, 17 February 2005 - 07:38 PM.


#6 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,164 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 17 February 2005 - 08:04 PM

I play with the defaults - No Shared Resources (AI doesn't share resources unfortunately - that would be cool to add an AI ability to give money to allies before it dies).. hmmmm.. Standard Resource Gathering, Fast Game Speed, Locked Teams.. Nothing special.

The Generator/Big Generator scripts are very reliable as they are now. Nothing is more important mid-late game for the AI to have lots of power resource. Before Chaos was super-notorious for only having a couple of Gens. Now he always has 6 and can support large armies. Play a 3vs3 on 6p_Bloodshed Alley and put a Chaos player on StartPoint3 with the regular Gen scripts. He simply fails to build Gens.. why.. dunno but with these new ones it works perfectly. I'm liking it alot + Big Generator creation is far more reliable now. An AI simply cannot have enough resource income AT ANY TIME. :)

SquadLimits will need to be tweaked.. thats for v1.1. Right now, AI is a masser. With the 300/150 requirment for turrets his forces will be titanic! :wub: When I play mixed races, the AI's randomize their units with all sorts of shiet -> for Chaos its maybe 5 Defilers and 1-2 Preds. Other games its half Defiler and Half Pred with a huge army. Eldar - sometimes its a Fire Prism rush and others its a WraithLord rush. Ork - its a Loot Tank Rush (ouch! hate those) or its a KillKan one with heavy infantry (Nobz squad all around).
Some games are different than others but in all of them - the AI mixes the high end vehicles with infantry. Now that they're all upgraded via the tech-tree they are far far more difficult to repel. Still.. we have work to do make it even better.

No complaints about the startposition - already determined some maps fully benefit from moving the StartPoint away from obstructions.

The AI-remaining-static mid-to-late game bug always needs addressing. He simply needs to attack. I wonder if it has something to do with those turrets you built (he considers them too hard to break through so he stops).. Odd though as I've had 20 turrets all randomly upgraded with 1-3 troops squads around them and he just crushed right through. I mean, we could drop the attack_rating more AND make defensive turrets less attractive in cpu_manager.ai.

Last point - there are scripts already for the AI to defend its main base. However, by the time you can get to the AI's main base his forces were likely already eaten through kuzz you made it through. Now, if his forces are "picking their noses" at the bottom of the map with their allies and doesn't react even before the first LP is attacked OR is, as you said, too far down the map, then we need to ensure the AI isn't far to protect its critical assets.

Good points man.. those are very advanced scripts for v1.1 methinks.

Edited by thudo, 17 February 2005 - 08:11 PM.

Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#7 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 17 February 2005 - 08:49 PM

Your code will build generators if there is req, mine will build if they are really needed. Watch replays, often the AI has 2000+ power with less than 6 generators, so why do you want to force them. This is WASTED.

Over and out, read my "I'm out" post.

#8 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,164 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 17 February 2005 - 10:10 PM

Then I'll revisit and fix it. I know I was a little "pig-headed" wanting the Chaos AI to ensure it had enough power even though SM, Eldar, and Ork always built their max Gens. I still don't get what makes Chaos different in the power front verses the rest? Bloody bizzare. Power is important across all sides - probably moreso for Ork as they need so much of it yet their reactors provide not as much as the others.
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users