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

AI: Difference between revisions

From ModEnc
Jump to navigation Jump to search
No edit summary
Nighthawk200 (talk | contribs)
Major reworking of page using the Styleguide
Line 14: Line 14:


=General information about RA2/YR's Artificial Intelligence=
=General information about RA2/YR's Artificial Intelligence=
{{Cleanup}}
 
'''Allied General'''
'''Allied General's information on the AI'''


RA2/YR AI Engine is based upon the AI engine used in TS.
RA2/YR AI Engine is based upon the AI engine used in TS.
Line 26: Line 26:
* it actions are based upon predetermined "scripts" and "events"
* it actions are based upon predetermined "scripts" and "events"


However implementation of pool teams, [AIGenerals] (mainly for RA2) and a significant amount of modfication to taskforces and teamtypes can deliver an impressive AI as seen in Deezire's RA2 modification.
However implementation of pool teams, <tt>[[AIGenerals|[AIGenerals]]]</tt> (mainly for RA2) and a significant amount of modfication to taskforces and teamtypes can deliver an impressive AI as seen in Deezire's RA2 modification.


For more information vist [http://www.deezire.net/ Deezire Online] register and download his editing guide and read the word doc AI


'''Kiith-Sa's information on the rulesmd.ini AI tags'''


'''Kiith-Sa'''


* <tt>[[CloseEnough|CloseEnough=]]</tt> - If your big taskforces get stuck, increase this.


* CloseEnough= If your big taskforces get stuck, increase this.
* <tt>[[Stray|Stray=]]</tt>          - If you want to use bigger TaskForces, increase this. Recommended: 4-5.


* Stray=         ;If you want to use bigger TaskForces, increase this. ;Recommended:4-5.
* <tt>[[RelaxedStray|RelaxedStray=]]</tt>  - Increasing this prevens big TaskForces to get stuck at regroup and gather command. Recommended: 5-7.


* RelaxedStray=   ;Increasing this prevens big TaskForces to get stuck at regroup and gather command. ;Recommended:5-7.
* <tt>[[GuardModeStray|GuardModeStray=]]</tt> - Again, if you want to use bigger TaskForces, increase this. Recommended: 3-4.


* GuardModeStray= ;Again, if you want to use bigger TaskForces, increase this. ;Recommended:3-4.
* <tt>[[TeamDelays|TeamDelays=]]</tt>        - This number says how often the AI checks for creating a TeamType in frames. Decreasing it is maybe the best thing you can ever do for the AI. Brutal, Medium, Easy. Recommended: <100.


* TeamDelays=         ;This number says how often the AI checks for creating a TeamType in frames. Decreasing it is maybe the best thing you can ever do for the AI. Brutal, Medium, Easy. Recommended: Under 100.
* <tt>[[AIHateDelays|AIHateDelays=]]</tt>      - Delay in frames before AI chooses an enemy. Keep it low.


* AIHateDelays=       ;Delay in frames before AI chooses an enemy. Keep it low.
* <tt>[[MultiplayerAICM|MultiplayerAICM=]]</tt>    - Percent of addition money for AI. If you want your AI to have plenty of money, increase, but have more dogs guarding AI bases becouse if player's spy gets into an AI refinery, he gets a LOT of money. Brutal, Medium, Easy.


* MultiplayerAICM=   ;Percent of addition money for AI. If you want your AI to have plenty of money, increase, but have more dogs guarding AI bases becouse if player's spy gets into an AI refinery, he gets a LOT of money. Brutal, Medium, Easy.
* <tt>[[AIVirtualPurifiers|AIVirtualPurifiers=]]</tt> - Same as above. 1 gives 25% bonus to money. Brutal, Medium, Easy.


* AIVirtualPurifiers= Same as above. 1 gives 25% bonus to money. Brutal, Medium, Easy.
* <tt>[[HarvestersPerRefinery|HarvestersPerRefinery=]]</tt> - Do not edit this. Only one AI will build additional harvesters and others will get stuck.


* HarvestersPerRefinery= Do not edit this. Only one AI will build additional harvesters and others will get stuck.
* <tt>[[AIExtraRefineries|AIExtraRefineries=]]</tt> - Same as above, but decreasing this can give AI more free space in base, and AI can replace a refinery fast. (but it also has less harvesters then, and less money) If you have big TaskForces and need space in base, decrease to 0,0,0 and increase AICM or VirtualPurifiers.


* AIExtraRefineries= Same as above, but decreasing this can give AI more free space in base, and AI can replace a refinery fast. (but it also has less harvesters then, and less money) If you have big TaskForces and need space in base, decrease to 0,0,0 and increase AICM or VirtualPurifiers.
* <tt>[[MinimumAIDefensiveTeams|MinimumAIDefensiveTeams=]]</tt> - Minimum number of <tt>[[IsBaseDefense|IsBaseDefense=yes]]</tt> TeamTypes AI will build. If it is higher than max number of <tt>[[IsBaseDefense|IsBaseDefense=yes]]</tt> TeamTypes AI can build, it will get stuck causing Soviet (But if high enough, also Allied and Yuri) dead AI issue. To prevent this, just make more <tt>[[IsBaseDefense|IsBaseDefense=yes]]</tt> Teamtypes or increase their <tt>[[Max|Max=]]</tt>. Recommended:3-5.


* MinimumAIDefensiveTeams= Minimum number of IsBaseDefense=yes TeamTypes AI will build. If it is higher than max number of IsBaseDefense=yes TeamTypes AI can build, it will get stuck causing Soviet (But if high enough, also Allied and Yuri) dead AI issue. To prevent this, just make more IsBaseDefense=yes Teamtypes or increase their Max=. Recommended:3-5.
* <tt>[[MaximumAIDefensiveTeams|MaximumAIDefensiveTeams=]]</tt> - Maximum number of <tt>[[IsBaseDefense|IsBaseDefense=yes]]</tt> TeamTypes the AI will build. Should be higher than minimum. Recomennded:5-7.


* MaximumAIDefensiveTeams= Maximum number of IsBaseDefense=yes TeamTypes AI will build. Should be higher than minimum. Recomennded:5-7.
* <tt>[[TotalAITeamCap|TotalAITeamCap=]]</tt> - Maximum of teams used by AI. Good idea to increase, but not too much if you haven't done something to give the AI more free space.


* TotalAITeamCap= Maximum of teams used by AI. Good idea to increase, but not too much if you haven't done something to give the AI more free space.
The following tags are the absolute ordering of targets when AI fires a Weather Storm or Nuclear Missile.<br>
Basic tag description:


* AIIonCannonxxxValue= Absolute ordering of targets when AI fires Weather Storm or Nuke.  
* <tt>[[AIIonCannonConYardValue|AIIonCannonConYardValue=]]</tt>  - Value of buildings with <tt>[[ConstructionYard|ConstructionYard=yes]]</tt>
Descripion:
* <tt>[[AIIonCannonWarFactoryValue|AIIonCannonWarFactoryValue=]]</tt> - Value of buildings with <tt>[[WeaponsFactory|WeaponsFactory=yes]]</tt>
* <tt>[[AIIonCannonPowerValue|AIIonCannonPowerValue=]]</tt>      - Value of buildings with <tt>[[Power|Power=]]</tt> above 0
* <tt>[[AIIonCannonTechCenterValue|AIIonCannonTechCenterValue=]]</tt> - Value of BattleLabs
* <tt>[[AIIonCannonEngineerValue|AIIonCannonEngineerValue=]]</tt>  - Value of Engineers
* <tt>[[AIIonCannonThiefValue|AIIonCannonThiefValue=]]</tt>      - Value of Thieves (Logic still present in RA2)
* <tt>[[AIIonCannonHarvesterValue|AIIonCannonHarvesterValue=]]</tt>  - Value of Harvesters
* <tt>[[AIIonCannonMCVValue|AIIonCannonMCVValue=]]</tt>        - Value of MCVs
* <tt>[[AIIonCannonAPCValue|AIIonCannonAPCValue=]]</tt>        - Value of Transports
* <tt>[[AIIonCannonBaseDefenseValue|AIIonCannonBaseDefenseValue=]]</tt> - Value of buildings with <tt>[[IsBaseDefense|IsBaseDefense=yes]]</tt>
* <tt>[[AIIonCannonPlugValue|AIIonCannonPlugValue=]]</tt>      - Value of buildings with <tt>[[IsPlug|IsPlug=yes]]</tt>-if you give <tt>[[IsPlug|IsPlug=yes]]</tt> to for example, SWs,this is their value. Of course, you must delete the comment first, or you get an IE.
* <tt>[[AIIonCannonHelipadValue|AIIonCannonHelipadValue=]]</tt>  - Value of buildings with <tt>[[HoverPad|HoverPad=yes]]</tt>. Deleting the comment fixes HoverPad SW targeting IE.
* <tt>[[AIIonCannonTempleValue|AIIonCannonTempleValue=]]</tt>    - Value of buildings with <tt>[[IsTemple|IsTemple=yes]]</tt>. Same as with Plug. Tip- use for SWs,refineries or with Purifiers/Vats/Plants


* AIIonCannonConYardValue=   Value of buildings with ConstructionYard=yes
* <tt>[[AISafeDistance|AISafeDistance=]]</tt> - Distance from enemy/own base at which AI will execute the gather/regroup command. If your AI builds large bases, increase.    
* AIIonCannonWarFactoryValue= Value of buildings with WeaponsFactory=yes
* AIIonCannonPowerValue=      Value of buildings with Power= above 0
* AIIonCannonTechCenterValue= Value of BattleLabs
* AIIonCannonEngineerValue=  Value of Engineers
* AIIonCannonThiefValue=      Value of Thiefs (Logic still present in RA2)
* AIIonCannonHarvesterValue=  Value of Harvesters
* AIIonCannonMCVValue=        Value of MCVs
* AIIonCannonAPCValue=        Value of Transporters
* AIIonCannonBaseDefenseValue=Value of buildings with IsBaseDefense=yes
* AIIonCannonPlugValue=      Value of buildings with IsPlug=yes-if you give IsPlug=Yes to for example, SWs,this is their value. Of course, you must delete the comment first, or you get an IE.  
* AIIonCannonHelipadValue=  Value of buildings with HoverPad=yes. Deleting the comment fixes HoverPad SW targeting IE.
* AIIonCannonTempleValue=    Value of buildings with IsTemple=yes. Same as with Plug. Tip- use for SWs,refineries or with Purifiers/Vats/Plants


* AISafeDistance= Distance from enemy/own base at which AI will execute the gather/regroup command. If your AI builds large bases, increase.    
* <tt>[[AIMinorSuperReadyPercent|AIMinorSuperReadyPercent=]]</tt>  - If Iron Curtain or Chronosphere is this charged, AI will start preparing teams which make use of it. Decrease if you have long-building Chrono or Curtain teams.  


* AIMinorSuperReadyPercent=  If Iron Cortain or ChronoSphere is this charged, AI will start preparing teams which make use of it. Decrease if you have long-building Chrono or Curtain teams.  
* <tt>[[AlliedBaseDefenseCounts|AlliedBaseDefenseCounts=]]</tt>
* <tt>[[SovietBaseDefenseCounts|SovietBaseDefenseCounts=]]</tt>
* <tt>[[ThirdBaseDefenseCounts|ThirdBaseDefenseCounts=]]</tt>
* Notes on BaseDefenseCounts tags:  Numbers are ordered Brutal, Medium, Easy. These are the number of defense buildings the AI will build for each side. If these are too high, AI just builds defenses and somehow forgets other buildings, also it then builds defense "chains". If you get total control of what AI builds when, then set defenses to be build later, increase this number to a very high number like 100, and you have nice ring of defenses around the AI base. If you want AI to have many defenses, but it always builds those chains, you can simply disable defenses and use tons of cloned buildings, that allows you to control when AI builds each building including defenses and things like sending SHK to all TESLA thanks to different building IDs.  


* AlliedBaseDefenseCounts= Brutal, Medium, Easy. Number of defense builddings the AI will build
* <tt>[[AISuperDefenseProbability|AISuperDefenseProbability=]]</tt> - Probability that AI will use the Force Shield when attacked by major SWs. Recommended:99
* SovietBaseDefenseCounts= for each side. If too high, AI just builds defenses and somehow
* ThirdBaseDefenseCounts=  forgets other buildings, also it then  builds defense "chains". If you get total control of what AI builds when, then set defenses to be build later, increase this number to a very high number like 100, and you have nice ring of defenses around the AI base. If you want AI to have many defenses, but it always builds those chains, you can simply disable defenses and use tons of cloned buildings, that allows you to control when AI builds each building including defenses and things like sending SHK to all TESLA thanks to different building IDs.  


* AISuperDefenseProbability= Propability that AI will use ForceShield when attacked by major  
* <tt>[[AISuperDefenseFrames|AISuperDefenseFrames=]]</tt> - If the Force Shield is not ready when AI is attacked by major SWs, it can wait maximally this long or it will not fire. Set to as high as is the shortest delay before nuke hits, storm starts etc.  
SWs. Recommended:99


* AISuperDefenseFrames= If ForceShield is not ready when AI is attacked by major SWs, it can wait maximally this long or it will not fire. Set to as high as is the shortest delay before nuke hits, storm starts etc.  
* <tt>[[NodRegularPower|NodRegularPower=]]</tt>
* <tt>[[GDIPowerPlant|GDIPowerPlant=]]</tt>
* <tt>[[ThirdPowerPlant|ThirdPowerPlant=]]</tt>
* Notes on the PowerPlant tags: These list the power plants that are built by the AI when it needs more power (All powerplants AI builds are this, except first one). It is a good idea to set this to the powerplant with highest <tt>[[Power|Power=]]</tt> your mod has for that side, even for the Soviets (having NANRCT is risky, but it saves much space) If you want AI to have more space, make high output powerplant for every side and set this to it.


* NodRegularPower= Power plants that is built by the AI when it needs more power (All powerplants AI builds are this, except first one)
* GDIPowerPlant=    It is a good idea to set this to the
* ThirdPowerPlant= powerplant with highest Power= your mod has for that side, even for the Soviets (having NANRCT is risky, but it saves much space) If you want AI to have more space, make high output powerplant for every side and set this to it.


* A note to [BuildingTypes]:
* A note on <tt>[[BuildingTypes|[BuildingTypes]]]</tt>:
As jkraska discovered, AI goes down trough the building type list building buildings as they  
As jkraska discovered, AI goes down trough the building type list building buildings as they  
are listed here. If it can't build next building, it starts again checking for its  
are listed here. If it can't build next building, it starts again checking for its  
Prerequisites=. This means, that if you have GAWEAT higher in list than GACSPH, like:
<tt>[[Prerequisite|Prerequisites=]]</tt>. This means, that if you have GAWEAT higher in list than GACSPH, like:


17=GAWEAT
<tt><pre>17=GAWEAT
...
...
22=GACSPH
22=GACSPH</pre></tt>


,it will build Weather Conrol first and Chronosphere later.  
it will build Weather Conrol first and Chronosphere later.  
Of course it builds only buildings with AIBuildThis=yes.
Of course it builds only buildings with <tt>[[AIBuildThis|AIBuildThis=yes]]</tt>.
Trough playing with building clones, changing positions of buildings in this list,  
Through playing with building clones, changing positions of buildings in this list,  
and Prerequisites, you can get pretty good control of what AI builds when,  
and Prerequisites, you can get pretty good control of what AI builds when,  
but you will mess up ScriptTypes and have to fix them.
but you will mess up <tt>[[ScriptTypes|ScriptTypes]]</tt> and have to fix them.
 


* BuildXXX:All of these read only 1 building per side including ConcreteWalls.


* BuildConst= ;Have all your Construction Yards here.
* <tt>BuildXXX</tt> - All of these read only 1 building per side including <tt>[[ConcreteWalls]]</tt>.
* BuildPower= ;This is the first powerplant AI builds. You can have NANRCT here if you want,
but it will look strange. Also, this reads only one power plant per side so having here both 
NAPOWR and NANRCT just builds NAPOWR.


* BuildRefinery= ;Have all your refineries here, even if they use Slave Miner logic.
* <tt>[[BuildConst|BuildConst=]]</tt> - Have all your Construction Yards here.
* BuildBarracks= ;Have all your barracks here.
* <tt>[[BuildPower|BuildPower=]]</tt> - This is the first powerplant AI builds. You can have NANRCT (the Nuclear Reactor) here if you want, but it will look strange. Also, this reads only one power plant per side so having here both NAPOWR (regular Tesla Reactor) and NANRCT just builds NAPOWR.
* BuildTech=    ;Have all your Battle Labs here.
* <tt>[[BuildRefinery|BuildRefinery=]]</tt> - Have all your refineries here, even if they use Slave Miner logic.
* BuildWeapons=  ;Have all your War Factories here
* <tt>[[BuildBarracks|BuildBarracks=]]</tt> - Have all your barracks here.
* BuildRadar=    ;Have all your Radars here
* <tt>[[BuildTech|BuildTech=]]</tt>     - Have all your Battle Labs here.
* ConcreteWalls= ;Have all your walls here. These will be built around ProtectWithWall  
* <tt>[[BuildWeapons|BuildWeapons=]]</tt> - Have all your War Factories here
buildings, so if you replace GAWALL by GAPILL, it will build pillboxes around those buildings  
* <tt>[[BuildRadar|BuildRadar=]]</tt>   - Have all your Radars here
(And AI will be slower than ever before)
* <tt>[[ConcreteWalls|ConcreteWalls=]]</tt> - Have all your walls here. These will be built around ProtectWithWall buildings, so if you replace GAWALL (Allied Walls) with GAPILL (Allied Pillbox, it will build pillboxes around those buildings and the AI will be slower than ever before.
* BuildNavalYard=;Have all your Naval Yards here.
* <tt>[[BuildNavalYard|BuildNavalYard=]]</tt> - Have all your Naval Yards here.


* BuildDefense=  ;Used for standard defenses, but obsolete in YR
* <tt>[[BuildDefense|BuildDefense=]]</tt> - Used for standard defenses, but obsolete in YR
* BuildPDefense= ;Used for power consuming defenses, obsolete in YR
* <tt>[[BuildPDefense|BuildPDefense=]]</tt> - Used for power consuming defenses, obsolete in YR
* BuildAA=      ;Used for AA defenses, obsolete in YR
* <tt>[[BuildAA|BuildAA=]]</tt>       - Used for AA defenses, obsolete in YR


* AlliedBaseDefenses=  
* <tt>[[AlliedBaseDefenses|AlliedBaseDefenses=]]</tt>
* SovietBaseDefenses=
* <tt>[[SovietBaseDefenses|SovietBaseDefenses=]]</tt>
* ThirdBaseDefenses=
* <tt>[[ThirdBaseDefenses|ThirdBaseDefenses=]]</tt>
Have your defense buildings here. This can take unlimited number of these buildings,  
Have your defense buildings listed here. This can take unlimited number of these buildings,  
buildings listed here ignore BuildLimit and if you set it for country specific buildings like  
buildings listed here ignore BuildLimit and if you set it for country specific buildings like  
GTGCAN, it will build them for the whole side, that is why some modders prefer to clone Grand  
GTGCAN (French Grand Cannnon), it will build them for the whole side, that is why some modders prefer to clone Grand Cannon. Maximum of these buildings built is specified by XXXBaseDefenseCounts=, numbers of specific buildings built change with <tt>[[AIForcePredictionFudge]]</tt> and their AntiXXXValue.
Cannon. Maximum of these buildings built is specified by XXXBaseDefenseCounts=,  
numbers of specific buildings built change with AIForcePredictionFudge and their AntiXXXValue.


* AIForcePredictionFudge= AI chooses its defenses by analyzing units of player it chose as its  
* <tt>[[AIForcePredictionFudge|AIForcePredictionFudge=]]</tt> - AI chooses its defenses by analyzing units of player it chose as its enemy, and make weighted distribution of defense based on their AntiXXXValue. It is good to try to experiment with this value, sometimes lower can be better than higher, and combine this with extreme changes in defenses AntiXXXValues.
enemy, and make weighted distribution of defense based on their AntiXXXValue. It is good to try to experiment with this value, sometimes lower can be better than higher, and combine this with  
extreme changes in defenses AntiXXXValues.


* MaximumBaseDefenseValue= Comments in Rulesmd say it is obsolete, but changing this to very high values (like 4000) can have interesting results, but it will make AI concentrate on building  
* <tt>[[MaximumBaseDefenseValue|MaximumBaseDefenseValue=]]</tt> - Comments in Rulesmd say it is obsolete, but changing this to very high values (like 4000) can have interesting results, but it will make AI concentrate on building defenses only and so you need again more control of what AI builds when.
defenses only and so you need again more control of what AI builds when.


* CreditReserve= ;AI will repair building only if it has more than this credits.
* <tt>[[CreditReserve|CreditReserve=]]</tt> - AI will repair buildings only if it has more than this amount of credits.


* PowerSurplus= ;AI will build power plants until it has this surplus.
* <tt>[[PowerSurplus|PowerSurplus=]]</tt> - AI will build power plants until it has this amount of surplus power.


* BaseSizeAdd=  ;Increasing this to very high numbers can make AI build huge bases,  
* <tt>[[BaseSizeAdd|BaseSizeAdd=]]</tt> - Increasing this to very high numbers can make AI build huge bases, but only increases number of power plants and defenses as it cannot build more factories or refineries. You should increase it if you increased XXXBaseDefenseCounts=.
but only increases number of power plants and defenses as it cannot build more factories or  
refineries. You should increase it if you increased XXXBaseDefenseCounts=.


* PowerEmergency= ;AI will sell buildings if it has less than this percent of power.
* <tt>[[PowerEmergency|PowerEmergency=]]</tt> - AI will sell buildings if it has less than this percent of power.


* AIBaseSpacing= ;This is average space AI will leave between its buildings.  
* <tt>[[AIBaseSpacing|AIBaseSpacing=]]</tt> - This is average space AI will leave between its buildings.  
Increase only if you have only few buildings or replaced maps with some that have more space  
Increase only if you have only few buildings or replaced maps with some that have more space  
for bases or in map files.
for bases or in map files.


* [AIGenerals] ;This section was supposed for TS, but never finished. To make use of it,  
* <tt>[[AIGenerals|[AIGenerals]]]</tt> - This section was meant to be used in TS, but was never finished. To make use of it, you must get the AI.TLB file from TS and if you are modding YR, rename it to AIMD.TLB. You must place it into RA2 directory and then you can uncomment it with no IE. These CLSID tags are actually 5 Generals, different behaviours AI can have, something like bots. You need to use TriggerTypes (I'm not talking about TeamTypes here) IsBaseDefense and then you will find a new problem. Allies are attacking Soviets and vice versa, but Allies vs Allies is one really boring match, as they are doing almost nothing. To fix this bug, you must write MANY triggers attacking specific sides (not Attack Factories, but Attack Enemy NACNST for Soviets  etc.) an if you do this, you can have better and more unpredictable AI, but Yuri is unchanged, as this was meant for GDI and Nod in TS, which are still the references for the Allies and Soviets in rules(md).ini. This section could maybe also have something with an unknown part of TriggerTypes, where Deezire says, that you could specify which General uses this Trigger. Anyway, this section is really hard work and you need to be really sure you want to do this.  Still, if you thik you are an AI expert, you can try. I think Deezire used it in his mod, but I'm not sure.  
you must get AI.TLB file from TS and if you are modding YR, rename it to AIMD.TLB .  
You must place it into RA2 directory and then you can uncomment it with no IE.  
This section are actoally 5 Generals, different behaviours AI can have,  
something like bots. You need to use TriggerType (I'm not talking about TeamType here) BaseDefense and then you will find a new problem.  
Allies are attacking Soviets and vice versa, but Allies vs Allies is one really boring match,
as they are doing almost nothing. To fix this bug, you must write MANY triggers attacking  
specific sides (not Attack Factories, but Attack Enemy NACNST for Soviets  etc.)  
an if you do this, you can have better and more unpredictable AI, but Yuri is unchanged,  
as this was meant for GDI and Nod. This section could maybe also have something with unknown  
part of TriggerTypes, where Deeyire says, that it could specify which General uses this  
Trigger. Anyway, this section is a really hard work and you need to be really sure you want to  
do this.  Still, if you thik you are an AI expert, you can try.  
I think Deezire used it in his mod, but I'm not sure.  




* AI Tips: By increasing RepairPercent= and lowering RepairRate= you'll get faster but more  
* AI Tips: By increasing <tt>[[RepairPercent|RepairPercent=]]</tt> and lowering <tt>[[RepairRate|RepairRate=]]</tt> you'll get faster but more costly structure repair, with cost that is propably still no harm for AI and it makes AI much more annoying as it repairs everything under attack if it has enough money.
costly structure repair, with cost that is propably still no harm for AI and it makes AI  
much more annoying as it repairs everything under attack if it has enough money.




AI(MD).INI TIPS:
AI(MD).INI TIPS:
1:AI wont deploy Siege Chopper.  
1: AI wont deploy the Siege Chopper.  
If you want to make AI use it, you must make it fire from air and use normal attacking script.
If you want to make the AI use it, you must make it fire from air and use normal attacking script.


2:If you have a transport in your TaskForce, you can have ONLY 1 with transporting scripts.
2: If you have a transport in your TaskForce, you can have ONLY 1 with transporting scripts.
If you have more, the AI will get stuck with it. Also, other units must exactly fit to the transport, so:
If you have more, the AI will get stuck with it. Also, other units must exactly fit to the transport, so:<br>
0 = 1 , HTK
0 = 1 , HTK<br>
1 = 4 , IVAN  -or 6
1 = 4 , IVAN  -or 6<br>
doesnt work.
doesnt work.<br>
but 5 does as IVAN has Size=1 and HTK has Passengers=5
but 5 does as IVAN has <tt>[[Size|Size=1]]</tt> and HTK has <tt>[[Passengers|Passengers=5]]</tt>
You can have max of 2 transport by using TeamType 2 in the trigger.
You can have max of 2 transports by using TeamType 2 in the trigger.


3:If you use both teamtypes 1+2 to double your TaskForce, check Max= of them if AI builds only one.
3 :If you use both teamtypes 1+2 to double your TaskForce, check the <tt>[[Max|Max=]]</tt> of them if AI builds only one.

Revision as of 10:39, 27 October 2006

This page should correctly be named "[AI]"; it is wrong due to technical restrictions.



In this section of rules(md).ini, the game's Artificial Intelligence settings are located. Note that the game's AI relies on more than just these flags, and, at least for some of us, only the slightest modification of them has sent the AI into a coma.

See also


General information about RA2/YR's Artificial Intelligence

Allied General's information on the AI

RA2/YR AI Engine is based upon the AI engine used in TS.

The AI in RA2/YR is very dumb for the following reasons.

  • it takes ages to assemble teams
  • it builds tiny bases
  • it attacks infrequently and in small numbers
  • it actions are based upon predetermined "scripts" and "events"

However implementation of pool teams, [AIGenerals] (mainly for RA2) and a significant amount of modfication to taskforces and teamtypes can deliver an impressive AI as seen in Deezire's RA2 modification.


Kiith-Sa's information on the rulesmd.ini AI tags


  • CloseEnough= - If your big taskforces get stuck, increase this.
  • Stray= - If you want to use bigger TaskForces, increase this. Recommended: 4-5.
  • RelaxedStray= - Increasing this prevens big TaskForces to get stuck at regroup and gather command. Recommended: 5-7.
  • GuardModeStray= - Again, if you want to use bigger TaskForces, increase this. Recommended: 3-4.
  • TeamDelays= - This number says how often the AI checks for creating a TeamType in frames. Decreasing it is maybe the best thing you can ever do for the AI. Brutal, Medium, Easy. Recommended: <100.
  • AIHateDelays= - Delay in frames before AI chooses an enemy. Keep it low.
  • MultiplayerAICM= - Percent of addition money for AI. If you want your AI to have plenty of money, increase, but have more dogs guarding AI bases becouse if player's spy gets into an AI refinery, he gets a LOT of money. Brutal, Medium, Easy.
  • HarvestersPerRefinery= - Do not edit this. Only one AI will build additional harvesters and others will get stuck.
  • AIExtraRefineries= - Same as above, but decreasing this can give AI more free space in base, and AI can replace a refinery fast. (but it also has less harvesters then, and less money) If you have big TaskForces and need space in base, decrease to 0,0,0 and increase AICM or VirtualPurifiers.
  • TotalAITeamCap= - Maximum of teams used by AI. Good idea to increase, but not too much if you haven't done something to give the AI more free space.

The following tags are the absolute ordering of targets when AI fires a Weather Storm or Nuclear Missile.
Basic tag description:

  • AISafeDistance= - Distance from enemy/own base at which AI will execute the gather/regroup command. If your AI builds large bases, increase.
  • AIMinorSuperReadyPercent= - If Iron Curtain or Chronosphere is this charged, AI will start preparing teams which make use of it. Decrease if you have long-building Chrono or Curtain teams.
  • AlliedBaseDefenseCounts=
  • SovietBaseDefenseCounts=
  • ThirdBaseDefenseCounts=
  • Notes on BaseDefenseCounts tags: Numbers are ordered Brutal, Medium, Easy. These are the number of defense buildings the AI will build for each side. If these are too high, AI just builds defenses and somehow forgets other buildings, also it then builds defense "chains". If you get total control of what AI builds when, then set defenses to be build later, increase this number to a very high number like 100, and you have nice ring of defenses around the AI base. If you want AI to have many defenses, but it always builds those chains, you can simply disable defenses and use tons of cloned buildings, that allows you to control when AI builds each building including defenses and things like sending SHK to all TESLA thanks to different building IDs.
  • AISuperDefenseFrames= - If the Force Shield is not ready when AI is attacked by major SWs, it can wait maximally this long or it will not fire. Set to as high as is the shortest delay before nuke hits, storm starts etc.
  • NodRegularPower=
  • GDIPowerPlant=
  • ThirdPowerPlant=
  • Notes on the PowerPlant tags: These list the power plants that are built by the AI when it needs more power (All powerplants AI builds are this, except first one). It is a good idea to set this to the powerplant with highest Power= your mod has for that side, even for the Soviets (having NANRCT is risky, but it saves much space) If you want AI to have more space, make high output powerplant for every side and set this to it.


As jkraska discovered, AI goes down trough the building type list building buildings as they are listed here. If it can't build next building, it starts again checking for its Prerequisites=. This means, that if you have GAWEAT higher in list than GACSPH, like:

17=GAWEAT
...
22=GACSPH

it will build Weather Conrol first and Chronosphere later. Of course it builds only buildings with AIBuildThis=yes. Through playing with building clones, changing positions of buildings in this list, and Prerequisites, you can get pretty good control of what AI builds when, but you will mess up ScriptTypes and have to fix them.


  • BuildXXX - All of these read only 1 building per side including ConcreteWalls.
  • BuildConst= - Have all your Construction Yards here.
  • BuildPower= - This is the first powerplant AI builds. You can have NANRCT (the Nuclear Reactor) here if you want, but it will look strange. Also, this reads only one power plant per side so having here both NAPOWR (regular Tesla Reactor) and NANRCT just builds NAPOWR.
  • BuildRefinery= - Have all your refineries here, even if they use Slave Miner logic.
  • BuildBarracks= - Have all your barracks here.
  • BuildTech= - Have all your Battle Labs here.
  • BuildWeapons= - Have all your War Factories here
  • BuildRadar= - Have all your Radars here
  • ConcreteWalls= - Have all your walls here. These will be built around ProtectWithWall buildings, so if you replace GAWALL (Allied Walls) with GAPILL (Allied Pillbox, it will build pillboxes around those buildings and the AI will be slower than ever before.
  • BuildNavalYard= - Have all your Naval Yards here.
  • BuildDefense= - Used for standard defenses, but obsolete in YR
  • BuildPDefense= - Used for power consuming defenses, obsolete in YR
  • BuildAA= - Used for AA defenses, obsolete in YR

Have your defense buildings listed here. This can take unlimited number of these buildings, buildings listed here ignore BuildLimit and if you set it for country specific buildings like GTGCAN (French Grand Cannnon), it will build them for the whole side, that is why some modders prefer to clone Grand Cannon. Maximum of these buildings built is specified by XXXBaseDefenseCounts=, numbers of specific buildings built change with AIForcePredictionFudge and their AntiXXXValue.

  • AIForcePredictionFudge= - AI chooses its defenses by analyzing units of player it chose as its enemy, and make weighted distribution of defense based on their AntiXXXValue. It is good to try to experiment with this value, sometimes lower can be better than higher, and combine this with extreme changes in defenses AntiXXXValues.
  • MaximumBaseDefenseValue= - Comments in Rulesmd say it is obsolete, but changing this to very high values (like 4000) can have interesting results, but it will make AI concentrate on building defenses only and so you need again more control of what AI builds when.
  • CreditReserve= - AI will repair buildings only if it has more than this amount of credits.
  • PowerSurplus= - AI will build power plants until it has this amount of surplus power.
  • BaseSizeAdd= - Increasing this to very high numbers can make AI build huge bases, but only increases number of power plants and defenses as it cannot build more factories or refineries. You should increase it if you increased XXXBaseDefenseCounts=.
  • PowerEmergency= - AI will sell buildings if it has less than this percent of power.
  • AIBaseSpacing= - This is average space AI will leave between its buildings.

Increase only if you have only few buildings or replaced maps with some that have more space for bases or in map files.

  • [AIGenerals] - This section was meant to be used in TS, but was never finished. To make use of it, you must get the AI.TLB file from TS and if you are modding YR, rename it to AIMD.TLB. You must place it into RA2 directory and then you can uncomment it with no IE. These CLSID tags are actually 5 Generals, different behaviours AI can have, something like bots. You need to use TriggerTypes (I'm not talking about TeamTypes here) IsBaseDefense and then you will find a new problem. Allies are attacking Soviets and vice versa, but Allies vs Allies is one really boring match, as they are doing almost nothing. To fix this bug, you must write MANY triggers attacking specific sides (not Attack Factories, but Attack Enemy NACNST for Soviets etc.) an if you do this, you can have better and more unpredictable AI, but Yuri is unchanged, as this was meant for GDI and Nod in TS, which are still the references for the Allies and Soviets in rules(md).ini. This section could maybe also have something with an unknown part of TriggerTypes, where Deezire says, that you could specify which General uses this Trigger. Anyway, this section is really hard work and you need to be really sure you want to do this. Still, if you thik you are an AI expert, you can try. I think Deezire used it in his mod, but I'm not sure.


  • AI Tips: By increasing RepairPercent= and lowering RepairRate= you'll get faster but more costly structure repair, with cost that is propably still no harm for AI and it makes AI much more annoying as it repairs everything under attack if it has enough money.


AI(MD).INI TIPS: 1: AI wont deploy the Siege Chopper. If you want to make the AI use it, you must make it fire from air and use normal attacking script.

2: If you have a transport in your TaskForce, you can have ONLY 1 with transporting scripts. If you have more, the AI will get stuck with it. Also, other units must exactly fit to the transport, so:
0 = 1 , HTK
1 = 4 , IVAN -or 6
doesnt work.
but 5 does as IVAN has Size=1 and HTK has Passengers=5 You can have max of 2 transports by using TeamType 2 in the trigger.

3 :If you use both teamtypes 1+2 to double your TaskForce, check the Max= of them if AI builds only one.