It is currently 29 Oct 2025, 12:27
   
Text Size

New "Produce$ Any" feature for AbilityMana

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 31 Dec 2011, 20:09

I finally got some time to work on the adding this feature. I needed rework the AI logic for paying mana costs to account for any color sources. In the process I uncovered some other bugs/problems with paying mana costs. Because there were some big changes, I created a branch in the repository so I could check in changes without breaking the trunk. I believe the code is back to a playable state but I am going to play test for a while before I merge the changes back into the trunk.

Here's what I have added and fixed

1) added support for "Produced$ Any" in Mana AF scripting (Issue 266)
2) converted a small set of cards for testing (City of Brass, Mox Opal, Glimmervoid)
3) added new card Manamorphose that is now scriptable
4) fixed infinite mana bug (Issue 83 and 306 in bug tracker)
5) fixed an issue where AI wouldn't play a card because of the order sources were used (Issue 408)
6) fixed AI issues with snow mana
7) fix issue with GUI not always giving choice when multiple mana abilities on source can be used to pay a cost (Issue 409)

Known issues
1) There are some functions related to draft mode games that won't handle the keyword correctly yet.
2) There are some minor issues with the AI logic related to cards that use "ManaNeededToAvoidNegativeEffect"
3) Manamorphose will cause is issues if the AI tries to use it

I would also like feedback on how the color choice is handled for the human player. Right now the user always gets asked to choose a color.

If you want to help playtesting, you can point your development workspace to "http://svn.slightlymagic.net/forge/branches/Issue_0000266"

Please post an issues/comments found in this thread
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: New "Produce$ Any" feature for AbilityMana

Postby slapshot5 » 31 Dec 2011, 23:22

I'm getting errors in that branch:

Code: Select all
Description   Resource   Path   Location   Type
tmpMana cannot be resolved or is not a field   AbilityFactoryMana.java   /ForgeBranch-AnyMana/src/main/java/forge/card/abilityfactory   line 128   Java Problem

Description   Resource   Path   Location   Type
af cannot be resolved or is not a field   AbilityFactoryMana.java   /ForgeBranch-AnyMana/src/main/java/forge/card/abilityfactory   line 128   Java Problem
Fresh checkout r12904

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 01 Jan 2012, 01:32

slapshot5 wrote:I'm getting errors in that branch:

Code: Select all
Description   Resource   Path   Location   Type
tmpMana cannot be resolved or is not a field   AbilityFactoryMana.java   /ForgeBranch-AnyMana/src/main/java/forge/card/abilityfactory   line 128   Java Problem

Description   Resource   Path   Location   Type
af cannot be resolved or is not a field   AbilityFactoryMana.java   /ForgeBranch-AnyMana/src/main/java/forge/card/abilityfactory   line 128   Java Problem
Fresh checkout r12904

-slapshot5
fixed in r12905
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: New "Produce$ Any" feature for AbilityMana

Postby Sloth » 01 Jan 2012, 16:49

That sounds very promising ArsenalNut. =D>

I can't test right now, but your 3 issues sound pretty minor compared to the new features. If nothing serious arises, i vote for merging.
Once i'm back home i can lend you a hand with issue 1 and 2.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New "Produce$ Any" feature for AbilityMana

Postby friarsol » 01 Jan 2012, 17:46

Yea I agree with Sloth that as long as the biggest stability issue are the three you mentioned, it should be able to added in.

As far as Color Choice goes, we should reduce the amount the player has to select as much as possible. For things that care about Mana (Sunburst, and other similar) we should probably always prompt. For the most part besides that, it should choose for you. Especially for paying colorless mana.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 01 Jan 2012, 21:09

Sloth wrote:That sounds very promising ArsenalNut. =D>

I can't test right now, but your 3 issues sound pretty minor compared to the new features. If nothing serious arises, i vote for merging.
Once i'm back home i can lend you a hand with issue 1 and 2.
I checked in some updates that addressed the issues with the draft modes and interactions with reflected mana sources so issue #2 is taken care of.

Turns out the AI won't try to cast Manamorphose because it's mana producing spell as opposed to a mana ability so #3 is not a stability issue.

Issue #1 is pretty minor in terms of playability. I have a test case where the AI has the necessary mana sources to avoid the negative effects when casting a Azorius Herald. However due to the way the sources are ordered in the search list, the AI uses it's only blue source (Glimmervoid) for white instead. I have a couple idea that should solve the problem.

