The Twelve Strategic Number Settings You Must Change Immediately

I hope you enjoy clickbaity titles. Each strategic number has a default setting that the developers decided was the best setting in most cases. However, some of these default settings actually make no sense and cause frustration for many new scripters. Here is a list of strategic numbers you should change in your AI if you haven't already.

Example Code

Here is some code you can quickly copy and paste into your AI to change the SN defaults to the values recommended in this article. The change for sn-gate-type-for-wall isn't included since it's only required for Return of Rome gates.

(defrule
	(true)
=>
	(set-strategic-number sn-cap-civilian-builders 200)
	(set-strategic-number sn-consecutive-idle-unit-limit 1)
	(set-strategic-number sn-do-not-scale-for-difficulty-level 1)
	(set-strategic-number sn-enable-boar-hunting 1)
	(set-strategic-number sn-enable-offensive-priority 1)
	(set-strategic-number sn-enable-patrol-attack 1)
	(set-strategic-number sn-initial-exploration-required 0)
	(set-strategic-number sn-maximum-fish-boat-drop-distance 30)
	(set-strategic-number sn-maximum-food-drop-distance 20)
	(set-strategic-number sn-maximum-gold-drop-distance 20)
	(set-strategic-number sn-maximum-hunt-drop-distance 30)
	(set-strategic-number sn-maximum-stone-drop-distance 20)
	(set-strategic-number sn-scale-minimum-attack-group-size 0)
	(set-strategic-number sn-task-ungrouped-soldiers 0)
	(disable-self)
)
(defrule
	(true)
=>
	(set-strategic-number sn-zero-priority-distance 255)
	(disable-self)
)

sn-cap-civilian-builders

sn-cap-civilian-builders sets the maximum number of total villagers that the AI will use to construct buildings. I suggest 200, but really any reasonably high number is fine. The default is 2, but there is no real reason to cap the number of builders your AI can use at once. The AI will only assign builders as necessary, so setting this SN to a huge number like 200 won't tell your AI to send all of its villagers to construct buildings.

sn-consecutive-idle-unit-limit

sn-consecutive-idle-unit-limit sets the number of seconds an attacking or exploring group will sit idle after finishing a task before it will be assigned a new one. The default is 15. Especially if you don't use attack-now or attack groups to attack, the primary effect of this SN is that if an exploring unit is given a non-exploring task, such as claiming sheep with DUC, it will wait 15 seconds before going back to exploring once it finished its non-exploring task. To remove this delay without issues, you'll want this SN to be 1. You could set this SN to 0, but setting this SN to 0 allows the scouting unit to be reassigned to a new task if it is resting momentarily between scouting waypoints.

sn-do-not-scale-for-difficulty-level

If set to the default value of 0, sn-do-not-scale-for-difficulty level automatically reduces the values of certain SNs depending on the difficulty level to make the AI weaker on lower difficulty levels. See the link to the sn-do-not-scale-for-difficulty-level page for which SNs are affected. The effects are more dramatic in scenarios. I recommend setting this SN to 1 so that you have direct control over how your AI gets weaker or stronger depending on the difficulty level and you aren't surprised when your AI doesn't send all of its soldiers to attack.

sn-enable-boar-hunting

sn-enable-boar-hunting actually controls both boar and deer hunting. By default, when set to 0, AIs will only hunt deer and not boar. If set to 1, both boar and deer will be able to be hunted. Be sure to see the Linked SNs and Related SNs on the sn-enable-boar-hunting info page for other SNs that influence boar hunting in order to fine-tune your boar hunting. If you set sn-enable-boar-hunting to 2, this will allow AIs to hunt only boar and will ignore deer. With the SN set to 2, you can limit the total number of animals your AI is trying to gather at once, limiting dead animal food decay. The recommended setting is 1 when you are just starting to script so that your AI doesn't ignore free and valuable food resources. Hunting is one of the fastest sources of food. See this page for examples on how different SN hunting values affects your hunting.

sn-enable-offensive-priority

sn-enable-offensive-priority allows soldiers attacking using attack-now and attack groups to target using the priorities set by up-set-offense-priority. Using up-set-offense-priority allows you to control which buildings and units have lower and higher priority when the AI is selecting an attack target. If you don't set sn-enable-offensive-priority to 1, up-set-offense-priority will have no effect. up-set-defense-priority does not have a corresponding strategic number that you need to set to 1 for the command to work, just up-set-offense-priority.

