Skip to content

agent/Add Chaos Ritual (Ritual of Light and Darkness) - #283

Merged
mercury233 merged 10 commits into
IceYGO:masterfrom
Yuan-Chun-Chih:agent/chaos-ritual-pr
Aug 29, 2026
Merged

agent/Add Chaos Ritual (Ritual of Light and Darkness)#283
mercury233 merged 10 commits into
IceYGO:masterfrom
Yuan-Chun-Chih:agent/chaos-ritual-pr

Conversation

@Yuan-Chun-Chih

@Yuan-Chun-Chih Yuan-Chun-Chih commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Add the Chaos Ritual deck and its AI decision-making logic.

Changes

  • Add AI_ChaosRitual.ydk.
  • Add and register the Chaos Ritual bot in BotWrapper/bot.conf.
  • Add ChaosRitualExecutor.cs .

Validation

  • Successfully built with Debug Any CPU configuration.
  • Result: 0 errors.
  • Existing compiler warnings remain unchanged.

Follow-up Files

For additional explanation of the AI logic, please see:
AI_ChaosRitual_rule copy.md

Add a full ChaosRitual deck AI executor with extensive logic: summon/activate executors, chain/select handlers, Mind Shuffle and Light & Darkness Ritual handling, Gallant Thief tribute selection, Skull Archfiend recycle rules, search/setting reservations, hand-trap and extra-deck priorities, and many helper selectors and lifecycle trackers. Also register the new Deck=ChaosRitual entry in BotWrapper/bot.conf. Changes are localized to ChaosRitualExecutor.cs and bot.conf; no unrelated files modified.
@mercury233

Copy link
Copy Markdown
Collaborator

GPT 5.6:

  1. [P1] 精灵圣贤者的召唤成功诱发效果被错误“延后”
    ChaosRitualExecutor.cs:887

    诱发效果的窗口不能延后。此处读取的是上一次 SelectIdleCmd 留下的 MainPhase.SpecialSummonableCards;若召唤前黑混沌可特殊召唤,圣贤者召唤后便会返回 false,永久错过抽 3 丢 2 的效果。

  2. [P1] 两颗心灵的效果描述偏移整体错一位
    ChaosRitualExecutor.cs:976

    本地脚本中检索效果是 offset 0,换怪效果是 offset 1;代码判断的是 1 和不存在的 2。结果是换怪效果套用了检索条件,可能在没有牌组检索对象时拒绝合法响应,也可能在无突破需要时随意换怪。

  3. [P1] 骸骨恶魔的三卡选择没有保证必需的卡名记述卡
    ChaosRitualExecutor.cs:1862

    脚本要求选出的 3 张中至少 1 张记述「光与暗的仪式」。当前排序只考虑位置和资源价值,甚至会把无关的对方墓地卡固定放在第一位。若前三张均不满足 gcheckSelectSubGroup 无法结束;WindBot 又不会回退取消已选卡,可能卡住选择流程。

  4. [P2] 魔法效果之剑被破坏后的诱发效果永远不会主动发动
    ChaosRitualExecutor.cs:1433

    该延迟诱发效果进入提示时当前连锁已经结束,因此 Duel.CurrentChain.Count == 0,函数会直接拒绝。应按墓地位置或 offset 3 单独处理。

  5. [P2] 栗球兽卫把仪式魔法误判成可盖放对象
    ChaosRitualExecutor.cs:2906

    脚本只允许盖放速攻魔法或陷阱;「光与暗的仪式」是仪式魔法。这个误判会让 AI 丢弃栗球兽卫,但实际没有盖放选项,最终回退选择不需要的伤害免除效果。

  6. [P2] 圣贤者在召唤前把自己计入了手牌条件
    ChaosRitualExecutor.cs:862

    CelticMystic 自身属于 IsRitualRelatedCard,而召唤判断时它仍在手牌,因此条件实际上总为真。AI 会在没有其他相关手牌、无法抽 3 或特殊召唤仪式怪兽时仍优先通常召唤它;同样问题也出现在 ShouldSummonCelticMysticFirst()

  7. [P2] 黑色混沌之魔术师的两个场上效果使用了同一条件
    ChaosRitualExecutor.cs:1416

    墓地存在魔法卡只与召唤成功回收效果有关。里侧除外效果不需要该条件,因此通过两颗心灵等方式特殊召唤、墓地尚无魔法时,AI 会拒绝合法的除外效果。

  8. [P2] 等待大义贼的判断没有确认手里真的有大义贼
    ChaosRitualExecutor.cs:730

    CanSummonGallantThief() 在主阶段作为该卡执行器条件时成立,但复用于通用等待逻辑后缺少手牌检查。先攻方场面满足条件但手里没有大义贼时,AI 仍可能在自己抽卡/准备阶段拒绝灰流丽、增殖的 G 等响应。项目中的絢嵐实现明确检查了 Bot.HasInHand(...)