This brings up sort of secondary issue. Should the AI be allowed to cast cards with ManaNeededToAvoidNegativeEffect if the mana cannot be paid? I think since the AI is basically an aggro opponent, it is hurt more often than it is helped if it has to sacrifice the creature immediately. It would be easy to manipulate the cost in ComputerUtil.payManaCost to make the colors in ManaNeededToAvoidNegativeEffect mandatory.
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 01 Jan 2012, 21:47

friarsol wrote:Yea I agree with Sloth that as long as the biggest stability issue are the three you mentioned, it should be able to added in.

As far as Color Choice goes, we should reduce the amount the player has to select as much as possible. For things that care about Mana (Sunburst, and other similar) we should probably always prompt. For the most part besides that, it should choose for you. Especially for paying colorless mana.
The cards that use the "Produced$ Any" feature work like reflected mana cards where the color choice is made during the resolve call which means the color choice has no information about what the mana will be used for. I have an idea for passing an automatic choice but I have come across some rare times where the express choice in InputPayManaCostUtil.activateManaAbility is not always what I intended. I wanted people to play test and see if having to make a choice every time is a big deal.

One of the big changes that I made in ComputerUtil.payManaCost is that the AI now uses the abiltiyMana.resolve to actually put mana into its mana pool then the costs are subtracted from the mana pool just like the human player. I didn't see any reason why the computer couldn't do this but I wanted to play test outside the trunk to make sure. I have played the constructed mode for several hours now with no problems but I wouldn't mind some other people testing too.
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: New "Produce$ Any" feature for AbilityMana

Postby Sloth » 02 Jan 2012, 08:36

ArsenalNut wrote:This brings up sort of secondary issue. Should the AI be allowed to cast cards with ManaNeededToAvoidNegativeEffect if the mana cannot be paid? I think since the AI is basically an aggro opponent, it is hurt more often than it is helped if it has to sacrifice the creature immediately. It would be easy to manipulate the cost in ComputerUtil.payManaCost to make the colors in ManaNeededToAvoidNegativeEffect mandatory.
This is agood idea. Please make it mandatory.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 02 Jan 2012, 20:30

Sloth wrote:
ArsenalNut wrote:This brings up sort of secondary issue. Should the AI be allowed to cast cards with ManaNeededToAvoidNegativeEffect if the mana cannot be paid? I think since the AI is basically an aggro opponent, it is hurt more often than it is helped if it has to sacrifice the creature immediately. It would be easy to manipulate the cost in ComputerUtil.payManaCost to make the colors in ManaNeededToAvoidNegativeEffect mandatory.
This is a good idea. Please make it mandatory.
I added this logic. I found that Gruul Scrapper and Shrieking Grotesque are using this keyword to get the AI to use certain colored mana to gain a positive effect. I don't think these should be mandatory for the AI so I am going to create another keyword ManaNeededForPositiveEffect to deal with these.

I also went ahead and merged my branch into the trunk. I'll start working on converting existing cards to the new keyword. I found several cards that might be scriptable now

Dawn's Reflection
Terrarion
Pulse of Llanowar
Trace of Abundance (if shroud on land works)
Quirion Sentinel
Overlaid Terrain
Divergent Growth (?)
Coalition Relic (?)
Carpet of Flowers (?)
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: New "Produce$ Any" feature for AbilityMana

Postby friarsol » 02 Jan 2012, 20:47

Ah good. I kept trying to test with Birds of Paradise but then realizing it hadn't been changed yet. After I converted Reflectable to an AF, I knew it would be much better to work the way everything else did but couldn't think of a good way to do it. I think it'd help a lot to find a way to reduce the choices/automatically choose for both these scenarios.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 03 Jan 2012, 06:14

friarsol wrote:Ah good. I kept trying to test with Birds of Paradise but then realizing it hadn't been changed yet. After I converted Reflectable to an AF, I knew it would be much better to work the way everything else did but couldn't think of a good way to do it. I think it'd help a lot to find a way to reduce the choices/automatically choose for both these scenarios.
I got all the cards starting with A-R converted tonight so you can test Birds of Paradise now.

I found Fertile Ground has a couple problems if you enchant an AI's land with it. The first problem is that the choice of mana is given to the owner of the enchantment not the owner of the land that was tapped. This bug happens with the version before I converted it also. The second problem is caused by payManaCost actually using mana from the computer's manpool. There is no check to see if the cost is actually paid after mana from the pool is used. I want to look more closely at how the computer mana pool is handled. I think there might be some other problems. This is going to be key to removing the restriction on the AI only using mana sources that produce one mana.

My plan is to work to follow items
1) convert remaining cards to "Any" keyword
2) fix issues with handling of computer mana
3) remove restrictions on AI using one mana sources
4) look at ways to automate choice for Any and Reflected mana sources
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: New "Produce$ Any" feature for AbilityMana

Postby friarsol » 14 Jan 2012, 23:24

Hey Arsenal,

Just got this crash:

Code: Select all
java.lang.RuntimeException: AbilityFactoryMana::manaResolve() - any color mana choice is empty for Gemhide Sliver
   at forge.card.abilityfactory.AbilityFactoryMana.manaResolve(AbilityFactoryMana.java:324)
   at forge.card.abilityfactory.AbilityFactoryMana$1.resolve(AbilityFactoryMana.java:80)
   at forge.ComputerUtil.payManaCost(ComputerUtil.java:776)
   at forge.ComputerUtil.payManaCost(ComputerUtil.java:553)
   at forge.card.cost.CostMana.payAI(CostMana.java:192)
   at forge.card.cost.CostPayment.payComputerCosts(CostPayment.java:309)
   at forge.ComputerUtil.handlePlayingSpellAbility(ComputerUtil.java:179)
   at forge.ComputerUtil.playSpellAbilities(ComputerUtil.java:124)
   at forge.ComputerAIGeneral.playCards(ComputerAIGeneral.java:93)
   at forge.ComputerAIGeneral.main2(ComputerAIGeneral.java:76)
   at forge.ComputerAIInput.think(ComputerAIInput.java:111)
   at forge.ComputerAIInput.showMessage(ComputerAIInput.java:71)
Not sure what the AI was trying to play with it since it crashed on it.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 15 Jan 2012, 00:30

friarsol wrote:Hey Arsenal,

Just got this crash:

Code: Select all
java.lang.RuntimeException: AbilityFactoryMana::manaResolve() - any color mana choice is empty for Gemhide Sliver
   at forge.card.abilityfactory.AbilityFactoryMana.manaResolve(AbilityFactoryMana.java:324)
   at forge.card.abilityfactory.AbilityFactoryMana$1.resolve(AbilityFactoryMana.java:80)
   at forge.ComputerUtil.payManaCost(ComputerUtil.java:776)
   at forge.ComputerUtil.payManaCost(ComputerUtil.java:553)
   at forge.card.cost.CostMana.payAI(CostMana.java:192)
   at forge.card.cost.CostPayment.payComputerCosts(CostPayment.java:309)
   at forge.ComputerUtil.handlePlayingSpellAbility(ComputerUtil.java:179)
   at forge.ComputerUtil.playSpellAbilities(ComputerUtil.java:124)
   at forge.ComputerAIGeneral.playCards(ComputerAIGeneral.java:93)
   at forge.ComputerAIGeneral.main2(ComputerAIGeneral.java:76)
   at forge.ComputerAIInput.think(ComputerAIInput.java:111)
   at forge.ComputerAIInput.showMessage(ComputerAIInput.java:71)
Not sure what the AI was trying to play with it since it crashed on it.
I didn't account for the way abilities are added through continuous effects. This should be fixed in r13154.
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: New "Produce$ Any" feature for AbilityMana

Postby friarsol » 20 Jan 2012, 20:10

I tapped my Birds of Paradise the turn before for Blue to float it to my next turn with an Upwelling. On the next turn, I want to float a White, but I don't get the dialog when tapping in the same exact manner. I wasn't in the middle of paying a cost, so I should always get the dialog, right?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New "Produce$ Any" feature for AbilityMana

Postby ArsenalNut » 20 Jan 2012, 21:29

friarsol wrote:I tapped my Birds of Paradise the turn before for Blue to float it to my next turn with an Upwelling. On the next turn, I want to float a White, but I don't get the dialog when tapping in the same exact manner. I wasn't in the middle of paying a cost, so I should always get the dialog, right?
The issue occurs because the last choice doesn't get cleared when a source is tapped to put mana in the pool and not to pay a cost. I am keying off whether the choice is empty or not when showing the choices. The choice gets used again when subtracting from the mana pool for paying a cost so I couldn't just clear it after the Mana_AF is done with it. I didn't want to add another flag for the express choice but that is the quickest fix. The other fix is to remove the dependency in paying the cost so the Mana_AF can reset it. Any preference?

Edit: fixed this in r13379
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 13 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 13 users online :: 0 registered, 0 hidden and 13 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 13 guests

Login Form