sn-enable-patrol-attack

sn-enable-patrol-attack allows attacking or defending soldiers that aren't in formation to attack enemy units along the way to their target. It doesn't cause your AI to put soldiers into formation and patrol a formed group toward the enemy, as the name might suggest. If you use one-soldier attack groups or TSA, you'll almost always want to set this SN to 1. This SN was added in the Userpatch, where the SN defaults were often set to whatever behavior caused no change in AI gameplay so that any non-UP AIs that were running in UP games would not have different behavior than they did before UP. There may be cases where you may want to keep this SN at zero, such as if your AI is trying to raid or if the enemy has a forward tower that you want to ignore, so that your soldiers will march all the way to their attack target without getting sidetracked.

sn-initial-exploration-required

sn-initial-exploration-required sets a minimum percentage of the map that must be explored before the AI can construct any buildings. The default is 2%. On larger maps this can cause your AI to significantly delay the construction of its first houses. Just set this SN to 0 and forget about it. The default value is annoying and causes a lot of hair-pulling until the scripter realizes they didn't change this SN.

sn-maximum-xxxx-drop-distance SNs

sn-maximum-fish-boat-drop-distance, sn-maximum-food-drop-distance, sn-maximum-gold-drop-distance, sn-maximum-hunt-drop-distance, sn-maximum-stone-drop-distance, and sn-maximum-wood-drop-distance control the maximum distance that a villager will walk from a dropsite to gather the corresponding resources. If the resource is further than the SN distance, the resource will not be gathered. The default of each of these SNs is -1, meaning the SN is ignored by default. This can allow the AI's villager to walk all the way across the map to gather resources if the AI ran out of that resource at home. To fix this, set a reasonable maximum distance at the beginning of the game, such as 20 or 30, and increase it throughout the game, perhaps per age. You'll probably want to set these SNs back to -1 later on in the game, perhaps in the Imperial Age or after an hour of game time, to prevent your AI from ignoring certain resources.

sn-scale-minimum-attack-group-size

sn-scale-minimum-attack-group-size affects the minimum size of attack groups. Specifically, it automatically increases sn-minimum-attack-group-size by the value of sn-scale-minimum-attack-group-size every X minutes, where X is the value of sn-scaling-frequency. If kept at the default of 1 and sn-scaling-frequency is kept at the default value of 10, then sn-minimum-attack-group-size will increase by 1 every 10 minutes. This behavior on its own isn't a big deal, but the default value of the corresponding SN sn-scale-maximum-attack-group-size is zero, meaning that sn-maximum-attack-group-size isn't automatically increased in the same manner, and eventually sn-minimum-attack-group-size can exceed sn-maximum-attack-group-size. My understanding is that this will prevent attack groups from being sent, since it is impossible for attack groups to have a valid size in this situation. Even if attack groups are still sent, it is more straightforward for scripters to set sn-scale-minimum-attack-group-size to zero and to increase sn-minimum-attack-group-size directly over time.

sn-task-ungrouped-soldiers

When set to the default value of 1, sn-task-ungrouped-soldiers requires all idle military units to keep a certain distance from each other, usually around 4-6 tiles. The AI will check every few seconds, and if it finds units that are too close together, it will order those units to spread out. In practice, it makes units look like the are slowly wandering around the town in a random pattern, and if the AI has a large army, these soldiers may spread out a far distance away from the center of the AI's town. In most cases the behavior of sn-task-ungrouped-soldiers is undesirable, and setting the SN to zero is better. However, some scripters will temporarily set this SN to 1 every minute or so to prevent soldiers from clumping around their training buildings after being trained.

sn-zero-priority-distance

sn-zero-priority-distance either will cause units beyond this distance from the main town center to become idle, or it makes enemy targets beyond this to have zero priority, meaning the AI won't attack them. Neither outcome is desirable, so set this to the max value of 255 so you don't have to worry about it. The default value is 50.

sn-gate-type-for-wall

This change is only necessary for scripting for Return of Rome. In AoE2 DE, sn-gate-type-for-wall tells the AI to build stone gates when it's set to the default value of 0 whenever it sees the build-gate command, and it tells the AI to build palisade gates when it's set to 1. In Return of Rome, small gates are based on palisade gates, so you must set sn-gate-type-for-wall to 1 before your AI can build gates.