AI modding:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.5
(merge from offical wiki)
 
(文本替换 - 替换“[[Category:”为“[[分类:”)
 
(未显示1个用户的2个中间版本)
第1行: 第1行:
{{version|1.5}}
{{version|1.5}}


AI in Hearts of Iron IV can be modified in many aspects. The following files and folders handle AI primarily:
钢铁雄心4中的 AI 可以在许多方面修改. 以下文件主要处理 AI:


* {{path|common/ai_areas}}
* {{path|common/ai_areas}}
第12行: 第12行:
* {{path|common/ai_personalities.txt}}
* {{path|common/ai_personalities.txt}}


Many other places that present choices to the player have an AI chance attached to it, using the keyword '''ai_will_do'''.
许多其他给玩家提供选择的地方应附有 AI 倾向来表达 AI 对各选项的权衡,这些地方使用'''ai_will_do '''


== AI chance ==
== AI 倾向 ==
{{SVersion|1.8}}
{{SVersion|1.8}}
{{anchor|ai_will_do}}
{{anchor|ai_will_do}}
Found in numerous files, '''ai_will_do''' is an element that produces a number for the AI to use when weighing decisions. It is functionally very similar to [[Event_modding#Mean_time_to_happen_2|mean_time_to_happen]] and uses the same modifier system described there. It has a different interpretation of ''base'' and ''factor'' though.
正如在许多文件中看到的那样,'''ai_will_do''' mb是一个为 AI 提供决策时权重的参数。在功能上它与 [[Event_modding#Mean_time_to_happen_2|mean_time_to_happen]] 非常相似。它与其使用相同的修正系统,尽管它对 ''base'' ''factor'' 有不同的解释。


Note that the AI's interpretation of the resulting number is not the same in all use cases, but usually [[wp:Sampling_(statistics)#Probability-proportional-to-size_sampling|probability-proportional-to-size sampling]].
注意:AI 对这个参数的运算结果不是完全遵从的,而通常与 [[wp:Sampling_(statistics)#Probability-proportional-to-size_sampling|probability-proportional-to-size sampling]] 类似。


==== base ====
==== base ====
''(Type: scoped variable, default: 1)'' The base value of the calculation, before applying any modifiers.
''(Type: scoped variable, default: 1)'' 在应用其他修改前的基础数值。
==== factor ====
==== factor ====
''(Type: number (with 3 decimal places), default: 1)'' A final factor applied to the calculation.
''(Type: number (with 3 decimal places), default: 1)'' 应用于计算的系数,


=== Example ===
=== 例子 ===
<pre>
<pre>
ai_will_do = {
ai_will_do = {
第45行: 第45行:
    factor = 2
    factor = 2
}</pre>
}</pre>
Assuming normal majors, the result is 0 for GER, 74 for FRA, 23 for other majors and 21 for minors.
假设正常计算,对于GER(德国) 结果为0,对于FRA(法国)结果为74,对于其余主要国家为23,对于次要国家则为21。
== AI area ==
== AI 区域 ==
{{SVersion|1.8}}
{{SVersion|1.8}}
The {{path|common/ai_areas}} directory controls the assignment of land [[province]]s to named AI areas. These in turn are only used by the AI strategy <code>area_priority</code> described further below. Each land province is assigned to only one AI area. The first matching area is used. It is not necessary to assign an AI area to every land province, but the unassigned ones can not be referenced by the <code>area_priority</code> strategy.
{{path|common/ai_areas}} 直接控制了陆地[[province|省份]] 在有命名的 AI 区域的分配。但它们只被下文定义的 AI 策略 <code>area_priority</code> 使用。 每个省份只被分配到一个 AI 区域,并且是第一个匹配的区域。没必要将每个省份都分给 AI 区域,但未被分配的不能被 <code>area_priority</code> 策略调用。


The AI area is shown in the province debug tooltip.
在省份的 debug tooltip 可以看到 AI 区域。


Here is a generic example:
这是一个通用示例:
<pre>
<pre>
<area name> = {
<area name> = {
第67行: 第67行:
</pre>
</pre>


== AI Focuses ==
== AI 国策 ==
See [[AI focuses#Modding]]
参考 [[AI focuses#Modding]]


== AI Peace ==
== AI 和平策略 ==
{{SVersion|1.5}}
{{SVersion|1.5}}
The {{path|common/ai_peace}} files controls how the AI handles peace.
{{path|common/ai_peace}} 中的文件控制了 AI 如何完成和平会议。


There are five types of peace behaviour:
There are five types of peace behaviour 一共有 5 种 AI 和平策略:


* civilwar
* 内战
* democratic
* 民主主义
* communist
* 共产主义
* fascist
* 法西斯主义
* default
* 默认


There are five peace options, which are:
和平会议一共有 5 种和平行动:


* annex
* 吞并国家
* liberate
* 解放国家
* puppet
* 傀儡国家
* take_states
* 获取土地
* force_government
* 改变政府(原版民主主义专属)


Here is a generic example:
这是一个通用示例:
<pre>
<pre>
<type>_peace = {
<type>_peace = {
第121行: 第121行:
</pre>
</pre>


== AI strategy ==
== AI 策略 ==
{{SVersion|1.8}}
{{SVersion|1.8}}
The strategic AI influences decision making in other AI components along certain strategic considerations ('''types''') which can also be targeted. For example a country may strategically be interested in protecting another country, irrespective of the current diplomatic relation and alliance status. Or it may want to produce more units of a certain type.
AI 策略影响在特定策略考量 ('''types''') 中,其他 AI 组件中的决策形成,这也可以是定向的。例如一个国家可以在策略上对保护另一国家有兴趣,而不考虑当前外交与同盟关系;或者它更倾向于训练某一特定类型的师。


In terms of structure, an AI strategy has just four attributes: <code>type</code>, <code>value</code>, <code>id</code>, and <code>target</code>. Only some types make use of <code>id</code> and/or <code>target</code>. All four attributes are integer numbers inherently, but if the <code>type</code> is specified first, the <code>id</code> attribute can reference respective values by name (see table below). <code>target_country</code> is another way to set <code>target</code>. It accepts a country index or a tag and will check in both cases that it refers to a valid country.
在结构层面,一个 AI 策略只有 4 个参数:<code>type</code> <code>value</code> <code>id</code> ,以及 <code>target</code> 。只有部分类型的 AI 策略使用了 <code>id</code> / <code>target</code> 。本来,4 个参数都是整型,但如果 <code>type</code> 先被指定,那么<code>id</code> 参数可以用名字来调用对应的值(参考下文表格)。<code>target_country</code> 是另一种设置 <code>target</code> 的方式。它接受一个国家下标或国家 Tag,并会检查其是否指向了一个可用的国家。


The AI creates dynamic strategies by itself but static strategies can be added as well. Static strategies are primarily defined with an '''AI strategy entry''' in {{path|common/ai_strategy}} or an '''AI strategy plan''' (see below). Country leader traits (in {{path|common/country_leader}}) can carry AI strategies that are enabled when the associated person becomes the ruler. Individual strategies can also be added directly using the '''add_ai_strategy''' effect (for example in event, national focuses etc.).
AI 会自己生成动态策略,但想添加静态策略也是可行的。静态策略的主要被{{path|common/ai_strategy}} 中的 '''AI 策略条目''' 或 '''AI 策略计划''' 定义(见下文)。领导人特质({{path|common/country_leader}} 中)可以修改 AI 策略,当特质携带者成为国家领导人时。独立的策略也可以用'''add_ai_strategy''' 命令直接添加(例如事件·,国策中,等等)。


The effective AI strategies of a country are saved in save files, as the <code>ai</code> attribute of a country.
一个国家有效的 AI 策略保存在保存文件中,作为该国的<code>ai</code> 属性。


=== Types ===
=== 类型 ===
When defining an '''ai_strategy''', the type controls what aspect of AI strategy is altered.
定义 '''ai_strategy''' , 类型决定了 AI 策略改变的方面。
Additional ai_strategy's from LaR can be found in common/ai_strategy/default.txt
抵抗运动 dlc 中新增的 AI 策略可以在 common/ai_strategy/default.txt 中找到。


{| class="wikitable sortable mw-collapsible"
{| class="wikitable sortable mw-collapsible"
第391行: 第391行:
|}
|}


=== AI strategy entry ===
=== AI 策略条目 ===
A strategy entry contains one or more AI strategies and defines when and how they should apply. When a country checks an entry, it will only enable it if <code>enable</code> is true and <code>abort</code> is empty or false. An entry gets disabled if <code>abort</code> is non-empty and true. It also gets disabled if <code>abort_when_not_enabled</code> is set and <code>enable</code> is false.
一个策略条目包含了一个或多个 AI 策略,并定义了应用的时机和方式。在一个国家检查一个条目的时候,只有在<code>enable</code> 为真以及<code>abort</code> 为空或假时才会激活这个条目。条目将在<code>abort</code> 非空且为真时,或者填写了<code>abort_when_not_enabled</code> <code>enable</code> 为假时被废除。


A '''reversed''' entry works quite differently. The entry gets enabled for a source country if it is mentioned as an <code>id</code> in an <code>ai_strategy</code> and <code>enable_reverse</code> is empty or true. The entry then gets checked against targets. If <code>target_array</code> and/or <code>targets</code> is set, they are used as possible targets. Otherwise ''all'' countries are used as possible targets. The <code>enable</code> and <code>abort</code> triggers are checked for each possible target. If a target passes these checks, all <code>ai_strategy</code>s of the entry are enabled for source, but replacing their <code>id</code> with target.
一个'''逆'''('''reversed ''' 条目工作的方法却不同。如果条目在<code>ai_strategy</code> 中作为<code>id</code> 引用且<code>enable_reverse</code> 为空或真,条目将对源国家激活。然后此条目将对目标国家检查。如果<code>target_array</code> / <code>targets</code> 有设置,它们将用作可能的目标;否则,所有国家都作为可能的目标。<code>enable</code> <code>abort</code> 触发器将对每个目标检查。如果一个国家通过了检查,那么条目中所有<code>ai_strategy</code> 的将对源国家激活,同时从目标中移除他们的<code>id</code>


==== Attributes ====
==== 属性/参数 ====
* allowed: ''(type: AND [[trigger]])'' Only evaluated once at the start of the game, so the conditions should be static (e.g. <code>tag = GER</code> or <code>is_historical_focus_on = yes</code>). If an entry is not allowed it never gets checked again, so this can be used to improve performance.
* allowed: ''(type: AND [[trigger]])'' 在游戏开始时只评估一次,因此条件应该是静态的 ( 例如 <code>tag = GER</code> <code>is_historical_focus_on = yes</code>). 如果未通过条目,它将不再被检查以提高性能。
* enable: ''(type: AND [[trigger]])'' Enables the entry (unless abort is also non-empty and true).
* enable: ''(type: AND [[trigger]])'' 激活条目 ( 除非 abort 非空且为真).
* abort: ''(type: AND [[trigger]])'' If non-empty and true, disables the entry.
* abort: ''(type: AND [[trigger]])'' 若非空且为真,废除该条目。
* abort_when_not_enabled: ''(type: yes/no, default: no)'' If enabled, the entry will be disabled when <code>enable</code> becomes false.
* abort_when_not_enabled: ''(type: yes/no, default: no)'' 若为真,则在<code>enable</code> 为假时废除该条目。
* ai_strategy: ''(type: AI strategy, may appear multiple times)'' an AI strategy to apply with this entry
* ai_strategy: ''(type: AI strategy, may appear multiple times)'' 在条目激活后应用的 AI 策略。
* reversed: ''(type: yes/no, default: no)'' use reversed semantics as described above
* reversed: ''(type: yes/no, default: no)'' 使用上文所述的逆语义。
* enable_reverse: ''type: AND [[trigger]])'' an additional trigger for the source country to pass in a reversed trigger
* enable_reverse: ''type: AND [[trigger]])'' 源国家通过逆触发器向目标国家传递的另一个触发器
* target_array: ''(type: variable)'' An array variable containing reverse targets, e.g. <code>neighbors</code>, <code>exiles</code> or <code>enemies</code>.
* target_array: ''(type: variable)'' 包含反向目标的数组变量, 例如 <code>neighbors</code>, <code>exiles</code> <code>enemies</code>.
* targets: ''(type: list of variables)'' A list of individual reverse targets, e.g. <code>{ GER ENG FRA }</code>
* targets: ''(type: list of variables)'' 独立的反向目标列表, 例如 <code>{ GER ENG FRA }</code>


== AI Strategy Plans ==
== AI 策略计划 ==
{{SVersion|1.5}}
{{SVersion|1.5}}
The {{path|common/ai_strategy_plans}} files defines specific overall AI behaviour for specific tags, used for historical plans by default.
{{path|common/ai_strategy_plans}} 中的文件定义了特定 Tag 的全面 AI 行为,用以模拟历史上的战略计划。


Here is a generic example:
这是一个通用示例:
<pre>
<pre>
<strategy_plan> = {
<strategy_plan> = {
第468行: 第468行:
</pre>
</pre>


== AI Templates ==
== AI 模板 ==
{{SVersion|1.5}}
{{SVersion|1.5}}
The {{path|common/ai_templates}} files defines the templates used by roles that are used by the AI to dictate the templates they use.
{{path|common/ai_templates}} 中的文件定义了 AI 角色所使用的模板,以指明其使用的模板。


Roles are the core of the AI template system. They can be created arbitrarily, allowing modders to create custom roles.
角色是 AI 模板系统的核心。它们可以任意创建,允许 Modders 创建自定义角色。


Each template assigned to a role will form a group for the role, and then the fitness score of each available template is used to determine which is used at a specific moment for a specific role.
分配给某个角色的每个模板将组成一个组,然后以每个可用模板的适应度得来确定在特定时刻为角色使用哪个模板。


Here is a generic example:
这是一个通用示例:
<pre>
<pre>
<role_template_name> = {
<role_template_name> = {
第607行: 第607行:


{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding]]
[[ 分类:Modding]]

2022年12月5日 (一) 16:10的最新版本


钢铁雄心4中的 AI 可以在许多方面修改. 以下文件主要处理 AI:

  • /Hearts of Iron IV/common/ai_areas
  • /Hearts of Iron IV/common/ai_focuses
  • /Hearts of Iron IV/common/ai_peace
  • /Hearts of Iron IV/common/ai_strategy
  • /Hearts of Iron IV/common/ai_strategy_plans
  • /Hearts of Iron IV/common/ai_templates
  • /Hearts of Iron IV/common/ai_attitudes.txt
  • /Hearts of Iron IV/common/ai_personalities.txt

许多其他给玩家提供选择的地方应附有 AI 倾向来表达 AI 对各选项的权衡,这些地方使用ai_will_do。

AI 倾向

正如在许多文件中看到的那样,ai_will_do mb是一个为 AI 提供决策时权重的参数。在功能上它与 mean_time_to_happen 非常相似。它与其使用相同的修正系统,尽管它对 basefactor 有不同的解释。

注意:AI 对这个参数的运算结果不是完全遵从的,而通常与 probability-proportional-to-size sampling 类似。

base

(Type: scoped variable, default: 1) 在应用其他修改前的基础数值。

factor

(Type: number (with 3 decimal places), default: 1) 应用于计算的系数,

例子

ai_will_do = {
    base = 10.5  # may also be a variable
    
    # If the country is Germany, set the value to 0,
    # causing an early end of the evaluation.
    modifier = { tag = GER factor = 0 }

    modifier = { is_major = yes add = 1 }

    modifier = {
        factor = 3
        add = 2.5
        tag = FRA
    }

    factor = 2
}

假设正常计算,对于GER(德国) 结果为0,对于FRA(法国)结果为74,对于其余主要国家为23,对于次要国家则为21。

AI 区域

/Hearts of Iron IV/common/ai_areas 直接控制了陆地省份在有命名的 AI 区域的分配。但它们只被下文定义的 AI 策略 area_priority 使用。 每个省份只被分配到一个 AI 区域,并且是第一个匹配的区域。没必要将每个省份都分给 AI 区域,但未被分配的不能被 area_priority 策略调用。

在省份的 debug tooltip 可以看到 AI 区域。

这是一个通用示例:

<area name> = {
    # Used to add continents
    continents = {
        <continent>
    }
    
    # Used to add specific strategic regions
    strategic_regions = {
        <strategic region ids>
    }
}

AI 国策

参考 AI focuses#Modding

AI 和平策略

/Hearts of Iron IV/common/ai_peace 中的文件控制了 AI 如何完成和平会议。

There are five types of peace behaviour一共有 5 种 AI 和平策略:

  • 内战
  • 民主主义
  • 共产主义
  • 法西斯主义
  • 默认

和平会议一共有 5 种和平行动:

  • 吞并国家
  • 解放国家
  • 傀儡国家
  • 获取土地
  • 改变政府(原版民主主义专属)

这是一个通用示例:

<type>_peace = {
    # Determines when this peace AI is used by the AI (ROOT is taker, FROM is giver)
    enable = {
        <triggers>
    }
    
    # Random factors applied to AI decision making when determining which
    # peace option to use.
    annex_randomness = <int>
    liberate_randomness = <int>
    puppet_randomness = <int>
    take_states_randomness = <int>
    force_government_randomness = <int>
    
    # Weighting towards the option. (ROOT is taker, FROM is giver)
    <peace option> = {
        factor = <float>
        
        <triggers>
        
        modifier = {
            factor = <float>
            
            <triggers>
        }
    }
}

AI 策略

AI 策略影响在特定策略考量 (types) 中,其他 AI 组件中的决策形成,这也可以是定向的。例如一个国家可以在策略上对保护另一国家有兴趣,而不考虑当前外交与同盟关系;或者它更倾向于训练某一特定类型的师。

在结构层面,一个 AI 策略只有 4 个参数:typevalueid,以及 target 。只有部分类型的 AI 策略使用了 id和/或 target。本来,4 个参数都是整型,但如果 type先被指定,那么id参数可以用名字来调用对应的值(参考下文表格)。target_country 是另一种设置 target的方式。它接受一个国家下标或国家 Tag,并会检查其是否指向了一个可用的国家。

AI 会自己生成动态策略,但想添加静态策略也是可行的。静态策略的主要被/Hearts of Iron IV/common/ai_strategy中的 AI 策略条目AI 策略计划 定义(见下文)。领导人特质(/Hearts of Iron IV/common/country_leader中)可以修改 AI 策略,当特质携带者成为国家领导人时。独立的策略也可以用add_ai_strategy命令直接添加(例如事件·,国策中,等等)。

一个国家有效的 AI 策略保存在保存文件中,作为该国的ai属性。

类型

定义 ai_strategy 时, 类型决定了 AI 策略改变的方面。 抵抗运动 dlc 中新增的 AI 策略可以在 common/ai_strategy/default.txt 中找到。

Type ID Type ID Description
45 added_military_to_civilian_factory_ratio Alters the Military-to-Civilian factory ratio.
28 air_factory_balance Alters the Air factory ratio.
8 alliance <tag> Nudges diplomatic AI towards forming an alliance with another specified country.
3 antagonize <tag> Nudges diplomatic AI towards being meaner to another specified country.
33 area_priority <ai_area> Encourages the military AI to target specified AI area.
4 befriend <tag> Nudges diplomatic AI towards being nicer to another specified country.
10 build_airplane Unused.
11 build_army <unit role> Orders the AI to build a type of division or equipment (as in air planes or ships) that belong to the specified unit role.
12 build_building <building> Orders the AI to build a specific building in a specific location. Uses target to specify the state location.
9 build_ship Unused.
56 building_target <building> Orders the AI to build towards specified amount of <building>. This includes those already owned and acquired by trade (Civilian Factory).
1 colonize Unused.
0 conquer <tag> Encourages the military AI to target specified tag.
6 consider_weak <tag> Nudges the AI disposition towards considering the specified tag weak.
17 contain <tag> Nudges the diplomatic AI towards taking actions against another country, such as guaranteeing their future potential enemies.
41 declare_war <tag> Nudges the AI disposition towards declaring war against the specified tag.
48 dockyard_to_military_factory_ratio Alters the Dockyard-to-Military factory ratio.
49 dont_defend_ally_borders <tag> Nudges the AI disposition towards not defending the specified ally's borders.
44 dont_join_wars_with <tag> Nudges the AI disposition towards not defending the target country when the specified tag is involved. Uses target_country to define the target country.
29 equipment_production_factor <unit type> Alters the equipment production disposition for the specified unit type.
31 equipment_production_min_factories <unit type> Sets the minimum factory count needed to start equipment production for the specified unit type.
26 equipment_stockpile_surplus_ratio Sets the base equipment stockpile surplus value.
30 equipment_variant_production_factor <equipment> Alters the equipment variant production disposition for the specified equipment.
2 explore Unused.
46 factory_build_score_factor Modifies the AI build disposition for a state. Uses target to specific the target state.
50 force_defend_ally_borders Unused.
15 garrison <integer> (scale of 100) Used in ai_strategies/SOV.txt, USA.txt, ENG.txt how much of the army should be kept on garrison duty
32 ignore <tag> Nudges the AI disposition towards ignoring the specified tag.
42 ignore_army_incompetence Sets the AI disposition towards ignoring army incompetence.
47 ignore_claim <tag> Sets AI ignorance of claims against the specified tag. Accepts 1 as a value.
7 influence Unused.
18 invade <tag> Nudges the AI disposition towards invading the specified tag.
21 land_xp_spend_priority Unused.
37 naval_avoid_region <strategic region> Alters AI avoidance of the specified strategic region navally.
35 occupation_policy <tag> Determines the occupation policy towards the specified tag. Accepts values 0 to 3.
40 pp_spend_amount
  • admiral
  • relation
  • guarantee
  • decision
  • etc.
Sets the amount allowed for spending Political Power on the specified action.
22 pp_spend_priority
  • admiral
  • relation
  • guarantee
  • decision
  • etc.
Sets the priority for spending Political Power on the specified action.
38 prepare_for_war <tag> it nudges the AI to plan an attack ahead of time for a possible war with target
5 protect <tag> Nudges the diplomatic AI of a country to try to defend another specified country.
13 research_tech <technology> Orders the AI to research a specific technology, if possible.
20 role_ratio <unit role> Out of the entire army, this is the ratio (in %) of that unit role that the army should have. Roles can be defined arbitrarily in ai_templates.
39 save_equipment <equipment> Makes the AI save equipment of the specified type to the set value.
34 send_volunteers_desire <tag> Alters AI disposition towards sending volunteers to the specified tag.
43 spare_unit_factor Sets the spare unit factor. Used to encourage AI to send more units off to assist in allied fronts and not garrison their home territory.
36 support <tag> Alters AI disposition towards supporting the specified tag against partisans.
23 template_prio <unit type> Sets the template priority of the specified unit type for the AI.
24 template_xp_reserve Sets the XP reserved needed for the AI to consider template changes.
61 force_build_armies Added in 1.6.2, to force AI build armies... Mainly used for China to prepare for war against Japan
19 unit_ratio <unit type> Out of the entire army, this is the ratio (in %) of that unit type that the army should have.
25 equipment_design_priority
58 production_upgrade_desire_offset <equipment>
put_unit_buffers See ai_strategy/default.txt Used to tell AI to garrison certain states

AI 策略条目

一个策略条目包含了一个或多个 AI 策略,并定义了应用的时机和方式。在一个国家检查一个条目的时候,只有在enable 为真以及abort 为空或假时才会激活这个条目。条目将在abort 非空且为真时,或者填写了abort_when_not_enabledenable为假时被废除。

一个reversed) 条目工作的方法却不同。如果条目在ai_strategy中作为id引用且enable_reverse为空或真,条目将对源国家激活。然后此条目将对目标国家检查。如果target_array和/或targets 有设置,它们将用作可能的目标;否则,所有国家都作为可能的目标。enableabort 触发器将对每个目标检查。如果一个国家通过了检查,那么条目中所有ai_strategy的将对源国家激活,同时从目标中移除他们的id

属性/参数

  • allowed: (type: AND trigger) 在游戏开始时只评估一次,因此条件应该是静态的 (例如 tag = GERis_historical_focus_on = yes). 如果未通过条目,它将不再被检查以提高性能。
  • enable: (type: AND trigger) 激活条目 (除非 abort 非空且为真).
  • abort: (type: AND trigger) 若非空且为真,废除该条目。
  • abort_when_not_enabled: (type: yes/no, default: no) 若为真,则在enable为假时废除该条目。
  • ai_strategy: (type: AI strategy, may appear multiple times) 在条目激活后应用的 AI 策略。
  • reversed: (type: yes/no, default: no) 使用上文所述的逆语义。
  • enable_reverse: type: AND trigger) 源国家通过逆触发器向目标国家传递的另一个触发器
  • target_array: (type: variable) 包含反向目标的数组变量, 例如 neighbors, exilesenemies.
  • targets: (type: list of variables) 独立的反向目标列表, 例如 { GER ENG FRA }

AI 策略计划

/Hearts of Iron IV/common/ai_strategy_plans 中的文件定义了特定 Tag 的全面 AI 行为,用以模拟历史上的战略计划。

这是一个通用示例:

<strategy_plan> = {
    name = <name>       # Name of the plan
    desc = <desc>       # Description of the plan
    
    # When this plan is enabled.
    enable = {
        <triggers>
    }
    
    # When this plan is aborted.
    abort = {
        <triggers>
    }
    
    # Defines which national focuses the AI picks first during this plan.
    ai_national_focuses = {
        <focus> # AI picks top downwards
    }
    
    # Defines which technology categories the AI has weighting towards/against during this plan.
    research = {
        <category> = <weight>
    }
    
    # Defines which ideas the AI has weighting towards/against during this plan.
    ideas = {
        <idea> = <weight>
    }
    
    # Defines which traits the AI has weighting towards/against during this plan.
    traits = {
        <trait> = <weight>
    }
    
    # Defines AI strategies to apply during this plan. 
    ai_strategy = {
        <strategy attributes>
    }
    
    # Defines pick weights for specific focuses during this plan.
    focus_factors = {
        <focus> = <weight>
    }
    
    # Keep small, as it is used as a factor for some things (such as research needs)
    # Recommended around 1.0. Useful for relation between plans
    weight = {
        factor = 1.0
        modifier = {
            factor = 1.0
        }
    }
}

AI 模板

/Hearts of Iron IV/common/ai_templates中的文件定义了 AI 角色所使用的模板,以指明其使用的模板。

角色是 AI 模板系统的核心。它们可以任意创建,允许 Modders 创建自定义角色。

分配给某个角色的每个模板将组成一个组,然后以每个可用模板的适应度得来确定在特定时刻为角色使用哪个模板。

这是一个通用示例:

<role_template_name> = {
    # Defines the actual role(s) the template covers.
    roles = {
        <roles>
    }
    
    # Restricts the template to only the specified tags. Optional.
    available_for = {
        <tags>
    }
    
    # Blocks the template for the specified tags. Optional.
    blocked_for = {
        <tags>
    }
    
    # Determines which existing templates are included in this role
    match_to_count = <float> # By default 0.5
    
    # Determines the importance of the role template, highest importance is the role used by the AI.
    upgrade_prio = {
        factor = <float> # Base factor
        
        # Modifies the base factor
        modifier = {
            factor = <float>
            
            <triggers>
        }
    }
    
    # A template that belongs to this role. Multiple are allowed per role template.
    <template_name> = {
        # Determines the importance of the template amoungst other templates listed within the same role.
        upgrade_prio = {
            factor = <float> # Base factor
            
            # Modifies the base factor
            modifier = {
                factor = <float>
                
                <triggers>
            }
        }
        
        # Determines which template the AI will assign to a deployment line for a role. Highest score wins.
        production_prio = {
            factor = <float> # Base factor
            
            # Modifies the base factor
            modifier = {
                factor = <float>
                
                <triggers>
            }
        }
        
        # Determines the requirement to upgrade in field
        can_upgrade_in_field = {
            <triggers>
        }
        
        custom_icon = <int>
        reinforce_prio = <int>
        target_width = <float>
        width_weight = <float>
        column_swap_factor = <float> 

        # Determines the weights for each stat for this template.
        # Order determines which stat the value affects.
        stat_weights = {
            <float> #-- default_morale
            <float> #-- defense
            <float> #-- breakthrough
            <float> #-- hardness
            <float> #-- soft_attack
            <float> #-- hard_attack
            <float> #-- recon
            <float> #-- entrenchment
            <float> #-- initiative
            <float> #-- casualty_trickleback
            <float> #-- supply_consumption_factor
            <float> #-- supply_consumption
            <float> #-- suppression
            <float> #-- suppression_factor
            <float> #-- experience_loss_factor
            <float> #-- equipment_capture_factor
            
            #-- Air Values
            <float> #-- air_attack
            
            #-- Common Values
            <float> #-- max_organisation
            <float> #-- max_strength
            <float> #-- maximum_speed
            <float> #-- armor_value
            <float> #-- ap_attack
            <float> #-- reliability
            <float> #-- reliability_factor
            <float> #-- weight
            <float> #-- build_cost_ic
        }
        
        # 
        target_template = {
            weight = <float>
            match_value = <float>
            
            support = {
                <support unit> = <amount>
            }
            
            regiments = {
                <unit> = <amount>
            }
        }
        
        allowed_types = {
            <units>
        }
        
        replace_at_match = <float>
        replace_with = <template>
        target_min_match = <float>
    }
}