ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

The Threat System

From ModEnc
Revision as of 08:42, 27 November 2009 by EvilRenegade (talk | contribs) (Replacing Template:TTL with Template:F.)
Jump to navigation Jump to search

The threat evaluation system was supposed to make the AI appear more 'intelligent' by targeting the more important threats first. In early development stages of Tiberian Sun this was planned as a Superweapon for GDI, but was scrapped, although the logic in all its incomplete glory remains in all later games up to and including Yuri's Revenge. As with various other logics, there is a lot of speculation surrounding this system.

Related INI Flags

IsThreatRatingNode
when a Building with this flag set is placed, its owner gains the "threat rating node" which is supposed to be the activator of the intelligent threat analysis logic. Through a bug in the game code, once a house gains this ability, it will not lose it even when the building in question is destroyed.
[General]EnemyHouseThreatBonus=
An additional weight applied when the owner of the targeted unit is the house's selected enemy house.

The threat rating system also relies on multiple floating-point coefficients that can be applied to each unit describing its "effectiveness" and reliance on external factors such as distance from the target. These coefficients have two values, one applied under normal circumstances and one applied when the owner house has the "Threat Rating Node".


Per-unit floating-point coefficients
Coefficient name Flag name with ThreatRatingNode Flag name without ThreatRatingNode
Self Effectiveness [unit]→MyEffectivenessCoefficient [General]DumbMyEffectivenessCoefficient=
Target Effectiveness [unit]→TargetEffectivenessCoefficient [General]DumbTargetEffectivenessCoefficient=
Special Threat Coefficient [unit]→TargetSpecialThreatCoefficient [General]DumbTargetSpecialThreatCoefficient=
Special Threat Value [unit]→SpecialThreatValue [unit]→SpecialThreatValue
Target Strength [unit]→TargetStrengthCoefficient [General]DumbTargetStrengthCoefficient=
Target Distance [unit]→TargetDistanceCoefficient [General]DumbTargetDistanceCoefficient=

Threat Calculation

The basic algorithm estimating how much threat a certain object (Attacker) poses to a Defender works like this:

float Threat = Attacker's best weapon's Verses against Defender * Target Effectiveness;
if(Attacker is currently targeting Defender) { // don't look at me, I didn't write the code
  Threat = Threat * (-1);
}

float tempValue = Special Threat Value * Special Threat Coefficient;
Threat = Threat + tempValue;

if(Defender is currently considering Attacker's owner house as the Enemy House) {
  Threat = Threat + [General]EnemyHouseThreatBonus=;
}

tempValue = Defender's best weapon's Verses against Attacker * Self Effectiveness;
Threat = Threat + tempValue;

tempValue = Target Strength * Attacker's current health percentage;
Threat = Threat + tempValue;

tempValue = Target Distance * Distance between Defender and Attacker;
Threat = Threat + tempValue;

Threat = Threat + 100000.0;

Applicability

The threat rating logic is utilised when the object is selecting a target freely and when it is deciding whether or not to retaliate. However, both of those decisions are very complex and depend on a lot of other variables.