Hoi4 modding Wiki
Register
Advertisement

Definition[]

The ai_will_do value is used as a subobject that determines the likelihood the AI will pick something for the country. it is used as part of defining national focuses and government positions.

When the AI needs to pick a focus within its focus tree, it considers all possibilities and then picks a random number between 0 and all factors added together. So if there are only two focuses available, one has a factor of 10 and the other has a factor of 20. Then the AI is twice as likely to pick the focus with the factor of 20. If there are two focuses with a factor of 40 and a focus with a factor of 80, then the AI is 50% likely to pick the focus of factor 80 because 80 is half of the total factor of 160.

Format[]

ai_will_do = {
  factor = 60

  modifier = {
    factor = 0.5
    is_in_faction_with = 
  }
}

The way the ai_will_do works is a bit misleading.

ai_will_do contains the keyword "factor" which gives the chance the AI will perform this action. The number you set it to, is not a percentage nor a fraction itself: neither 1.0 nor 100 represents a 100% likelihood that the AI will pick it.

The modifier keyword and value can be used to denote a conditional multiplier to the base factor. The modifier value consists of a factor of its own and any amount of conditions. If the conditions are met then the factor value is multiplied with the base factor. In the example above the result would be a likelihood of 30 for the AI to still pick that focus.

Tips[]

  1. When not defined, the ai_will_do factor defaults to 1 (unconfirmed).
  2. If you use a factor of 0, then the AI will never pick it, even if it has no other options available.
  3. There seems to be a hidden modifier that already increases the likelihood for the AI to pick focuses deeper down the focus tree.
  4. Not only can you use multiple conditions within a single modifier value, but you can also use multiple modifiers within a single ai_will_do value. If you do, the base factor will be multiplied by all modifier factors where the conditions are met.
  5. It is recommended that when changing a file, you try to stick to similar amounts of factor values as used elsewhere in that file, to avoid erratic AI behavior.
  6. The AI does not seem to recognize the ai_will_do factor of focuses it has not yet unlocked. It will not go through low priority focuses just to end up on a big priority one.

The Base 40 system[]

The Base 40 system is a system for ai_will_do, where it assumes the average factor of any choice is 40. Now that you have this baseline in your head, it is much easier to imagine what a factor of 20 or 80 means respectively. The number 40 is picked because it is a nice number to half or double multiple times with modifiers, while being an easy number to work with.

You can set up your factors to represent the chances as shown below in the table.

Factor Represents Effect Chance vs 40
0 Never Will never be picked by the AI. 0%
1 Do last 40x as unlikely to be picked. That is incredibly unlikely. Because of this, most of these options will remain among the last options available, In which case the AI will do them then. 2.4%
10 Minor priority 4x as unlikely to be picked. Often the AI will end up doing a few of these choices here and there, but it might take a while. 20%
20 Low priority 2x as unlikely to be picked. The AI will do these from time to time 33.3%
40 Average priority Will be picked just as likely as any other option. 50%
80 High priority 2x as likely to be picked. High priority options are good contenders to be picked next, but nothing guarantees that they will be picked immediately, they usually will be picked once the AI has picked a few times. Should be used for benefits that will help the AI down the line. 66.7%
160 Very high priority 4x as likely to be picked. A very high priority means the AI will end up picking this option rather quickly once its available. It should be used for any option that is very important or beneficial to the AI. 80%
320 Immediate priority 8x as likely to be picked. An immediate priority option is meant to be a good portion of all other options combined. You expect the AI to definetly pick this up within its next one to three picks, but still leave it up to chance when it exactly does. 88.9%
4000 Top priority 100x as likely to be picked. A top priority option is large enough so that it is almost always picked first. 99%
Advertisement