Wiki

trigger · ai_irrationality

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check the ai irrationality value

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

ai_irrationality 常用于 AI 行为调试和特殊事件触发场景,例如当 AI 的非理性值超过某个阈值时解锁特殊决议或触发随机事件,也用于判断某个 AI 国家当前的决策"混乱程度"以给玩家提供情报反馈。典型场景是在 AI 专属的 limit 块中过滤掉理性值过低的国家,避免其触发需要稳定逻辑的 focus 链。

# 仅当 AI 非理性值满足条件时才允许触发某事件
country_event = {
    trigger = {
        is_ai = yes
        ai_irrationality > 10
    }
    ...
}

# 在决策的 available 块中用作门槛
available = {
    ai_irrationality < 5
}

配合关系

  • [has_country_flag](/wiki/trigger/has_country_flag):先用国家标记记录某次非理性行为是否已触发过,再配合 ai_irrationality 做双重门槛,防止重复执行。
  • [is_ai](/wiki/trigger/is_ai)(注:白名单未列出,以下替换)[exists](/wiki/trigger/exists):确保目标国家存在后再检测非理性值,避免对已亡国目标报错。
  • [add_ai_strategy](/wiki/effect/add_ai_strategy):当非理性值超限时,通过添加 AI 策略来"纠偏"其行为倾向,形成"检测→矫正"的完整逻辑闭环。
  • [has_country_flag](/wiki/trigger/has_country_flag) + [clr_country_flag](/wiki/effect/clr_country_flag):结合标记的清除与判断,实现对非理性值触发窗口的精确控制,避免同一周期内多次响应。

常见坑

  1. 忘记限定 AI scopeai_irrationality 只对 AI 控制的国家有意义,若在玩家控制的国家 scope 下使用,其值通常为 0 或无意义,需配合逻辑确保仅在 AI 国家中调用,否则条件永远不会按预期触发。
  2. 误用比较运算符:新手常省略比较符直接写 ai_irrationality = 5,但该 trigger 需要使用 > / < / >= 等数值比较形式,写成等号通常无法正确匹配,导致条件块静默失效。

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

Hands-On Usage

ai_irrationality is commonly used for AI behavior debugging and special event trigger scenarios. For example, unlocking special decisions or triggering random events when an AI's irrationality value exceeds a certain threshold, or assessing a given AI nation's current decision-making "chaos level" to provide intelligence feedback to the player. A typical use case is filtering out nations with low rationality values in AI-exclusive limit blocks to prevent them from triggering focus chains that require stable logic.

# Only trigger certain events when AI irrationality meets the condition
country_event = {
    trigger = {
        is_ai = yes
        ai_irrationality > 10
    }
    ...
}

# Use as a threshold in the available block of a decision
available = {
    ai_irrationality < 5
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): Use country flags to record whether a particular irrational behavior has already been triggered, then combine with ai_irrationality as a double threshold to prevent repeated execution.
  • [is_ai](/wiki/trigger/is_ai): Ensure the target nation exists before checking irrationality values, preventing errors against dead nations.
  • [add_ai_strategy](/wiki/effect/add_ai_strategy): When irrationality exceeds limits, add AI strategies to "correct" behavioral tendencies, forming a complete "detect→correct" logic loop.
  • [has_country_flag](/wiki/trigger/has_country_flag) + [clr_country_flag](/wiki/effect/clr_country_flag): Combine flag clearing and checking to precisely control the trigger window for irrationality values, avoiding multiple responses within the same time period.

Common Pitfalls

  1. Forgetting to scope to AI nations: ai_irrationality only makes sense for AI-controlled nations. If used within a player-controlled nation scope, its value is typically 0 or meaningless. You must combine it with logic to ensure it's only called within AI nation scopes, otherwise conditions will never trigger as expected.
  2. Misusing comparison operators: Beginners often omit the comparison operator and write ai_irrationality = 5 directly, but this trigger requires using > / < / >= and other numerical comparison forms. Using equals signs typically fails to match correctly, silently breaking the condition block.