It is currently 10 Sep 2025, 16:44
   
Text Size

Manapool

Post MTG Forge Related Programming Questions Here

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

Manapool

Postby friarsol » 03 Aug 2010, 21:23

Alright. So the last few days my local codebase has been an utter mess as I tried to untie some of the mess that was the Manapool. I think it's all straight now, but I want some good playing conditions to test out.

I ran the Mana_PartTest unit test with all successes. I even added in a test that would do Reaper King's Casting Cost and handles it by paying mana in non-sequential order. I think I'm going to try that in during a game environment and see if it still works.

I was testing the Snow Lands can give you infinite mana bug, and I believe that is fixed right now. The issue had to do with Mana being passed in as a String. Now it passes in as a Mana object, which holds a specific isSnow() boolean.

So gimme some ideas for funky things that I should test with the revamped ManaPool. A fair amount of destruction went on with it, so I definitely want to have a broad range of this tested up before submitting any code.

Oh and a related question. Can the Computer use any abilities that cost Snow mana? It seems like they may not be right now from the code I looked through, but maybe it was in a different area that is able to do it?

The new Mana work should also allow for cards that have payment restrictions to more easily be coded up (like Imperiosaur).
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Manapool

Postby Chris H. » 03 Aug 2010, 22:06

friarisol wrote:Alright. So the last few days my local codebase has been an utter mess as I tried to untie some of the mess that was the Manapool. I think it's all straight now, but I want some good playing conditions to test out.

I ran the Mana_PartTest unit test with all successes. I even added in a test that would do Reaper King's Casting Cost and handles it by paying mana in non-sequential order. I think I'm going to try that in during a game environment and see if it still works.

I was testing the Snow Lands can give you infinite mana bug, and I believe that is fixed right now. The issue had to do with Mana being passed in as a String. Now it passes in as a Mana object, which holds a specific isSnow() boolean.

So gimme some ideas for funky things that I should test with the revamped ManaPool. A fair amount of destruction went on with it, so I definitely want to have a broad range of this tested up before submitting any code.

Oh and a related question. Can the Computer use any abilities that cost Snow mana? It seems like they may not be right now from the code I looked through, but maybe it was in a different area that is able to do it?

The new Mana work should also allow for cards that have payment restrictions to more easily be coded up (like Imperiosaur).
`
The computer can not use abilities that cost Snow mana. If I remember correctly, the human pays mana costs in Ability_Mana and the computer pays mana costs in ComputerUtil.payManaCost(). Zerker did the original snow mana code and got busy with schooling and was not able to finish.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Manapool

Postby friarsol » 05 Aug 2010, 19:28

Alright I submitted the changes for this. If anyone notices anything funky lemme know and I'll try to fix it quickly.

When you notice something wrong give me specifics about what cards were used and how the situation arose so I can isolate the issue and try to resolve it quickly, since ManaPool can affect a lot of other things.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Manapool

Postby Chris H. » 05 Aug 2010, 20:06

friarisol wrote:Alright I submitted the changes for this. If anyone notices anything funky lemme know and I'll try to fix it quickly.

When you notice something wrong give me specifics about what cards were used and how the situation arose so I can isolate the issue and try to resolve it quickly, since ManaPool can affect a lot of other things.
`
Thank you. I just merged your work into my local copy and will run some tests. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Manapool

Postby Chris H. » 05 Aug 2010, 21:13

I played several games without a problem in quest mode. After a couple of games I tapped a Boros Garrison to add R W to my mana pool and got this error:

Code: Select all
An error has occured. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
   http://www.slightlymagic.net/forum/viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
   mtgerror@yahoo.com


For input string: "RW"


Version:
Forge -- official beta: $Date: 2010-05-01 03:21:42 -0400 (Sat, 01 May 2010) $, SVN revision: $Revision: 916 $

OS: Mac OS X Version: 10.6.4 Architecture: x86_64

Java Version: 1.6.0_20 Vendor: Apple Inc.

Detailed error trace:
java.lang.NumberFormatException: For input string: "RW"
   at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
   at java.lang.Integer.parseInt(Integer.java:449)
   at java.lang.Integer.parseInt(Integer.java:499)
   at forge.ManaPool.addManaToFloating(ManaPool.java:129)
   at forge.ManaPool.addMana(ManaPool.java:105)
   at forge.Ability_Mana.resolve(Ability_Mana.java:266)
   at forge.MagicStack.add(MagicStack.java:113)
   at forge.GameAction.playSpellAbility(GameAction.java:3334)
   at forge.GameAction.playCard(GameAction.java:2897)
   at forge.InputUtil.playAnyCard(InputUtil.java:46)
   at forge.Input_Main.selectCard(Input_Main.java:49)
   at forge.GuiInput.selectCard(GuiInput.java:48)
   at forge.GuiDisplay3$7.mousePressed(GuiDisplay3.java:371)
   at java.awt.Component.processMouseEvent(Component.java:6345)
   at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
   at java.awt.Component.processEvent(Component.java:6113)
   at java.awt.Container.processEvent(Container.java:2085)
   at java.awt.Component.dispatchEventImpl(Component.java:4714)
   at java.awt.Container.dispatchEventImpl(Container.java:2143)
   at java.awt.Component.dispatchEvent(Component.java:4544)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
   at java.awt.Container.dispatchEventImpl(Container.java:2129)
   at java.awt.Window.dispatchEventImpl(Window.java:2478)
   at java.awt.Component.dispatchEvent(Component.java:4544)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Manapool

Postby Rob Cashwalker » 05 Aug 2010, 21:42

Are you also responsible for adding the new Ability_Cost? I see it's been merged into the abPump code, and I question if the AI can even use it. If it can't then what will it take to make it work?
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Manapool

Postby friarsol » 05 Aug 2010, 22:08

Chris H. wrote:I played several games without a problem in quest mode. After a couple of games I tapped a Boros Garrison to add R W to my mana pool and got this error:
Ah good. Fix is up for this.

Hopefully that's the last of them but I'm keeping my fingers crossed. I had noticed the issue with the mana strings that come in without spacing when testing Priest of Titania/Gaea's Cradle and didn't expect the Garrison and similar cards to cause an issue once the spacing was added to the cards file.

I'll get some time tomorrow to have the Mana Pool code handle this situation more gracefully.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Manapool

Postby DennisBergkamp » 07 Aug 2010, 05:28

Code: Select all
An error has occured. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
   http://www.slightlymagic.net/forum/viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
   mtgerror@yahoo.com


There is an error in the card code for Boomerang:



Version:
Forge -- official beta: $Date: 2010-05-01 02:21:42 -0500 (Sat, 01 May 2010) $, SVN revision: $Revision: 916 $

OS: Windows Vista Version: 6.0 Architecture: x86

Java Version: 1.7.0-ea Vendor: Sun Microsystems Inc.

Detailed error trace:
java.lang.RuntimeException: Mana_Part : checkMana() error, argument mana is invalid mana, mana - C
   at forge.Mana_Part.checkSingleMana(Mana_Part.java:32)
   at forge.Mana_PartColor.<init>(Mana_PartColor.java:15)
   at forge.ManaCost.split(ManaCost.java:158)
   at forge.ManaCost.<init>(ManaCost.java:24)
   at forge.CardUtil.getConvertedManaCost(CardUtil.java:208)
   at forge.CardFactoryUtil.AI_getMostExpensivePermanent(CardFactoryUtil.java:44)
   at forge.CardFactory$19.canPlayAI(CardFactory.java:2625)
   at forge.ComputerAI_General.getPlayable(ComputerAI_General.java:230)
   at forge.ComputerAI_General.getMain1(ComputerAI_General.java:190)
   at forge.ComputerAI_General.playCards(ComputerAI_General.java:35)
   at forge.ComputerAI_General.main1(ComputerAI_General.java:26)
   at forge.ComputerAI_Input.think(ComputerAI_Input.java:41)
   at forge.ComputerAI_Input.showMessage(ComputerAI_Input.java:29)
   at forge.GuiInput.setInput(GuiInput.java:27)
   at forge.GuiInput.update(GuiInput.java:21)
   at java.util.Observable.notifyObservers(Observable.java:159)
   at java.util.Observable.notifyObservers(Observable.java:115)
   at forge.MyObservable.updateObservers(MyObservable.java:10)
   at forge.Phase.nextPhase(Phase.java:280)
   at forge.Phase.nextPhase(Phase.java:284)
   at forge.Phase.nextPhase(Phase.java:284)
   at forge.Phase.nextPhase(Phase.java:284)
   at forge.Phase.nextPhase(Phase.java:284)
   at forge.Phase.nextPhase(Phase.java:284)
   at forge.GuiDisplay4$25.actionPerformed(GuiDisplay4.java:781)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2015)
   at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2338)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
   at javax.swing.plaf.basic.BasicButtonListener$Actions.actionPerformed(BasicButtonListener.java:304)
   at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1650)
   at javax.swing.JComponent.processKeyBinding(JComponent.java:2879)
   at javax.swing.JComponent.processKeyBindings(JComponent.java:2926)
   at javax.swing.JComponent.processKeyEvent(JComponent.java:2842)
   at java.awt.Component.processEvent(Component.java:6207)
   at java.awt.Container.processEvent(Container.java:2203)
   at java.awt.Component.dispatchEventImpl(Component.java:4790)
   at java.awt.Container.dispatchEventImpl(Container.java:2261)
   at java.awt.Component.dispatchEvent(Component.java:4616)
   at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1905)
   at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:752)
   at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1017)
   at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:889)
   at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:717)
   at java.awt.Component.dispatchEventImpl(Component.java:4660)
   at java.awt.Container.dispatchEventImpl(Container.java:2261)
   at java.awt.Window.dispatchEventImpl(Window.java:2671)
   at java.awt.Component.dispatchEvent(Component.java:4616)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:651)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:255)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:170)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:160)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:155)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:136)
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Manapool

