AI modding

From Stellaris Wiki
Jump to: navigation, search

Version

Outliner top.png
This article may contain outdated information that is inaccurate for the current version of the game. It was last updated for 1.4.

Summary[edit]

Stellaris AI behaviour is determined by attitudes and behaviours. Attitudes describe which actions an AI empire can pursue according to its current opinion level towards another empire, while behaviours describe the AI empire's behaviour in general.

AI attitudes[edit]

AI attitudes describe how an AI empire would react at certain opinion levels towards another empire, and what actions it may take. Attitude entries consist of a type and a list of allowed behaviours. The type of attitude is normally set to be the same as the name of the entry itself.

Structure[edit]

Example:

   neutral = {
       type = neutral
       behaviour = {
           trade = yes
       }
   }

Any number of behaviours may be attached to the behaviour list on each attitude entry. If a behaviour is not listed inside the attitude's behaviour list, it will assume the value of 'no'. Available behaviours are listed in the table below.

Behaviour name Data type Default value ! Example Description
trade Boolean (yes/no) no trade = yes An attitude with trade set to yes will permit an empire to be traded with.
weaken Boolean (yes/no) no weaken = yes An attitude with weaken set to yes will cause an empire to try and weaken another. This does not mean that they will fight.
attack Boolean (yes/no) no attack = yes An attitude with attack set to yes will cause an empire to actively attack another, provided that war goals can be achieved.
vassalize Boolean (yes/no) no vassalize = yes An attitude with vassalize set to yes will cause an empire to attempt vassalization on another. This does not necessarily involve war.
coexist Boolean (yes/no) no coexist = yes An attitude with coexist set to yes will cause the empire to be more accepting of non-aggression pacts.
alliance Boolean (yes/no) no alliance = yes An attitude with alliance set to yes will cause the empire to try and seek an alliance, or accept an alliance offer if it comes their way.

Warnings[edit]

Removing attitude entries from attitudes.txt can cause the game to crash to desktop. It is likely that these are accessed in a hard-coded manner by the game.

AI personalities[edit]

Personalities describe how an AI empire will react to other empires around them. Each personality consists of a behaviour archetype which describes the empire's goal, a list of behaviours which describe the likely actions taken against other empires and pops, and several modifiers which alter other features which require numeric values as inputs.

Personality archetypes[edit]

Personality archetypes describe the overall goal of the AI nation. If a personality archetype is not set, then the AI will pursue a balanced goal with no distinct focus.

Personality name Description
honorbound Cares about honor and martial prowess above all else.
capitalist Cares about trade and material profit above all else.
hegemon Cares about the superiority of their own empire above all else.
ideologue Cares about combating opposing ethoses above all else.
isolationist Cares about maintaining their isolation from other empires above all else.
federation builder Cares about bringing different species together in a federation above all else.
propagator Cares about the propagation of its species above all else.
purifier Cares about purifying the galaxy of other species above all else.
explorer Cares about exploring the galaxy and making scientific or spiritual discoveries above all else.

Behaviours[edit]

Behaviours determine the type of actions that an AI empire may take against other empires. These are set either to yes or no only; there is no current way to weight the AI's emphasis on certain aspects of their interactions. Currently, it is unknown what behaviour the AI will assume for each type of action if it remains unset. These behaviours are listed in the table below:

Behaviour name Description
conqueror Will they conquer planets from other empires?
subjugator Will they vassalise other empires?
liberator Will they liberate conquered empires?
opportunist Are they more likely to attack someone already embroiled in war?
uplifter Will they uplift and enlighten other species?
infiltrator Will they infiltrate primitives?
dominator Will they invade primitives?
slaver Will they enslave pops?
purger Will they purge alien pops?
robot_exploiter Will they use robots for menial labor?
robot_liberator Will they give rights to robots?
migrator Will they want to migrate to other empires?

Example:

   behaviour = {
       conqueror = no
       subjugator = no
       liberator = no
       opportunist = yes
       slaver = no
       uplifter = no
       purger = no
       dominator = no
       infiltrator = no
       robot_exploiter = yes
       robot_liberator = no
       migrator = no
   }

Modifiers:[edit]

Modifiers affect specific aspects of interactions that an AI empire may take against other empires. Unlike behaviours, these are numeric and allow for fine-tuning of the AI personality. All modifier values are assumed to be floating-point numbers. These modifiers are listed in the table below:

Modifier name Description
aggressiveness Chance of declaring wars. Multiplier; set this to 1.0 for default AI behaviour. Values between 0 and 1 will result in a less aggressive AI. Values greater than 1 will result in a more aggressive AI. Must be greater than or equal to zero.
trade_willingness Willingness to pursue trade. At 0.0, trade will not be considered; at 1.0, trades will attempt to achieve a total value which is approximately equal for both sides. Greater values will weight the trade towards the other party. Must be greater than or equal to zero.
bravery Affects the chance that they will pick rivals and war targets of similar strength, instead of picking on the weak. Values between 0 and 1 will result in an AI which prefers to target weakened enemies. Values greater than 1 will result in an AI that may declare war against an equal or stronger enemy. Must be greater than or equal to zero.
military_spending Affects mineral and energy budget that goes to navies and armies. Values between 0 and 1 will result in an AI which spends less than normal on its military. Values greater than 1 will result in an AI that spends more than normal on its military. Must be greater than or equal to zero.
colony_spending Affects mineral and energy budget that goes to new colonies. Values between 0 and 1 will result in an AI which spends less than normal on colonising new worlds. Values greater than 1 will result in an AI that spends more than normal on colonising new worlds. Must be greater than or equal to zero.
alliance_acceptance Affects the likelihood of an AI accepting alliance offers from other nations. Value is additive to the base reluctance values.
federation_acceptance Affects the likelihood of an AI accepting federation offers from other nations. Value is additive to the base reluctance values.
threat_modifier Affects the severity of opinion modifiers generated by wars near an AI nation, or against the AI nation. Values between 0 and 1 will result in an AI that doesn't care too much about threat. Values higher than 1 will cause threat to be generated faster than normal.
friction_modifier Affects the severity of opinion modifiers generated by colonies or frontier outposts near an AI nation's borders. Values between 0 and 1 will result in an AI that cares less about contested borders and territorial pressure. Values higher than 1 will result in an AI that cares more about contested borders and territorial pressure.

