Jump to content


Photo

Code question


11 replies to this topic

#1 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 06 October 2005 - 12:51 PM

Here is a code fragment from attackplan.ai. AI is gathering forces for attack at self.gather_pos and its army there is bigger than the enemies at the target location. Now it has to check for min_units to be satisfied to start attack.

elseif army_cost >= enemy_cost then
	
  --they are at the gather point
  local num_at_gather_pt = 0
  
  for i in self.attack_units do
 	 
 	 local tolerance_sqr = max_tolerance*max_tolerance
 	 local squad_ai = self.attack_units[i]

 	 --check I'm in proximity of the target
 	 if distance_sqr( squad_ai:GetSquad():GetPosition(), self.gather_pos ) < tolerance_sqr and 
    not squad_ai:IsInCombat() and not squad_ai:IsInStateAttackMove() then
    
    squad_ai:DoAttackMove( self.gather_pos )
 	 
 	 end
  
 	 local dist_sqr = distance_sqr( self.attack_units[i]:GetSquad():GetPosition(), self.gather_pos )

 	 if dist_sqr <=  max_tolerance*max_tolerance then
    num_at_gather_pt = num_at_gather_pt + 1
 	 end
  end
  
  --attack if I have enough people
  if num_at_gather_pt >= self.min_units then
 	 Plan.SetState( self, "Attack!", AttackPlan.Attack )
 	 return
  end
	
	end

Look at that line

 --check I'm in proximity of the target
 	 if distance_sqr( squad_ai:GetSquad():GetPosition(), self.gather_pos ) < tolerance_sqr and 
    not squad_ai:IsInCombat() and not squad_ai:IsInStateAttackMove() then
    
    squad_ai:DoAttackMove( self.gather_pos )
 	 
 	 end

Shouldn't it better be if distance_sqr(...) > tolerance_sqr instead of "< " ???

This way it will try to gather more squads our of tolerance_sqr. Otherwise it will command squads already withing tolerance_sqr to move to self.gather_pos where they are already.

Edited by LarkinVB, 06 October 2005 - 12:52 PM.


#2 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 06 October 2005 - 01:01 PM

Ahh, forget it. Seems this comamnd is not for moving them to self.gater_pos (which is achieved by the tactic) but to do some fancy shuffeling moves at the gather point.

#3 Malkor

Malkor

    Eternity

  • Members
  • 375 posts
  • Projects:Loladins of Legend.
  •  Inanely inane inanities!

Posted 06 October 2005 - 07:54 PM

You know I've had an instance where in a 2v1 I got killed by an Insane Chaos and my ally (human) walled up with turrets and predators as SM and the Chaos camped outside his base, 20/20, with a bloodthirster and all, for about 30 minutes. No joke. I assume he thought he wasn't capable of handling the defenses (eventually my ally lured him inside and got owned by that thirster.)

Perhaps consider placing an override that sends the force to attack if it's fully gathered and completely maxed out with gobs of facilities and things to rebuild if it fails.

Unfortunately I didn't save the replay as it was about a two and a half hour game and I really didn't think anyone would spend that long watching it. This was on 1.5b5.


Also consider having them build two daemon pits. One to train the bloodthirster and one to spam obliterators. The thirster takes a fair while to acquire and during this time they cannot get obliterators.

Edited by Malkor, 06 October 2005 - 07:56 PM.


#4 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 06 October 2005 - 10:13 PM

Yes, AI won't attack if defense is maxed but why should it ? I plays to win :-). Most of the time player looses his nerves and quits the battle or charges which leads to a victory for the AI most of the time :-)

#5 Malkor

Malkor

    Eternity

  • Members
  • 375 posts
  • Projects:Loladins of Legend.
  •  Inanely inane inanities!

Posted 06 October 2005 - 11:18 PM

Perhaps a more preferable solution would be to see if you can get the AI to just shell the crap out of someone in that situation using artillery. Target any known turret clusters until they're dead then run in and cut everyone into itty bitty pieces.

#6 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 06 October 2005 - 11:31 PM

Yes, AI won't attack if defense is maxed but why should it ? I plays to win :-). Most of the time player looses his nerves and quits the battle or charges which leads to a victory for the AI most of the time :-)


I don't agree. A stalement situation is 1.) a very boring game and 2.) the AI will always loose it, because it will never attack. With multiple production buildings, losses are replaced so fast, that even if I loose all my forces, I can replace it fast enough to force the AI in another stalement situation before he reaches my base.

#7 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 07 October 2005 - 06:03 AM

A situation where a players turtles in his base at maxed army size is boring indeed. But not because of the AI ;-)

#8 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 07 October 2005 - 11:32 AM

Attacking should normally be more successfull. The AI calculates, that it has to fight the entire defense + army at a sepcific point. But actually, a full army + defense buildings need a lot of space. Often it's not that easy to get all units to fight.
Nevertheless, in all my games, normally the defender looses if he's waiting too long. DOW is not starcraft, if a full army attacks, you will loose a lot of units, too. If you're staying in your base, the opponent has normally map control and therefore more ressources. Maybe he looses the first battles, but in the end you will get problems with your ressources and therfore not be able to replace your units while the enemy sends one big wave after another.

#9 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 07 October 2005 - 12:25 PM

I'm sure we can add a max_attack_value to cause instand attack. Should need some testing to get a good value. I already had something like this in my code 6 month ago. Was about 12000 army value as trigger to attack regardless of oppositions strength. Have to reevalute for WA.

Edited by LarkinVB, 07 October 2005 - 12:25 PM.


#10 Flenser

Flenser

    title available

  • Members
  • 316 posts
  • Location:Glasgow, Scotland
  • Projects:Dawn of War AI Skirmish

Posted 07 October 2005 - 01:49 PM

I'm sure we can add a max_attack_value to cause instand attack. Should need some testing to get a good value. I already had something like this in my code 6 month ago. Was about 12000 army value as trigger to attack regardless of oppositions strength. Have to reevalute for WA.

<{POST_SNAPBACK}>

All the difficulty levels apart from Advanced (ie. Harder and Insane) have
max_army_size = xxxx
which forces the enemy to attack before it gets too powerful. Could be easily tweaked to ensure Harder and Insane attack when their armies are near full size.

Flenser

#11 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 07 October 2005 - 03:27 PM

Added this to advanced scripts (9000). This is pretty big and will happen for all races if players waits too long.

#12 Malkor

Malkor

    Eternity

  • Members
  • 375 posts
  • Projects:Loladins of Legend.
  •  Inanely inane inanities!

Posted 07 October 2005 - 04:59 PM

DOW is not starcraft, if a full army attacks, you will loose a lot of units, too.



Gaurantee you if you turtle against any decent SC player you're going to lose very fast. Period.


A blood thirster, avatar, whathaveyou, can tank an entire base easily while your main force blows it all up. Perhaps have the AI in such a situation just toss their uber unit in to soak up the damage, then rush everything else in and shoot everyone. Though, this tends to happen anyway.

Edited by Malkor, 07 October 2005 - 04:59 PM.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users