Postby friarsol » 07 Aug 2010, 14:13

Dennis, what was the situation when that came up? It looks like the AI was trying to target something, but it's not clear what that something was.

I didn't change that portion of the Mana_Part code (and it is very picky about how mana is formatted going in) and it looks like 'C' is getting sent into a function that only looks for colors, snow, or integers.

I guess in the old convertedManaCost it didn't care what symbol was being used for cost, but I'm not sure how a C would get slipped in there. What did you have in play when that was cast?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Manapool

Postby DennisBergkamp » 07 Aug 2010, 17:39

I really can't remember, nothing special though (bunch of creatures and possibly an enchantment).

This error happened from a match within the Map part though, maybe that has something to do with it? I'll keep on testing to see if I can reproduce it.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Manapool

Postby friarsol » 07 Aug 2010, 18:57

Yea keep an eye out if it shows up again. My best guess is some token was created and the mana cost was set improperly.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Manapool

Postby Chris H. » 07 Aug 2010, 19:18

friarisol wrote:Yea keep an eye out if it shows up again. My best guess is some token was created and the mana cost was set improperly.
`
Boomerang was recently converted to use the new spBounceTgt keyword:

    Boomerang
    U U
    Instant
    Return target permanent to its owner's hand.
    spBounceTgt:Permanent:Hand

There is a line in this keyword that is used to return the best permanent:

Code: Select all
} else if(Tgts[i].startsWith("Permanent")) {
    if(CardFactoryUtil.AI_getMostExpensivePermanent(choices, card, true) != null) results.add(CardFactoryUtil.AI_getMostExpensivePermanent(choices, card, true));
}
`
The CardFactoryUtil.AI_getMostExpensivePermanent() method is using CardUtil.getConvertedManaCost(all.get(i).getManaCost()); and if we try to bounce a token, well, Sol is right. I checked several cards which create a colorless token and right there it has "C".
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Manapool

Postby DennisBergkamp » 07 Aug 2010, 22:28

Ah, nice catch guys! Yes, now that I think of it, I think had an Awakening Zone in play (producing Eldrazi Spawn with "C" as casting cost :roll: ).
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Manapool

Postby Rob Cashwalker » 08 Aug 2010, 01:05

I just noticed that the mana pool only pays parts of the cost at a time. I don't use the man pool unless necessary... like when I play Harrow I tap the lands first, then select one of them to sac, then pay from the mana pool. Clicking the mana pool presents a choice window of G or G or G. Select one, click OK, then the input prompt says I still have 1 left to pay, click on the mana pool again, and it pulls the last mana out.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Manapool

Postby DennisBergkamp » 10 Aug 2010, 01:02

Yup, same here... I like to just directly pay for costs, unless there's no other way.

Anyway, I just fixed a few parts of the Eldrazi Spawn token creation on the SVN, hope that's all of them.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 22 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 22 users online :: 0 registered, 0 hidden and 22 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 22 guests

Login Form