The AI in Stronghold 2 is generic for all characters, as their behaviour and decision making is hard-coded into the game. They offer less modifiability than their Crusader counterparts. They introduce however new concepts and improvements.
- Hard-coded behaviour: the AI's decision making, unit management, etc. is programmed in the game and its code cannot be extracted nor modified, therefore it is not possible to be edited.
- Castle templates: the Stronghold 2 AI uses external (.aic) files for castle building and creating a base. These files are created by an AIV Editor, which can be downloaded for free here (needs Java to be installed beforehand).
- Media files: a backstep from Crusader is the fact that the AI has limited communication with the player. It is impossible to send them commands and requests, as well as they make no use of the video clips (they use them in the campaigns, however).
The Stronghold 2 AI is less sophisticated in terms of decision making. It has no stances whatsoever and it alternates quickly between these five actions (units will only be recruited if the AI has at least 200 gold):
- Recruiting bodyguards: all AI lords have their own small group of defenders that guard the Lord. These units change positions whenever the Lord stands atop the keep, has a feast or moves to the church or bedchamber to pay a visit. They are set on aggressive and they will attack everyone they provoke them. They move in column formation.
- Recruiting defenders: this includes ranged defense and guarding melee troops. They will always attempt to take their locations if possible, otherwise they will stay at the barracks/mercenary post and will not move. Guarding melee units are set on defensive and they will attack if units move near them or they are shot at.
- Building up reserves (troop pools): the AI will keep a number of ranged troops in reserve to replace fallen defenders. Units gathered at these assembly points will automatically take their fallen comrade's posts. They can also serve as an additional defense.
- Building up raiding groups: Similar to Crusader, the AI will send harassing units to wreak some havoc and to garrison/seize estates. It also adds catapults / fire ballistae in the mix if going for harassment. If the raiders have no valid target, they will retreat and patrol their own buildings until another path opens up. Raiders are set to aggressive and they are also sent to remove enemy troops that cross the home estate's borders. They move in line formation.
- Building up an attack force: The SH2 AI is more active with its siege forces. Instead of parking these units on the top of the keep, these troops form up gradually and they patrol friendly buildings until the AI sends them to battle. This also eliminates the need for regular patrols that was seen in Crusader. A siege camp will be erected and the force engages when all units have got to the camp. They move in column formation.
Note: The King and the Hawk build their own siege forces, but do not actually send them in battle. Both of them would recruit spearmen into their army, but their poleturners are set to create always pikes and they do not buy in spears for the armoury, thus their army is never completed. They need modified castle designs in order to create spearmen and send forth their forces.
Each AI character has a pre-determined set of goods they can/will produce, use or trade.
They continue to have the upper and lower limits for store, but the purpose of them is changed. The upper limit is kept to prevent the stockpile from getting full, while the AI will try to keep a minimum amount of goods to provide workshops and other goods producers with goods as the lower limit.
The AI will check the stockpile's stocks every now and then. Instead of buying/selling goods after one another, the AI decides how much of all goods to sell and buy. This means that the AI can trade simultaneously more goods than it would be possible by a human player. As a compensation, the AI trades with longer periods.
Weapons are similarly traded by the AI. They are always bought by two, but more of the same type is sold/bought at the same time. Unlike goods, weapons are traded beyond a gold limit: the AI will only buy in weapons if it has more than 400 gold.
Stronghold 2 AI characters do not communicate with their allies. They will notify them upon their attacks, but otherwise they will not do anything. They cannot be commanded or requested goods, but they can be sent goods if one builds a carter's post and sends goods via a carter.
Ranking up and estatesEdit
The AI in Stronghold 2 automatically ranks up as it collects honour. Its building pool is mostly the same as that of human players, but on Freeman, it can build walls and some military buildings, like the engineer's guild.
The AI also keeps track of estates and sometimes buys an estate instead of ranking up. It also sends units to garrison the estate flag and also sends raiding groups to seize enemy estates.
Notable differences from human playersEdit
- Some lords can quickly rank up to Duke from any rank, regardless of starting stocks and funds. They perform this gradually until they reach maximum rank. These lords are: Edwin, Olaf, The King, The Queen and The Bull. Sir William, Sir Grey, Lord Barclay, The Hawk, The Bishop and Lady Seren start at the same rank as the player and rank up normally.
- The AI weapon production is unique: if the armoury holds less then 5 weapons at the moment of delivery, then 5 weapons are added instead of 1 to the stock. Otherwise 1 unit of weapon is added (except for tanners, who deliver 3 leather armour).
- The AI trades simultaneously more goods, but at a much smaller rate (detailed above).
- Missile troops by the AI can be set on aggressive, while human-controlled ones cannot.
- The AI's building costs are much lower than that of human players.
- Actually, the AI's building costs are identical to version 1.0 values. It is possible that the AI's have their own building costs (generic) and they were not adjusted to the later patches' values.
- Buy/sell rates or methods, weapons production, ranking up and unit management can be observed carefully, if a computer player is allied with the player.
- The gold rates can be figured out by tracking your own treasury. When 200 wood has accumulated (worth 200 gold in the market), hold Shift and sell a 200 package of it. One treasure chest will be filled with gold. Additional sells may fill more treasure chests, and eventually gold bags will appear at the treasurer's office. Each of them means 200 gold, above that no more 'eyecandy' will appear.
- The lower costs can be revealed by viewing the allied AI's stockpile and its buildings (preferrably in the beginning of the game). Build a square tower and remember the load of stone disappearing. When the AI builds a tower, much fewer stone disappears and it can be counted how much (every stone block means 2 units of stone).