钢铁雄心4
ParaWikis
最新百科
都市天际线2百科
英雄无敌3百科
维多利亚3百科
奇妙探险队2百科
罪恶帝国百科
英白拉多:罗马百科
热门百科
群星百科
欧陆风云4百科
十字军之王2百科
十字军之王3百科
钢铁雄心4百科
维多利亚2百科
ParaWikis
申请建站
ParaWikis
ParaCommons
最近更改
随机页面
加入QQ群
工具
链入页面
相关更改
特殊页面
页面信息
页面值
帮助
译名手册
字词转换
编辑指南
编辑规范
练手沙盒
资助我们
ParaTranz
资助我们
×
欢迎访问钢铁雄心4百科!
注册一个账号
,一起参与编写吧!这里是
当前的工程
。
全站已采用新UI,任何使用上的问题请点击
这里
。欢迎所有对百科感兴趣的同学加入钢4编辑群:
1137478871
。
阅读
查看源代码
查看历史
讨论
查看“AI modding”的源代码
←
AI modding
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{version|1.5}} 钢铁雄心4中的 AI 可以在许多方面修改. 以下文件主要处理 AI: * {{path|common/ai_areas}} * {{path|common/ai_focuses}} * {{path|common/ai_peace}} * {{path|common/ai_strategy}} * {{path|common/ai_strategy_plans}} * {{path|common/ai_templates}} * {{path|common/ai_attitudes.txt}} * {{path|common/ai_personalities.txt}} 许多其他给玩家提供选择的地方应附有 AI 倾向来表达 AI 对各选项的权衡,这些地方使用'''ai_will_do。''' == AI 倾向 == {{SVersion|1.8}} {{anchor|ai_will_do}} 正如在许多文件中看到的那样,'''ai_will_do''' mb是一个为 AI 提供决策时权重的参数。在功能上它与 [[Event_modding#Mean_time_to_happen_2|mean_time_to_happen]] 非常相似。它与其使用相同的修正系统,尽管它对 ''base'' 和 ''factor'' 有不同的解释。 注意:AI 对这个参数的运算结果不是完全遵从的,而通常与 [[wp:Sampling_(statistics)#Probability-proportional-to-size_sampling|probability-proportional-to-size sampling]] 类似。 ==== base ==== ''(Type: scoped variable, default: 1)'' 在应用其他修改前的基础数值。 ==== factor ==== ''(Type: number (with 3 decimal places), default: 1)'' 应用于计算的系数, === 例子 === <pre> 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 }</pre> 假设正常计算,对于GER(德国) 结果为0,对于FRA(法国)结果为74,对于其余主要国家为23,对于次要国家则为21。 == AI 区域 == {{SVersion|1.8}} {{path|common/ai_areas}} 直接控制了陆地[[province|省份]]在有命名的 AI 区域的分配。但它们只被下文定义的 AI 策略 <code>area_priority</code> 使用。 每个省份只被分配到一个 AI 区域,并且是第一个匹配的区域。没必要将每个省份都分给 AI 区域,但未被分配的不能被 <code>area_priority</code> 策略调用。 在省份的 debug tooltip 可以看到 AI 区域。 这是一个通用示例: <pre> <area name> = { # Used to add continents continents = { <continent> } # Used to add specific strategic regions strategic_regions = { <strategic region ids> } } </pre> == AI 国策 == 参考 [[AI focuses#Modding]] == AI 和平策略 == {{SVersion|1.5}} {{path|common/ai_peace}} 中的文件控制了 AI 如何完成和平会议。 There are five types of peace behaviour一共有 5 种 AI 和平策略: * 内战 * 民主主义 * 共产主义 * 法西斯主义 * 默认 和平会议一共有 5 种和平行动: * 吞并国家 * 解放国家 * 傀儡国家 * 获取土地 * 改变政府(原版民主主义专属) 这是一个通用示例: <pre> <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> } } } </pre> == AI 策略 == {{SVersion|1.8}} AI 策略影响在特定策略考量 ('''types''') 中,其他 AI 组件中的决策形成,这也可以是定向的。例如一个国家可以在策略上对保护另一国家有兴趣,而不考虑当前外交与同盟关系;或者它更倾向于训练某一特定类型的师。 在结构层面,一个 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,并会检查其是否指向了一个可用的国家。 AI 会自己生成动态策略,但想添加静态策略也是可行的。静态策略的主要被{{path|common/ai_strategy}}中的 '''AI 策略条目''' 或 '''AI 策略计划''' 定义(见下文)。领导人特质({{path|common/country_leader}}中)可以修改 AI 策略,当特质携带者成为国家领导人时。独立的策略也可以用'''add_ai_strategy'''命令直接添加(例如事件·,国策中,等等)。 一个国家有效的 AI 策略保存在保存文件中,作为该国的<code>ai</code>属性。 === 类型 === 定义 '''ai_strategy''' 时, 类型决定了 AI 策略改变的方面。 抵抗运动 dlc 中新增的 AI 策略可以在 common/ai_strategy/default.txt 中找到。 {| class="wikitable sortable mw-collapsible" |- ! scope = "col" | Type ID ! scope = "col" | Type ! scope = "col" | ID ! scope = "col" class = "unsortable" | 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_modding#AI_area|<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 modding|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 策略,并定义了应用的时机和方式。在一个国家检查一个条目的时候,只有在<code>enable</code> 为真以及<code>abort</code> 为空或假时才会激活这个条目。条目将在<code>abort</code> 非空且为真时,或者填写了<code>abort_when_not_enabled</code>且<code>enable</code>为假时被废除。 一个'''逆'''('''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>。 ==== 属性/参数 ==== * allowed: ''(type: AND [[trigger]])'' 在游戏开始时只评估一次,因此条件应该是静态的 (例如 <code>tag = GER</code> 或 <code>is_historical_focus_on = yes</code>). 如果未通过条目,它将不再被检查以提高性能。 * enable: ''(type: AND [[trigger]])'' 激活条目 (除非 abort 非空且为真). * abort: ''(type: AND [[trigger]])'' 若非空且为真,废除该条目。 * abort_when_not_enabled: ''(type: yes/no, default: no)'' 若为真,则在<code>enable</code>为假时废除该条目。 * 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)'' 包含反向目标的数组变量, 例如 <code>neighbors</code>, <code>exiles</code> 或 <code>enemies</code>. * targets: ''(type: list of variables)'' 独立的反向目标列表, 例如 <code>{ GER ENG FRA }</code> == AI 策略计划 == {{SVersion|1.5}} {{path|common/ai_strategy_plans}} 中的文件定义了特定 Tag 的全面 AI 行为,用以模拟历史上的战略计划。 这是一个通用示例: <pre> <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 } } } </pre> == AI 模板 == {{SVersion|1.5}} {{path|common/ai_templates}}中的文件定义了 AI 角色所使用的模板,以指明其使用的模板。 角色是 AI 模板系统的核心。它们可以任意创建,允许 Modders 创建自定义角色。 分配给某个角色的每个模板将组成一个组,然后以每个可用模板的适应度得来确定在特定时刻为角色使用哪个模板。 这是一个通用示例: <pre> <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> } } </pre> {{Modding navbox}} [[分类:Modding]]
本页使用的模板:
Template:Ambox
(
查看源代码
)
Template:Ambox/core
(
查看源代码
)
Template:Anchor
(
查看源代码
)
Template:Clear
(
查看源代码
)
Template:Modding navbox
(
查看源代码
)
Template:Navbox
(
查看源代码
)
Template:Navboxgroup
(
查看源代码
)
Template:Path
(
查看源代码
)
Template:SVersion
(
查看源代码
)
Template:Version
(
查看源代码
)
返回
AI modding
。
×
登录
密码
记住登录
加入钢铁雄心4百科
忘记密码?
其他方式登录