AB$Pump and SP$Pump bug
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
14 posts
• Page 1 of 1
AB$Pump and SP$Pump bug
by Chris H. » 15 Nov 2010, 20:05
There appears to be a bug with the new AB$Pump and SP$Pump code.
and
- 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 Sky Weaver:
Version:
Forge -- official beta: $Date: 2010-09-14 08:34:27 -0400 (Tue, 14 Sep 2010) $, SVN revision: $Revision: 2039 $
OS: Mac OS X Version: 10.6.4 Architecture: x86_64
Java Version: 1.6.0_22 Vendor: Apple Inc.
Detailed error trace:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
at forge.AbilityFactory_Pump$3.addCard(AbilityFactory_Pump.java:228)
at forge.CardList.filter(CardList.java:258)
at forge.AbilityFactory_Pump.getPumpCreatures(AbilityFactory_Pump.java:215)
at forge.AbilityFactory_Pump.doTgtAI(AbilityFactory_Pump.java:274)
at forge.AbilityFactory_Pump.access$0(AbilityFactory_Pump.java:261)
at forge.AbilityFactory_Pump$2.canPlayAI(AbilityFactory_Pump.java:164)
at forge.ComputerAI_General.getPlayable(ComputerAI_General.java:151)
at forge.ComputerAI_General.getMain1(ComputerAI_General.java:106)
at forge.ComputerAI_General.playCards(ComputerAI_General.java:28)
at forge.ComputerAI_General.main1(ComputerAI_General.java:19)
at forge.ComputerAI_Input.think(ComputerAI_Input.java:46)
at forge.ComputerAI_Input.showMessage(ComputerAI_Input.java:31)
at forge.GuiInput.setInput(GuiInput.java:27)
at forge.GuiInput.update(GuiInput.java:21)
at java.util.Observable.notifyObservers(Observable.java:142)
at java.util.Observable.notifyObservers(Observable.java:98)
at forge.MyObservable.updateObservers(MyObservable.java:9)
at forge.Phase.nextPhase(Phase.java:436)
at forge.GuiDisplay3$26.actionPerformed(GuiDisplay3.java:800)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener$Actions.actionPerformed(BasicButtonListener.java:287)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1639)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2851)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2886)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2814)
at java.awt.Component.processEvent(Component.java:6129)
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.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1850)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:712)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:990)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:855)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:676)
at java.awt.Component.dispatchEventImpl(Component.java:4586)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
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)
and
- 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 Reckless Charge:
Version:
Forge -- official beta: $Date: 2010-09-14 08:34:27 -0400 (Tue, 14 Sep 2010) $, SVN revision: $Revision: 2039 $
OS: Mac OS X Version: 10.6.4 Architecture: x86_64
Java Version: 1.6.0_22 Vendor: Apple Inc.
Detailed error trace:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
at forge.AbilityFactory_Pump$3.addCard(AbilityFactory_Pump.java:228)
at forge.CardList.filter(CardList.java:258)
at forge.AbilityFactory_Pump.getPumpCreatures(AbilityFactory_Pump.java:215)
at forge.AbilityFactory_Pump.doTgtAI(AbilityFactory_Pump.java:274)
at forge.AbilityFactory_Pump.access$0(AbilityFactory_Pump.java:261)
at forge.AbilityFactory_Pump$1.canPlayAI(AbilityFactory_Pump.java:92)
at forge.ComputerAI_General.getPlayable(ComputerAI_General.java:151)
at forge.ComputerAI_General.getMain1(ComputerAI_General.java:106)
at forge.ComputerAI_General.playCards(ComputerAI_General.java:28)
at forge.ComputerAI_General.main1(ComputerAI_General.java:19)
at forge.ComputerAI_Input.think(ComputerAI_Input.java:46)
at forge.ComputerAI_Input.showMessage(ComputerAI_Input.java:31)
at forge.GuiInput.setInput(GuiInput.java:27)
at forge.GuiInput.update(GuiInput.java:21)
at java.util.Observable.notifyObservers(Observable.java:142)
at java.util.Observable.notifyObservers(Observable.java:98)
at forge.MyObservable.updateObservers(MyObservable.java:9)
at forge.Phase.nextPhase(Phase.java:436)
at forge.GuiDisplay3$26.actionPerformed(GuiDisplay3.java:800)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener$Actions.actionPerformed(BasicButtonListener.java:287)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1639)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2851)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2886)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2814)
at java.awt.Component.processEvent(Component.java:6129)
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.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1850)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:712)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:990)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:855)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:676)
at java.awt.Component.dispatchEventImpl(Component.java:4586)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
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)
-
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: AB$Pump and SP$Pump bug
by friarsol » 15 Nov 2010, 20:25
Looks like that getPumpCreatures() is doing something funky in an attempt to convert an ArrayList<String> to a String[].
Try changing
Try changing
- Code: Select all
String KWs[] = {"none"};
if (!Keywords.get(0).equals("none"))
KWs = (String[]) Keywords.toArray();
boolean hKW = c.hasAnyKeyword(KWs);
- Code: Select all
boolean hKW = c.hasAnyKeyword(Keywords);
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: AB$Pump and SP$Pump bug
by Chris H. » 15 Nov 2010, 23:58
`friarsol wrote:that should fix the crash.
- Code: Select all
boolean hKW = c.hasAnyKeyword(Keywords);
Hmm, I replaced the line of code and re-ran the test deck and got the same error exception. These cards work for me but the AI can't handle it.
-
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: AB$Pump and SP$Pump bug
by slapshot5 » 16 Nov 2010, 04:48
Is this just using the wrong toArray()?Chris H. wrote:Hmm, I replaced the line of code and re-ran the test deck and got the same error exception. These cards work for me but the AI can't handle it.
- Code: Select all
<T> T[] toArray(T[] a)
Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array.
- Code: Select all
KWs = (String[]) Keywords.toArray();
- Code: Select all
KWs = Keywords.toArray(KWs);
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: AB$Pump and SP$Pump bug
by friarsol » 16 Nov 2010, 04:54
It shouldn't need to use toArray at all. hasAnyKeyword() also takes an ArrayList<String> as a parameter.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: AB$Pump and SP$Pump bug
by slapshot5 » 16 Nov 2010, 05:32
Chris, can you post your test deck? I've seen this a couple times, but I can't reproduce it consistently.
Edit - Also, just to clarify, did you replace 1 line of code with 1 line of code, or did you replace all 4 lines of code with that 1 line of code?
-slapshot5
Edit - Also, just to clarify, did you replace 1 line of code with 1 line of code, or did you replace all 4 lines of code with that 1 line of code?
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: AB$Pump and SP$Pump bug
by Chris H. » 16 Nov 2010, 13:41
Originally, I was playing a deck using cards that I was converting to the new AF code. The computer was assigned a random deck. The Random AI deck just happened to include Reckless Charge and Sky Weaver.
I put together this test deck:
I can play this deck OK without the error exceptions. The error exceptions only appear when the AI plays this deck. Something is broken in the AI code I would guess.
I replaced the original 1 line of code with Sol's 1 line of code. I left the other three lines in place untouched.
When I use Slapshot5's line of code:
the computer will not activate the abilities and will just attack or do nothing.
I put together this test deck:
`test
[general]
constructed
[main]
1 Sky Weaver
1 Mox Ruby
1 Mox Pearl
1 Mox Sapphire
1 Reckless Charge
1 Court Homunculus
[sideboard]
I can play this deck OK without the error exceptions. The error exceptions only appear when the AI plays this deck. Something is broken in the AI code I would guess.
I replaced the original 1 line of code with Sol's 1 line of code. I left the other three lines in place untouched.
When I use Slapshot5's line of code:
- Code: Select all
KWs = Keywords.toArray(KWs);
the computer will not activate the abilities and will just attack or do nothing.
-
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: AB$Pump and SP$Pump bug
by friarsol » 16 Nov 2010, 15:07
Aha! I was expecting you to replace the whole block I gave you with the one line I gave you. Since the crash is actually happening on the ToArray() lineChris H. wrote:I replaced the original 1 line of code with Sol's 1 line of code. I left the other three lines in place untouched.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: AB$Pump and SP$Pump bug
by Chris H. » 16 Nov 2010, 15:14
`friarsol wrote:Aha! I was expecting you to replace the whole block I gave you with the one line I gave you. Since the crash is actually happening on the ToArray() lineChris H. wrote:I replaced the original 1 line of code with Sol's 1 line of code. I left the other three lines in place untouched.

This looked like one of those Mr. Green moments, hope people will forgive my indulgence. I will go back and retry the fix, this time correctly.

-
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: AB$Pump and SP$Pump bug
by slapshot5 » 16 Nov 2010, 16:15
Yeah, that's what I thought it was doing. I had a Merfolk deck with Zhuge Jin, Wu Strategist (which I had seen give problems). But it wouldn't use the ability. I didn't know if the canPlayAI stuff was hosing me (since I pared the deck down) or if that line of code was hosing me.Chris H. wrote:When I use Slapshot5's line of code:the computer will not activate the abilities and will just attack or do nothing.
- Code: Select all
KWs = Keywords.toArray(KWs);
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: AB$Pump and SP$Pump bug
by Chris H. » 16 Nov 2010, 17:23
I checked AbilityFactory and it does a "hostCard.setSVar("PlayMain1", "TRUE");" to the Bounce and Pump cards.
There may be something else in the getPumpCreatures() method.
There may be something else in the getPumpCreatures() method.
-
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: AB$Pump and SP$Pump bug
by Snacko » 16 Nov 2010, 18:55
If you ever use toArray, which in most places is pointless and bad coding practise you do it like:
- Code: Select all
KWs = Keywords.toArray(new String[Keywords.size()]);
Re: AB$Pump and SP$Pump bug
by Chris H. » 16 Nov 2010, 21:29
I mistakenly overwrote Snacko's fix to the AF $Pump bug and I re-merged his overwritten material and it is now back in the code base.
-
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: AB$Pump and SP$Pump bug
by Rob Cashwalker » 16 Nov 2010, 22:28
I'm responsible for breaking that part. When I adapted the Pump code to be more generic for the AF, I thought using an ArrayList would be easier in the long run, but ran into such trouble with handling it as an array in one place and ArrayList in another. I didn't know the correct syntax as Snacko posted, so I let eclipse "fix" it.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
14 posts
• Page 1 of 1
Who is online
Users browsing this forum: Google [Bot] and 262 guests