Tightens ChaosRitual executor logic to fix misfires and incorrect selections. Separates Celtic Mystic summon-success draw from its ignition effect and tracks pending triggers; prevents stale generic descriptions from inheriting wrong conditions. Implements Light & Darkness Ritual material selection state to allow MSG_SELECT_UNSELECT confirmation and avoid over-selecting grave monsters. Improves Black Luster Soldier battle/attack ordering and description-aware activation checks for several cards (Gallant Thief, Magician of Dark Chaos, MaxxC, MindShuffle, Ragged Records, Skull Archfiend, Spell Shattering Sword). Adds opponent-target reservation checks, refines Spatial Trunade/selection priorities, and adjusts various activation/search guards to handle server/core description differences and prevent double-preselection.
@Yuan-Chun-Chih

Copy link
Copy Markdown
Contributor Author

感谢大佬的 review,问题我已经逐项修正,并重新检查了一下逻辑。

  1. 精灵圣贤者召唤成功诱发效果
    已移除抽三丢二效果对旧的 SpecialSummonableCards 快照依赖。
    现在:
  • 精灵圣贤者召唤成功后,抽三丢二效果会正常优先进入诱发窗口。
  • 只有解放自身特殊召唤仪式怪兽的效果,才会延后到其他更高优先级动作之后。
  • 另外增加了独立的召唤成功触发状态,避免两个效果在 ActivateDescription == -1 时互相误判。
  1. 双心切换的效果描述偏移
    已修正为:
  • offset 0:检索效果。
  • offset 1:怪兽返回及特殊召唤效果。
  1. 骷髅恶魔选卡
    现在会:
  • 优先按照原本的资源价值排序。
  • 强制将符合仪式记述条件的卡放入有效选择范围。
  • 如果当前服务器候选与预期不一致,则不会继续提交不满足脚本 gcheck 条件的选择,避免卡在选择流程中。
  1. 魔法效果之剑墓地诱发效果
    已修正墓地延迟诱发效果的判断。
    现在墓地效果不会再要求当前连锁必须存在:
  • 明确识别 offset 3。
  • 也兼容服务器以通用描述 -1 提供的诱发提示。
    因此即使当前连锁已经结束,也可以正常发动墓地效果。
  1. 栗球兽卫误判仪式魔法为可盖放对象
    已移除将 光与闇的儀式 当作栗球兽卫可盖放对象的逻辑。
    栗球兽卫现在只会考虑:
  • 速攻魔法。
  • 陷阱卡。
    不会再因为手上存在仪式魔法而错误发动效果。
  1. 精灵圣贤者召唤前把自己计入手牌条件
    已修正 CelticMysticSummon() 和 ShouldSummonCelticMysticFirst()。
    现在判断手牌中的仪式相关卡时,会排除当前正在召唤的精灵圣贤者本身,避免只有精灵圣贤者一张相关卡时仍被错误判断为满足条件。
  2. 黑混沌魔术师两个场上效果使用同一条件
    已分开处理:
  • 召唤成功后的墓地魔法回收效果:检查我方墓地是否有魔法卡。
  • 里侧除外效果:只检查对手场上是否存在可处理的卡,不再要求我方墓地必须存在魔法卡。
    因此即使墓地没有魔法卡,也不会再错误拒绝合法的里侧除外效果。
  1. 大义贼等待判断没有确认手牌
    已修正等待逻辑,现在会先确认我方手牌中实际存在天下独步的大义贼,并且确认:
  • 我方场上没有怪兽。
  • 对手场上存在怪兽。
  • 祭品条件满足。
    大义贼的祭品选择策略仍然保留优先使用对手场上的怪兽;如果对手场上的祭品不足,才允许使用我方手牌怪兽作为备援。