Example:

   aggressiveness = 0.5
   trade_willingness = 0.5
   bravery = 0.75
   military_spending = 1.2
   colony_spending = 1.0
   alliance_acceptance = -50
   federation_acceptance = -50
   threat_modifier = 0.75
   friction_modifier = 2.0

Requirements and weighting[edit]

Personality types for randomly-generated AI nations can be restricted by adding additional conditions. Standard conditions may be inserted to restrict personalities from being attached to certain empire types, or to weight personalities more heavily on others.

To allow a personality to be attached, every condition in the field 'allow' must evaluate to true.

Example:

   allow = {
        NOT { is_country_type = fallen_empire }         ## Does not permit this personality to be attached to a fallen empire.
        NOT { has_ethic = ethic_pacifist }              ## Does not permit this personality to be attached to a pacifist empire.
   }

Weighting is described in a similar manner. The field 'weight_modifier' must contain a numeric weight value greater than zero, and a list of weight modifiers containing a modifying factor and a list of conditions which must all evaluate to true for the modifying factor to apply.

Example:

   weight_modifier = {
       weight = 10	
       modifier = {
           factor = -2
           NOT = {
               has_ethic = "ethic_pacifist"
               has_ethic = "ethic_fanatic_pacifist"		
           }
       }
   }

Examples[edit]

Below are examples of complete AI personalities taken from the base game files, with comments to illustrate the effects that each line has.

Honorbound warriors[edit]

   honorbound_warriors = {
       type = honorbound                                ## Is of the 'honorbound' archetype.
       aggressiveness = 1.75                            ## At 1.75 aggressiveness, this AI is more likely than normal to pursue hostile relations with other nations.
       trade_willingness = 0.7                          ## At 0.7 trade willingness, this AI will try to achieve trades that give a 30% larger profit for itself, as determined by trade item values.
       bravery = 1.5                                    ## At 1.5 bravery, this AI will be more likely to declare war against enemies that are equal or greater in strength to itself.
       military_spending = 1.2                          ## At 1.2 military spending, this AI nation will spend more than normal on its ships and armies.
       colony_spending = 0.9                            ## At 0.9 colony spending, this AI nation will spend less than normal on colonisation.
       alliance_acceptance = -10                        ## Alliance offers made to this AI nation will have an additional -10 reluctance added.
       federation_acceptance = -50                      ## Federation offers made to this AI nation will have an additional -50 reluctance added.
       threat_modifier = 1.0                            ## At 1.0 threat modifier, this AI nation responds normally to generated threat.
       friction_modifier = 1.0                          ## At 1.0 friction modifier, this AI nation responds normally to border friction.
       behaviour = {
           conqueror = yes                              ## AI nation will seek to seize planets in peace deals.
           subjugator = yes                             ## AI nation will try to vassalise other nations.
           liberator = no                               ## AI nation will not try to liberate new nations from existing ones.
           slaver = no                                  ## AI nation will not enslave pops.
           uplifter = no                                ## AI nation will not uplift pre-sentient species.
           purger = no                                  ## AI nation will not purge alien pops.
           infiltrator = no                             ## AI nation will not try to infiltrate primitive civilisations.
           dominator = yes                              ## AI nation will try to dominate primitive civilisations by conquest.
           robot_exploiter = no                         ## AI nation will not use robots for mineral mining.
           robot_liberator = no                         ## AI nation will not try to give synthetics rights.
           migrator = no                                ## AI nation will not try to spread its pops outside its borders.
       }
       allow = {                                        ## This personality has two conditions, which must be true for an AI nation before it can be applied.
           NOT = { is_country_type = fallen_empire }    ## Cannot be applied to fallen empires.
           has_ethic = "ethic_fanatic_militarist"       ## Must have ethic 'fanatic militarist'.
           OR = {                                       ## Must have at least one of the following list evaluate to true.
               has_ethic = "ethic_spiritualist"         ## If the AI nation has the spiritualist ethic, evaluate to true.
               has_ethic = "ethic_individualist"        ## If the AI nation has the individualist ethic, evaluate to true.
           }
       }
       weight_modifier = {
           weight = 100
       }
   }


References[edit]


Modding
Static modding DefinesStatic modifiersMapSpeciesTraitsEthosGovernmentsEmpiresPoliciesEdictsTechnologyBuildingsShipsFleetsEventsCrisisAnomaliesAgenda
Dynamic modding EffectsConditionsScopesModifiersGameplayDecisionsObjectivesAI
Media/localisation Maya exporterGraphicsPortraitsFlagsEvent picturesEvent soundsInterfaceIconsMusicLocalisation
Other Console commandsSave-game editingSteam Workshop