Jump to content

R&D AI Improvements


Amineri

Recommended Posts

So, to shut down an alien :

0) Alien must be in cover

1) Put the stunner in cover to the alien (not exposed or flanked), within stun range but not flanking the alien

2) Suppress but do not overwatch the alien

3) Flank the alien with a unit at a distance (to avoid range bonuses), preferably one with defense bonuses from armor / tactical sense

 

This will result in the alien taking no action during its turn. It is only allowed to shoot the flankers, but all attack abilities are filtered because it is flanked. The move action is filtered because it is suppressed (and not overwatched). Paradoxically, overwatching the enemy in this situation will allow it to take attack actions like using grenades -- not overwatching will prevent them from happening.

Well, this is clearly an exploit (never have done this particular combination of actions myself). And what I mean in previous post, that I just do not want for aliens to try to flee and then senselessly die under massed overwatch/reaction fire (and undo all my hard work to not just kill them outright already). However, I am perfectly okay with alien attempting to do something against his would-be captors (like shooting, using grenade or taking out whatever trick they still may have up in their sleeve).

Edited by Tycus
Link to comment
Share on other sites

  • Replies 144
  • Created
  • Last Reply

Top Posters In This Topic

 

Well, this is clearly an exploit (never have done this particular combination of actions myself). And what I mean in previous post, that I just do not want for aliens to try to flee and then senselessly die under massed overwatch/reaction fire (and undo all my hard work to not just kill them outright already). However, I am perfectly okay with alien attempting to do something against his would-be captors (like shooting, using grenade or taking out whatever trick they still may have up in their sleeve).

 

 

It is kind of specialized, so I imagine it's not a commonly used exploit.

 

The two fixes above appear to implement (partially via luck and partially via the previous excellent work by Firaxis in designing the AI) the rather ideal situation.

 

The one change closes the loophole where suppressing (but not overwatching) an enemy causes all non-move actions to be filtered from priority calculations -- thus grenades, shooting, etc all become priority-scored.

 

The other creates a back-up situation in case all other options have actually been closed off. In that case the unit flees, overriding the suppression-restriction on movement. In the example I had given the Muton had already thrown its grenade (dealing 4 points of damage to my Engineer, which my Medic healed before the Engineer went in) so it had no grenade charges left.

 

As long as my assault was present it had at least some valid shot option -- albeit only 8% hit chance. As soon as the Assault moved it had no valid shot options (Engineer wasn't valid because the unit was flanked and Engineer wasn't flanking), which prompted the unit to dash-move flee even though suppressed.

I think at that point that is really the only valid option. Overwatching doesn't make much sense because the units are already in position. Hunkering down doesn't help because the unit is already flanked. No grenades left. Only shots at flanking targets are 1% shots. So making the dash move is the remaining valid choice.

 

When I said that it was going to make captures harder, I suppose I meant "harder for me", because the aliens can't be locked into a 'no action' state any longer.

 

That's me -- fixing the exploits that I use :D

Link to comment
Share on other sites

I think at that point that is really the only valid option. Overwatching doesn't make much sense because the units are already in position. Hunkering down doesn't help because the unit is already flanked. No grenades left. Only shots at flanking targets are 1% shots. So making the dash move is the remaining valid choice.

 

When I said that it was going to make captures harder, I suppose I meant "harder for me", because the aliens can't be locked into a 'no action' state any longer.

 

That's me -- fixing the exploits that I use :biggrin:

I have to disagree on that "valid option" (mostly, because I play differently, and my mod is played differently). If alien has still functioning weapon - it should shoot (overwatch) anyway, if has not - well, tough luck for that alien. Besides, in my mod I don't think any alien would have 1% shot against target at stun range (even if said target is in high cover, and alien is being suppressed) because of close range aim bonus. Otherwise overwatch is valid option. However aliens should flee out of flanked/exposed position, if overwatch/reaction shots have low percentage to hit (65% or lower), or damage on successful hit is not guaranteed kill (ie if it is non-crit).

Edited by Tycus
Link to comment
Share on other sites

 

I have to disagree on that "valid option" (mostly, because I play differently, and my mod is played differently). If alien has still functioning weapon - it should shoot (overwatch) anyway, if has not - well, tough luck for that alien. Besides, in my mod I don't think any alien would have 1% shot against target at stun range (even if said target is in high cover, and alien is being suppressed) because of close range aim bonus. Otherwise overwatch is valid option. However aliens should flee out of flanked/exposed position, if overwatch/reaction shots have low percentage to hit (65% or lower), or damage on successful hit is not guaranteed kill (ie if it is non-crit).

 

 

