Improve AI mode selection for modal spells#10569
Improve AI mode selection for modal spells#10569Madwand99 wants to merge 2 commits intoCard-Forge:masterfrom
Conversation
|
Example of AI where the old code added extra Cost but shouldn't: AI used Because of that |
I looked into this case. We could add a narrow guard in CharmAi before paying for an extra mode: for paid ModeCost modes that are hidden ChangeZone effects from a known zone like graveyard to battlefield, check whether there is at least one matching card before adding the mode. That would stop the Lively Dirge case where the AI pays for the reanimation mode with no creatures in graveyard. However, after checking the current card scripts, this guard appears to only help Lively Dirge right now, so it feels a bit too card-shaped for this modal-spell PR. I think the better long-term fix is in ChangeZoneAi or the hidden-origin ChangeZone evaluation: “up to” hidden moves should not be considered useful just because choosing zero is legal, especially when an extra cost is being paid. I’m inclined to leave that as a follow-up unless maintainers prefer the narrow modal guard here. |
This improves CharmAi mode selection for modal spells that can choose extra modes when doing so is useful and payable.
Previously, the AI could identify one good mode and stop there, even on cards like Crush Contraband where choosing both modes is free and beneficial. It also did not properly reason about extra mode costs for mechanics like Escalate, Entwine, and Spree/Tiered.
Changes included:
Let non-trigger modal spells add additional useful modes when MinCharmNum < CharmNum.
Treat candidate extra modes like effects the AI can evaluate in the moment via normal spell/trigger heuristics.
Add cost-aware mode checks for:
Avoid crashes from sub-mode AI that assumes full spell context by falling back safely during optional mode evaluation.
Added regression coverage for:
Remaining known gap:
CanRepeatModes is still not properly handled by CharmAi. Cards like Confluences and Seasons that say “you may choose the same mode more than once” do not yet have smart repeat-mode selection. The current AI can choose multiple distinct good modes, but it does not intentionally rank and repeat the best mode when repetition would be optimal.