Skip to content

Improve Homarid Spawning Bed AI - #11717

Draft
vanja-ivancevic wants to merge 1 commit into
Card-Forge:masterfrom
vanja-ivancevic:codex/ai-homarid-spawning-bed
Draft

Improve Homarid Spawning Bed AI#11717
vanja-ivancevic wants to merge 1 commit into
Card-Forge:masterfrom
vanja-ivancevic:codex/ai-homarid-spawning-bed

Conversation

@vanja-ivancevic

@vanja-ivancevic vanja-ivancevic commented Aug 27, 2026

Copy link
Copy Markdown
Contributor
  • Reuse the existing threatened-sacrifice cost path so token abilities can cash in a legal permanent that is already predicted to die.
  • Keep threat detection independent of the payoff ability, then let the existing SacCost preference choose the threatened permanent.
  • Keep normal TokenAi behavior when no legal sacrifice is threatened.
  • Remove Homarid Spawning Bed's AI deck ban without adding card-specific AILogic or pre-payment token projection.
  • Verified locally that the Bed stays idle without a threat, responds to Doom Blade, and sacrifices the threatened creature instead of another legal choice.
  • This intentionally makes the Bed reactive instead of attempting to optimize proactive sacrifice value, avoiding the unresolved pre-payment architecture discussed in Let the AI count converge before it decides whether to cast #11486.

@vanja-ivancevic
vanja-ivancevic marked this pull request as ready for review August 27, 2026 20:17
ManaCost:U U
Types:Enchantment
A:AB$ Token | Cost$ 1 U U Sac<1/Creature.Blue/blue creature> | TokenAmount$ X | TokenScript$ u_1_1_camarid | TokenOwner$ You | SpellDescription$ Create X 1/1 blue Camarid creature tokens, where X is the sacrificed creature's mana value.
A:AB$ Token | Cost$ 1 U U Sac<1/Creature.Blue/blue creature> | TokenAmount$ X | TokenScript$ u_1_1_camarid | TokenOwner$ You | AILogic$ SacrificeThreatenedForManaValue | SpellDescription$ Create X 1/1 blue Camarid creature tokens, where X is the sacrificed creature's mana value.

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.

we need less AILogic for trivial stuff, not more
What about using AIPreference:SacCost...?

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.

Good suggestion. I removed the card-specific AILogic entirely and added SVar:AIPreference:SacCost$Creature.cmcGE1. The only Java change is now generic: when a token count depends on an unpaid sacrifice, TokenAi evaluates X on a detached ability copy containing the preferred sacrifice in its normal paid-cost list. This lets AbilityUtils calculate the existing Sacrificed$... expression without special card logic. I also verified that a positive-mana-value creature enables the ability, a zero-value Camarid does not, and the same path works for Tend the Pests.

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.

This problem trying to be solved here is pretty close to what I've already described in #11486 (comment)

I guess it's up to me to write down how this architecture should be handled, though I can't give this a high priority

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.

Thanks, the #11486 comparison made me step back from pre-payment projection entirely. I removed the copied-ability/token-value helper and the AIPreference. The revision now reuses the existing ComputerUtil.activateForCost path: TokenAi only bypasses its normal amount and phase heuristics when a legal sacrifice is already predicted to die, and the existing SacCost selection chooses that threatened permanent. There is no new AILogic, SVar prediction, or attempt to solve proactive sacrifice value. The focused test shows that the Bed stays idle without a threat, responds to Doom Blade, and selects the threatened creature over another legal sacrifice.

@vanja-ivancevic
vanja-ivancevic force-pushed the codex/ai-homarid-spawning-bed branch from a4361b5 to 5ec1c25 Compare August 28, 2026 08:18
@vanja-ivancevic

Copy link
Copy Markdown
Contributor Author

Post-revision self-review: the Java path is generic and one-pass. It runs only when the token amount currently evaluates to zero and the cost contains a sacrifice, uses the established sacrifice chooser, records the projected payment on a copied SpellAbility, and lets AbilityUtils evaluate the existing expression. It does not call generic playability or mana planning and does not mutate live card/game state. Homarid Spawning Bed uses the established AIPreference:SacCost mechanism rather than card-specific Java logic. The positive-mana-value, zero-mana-value, and second sacrifice-derived token scenarios pass, as does a clean forge-ai reactor build.

@vanja-ivancevic
vanja-ivancevic force-pushed the codex/ai-homarid-spawning-bed branch 2 times, most recently from 62a7e6b to 55b2cfc Compare August 28, 2026 12:12
@vanja-ivancevic
vanja-ivancevic force-pushed the codex/ai-homarid-spawning-bed branch from 55b2cfc to 8e6f3c3 Compare August 28, 2026 12:15

@tool4ever tool4ever left a comment

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.

sacrificing everything threatened is way too generic, feels like we're running in circles

@vanja-ivancevic
vanja-ivancevic force-pushed the codex/ai-homarid-spawning-bed branch from 8e6f3c3 to e87a334 Compare August 29, 2026 18:19
@tool4ever
tool4ever marked this pull request as draft August 29, 2026 18:29
@vanja-ivancevic
vanja-ivancevic force-pushed the codex/ai-homarid-spawning-bed branch from e87a334 to 8e6f3c3 Compare August 29, 2026 18:33
@vanja-ivancevic

Copy link
Copy Markdown
Contributor Author

Would a card-specific SpecialCardAi path be a better direction here? I would revert the generic TokenAi and ComputerUtil changes, use AIPreference:SacCost$Creature.cmcGE1 only for sacrifice selection, and activate Homarid Spawning Bed only when that selected creature is predicted to die. This would avoid new AILogic, pre-payment projection, and behavior changes to other token or sacrifice abilities. Or would you prefer leaving the card excluded until the broader payment architecture is defined?

@vanja-ivancevic

Copy link
Copy Markdown
Contributor Author

Sorry, I accidentally clicked re-request review.

@tool4ever

Copy link
Copy Markdown
Contributor

first it depends a bit on if there are more cards that have this cost->effect pattern, it doesn't look like that research was done so far 🤷‍♂️

#11712 was a step in the right direction for how heuristics could pass information to different effect parts, however that was on Card level + between subabilities - now we need SpellAbility + between its cost

maybe it's possible together with addChangedSVars to substitute and use Remembered? but yea I'd prefer architecture outline before code dump...

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