Skip to content

Improve AI draw-punisher avoidance heuristics#10576

Open
Madwand99 wants to merge 3 commits intoCard-Forge:masterfrom
Madwand99:ImproveAIforDrawPunishers
Open

Improve AI draw-punisher avoidance heuristics#10576
Madwand99 wants to merge 3 commits intoCard-Forge:masterfrom
Madwand99:ImproveAIforDrawPunishers

Conversation

@Madwand99
Copy link
Copy Markdown
Contributor

This narrows the previous AI decision work (#10559) to a lightweight heuristic for avoiding dangerous draw effects into opposing draw-punishers.

Changes include:

  • Adds a static heuristic for detecting risky self-draw plays without running a generic safety simulation.
  • Detects draw-heavy effects such as wheel-style hand redraws and permanent-triggered draw engines.
  • Detects opposing draw-punisher triggers by behavior, not card name, including damage/life-loss/token payoff triggers.
  • Applies the heuristic to normal AI spell selection, simulation picker candidates, and optional free-cast decisions.
  • Preserves a commander exception so the AI does not refuse to cast its own commander from the command zone.
  • Fixes Timetwister AI logic matching to handle the card script’s casing.
  • Adds regression coverage for Wheel of Fortune, Timetwister, Echo of Eons, Mindmoil, Teferi’s Puzzle Box, Arjun, Xyris, Nekusar, and Kederekt Parasite cases.

Comment thread forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java Outdated
return ComputerUtilCombat.attackerWouldBeDestroyed(ai, attacker, combat);
}

public static boolean shouldAvoidDrawPunisher(final Player ai, final SpellAbility sa) {
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.

hmn, I'll have to think on this:
we usually don't attempt guessing this sort of two level deep
(e.g. we have helpers for direct damage from etb/casting but this is more "I might draw from it" + "then I might lose life from drawing")

I'm not convinced that while at first this might look good for a few specific cases it doesn't end up causing just as much problems at other times, especially when it's hooked up this high in the chain 🤔

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.

Makes sense. This heuristic is intentionally trying to catch cases that are one step beyond direct “this spell hurts me”: “this play causes me to draw a lot” plus “an opponent has an active draw punisher.” That is why it catches things like Wheel effects into Nekusar/Xyris, but also why it is riskier than the usual direct ETB/cast damage checks.

I think there are a few possible directions:

  1. Keep the current high-level hook. This catches the broadest set of cases, including future draw-engine permanents like Mindmoil, Teferi’s Puzzle Box, and Arjun. The downside is exactly what you pointed out: false positives are expensive because this blocks the play before normal AI evaluation can consider context.
  2. Move the heuristic into narrower ability logic, e.g. ChangeZoneAllAi / wheel-style effects only. This is much safer and easier to reason about, but it would no longer catch permanents like Mindmoil/Puzzle Box/Arjun being cast into Xyris/Nekusar/Kederekt.
  3. Split the heuristic into narrower cases: immediate wheel-style draw effects in the relevant ability AI, plus a separate permanent-spell check only when the card being cast has its own large self-draw trigger. That would still catch Mindmoil/Puzzle Box/Arjun, but avoid using this as a broad “before any spell” gate.

Happy to go with any of these options.

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.

2 participants