Skip to content

#11065 Targets for each player fix#11139

Open
steven-robert-eddy wants to merge 2 commits into
Card-Forge:masterfrom
steven-robert-eddy:11065_NilsTargetsForEachPlayer
Open

#11065 Targets for each player fix#11139
steven-robert-eddy wants to merge 2 commits into
Card-Forge:masterfrom
steven-robert-eddy:11065_NilsTargetsForEachPlayer

Conversation

@steven-robert-eddy

@steven-robert-eddy steven-robert-eddy commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Issue #11065 reports that AI targeting for Nils, Discipline Enforcer does not correctly respect isForEachPlayer() restrictions, allowing targets to be chosen incorrectly instead of selecting one valid permanent per player.

Solution

Added logic to handle isForEachPlayer() targeting restrictions.

  • What changed?

    • Added a new conditional block that:
      1. Iterates through each player in the game.
      2. Gets targetable cards controlled by that player.
      3. For opponent creatures, selects the best creature using getBestAI().
      4. For AI-controlled creatures, selects the worst creature using getWorstPermanentAI() to minimize downside.
      5. One thing to note here is I am not exactly sure if this is the right implementation of which creature to target, please let me know what is expected here
      6. Adds exactly one selected target per player to the target list.
  • Why this approach?

    • Explicitly iterating over each player ensures the AI respects the "for each player" targeting restriction.
    • Existing AI heuristics are reused to maximize value against opponents while minimizing negative effects on the AI's own permanents.
  • Why not alternatives?

    • Random target selection would ignore strategic evaluation.
    • Selecting from a single combined pool could place multiple targets on one player's permanents, violating the intended targeting behavior.

Validation

  • mvn -pl forge-ai -am -DskipTests compile

  • Manual testing:

    • AI with multiple creatures targets exactly one creature per player.
    • Multiplayer games correctly target one creature for each opponent.

Known Limits

  • Limited to CountersPutAi handling of isForEachPlayer() targeting.
  • Applies only to abilities using the isForEachPlayer() restriction.
  • Only affects targeting of battlefield permanents that satisfy the ability's targeting requirements.

AI Assistance Disclosure

I used AI assistance to help analyze the issue, review the implementation, and draft this pull request description. I verified the implementation and performed the validation listed above.

Closes #11065

CardCollection targetable = CardLists.getTargetableCards(p.getCardsIn(ZoneType.Battlefield), sa);
if (!targetable.isEmpty()) {
Card choice;
if (p.isOpponentOf(ai)) {

@steven-robert-eddy steven-robert-eddy Jul 2, 2026

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.

I am not sure if this is the correct target for each player creature, please let me know if it is incorrect

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.

just use CardLists.canSubsequentlyTarget in the targeting loop instead of extra logic block

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.

doesn't look like your AI understood what I meant, I suggest you get to know this class a bit better first if possible 🤔

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.

Nils, Discipline Enforcer

2 participants