"ai_strategy_plan" Selection Probability

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Sir Doctor Professor

Private
47 Badges
Jun 17, 2016
11
7
  • Europa Universalis IV
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Semper Fi
  • Victoria: Revolutions
  • Europa Universalis IV: Res Publica
  • Hearts of Iron III Collection
  • Hearts of Iron III: Their Finest Hour
  • For the Motherland
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Hearts of Iron III
  • Europa Universalis IV: Art of War
  • Stellaris: Synthetic Dawn
  • Steel Division: Normand 44 - Second Wave
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Steel Division: Normandy 44 -  Back to Hell
  • Stellaris: Distant Stars
  • Stellaris: Megacorp
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Hearts of Iron IV: La Resistance
  • Stellaris: Federations
  • Battle for Bosporus
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Crusader Kings II
  • Hearts of Iron IV: Death or Dishonor
  • Steel Division: Normandy 44
  • Stellaris - Path to Destruction bundle
  • Hearts of Iron IV: Together for Victory
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Hearts of Iron IV: Cadet
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Mount & Blade: Warband
  • Europa Universalis IV: El Dorado
  • War of the Roses
  • Victoria 2
Does anyone know what value or values the AI uses when determining which "ai_strategy_plans" (listed in HOI4's files) will be assigned to each country at the start of the game? I'm working on reducing the probability AI run countries will engage in significantly ahistorical behavior when "historical focuses" is deselected (I obviously want some variation but every country doing an ideological 180 is a bit much) but cutting back the ai_will_do factor for the relevant national focuses (or even setting them to 0) does not seem to have the desired effect. I'll go ahead and apologize in advance as I'm not sure that this is the right subform for this question, that this question hasn't been already answered, or if I understand the system which determines AI national focus selection enough to ask this question without it seeming like gibberish (though the system seems to be needlessly opaque).
 
  • 2Like
Reactions:

bitmode

1st Reverse Engineer Battalion
Nov 10, 2016
3.812
6.989
AI strategy plans work via country flags. If you just disable "historical AI focus", no flag gets set and none of the plans will be executed. The AI will use the weights assigned to the individual focuses, advisors etc.

If you switch the country's AI behavior to "random" during game setup, an action at game start resolves that to one of the available plans according to a list of weights. Those are defined in common/on_actions/00_on_actions.txt:
Code:
#Not run on a specific country.
    on_startup = {
        effect = {
            GER = {
                if = {
                    limit = {
                        has_dlc = "Waking the Tiger"
                        has_game_rule = {
                            rule = GER_ai_behavior
                            option = RANDOM
                        }
                    }
                    random_list = {
                        50 = { GER = { set_country_flag = GER_AI_RANDOM_FASCIST } }
                        35 = { GER = { set_country_flag = GER_AI_RANDOM_KAISER } }
                        15 = { GER = { set_country_flag = GER_AI_RANDOM_DEMOCRATIC } }
                    }
                }
            }
            etc.
 
  • 6
Reactions:

Sir Doctor Professor

Private
47 Badges
Jun 17, 2016
11
7
  • Europa Universalis IV
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Semper Fi
  • Victoria: Revolutions
  • Europa Universalis IV: Res Publica
  • Hearts of Iron III Collection
  • Hearts of Iron III: Their Finest Hour
  • For the Motherland
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Hearts of Iron III
  • Europa Universalis IV: Art of War
  • Stellaris: Synthetic Dawn
  • Steel Division: Normand 44 - Second Wave
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Steel Division: Normandy 44 -  Back to Hell
  • Stellaris: Distant Stars
  • Stellaris: Megacorp
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Hearts of Iron IV: La Resistance
  • Stellaris: Federations
  • Battle for Bosporus
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Crusader Kings II
  • Hearts of Iron IV: Death or Dishonor
  • Steel Division: Normandy 44
  • Stellaris - Path to Destruction bundle
  • Hearts of Iron IV: Together for Victory
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Hearts of Iron IV: Cadet
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Common Sense
  • Mount & Blade: Warband
  • Europa Universalis IV: El Dorado
  • War of the Roses
  • Victoria 2
AI strategy plans work via country flags. If you just disable "historical AI focus", no flag gets set and none of the plans will be executed. The AI will use the weights assigned to the individual focuses, advisors etc.

If you switch the country's AI behavior to "random" during game setup, an action at game start resolves that to one of the available plans according to a list of weights. Those are defined in common/on_actions/00_on_actions.txt:
Code:
#Not run on a specific country.
    on_startup = {
        effect = {
            GER = {
                if = {
                    limit = {
                        has_dlc = "Waking the Tiger"
                        has_game_rule = {
                            rule = GER_ai_behavior
                            option = RANDOM
                        }
                    }
                    random_list = {
                        50 = { GER = { set_country_flag = GER_AI_RANDOM_FASCIST } }
                        35 = { GER = { set_country_flag = GER_AI_RANDOM_KAISER } }
                        15 = { GER = { set_country_flag = GER_AI_RANDOM_DEMOCRATIC } }
                    }
                }
            }
            etc.
Understood. Thank you very much!
 

FindFloppies

Some Assembly Required
88 Badges
Jul 8, 2015
848
1.464
  • Cities: Skylines Deluxe Edition
  • Europa Universalis IV: Cossacks
  • Stellaris
  • Europa Universalis IV: Cradle of Civilization
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Hearts of Iron IV: Expansion Pass
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Dharma
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Colonel
  • Battle for Bosporus
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Crusader Kings III
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Stellaris: Federations
  • Hearts of Iron IV: Death or Dishonor
  • Cities: Skylines - Green Cities
  • Stellaris: Nemesis
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: Sunset Invasion
  • Stellaris: Distant Stars
  • Victoria 3 Sign Up
  • Europa Universalis IV
  • Cities: Skylines - Parklife Pre-Order
  • Stellaris: Lithoids
  • Cities: Skylines - Campus
  • Stellaris: Apocalypse
  • Europa Universalis 4: Emperor
  • Hearts of Iron IV: No Step Back
  • Crusader Kings II: Way of Life
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Crusader Kings II: Holy Fury
  • Stellaris: Ancient Relics
  • Victoria 2
  • Cities: Skylines - Parklife
  • Stellaris: Necroids
  • Cities: Skylines
  • Europa Universalis III: Collection
  • Hearts of Iron IV: By Blood Alone
  • Europa Universalis IV: Golden Century
}
random_list = {
50 = { GER = { set_country_flag = GER_AI_RANDOM_FASCIST } }
35 = { GER = { set_country_flag = GER_AI_RANDOM_KAISER } }
15 = { GER = { set_country_flag = GER_AI_RANDOM_DEMOCRATIC } }
So, actually, Germany on non-historic does still have a weight of half, vs 15 Demo, 35 Empire. And can be manipulated/modded for any of the nations. Makes sense.

I had previously said Germany is evenly divided on paths, but it seems it's not so.

Thanks, Bitmode, for the steer.

(For others, if you look in the files, the other countries are in the same on_startup structure, just continue past GER.)

EDIT: Ah, not even X/100, it's X/<total>
 

MattZed

Major
49 Badges
Mar 21, 2019
563
512
  • Stellaris: Ancient Relics
  • Stellaris: Synthetic Dawn
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Stellaris: Megacorp
  • Europa Universalis IV: Golden Century
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Death or Dishonor
  • Stellaris: Lithoids
  • Hearts of Iron IV: La Resistance
  • Stellaris: Federations
  • Crusader Kings III
  • Crusader Kings III: Royal Edition
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Hearts of Iron IV: By Blood Alone
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Conquest of Paradise
  • Magicka 2
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV: Cossacks
  • Magicka 2: Ice, Death and Fury
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Hearts of Iron IV: Together for Victory
  • Stellaris - Path to Destruction bundle
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Wealth of Nations
  • Magicka
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Pre-order
  • Europa Universalis IV: Third Rome
AI strategy plans work via country flags. If you just disable "historical AI focus", no flag gets set and none of the plans will be executed. The AI will use the weights assigned to the individual focuses, advisors etc.

If you switch the country's AI behavior to "random" during game setup, an action at game start resolves that to one of the available plans according to a list of weights. Those are defined in common/on_actions/00_on_actions.txt:
Code:
#Not run on a specific country.
    on_startup = {
        effect = {
            GER = {
                if = {
                    limit = {
                        has_dlc = "Waking the Tiger"
                        has_game_rule = {
                            rule = GER_ai_behavior
                            option = RANDOM
                        }
                    }
                    random_list = {
                        50 = { GER = { set_country_flag = GER_AI_RANDOM_FASCIST } }
                        35 = { GER = { set_country_flag = GER_AI_RANDOM_KAISER } }
                        15 = { GER = { set_country_flag = GER_AI_RANDOM_DEMOCRATIC } }
                    }
                }
            }
            etc.
The devs have said that disabling historical focuses now (as of the NSB release) randomly picks one of the AI strategies, rather than using weighted focus picking. In fact, it seems every focus now has weight 100 to completely disregard this old functionality.

Is ticking off historical focuses now just the same as setting every AI to random, or can you tell if something different is going on?
 
  • 1
Reactions:

Niko92

Lt. General
105 Badges
Oct 8, 2007
1.693
1.587
  • Imperator: Rome - Magna Graecia
  • Europa Universalis IV: El Dorado
  • Hearts of Iron IV: No Step Back
  • Mount & Blade: Warband
  • Mount & Blade: With Fire and Sword
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Battle for Bosporus
  • Crusader Kings II: Conclave
  • Crusader Kings III: Royal Edition
  • Crusader Kings III
  • Stellaris: Galaxy Edition
  • Crusader Kings II: Holy Knight (pre-order)
  • Hearts of Iron IV Sign-up
  • Stellaris Sign-up
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Tyranny: Archon Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Lithoids
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • PDXCon 2019 "King"
  • Prison Architect
  • Stellaris: Federations
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Dharma
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma Pre-order
  • Cities: Skylines - Parklife
  • Europa Universalis IV: Rule Britannia
  • Stellaris: Humanoids Species Pack
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Golden Century
  • Cities: Skylines - Green Cities
  • Europa Universalis IV
  • Stellaris: Apocalypse
  • Stellaris: Ancient Relics
  • Hearts of Iron IV: Death or Dishonor
  • Crusader Kings II: Holy Fury
  • Surviving Mars
  • PDXCON 2017 Standard Ticket holder
  • Europa Universalis IV: Mandate of Heaven
  • Cities: Skylines - Mass Transit
  • Victoria 2
  • Warlock: Master of the Arcane
  • Age of Wonders: Planetfall
The devs have said that disabling historical focuses now (as of the NSB release) randomly picks one of the AI strategies, rather than using weighted focus picking. In fact, it seems every focus now has weight 100 to completely disregard this old functionality.

Is ticking off historical focuses now just the same as setting every AI to random, or can you tell if something different is going on?
Ticking off historical is the same as setting random in the strategy section for all countries (unless you've manually chose a certain path for the country). This is of course fully controlled by the on_action and not written directly into the game. I think bitmode's code is from an older game version, below is what it looks like now:
Code:
GER = {
                if = {
                    limit = {
                        has_dlc = "Waking the Tiger"
                        OR = {
                            AND = {
                                is_historical_focus_on = no
                                has_game_rule = {
                                    rule = GER_ai_behavior
                                    option = DEFAULT
                                }
                            }
                            has_game_rule = {
                                rule = GER_ai_behavior
                                option = RANDOM
                            }
                        }
                    }
                    random_list = {
                        40 = { GER = { set_country_flag = GER_AI_RANDOM_FASCIST } }
                        35 = { GER = { set_country_flag = GER_AI_RANDOM_KAISER } }
                        25 = { GER = { set_country_flag = GER_AI_RANDOM_DEMOCRATIC } }
                    }
                }
            }
So if you have historical focus turned off and "default" as the AI strategy, or you've chosen "random" as strategy, a random AI strategy will be chosen.
 
  • 4
  • 1Love
Reactions:

bitmode

1st Reverse Engineer Battalion
Nov 10, 2016
3.812
6.989
The devs have said that disabling historical focuses now (as of the NSB release) randomly picks one of the AI strategies, rather than using weighted focus picking. In fact, it seems every focus now has weight 100 to completely disregard this old functionality.
Oh wow. So I guess the answer to OP's question then is that is not possible anymore to have variation without ideologic 180s. Major step backward (pun intended) imho.
 
  • 2Like
  • 1
  • 1
Reactions:

Sebadoh

Private
31 Badges
Apr 4, 2019
18
13
  • Stellaris: Leviathans Story Pack
  • Hearts of Iron IV: La Resistance
  • Stellaris: Distant Stars
  • Europa Universalis IV: Rule Britannia
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Together for Victory
  • Stellaris: Digital Anniversary Edition
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV
  • Europa Universalis IV: El Dorado
  • Hearts of Iron IV: Colonel
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Europa Universalis IV: Third Rome
  • Stellaris - Path to Destruction bundle
  • Stellaris: Synthetic Dawn
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
This is where you will find an editable file that contains the AI path percentages for each of 31 counties.

C:\Program Files (x86)\Steam\steamapps\common\Hearts of Iron IV\common\on_actions\00_on_actions.txt . I am playing the Open Beta.

In my opinion there should be no country where the historical option is less than 50%. And yet it is, for most countries.

For my taste the historical path should be at least 70% likely.

Chaos.
 

FindFloppies

Some Assembly Required
88 Badges
Jul 8, 2015
848
1.464
  • Cities: Skylines Deluxe Edition
  • Europa Universalis IV: Cossacks
  • Stellaris
  • Europa Universalis IV: Cradle of Civilization
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Hearts of Iron IV: Expansion Pass
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Dharma
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Hearts of Iron IV: Colonel
  • Battle for Bosporus
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Crusader Kings III
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Stellaris: Federations
  • Hearts of Iron IV: Death or Dishonor
  • Cities: Skylines - Green Cities
  • Stellaris: Nemesis
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: Sunset Invasion
  • Stellaris: Distant Stars
  • Victoria 3 Sign Up
  • Europa Universalis IV
  • Cities: Skylines - Parklife Pre-Order
  • Stellaris: Lithoids
  • Cities: Skylines - Campus
  • Stellaris: Apocalypse
  • Europa Universalis 4: Emperor
  • Hearts of Iron IV: No Step Back
  • Crusader Kings II: Way of Life
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Crusader Kings II: Holy Fury
  • Stellaris: Ancient Relics
  • Victoria 2
  • Cities: Skylines - Parklife
  • Stellaris: Necroids
  • Cities: Skylines
  • Europa Universalis III: Collection
  • Hearts of Iron IV: By Blood Alone
  • Europa Universalis IV: Golden Century
This is where you will find an editable file that contains the AI path percentages for each of 31 counties.

C:\Program Files (x86)\Steam\steamapps\common\Hearts of Iron IV\common\on_actions\00_on_actions.txt . I am playing the Open Beta.

In my opinion there should be no country where the historical option is less than 50%. And yet it is, for most countries.

For my taste the historical path should be at least 70% likely.

Chaos.
So write a mod that does that. No twenty people will all agree what the values should be. If you want historic all the time, that button already exists.