Skip to content

Improve multiplayer and phasing evaluation in AI simulation - #11462

Open
Madwand99 wants to merge 8 commits into
Card-Forge:masterfrom
Madwand99:ImproveEvaluator
Open

Improve multiplayer and phasing evaluation in AI simulation#11462
Madwand99 wants to merge 8 commits into
Card-Forge:masterfrom
Madwand99:ImproveEvaluator

Conversation

@Madwand99

Copy link
Copy Markdown
Contributor

Summary

This improves GameStateEvaluator fidelity for multiplayer teams, phasing, and eliminated players.

Previously, the evaluator assumed every player other than the AI was an opponent. This caused allied cards, life, and permanents to reduce the AI's score. The evaluator now classifies resources using isOpponentOf() while preserving the existing weighting in normal one-on-one games.

Phased-out permanents are also included in long-term board and mana-base evaluation. Since they will phase back in, temporarily phasing a valuable permanent should not be scored as permanently losing it.

Finally, an AI player that has already lost now receives the terminal minimum score even when a multiplayer game continues.

Tests

Added focused coverage confirming that:

  • Allied permanents, life, and cards improve the team score.
  • Phased permanents retain their long-term board and mana-base value.
  • An eliminated player receives the minimum score in a continuing multiplayer game.

Thanks to Codex for help with code and tests!

Comment thread forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java Outdated
Comment thread forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java Outdated
Comment thread forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java Outdated
int summonSickScore = score;
PhaseType gamePhase = game.getPhaseHandler().getPhase();
for (Card c : game.getCardsIn(ZoneType.Battlefield)) {
for (Card c : game.getCardsIncludePhasingIn(ZoneType.Battlefield)) {

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.

you can't just leave these at the same score though

and even if you would half it AI might still thinking using Oubliette to save own creature would be a good play so I'm not sure this part really works out...

@Madwand99 Madwand99 Jul 30, 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.

Agreed that phased-out permanents should not simply receive the same immediate score as active permanents, especially for effects such as Oubliette. An arbitrary partial value would have the opposite problem, though: normal phasing effects such as Clever Concealment would appear to permanently lose the protected cards.
I changed the existing secondary score into a more general availableValue:
value is the strategic score and includes permanents guaranteed to phase in normally.
availableValue excludes phased-out permanents because they cannot currently provide mana, activate abilities, or participate in combat.
Permanents marked WontPhaseInNormal, as with Oubliette, are excluded from both scores.
SpellAbilityPicker uses the available score for its existing “hold this play for later” check, while simulation comparison retains the strategic score. The effect cache is only used when both score deltas agree, avoiding reuse of a result whose immediate and strategic consequences differ.
The tests now prove both sides: Clever Concealment remains acceptable, while using Oubliette on the AI’s own creature is rejected.

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.

yea this is almost too much together again...though I can understand how one thing can lead to another 😬

will do some manual checks in a bit

Comment thread forge-ai/src/main/java/forge/ai/simulation/SimulationController.java Outdated
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