Ah, I think the thing about the exploit you are missing is that a flanked alien is only allowed to shoot at targets that are flanking it. Even though my Engineer was quite close (a +29 to-hit bonus for range, yielding a 70 + 29 - 50 - 30 = 19% hit chance), because the Engineer was not flanking the Muton it's not allowed to shoot at the Engineer.

 

The AI is basically restricted from shooting at targets that aren't flanking it, even if the shot at the flanking target is 1% and the shot at a non-flanking target is 19%. I'm leery of trying to mess with this prioritization of flanking targets as I think it would create more problems than it solves.

 

The reason I say that overwatching isn't a valid option in that case is that all of the units are already in position -- no XCOM soldier have to move at all to accomplish anything. An already flanked unit choosing to overwatch isn't a great option generally. Unless of course all of the aliens have the Covering Fire perk ^_^.

 

There is code that adds to the Overwatch danger if the alien can be killed by a single shot already present.

 

I'm currently in the process of adding alien defense, Lightning Reflexes perk and damage reduction to the factors evaluated when determining the maximum danger. I'm a bit loathe to add the specific hit chances for the unit's as that starts to smack of "cheating" -- the AI knowing more about the XCOM units that it should. I'm already a bit skeptical about the function that evaluates whether an alien is at low health because it accesses the players possible damage stat, which is something that in general the XCOM player can't do for the aliens (without hacking into the DGC.ini, anyhow).

Link to comment
Share on other sites

Like we don't already remember all damage values for all alien weapons (I do), and just as likely we know about their aim values (for most alien types), so I don't see any "cheating" in that fix/change, at least with that AI can make some valid decisions.

Edited by Tycus
Link to comment
Share on other sites

Hmm, the more I think about this the more I agree that in hopeless situations like those described the alien should move even if it results in death by reaction fire.

 

I mean, what would a human player do? Sit there and overwatch only to be captured alive and grant XCOM a free pwngun?

 

It would mean that capturing is still possible against wounded aliens with friends on the field (thus increasing the risk and game-within-a-game for XCOM - always a good thing) but it would reduce the "last Alien is free RP and weapons" thing for experienced Arc Thrower laden squads.

 

I imagine it could result in some memorable gameplay moments too, with pinning a wounded rat only to have him bail and survive, getting the pin again and this time his dash results in reaction fire or suppression death.

 

"The one that got away".

 

I'm all for it.

Link to comment
Share on other sites

Like we don't already remember all damage values for all alien weapons already (I do), and just as likely we know about their aim values (for most alien types), so I don't see any "cheating" in that fix/change, at least with that AI can make some valid decisions.

 

Fair enough :smile:

 

Actually since there are possibly multiple units on overwatch, the AI "approximates" damage by only retrieving the damage stat for the first overwatching unit, ignoring the rest. It is also based purely on the equipped weapon's damage stat, which for Long War leaves out a host of perks and items that can boost damage, but I think that's generally fair.

 

However, it does bring up the difficulty in computing a correct statistical chance of being hit given a variety of units with different to-hit values possible. So, I'm thinking of making the AI somewhat pessimistic and assume that all XCOM units have pretty good to-hit values (I think this kind of mirrors my pessimistic thinking when I consider moving units when aliens are overwatching).

 

----------------------------------

 

Here's my initial concept for adjusting the overwatch danger :

 

The overwatch danger is designed to be evaluated on a scale of 0 to 3. This is from the vanilla code, and I'm not planning on changing it. In vanilla the overwatch danger is based on the number of overwatching units at close or far range. Difference between close and far is a function of the current difficulty, with Classic and Impossible setting it at 90% of visual range. Ironically this means that a single unit overwatching within 24.3 distance (16.2 tiles) counts as "overwatch danger" 3 -- the maximum.

 

This makes it easier to lock down aliens on Classic and Impossible, but makes it less likely that aliens will die to overwatch on Classic / Impossible.

 

Here is my proposed change to how overwatch danger is assessed :

if(m_arrEnemiesInOverwatch.Length == 0)
{
	return 0;
}
if(kUnit != none)
{
	bLowHP = IsAtLowHealth(kUnit, m_arrEnemiesInOverwatch[0]);
}
fHitChance = float(70 - m_kUnit.GetDefense())/100.0; 
if(m_kUnit.IsFlying())
{
	fHitChance -= 0.2;
}
foreach m_arrEnemiesInOverwatch(kEnemy,)
{
	if(!kEnemy.IsAliveAndWell())
	{
		continue;            
	}
	fDist = VSizeSq(kEnemy.Location - vLocation);
	if(fDist < 409600.0) // 640.0 ^2 -- 10 distance
	{
		fOverwatchAttacks += 1.5;
		continue;
	}
	if(fDist < 2985984.0) // 1728.0 ^2 -- 27 distance
	{
		fOverwatchAttacks += 1.0;
	}        
}
fDamageReductionFactor = (1.0 - 0.05 * float(m_kUnit.m_aCurrentStats[4])); // m_aCurrentStats[4] holds damage reduction
nOverwatchHits = int(fOverwatchAttacks * fHitChance * fDamageReductionFactor + 0.9);
if(bLowHP)
{
	nOverwatchHits *= 2.0;
}
if(m_kUnit.m_kCharacter.CharacterHasUpgrade(35)) // Lightning Reflexes
{
	nOverwatchHits -= 1;
}
return Min(3, nOverwatchHits);

The range factor is now severely reduced.

 

Factors:

  • The AI generally assumes that XCOM units have a base 90 offense (from levels and items), and assumes the -20 reaction fire penalty (making Opportunist generally a "surprise")
  • The AI subtracts its defense score, including flying bonuses. Dashing is not assumed.
  • Close Range units (within 10 distance, or 6.7 tiles) count as 1.5 shots to simulate range bonuses.
  • Damage Reduction acts as a multiplicative factor reducing "effective shots" by 5% per point of DR. (if a unit has 20 points of DR then it should pretty much ignore overwatch :smile: )
  • The AI then estimates the number of effective overwatch hits, based on number of attacks, hit chance, and DR. This is rounded up (pessimistically) when converted to integer.
  • This expected number of hits is the "overwatch danger"
  • Units with low HP (low enough to be killed by the first overwatcher) double the overwatch danger.
  • Lightning Reflexes subtracts 1 from the overwatch danger

Generally speaking a unit is not allowed to move if the overwatch danger is 2 or greater. In XGAIBehavior.ShouldAvoidMovement :

    if(m_iOverwatchDangerZone > (GetMaxDangerLevelForMovement()))
    {
        return true;
    }

GetMaxDangerLevelForMovement returns 2 for Easy Difficulty and 1 for Normal or higher, and 3 if the unit is set to ignore overwatchers (in vanilla is Chryssalids, Zombies and Sectopods).

 

This means that on Normal +, movement is filtered from priority calculations only if there are 2 expected hits.

 

Further ways that the OverwatchDanger is used :

  • In XGAIPlayer, when the AI is sorting the order that units will execute, units with lower overwatch danger are prioritized to act first. (function is XGAIPlayer.CompareProxInfoOrderBefore)
  • In XGAIAbilityDM.AI_GetScoreModifier, the total move priority is de-weighted based on the OverwatchDanger, using :
    if(kAbility.GetType() == 1)
    {
        if(!m_kBehavior.m_bIgnoreOverwatchers && m_kBehavior.m_iOverwatchDangerZone > 0)
        {            
            fModifier *= (0.30 / float(m_kBehavior.m_iOverwatchDangerZone));
        }
    }

Note that this code reflects the divide-by-zero error fix described earlier in this thread.

 

----------------------

 

Some examples :

 

A Sectoid with no defense bonus, no DR, no lightning reflexes:

Overwatched by 1 unit at distance > 7 tiles

fHitChance = 0.7;

fOverwatchAttacks = 1.0

nOverwatchHits = 1

If the Sectoid can take a hit, then it is not prevented from moving

If the sectoid can be killed by an average hit from an XCOM weapon then doubled to 2 and the sectoid is prevented from moving

 

Overwatched by 1 unit at close range < 7 tiles

fHitChance = 0.7

fOverWatchAttacks = 1.5

nOverwatchHits = 2

A sectoid overwatched by a unit at close range will be prevented from moving

 

Overwatched by 2 units at long range

fHitChance = 0.7

fOverwatchAttacks = 2.0

nOverwatchHits = 2

A sectoid overwatched by two units will be prevented from moving

 

 

Floater with +20 flying defense bonus

overwatched by 2 units :

fHitChance = 0.5

fOverwatchAttacks = 2.0

nOverwatchHits = 1

If not injured a flying floater can still move if overwatched by 2 units

If floater can be killed by 1 shot, then it is prevented from moving if overwatched by 2 units

 

Cyberdisc with +20 flying bonus and 2 damage reduction

overwatched by 3 units :

fHitChance = 0.5

nOverwatchAttacks = 3.0

fDamageReductionFactor = 0.9

nOverwatchHits = int(0.5 * 3.0 * 0.9 + 0.9) = 2

A cyberdisc overwatched by 3 units is prevented from moving

 

Muton with 10 defense bonus and Lightning Reflexes perk

overwatched by 2 units :

fHitChance = 0.6

fOverwatchAttacks = 2.0

nOverwatchHits = 2

If can be one-shot, is increased to 4

Lightning Reflexes reduces to 1 or 3. If uninjured, it can move. If injured, it is prevented from moving

 

overwatched by 3 units :

fHitChance = 0.6

fOverwatchAttacks = 3.0

nOverwatchHits = 2

Similar to 2 units overwatching. Unit can move if not too injured

Link to comment
Share on other sites

I mean, what would a human player do? Sit there and overwatch only to be captured alive and grant XCOM a free pwngun?

The stun may fail anyway and I meant overwatch as response to situation, where trooper with stunner is not yet close enough (because if he is in range, shot will have more than 1% to hit due to close range bonus and alien would have just shot him point blank to the face).

 

Let's just not continue this pointless debate (and agree that this is matter of personal opinion on a subject) and do something useful instead (like Amineri just did, when I was writing this reply).

Edited by Tycus
Link to comment
Share on other sites

There are two changes I posted up regarding Suppression.

The first I consider a bug fix, as vanilla prevented a unit that was suppressed and flanked (but not overwatched) from taking any action other than Launch. I really don't plan on any tweaks to this. I think that preventing suppressed units from moving may not be optimal from a game theory perspective, but is balanced in terms of gameplay, as it adds value to the Suppression perk (and overwatch is freely available to all units).

 

The second I consider a modlet, as it's a stylistic design change that appeals to some and not to others. Either way creates an interesting play experience, just in different ways. For this I'm open to ideas and suggestions on how to make it work differently (not better, just different), though I can't promise that I'll implement any particular suggestion.

 

---------------------------

 

Moving on the the overwatch changes, I'm considering adding the unit's aggression factor into the equation.

 

Each unit gets a randomized aggression built into its behavior, using :

    fAggroRange = m_fMaxAggro - m_fMinAggro;
    m_fAggression = (class'XComEngine'.static.SyncFRand() * fAggroRange) + m_fMinAggro;

m_fMinAggro is set by default to 0.0 , but the following aliens have a higher value:

  • Chryssalid : m_fMinAggro = 0.60
  • Floater : m_fMinAggro = 0.50
  • Muton : m_fMinAggro = 0.60
  • Sectoid : m_fMinAggro = 0.80
  • Sectoid Commander : m_fMinAggro = 0.80
  • Sectopod : m_fMinAggro = 0.80

m_fMaxAggro is set to 1.0 for all aliens.

 

The resultant randomized m_fAggression is saved as a part of the CheckpointRecord, but does not appear to be used anywhere. My thought is to use the unit's aggression as a factor in the degree to which it will ignore overwatchers. Nothing too drastic, just a bit more reckless.

 

However, I'm a bit confused by the high aggression settings on Sectoids and Sectoid Commanders. Note that sectoids that have initiated a mindmerge get m_bKeepHidden set to true, which overrides any other consideration aggression, I'm pretty sure (it's what makes those sectoids hide in the back).

Link to comment
Share on other sites

Moving on the the overwatch changes, I'm considering adding the unit's aggression factor into the equation.

  • Chryssalid : m_fMinAggro = 0.60
  • Floater : m_fMinAggro = 0.50
  • Muton : m_fMinAggro = 0.60
  • Sectoid : m_fMinAggro = 0.80
  • Sectoid Commander : m_fMinAggro = 0.80
  • Sectopod : m_fMinAggro = 0.80

m_fMaxAggro is set to 1.0 for all aliens.

 

The resultant randomized m_fAggression is saved as a part of the CheckpointRecord, but does not appear to be used anywhere. My thought is to use the unit's aggression as a factor in the degree to which it will ignore overwatchers. Nothing too drastic, just a bit more reckless.

 

However, I'm a bit confused by the high aggression settings on Sectoids and Sectoid Commanders. Note that sectoids that have initiated a mindmerge get m_bKeepHidden set to true, which overrides any other consideration aggression, I'm pretty sure (it's what makes those sectoids hide in the back).

Is good addition, as it adds a bit of unpredictability to the game. So were are those values listed? And can we tweak them as well?

Edited by Tycus
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...