@foohyfooh foohyfooh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was playing against this to try and practice against ROLAD so I noticed some things.

I am not sure where the logic for Black Skull Dragon the Archfiend Dragon of Unity selecting its position is but the bot only seems to summon it in defense even when it being in attack would have allowed it to win at that point.

return false;
}

private bool TheFallenTheVirtuousActivate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was playing against this it kept targeting Fiendsmith's Requiem which could have just used its effect to dodge the targeting.
Also it kinda let me get to Requiem rather than destroying the Lurrie so that is something to figure out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for testing the Bot and providing your feedback.

1.Regarding Black Skull Dragon the Archfiend Dragon of Unity, its own effect text specifically requires it to be Special Summoned in Defense Position. Therefore, it cannot be Special Summoned in Attack Position through that effect.

2.Regarding The Fallen & The Virtuous, one of its current rules intentionally prioritizes destroying Extra Deck monsters. However, its target evaluation is relatively complex, especially when facing cards such as Fiendsmith’s Requiem that can leave the field in response. I will continue considering how to further optimize its target-selection logic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.Regarding Black Skull Dragon the Archfiend Dragon of Unity, its own effect text specifically requires it to be Special Summoned in Defense Position. Therefore, it cannot be Special Summoned in Attack Position through that effect.

Sorry about that comment then. I read the effect and somehow missed that part.

This change tightens Chaos Ritual AI responsiveness around chain-snapshot tracking and selection state. It adds pending-target bookkeeping for Black Chaos, Spell Shattering Sword, and Fydraulis, prevents stale chain/Deck-search selection from consuming the wrong prompt, and improves target prioritization for Fallen/Fydraulis destruction and general effect targeting.

It also fixes several activation checks for multi-effect cards, face-up monster filtering, and Black Chaos/Griffoh support searches so the bot chooses the correct action without relying on stale chain data.
@mercury233

Copy link
Copy Markdown
Collaborator
  • OnSpSummoned 会设置 _celticMysticDrawTriggerPending,但紧接着原连锁结束时,OnChainEnd 又无条件清除它。
  • 「魔法效果之剑」被破坏后改为除外时,②效果不会发动。
  • 一个明显可优化点是 OnChaining 中读取 GetLatestChainInfo() 的分支:GameBehavior 在调用 OnChaining 之后才把当前 ChainInfo 加入列表,因此这里读到的只能是上一连锁环节;已有 OnChainSolved 兜底,该分支可以删除,避免误导后续维护。

@Yuan-Chun-Chih

Copy link
Copy Markdown
Contributor Author

已修正前述三项问题

精灵圣贤者

  • 特召成功后若仍在原连锁处理中,抽三丢二会跨过该次 OnChainEnd 保留。
  • 下一个诱发窗口便能正常发动。
  • 发动后、离场、新阶段或后续窗口失效时会清除旗标,避免残留。

魔法效果之剑

  • 被破坏后即使因替代处理进入除外区,②效果也会接受发动。
  • 现在同时辨识 Grave 与 Removed。

OnChaining

  • 已移除读取 GetLatestChainInfo() 的多效果卡追踪分支。
  • 因为当下新 ChainInfo 尚未加入,读到的确实只会是上一个连锁环节。
  • 多效果卡继续由 OnChainSolved 的正确快照追踪。

额外新增了天救龙的目标预约逻辑

  • 天救龙接受发动时,预约当前最高顺位的对手怪兽。
  • The Fallen 会将该怪兽视为已被其他效果处理。

@mercury233
mercury233 merged commit e5fd8b8 into IceYGO:master Aug 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants