Skip to content

Stop the AI crowning itself when it is already the monarch - #11446

Merged
Agetian merged 2 commits into
Card-Forge:masterfrom
omraj21:ai-monarch-noop
Jul 29, 2026
Merged

Stop the AI crowning itself when it is already the monarch#11446
Agetian merged 2 commits into
Card-Forge:masterfrom
omraj21:ai-monarch-noop

Conversation

@omraj21

@omraj21 omraj21 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

BecomeMonarch is mapped to AlwaysPlayAi, whose entire logic is return WillPlay — it never looks at the board.

GameAction.becomeMonarch returns immediately when the chosen player is already the monarch:

public void becomeMonarch(final Player p, final String set) {
    final Player previous = game.getMonarch();
    if (p == null || p.equals(previous)) {
        return;
    }
    ...

So activating one of these abilities while already holding the crown does nothing at all.

That is not merely a wasted activation, because several of these abilities cost a permanent:

card cost
Throne of the High City {4}, {T}, Sacrifice
King Solomon's Frogs {3}, {T}, Exile
Tchaka, Venerable King {3}, Exile from graveyard

The AI was throwing a permanent away for no effect. The added test shows Throne of the High City going from one copy on the battlefield to zero under the old mapping.

The fix

BecomeMonarchAi declines only when every player the ability would crown is already the monarch.

Targeted versions are deliberately left alone. Cards like Jared Carthalion, True Heir and Garland, Royal Kidnapper hand the crown to an opponent on purpose in order to turn on another ability, so always-play is still right for them.

Initiative is intentionally not changed

The initiative mechanic looks identical but is not. GameAction.takeInitiative explicitly documents:

// You can take the initiative even if you already have it

and still runs the TakesInitiative trigger in that case, so AlwaysPlayAi remains correct for TakeInitiative.

Verification

Three tests, each of which fails on the old mapping or covers a case that must keep working:

  • doesNotCrownItselfTwice — the regression; fails with expected:<1> but was:<0> without the fix
  • takesTheCrownFromAnOpponent — still activates when an opponent holds the crown
  • claimsAnUnclaimedCrown — still activates when nobody is the monarch

forge.ai.** test suite: 248 tests, 0 failures. Full mvn -U -B clean test across all 12 modules passes.


This PR was previously part of #11441, which bundled it with an unrelated UnlockDoor fix. Split out so each can be reviewed on its own.

Written with the help of GitHub Copilot CLI; the commit carries a Co-authored-by trailer for it.

BecomeMonarch was mapped to AlwaysPlayAi, which accepts every activation without
looking at the board. GameAction.becomeMonarch returns immediately when the
chosen player is already the monarch, so activating one of these abilities while
holding the crown does nothing.

That is not just a wasted activation. Throne of the High City taps and sacrifices
itself for 4, King Solomon's Frogs exiles itself, and Tchaka, Venerable King
exiles itself from the graveyard, so the AI was throwing a permanent away for no
effect. A test with the old mapping shows Throne of the High City going from one
copy on the battlefield to zero.

Add BecomeMonarchAi, which declines only when every player the ability would
crown is already the monarch. Targeted versions are deliberately left alone:
cards like Jared Carthalion, True Heir and Garland, Royal Kidnapper hand the
crown to an opponent on purpose to turn on another ability, so the previous
always-play behaviour is still right for them.

Initiative is intentionally not changed. GameAction.takeInitiative documents that
"You can take the initiative even if you already have it" and still runs the
trigger, so AlwaysPlayAi remains correct there.

forge.ai.** test suite: 248 tests, 0 failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Agetian

Agetian commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Looks good to me

@Agetian
Agetian merged commit dbcf96f into Card-Forge:master Jul 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI General AI tag Game Mechanics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants