RA2\Yr Deezires Ai Generals
This Deezires AI Generals tutorial which was one of the the old site RA2 tutorials
There is actually a way to make the AI tailor itself and it's 'strategy' to the state of battle during the game. The overall effect is limited, and the AI does not choose these strategies all that wisely, although there can be a noticeable difference in the AI if you use this trick.
Open the RULES file, and hop to the [AIGenerals] section. You will see that the entire section is commented out. This section was added in Tiberian Sun (but was commented out and thus unused there too). It's effect is to place some pre-determined strategies (or combat behavioural characteristics) into the AI, in order that it adopts one of them depending on the state of the battle. Each strategy is based on that of a military General. In other words, it could at times rush the human player(s) or play very heavily on defense, instead of simply continuing to play the game blindly in the same scripted manner at all times irrespective of how it or it's chosen enemy was doing. Naturally, this would make the AI a little more of a challenge and, at worst, more unpredictable (and theoretically more 'human').
Each entry in this section is a COM object within the game code that defines a General (ie a strategy). This works exactly like the Locomotor= statement which details a section of the code dealing with it (you will see that the hex numbers representing each General take exactly the same format as those used by the Locomotor= as they point to the game code in the same way). To get the AI to adopt the behaviour of these Generals, you simply have to delete the comments and re-include the section.
Once you have re-enabled this section, you may encounter random/sporadic/frequent Internal Errors in games played against AI armies. This is because those CLSIDs point to COM objects that are not present in Red Alert 2's code. However, they do exist in Tiberian Sun (even though they don't get used) and can all be found in the AI.TLB file (an OLE Type Library) in Tiberian Sun, so by copying that file and placing it directly in the Red Alert 2 directory you can enable this section and point to those COM objects in Red Alert 2 as well (you will also have to distribute that file with your mod if you plan on making use of this section).
It's worth noting 2 important points however;-
(i) significant changes to the AI strategy will hardly be noticed in Red Alert 2 because of the comparative lack of AI teams defined in the AI.INI file (less than half of those present in Tiberian Sun) - it stands to reason that the more AI triggers and teams that can be employed by the computer, the more apparent that the different strategies will become.
(ii) because AI.TLB comes from Tiberian Sun, it is designed for GDI vs Nod battles - thankfully, Allied and Soviet are still referred to as GDI and Nod in Red Alert 2 so it still works but you get best results in games where Soviets are playing against Allies and vice versa. Use of the Generals becomes much less apparent in games where Soviets play against Soviets or Allies play against Allies.
It may originally have been removed from Tiberian Sun because when using GDI vs Nod logic, the AI would be very ineffective if it was the only Nod player facing all Nod enemies (or vice versa, GDI vs GDI). You can get around that shortcoming by adding more AI Triggers and scripts to AI.INI that specifically tell Soviet armies to target other Soviet armies and Allied armies to target other Allied armies. If you dont do this, it will be a wasted excersize as the logic here is designed to support the AI when playing against the opposite faction, not the same one.
Hence it's well worth enabling this section only after you have finished all other AI editing and added considerable amounts to the AI's pool of TeamTypes and AITriggerTypes. In short, the more teams and scripts available to the AI, the harder it will become to beat as each General will make his presence more apparent. This is even more evident in Red Alert 2, since it's AI.INI file is almost less than half the size of Tiberian Sun's.
When using this section, the AI tends to employ the strategy of one of the Generals by performing some complex calculations in order to assess the threat posed to it by it's chosen enemy - this process is conducted therefore after it has decided who that enemy is to be, thus it may switch between more than one General throughout the battle. This is a special case enhancement to the standard threat evaluation logic and appears to consider the following factors;-
1 - How much money it has VS how much money it's enemy has
This enables the AI to decide whether or not it can afford to assume any strategy, or even if it is likely to fail by doing so since it's enemy's economy may lead to the strategy being nullified (eg tank rush easily countered by an enemy tank rush). Thus this will influence whether or not a General which uses many and/or expensive units would be used
2 - Available Ore storage it has VS enemy available Ore storage
This allows the AI to assess the effect it will have on the enemy economy by assuming a General's strategy. The decision would be a pay off between how much the strategy would cost the AI in money to produce against how much money it's enemy would lose as a result of it's attack. Thus this will influence whether or not a General which hits the enemy's economy would be used
3 - Current power outut VS current power drain
The AI uses this to decide if it stands a chance of a succesful assault on it's enemies base. If the base has a high power output and a low power usage, any assault may be fruitless as powered base defenses would dispense of any incursion. Thus this would influence whether or not a General which uses 'rushing' would be chosen
4 - Category of owned units VS category of enemy units
All units in the game are assigned to a Category=. The AI will assess how many units it has in each category and compare that to the same figures for it's chosen enemy. You should therefore make sure that your Category= descriptions are true and accurate or this part of the logic will fail or at best be ineffective (the defaults in Red Alert 2 are suprisingly inaccurate as many unit entries were 'copy n pasted' from others to save time). This will influence which types of units the AI will use for attack and defense - for example, if it's enemy has more LRFS type units, it would use AFV units against them. If the AI had more LRFS, it would use them to assault the enemy base, and so on. It's a kind of 'paper, rock, scissors' logic. This will also influence whether or not a defensive General will be used rather than an offensive one
5 - Center location of enemy base
The AI will try to determine the center point of it's enemy base to target super weapons and unit movement there. The idea is that this makes it's forces harder to eliminate as they will be dispersed between objects and attacking multiple targets due to the limited space between structures. This will influcence whether or not a 'hi-tech' or 'rushing' type General is used
Here's a list of all of the valid Generals and what their behaviours are;-
{F706E6E0-86DA-11D1-B706-00A024DDAFD1}
General BrainDead - has no pre-defined behaviour. This is the default setting for the AI and explains a lot about how weak it can be.
{9E0F6120-87C1-11D1-B707-00A024DDAFD1}
General Meade - the computer concentrates on strong defense and weak attack. It defends heavily and only retaliates rather than initiating attack.
{C6004D80-87D1-11D1-B707-00A024DDAFD1}
General Jackson - the computer attacks and defends strongly.
{FBE6D4A0-87D1-11D1-B707-00A024DDAFD1}
General Grant - the computer defends weakly and attacks frequently.
{FBE6D4A1-87D1-11D1-B707-00A024DDAFD1}
General Hooker - the computer is unpredictable and attacks/defends almost at random.
As you can see, the computer will thus choose a General behaviour most suited to the state of battle (or rather the status of it's chosen enemy) based on the outcome of the assessment logic detailed above.
|