Skip to content

Limit AI to cast Green Sun's Zenith for all its mana#9962

Closed
kojotak wants to merge 2 commits intoCard-Forge:masterfrom
kojotak:6720_green_suns_zenith
Closed

Limit AI to cast Green Sun's Zenith for all its mana#9962
kojotak wants to merge 2 commits intoCard-Forge:masterfrom
kojotak:6720_green_suns_zenith

Conversation

@kojotak
Copy link
Contributor

@kojotak kojotak commented Mar 1, 2026

An attempt to fix #6720 by allowing to limit the maximum mana cost X. It works for instant/sorcery, but doesn't work for a creature (Rocco, Cabaretti Caterer). Is there a better way, for example using SVar:AIPreference:AIMaxTgtCost?

An example of Green sun's zenith cast with X=2, which is the max CMC of all creatures in a library:

image

if (root.costHasManaX()) {
val = ComputerUtilMana.determineLeftoverMana(root, ai, effect);

if (sa.hasParam("AIMaxTgtCost")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too unflexible / think bigger - just allow scripters to provide the maximum value for good measure:
SVar:Y:Count$ValidLibrary Creature.YouOwn$GreatestCardManaCost

ManaCost:X G G
Types:Sorcery
A:SP$ ChangeZone | ChangeType$ Creature.YouCtrl+cmcLEX | Hidden$ True | Origin$ Library | OriginAlternative$ Graveyard | Destination$ Battlefield | ShuffleNonMandatory$ True | SubAbility$ DBPump | SpellDescription$ Search your library and/or graveyard for a creature card with mana value X or less and put it onto the battlefield. If you search your library this way, shuffle.
A:SP$ ChangeZone | ChangeType$ Creature.YouCtrl+cmcLEX | Hidden$ True | Origin$ Library | OriginAlternative$ Graveyard | Destination$ Battlefield | ShuffleNonMandatory$ True | SubAbility$ DBPump | AIMaxTgtCost$ MaxCMC | SpellDescription$ Search your library and/or graveyard for a creature card with mana value X or less and put it onto the battlefield. If you search your library this way, shuffle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one should probably consider an additional SVar in case you'd get really close to 10 and the secondary effect is worth it

@kojotak
Copy link
Contributor Author

kojotak commented Mar 2, 2026

This will take me more time than expected 🙈 "Much to learn, I have"

I still can not figure it out how to properly script the condition of limiting the library search by available mana - so there is an ugly if(svar) replace hack in 66adbd5 . And speaking of Finale of Devastation - I have yet to debug it why ai does not consider the pump effect at all (it casts it in main2 without any combat advantage).

@kojotak kojotak closed this Mar 2, 2026
@tool4ever
Copy link
Contributor

hmn, this looked ok now mostly:

  • you don't have to try and inject the mana there - if it's less than the maximum ChangeZoneAi logic should just take over to see if there's still something fetchable like in other cases too
  • probably just missing PlayMain1 SVar

@kojotak
Copy link
Contributor Author

kojotak commented Mar 3, 2026

if it's less than the maximum ChangeZoneAi logic should just take over to see if there's still something fetchable like in other cases too

Yes, I agree, but this will fix the issue #6720 only if available mana is > most expensive creature in library. That's the situation from the screenshot of this PR (available mana = 5, max payable CMC = 2, X is set to 2 ✅). When the library contains creature with higher CMC (for example Apex devastor CMC=10), then ComputerUtilCost resolves X to 5, all available mana is used and creature with only CMC = 2 is put into battlefield.

  • probably just missing PlayMain1 SVar

Thanks, I've finally found that too, but without luck. AI is still casting it in main2 despite having mana and multiple creatures in play (which can benefit from the +X/+X).

I don't give up. Yet 😉

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.

AI casts Green Sun's Zenith for all its mana

2 participants