It is currently 29 Aug 2025, 16:31
   
Text Size

spDiscard[Tgt|Opp]

Post MTG Forge Related Programming Questions Here

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

Re: spDiscard[Tgt|Opp]

Postby Chris H. » 10 Jul 2010, 18:50

Rob Cashwalker wrote:I fixed the addManaCosts method to correctly handle adding a mana cost with no numeric component. Mind Peel costs B, so Integer.valueOf("") apparantly is the number format exception.... In VB Val("") is 0.
`
Thank you for figuring this out. I will add the last card to the SVN later today.
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: spDiscard[Tgt|Opp]

Postby Rob Cashwalker » 11 Jul 2010, 05:04

Looking at Duress for implementing the Reveal and Choose mode, I discover that the computer cheats:

Code: Select all
public boolean canPlayAI() {
                    Card[] c = removeLandAndCreats(AllZone.Human_Hand.getCards());
                    return 0 < c.length;
                }
The spDiscardTgt AI:
Code: Select all
                public boolean canPlayAI()
                {
                   int nCards = getNumCards();
                   
                   PlayerZone pzH = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Human);
                   int numHHand = pzH.size();
                   
                   if (numHHand > (nCards - 1))
                   {
                      if (Tgt)
                         setTargetPlayer(Constant.Player.Human);
                      
                      return true;
                   }
                      
                   return false;
                }
My version will practically always be played as long as the human's hand has at least 1 card. It shouldn't matter to the AI to already know the contents of my hand....

If I were playing, my evaluation basically amounts to play it as long as the opponent has cards to discard. The only reason I wouldn't is if I knew the contents of his hand based on a previous reveal....

SSSAAAYYYYYYY, wouldn't it be kinda cool if somewhere we could remember the human's hand following a reveal. As the human plays cards, the game would remove them from this memorized list. This sort of knowledge could be applicable to all sorts of AI tweaks.
For example, knowing the player is holding a Giant Growth can affect the AI attack.

Edit --
While posting the AI code, I had a WTF moment, and realized that the Discarding of a Hand AI would allow the human to have a hand of zero, so those cards need to have the <numcards> parameter changed to 1.
I also am submitting a slight tweak to the AI code -
Code: Select all
if (numHHand >= nCards)
Don't know why I wrote it the way above....
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: spDiscard[Tgt|Opp]

Postby Rob Cashwalker » 17 Jul 2010, 03:13

I just added the RevealYouChoose method to the the SVN.

Cards we already have:
Code: Select all
Coercion
2 B
Sorcery
no text
spDiscardOpp:RevealYouChoose:1:Target opponent reveals his or her hand. You choose a card from it. That player discards that card.:Coercion - opponent reveals hand and discards a card

Distress
B B
Sorcery
no text
spDiscardTgt:RevealYouChoose/Artifact.nonLand,Creature.nonLand,Enchantment,Instant,Planeswalker,Sorcery:1:Target player reveals his or her hand. You choose a nonland card from it. That player discards that card.:Distress - player reveals hand and discards a card 

Thoughtseize
B
Sorcery
no text
spDiscardTgt:RevealYouChoose/Artifact.nonLand,Creature.nonLand,Enchantment,Instant,Planeswalker,Sorcery:1:Drawback$YouLoseLife/2:Target player reveals his or her hand. You choose a nonland card from it. That player discards that card. You lose 2 life.:Thoughtsieze - player reveals hand and discards a card

Duress
B
Sorcery
no text
spDiscardOpp:RevealYouChoose/Artifact.nonCreature.nonLand,Enchantment.nonCreature,Instant,Planeswalker,Sorcery:1:Target opponent reveals his or her hand. Choose a noncreature, nonland card from it. That player discards that card.:Duress - opponent reveals hand and discards a card

Ostracize
B
Sorcery
no text
spDiscardOpp:RevealYouChoose/Creature:1:Target opponent reveals his or her hand. Choose a creature card from it. That player discards that card.:Ostracize - opponent reveals hand and discards a card
Cards that can be added:
Code: Select all
Brainbite
2 U B
Sorcery
no text
spDiscardOpp:RevealYouChoose:1:Target opponent reveals his or her hand. You choose a card from it. That player discards that card.:Brainbite - opponent reveals hand and dicards a card
Draw a card.

Encroach
B
Sorcery
no text
spDiscardTgt:RevealYouChoose/Land.nonBasic:1:Target player reveals his or her hand. You choose a nonbasic land card from it. That player discards that card.:Encroach - player reveals hand and discards a card

Psychic Spear
B
Sorcery
no text
spDiscardTgt:RevealYouChoose/Creature.Spirit,Instant.Arcane,Sorcery.Arcane:1:Target player reveals his or her hand. You choose a Spirit or Arcane card from it. That player discards that card.:Psychic Spear - player reveals hand and discards a card

Shattered Dreams
B
Sorcery
no text
spDiscardOpp:RevealYouChoose/Artifact:1:Target opponent reveals his or her hand. You choose an artifact card from it. That player discards that card.:Shattered Dreams - opponent reveal hand and discards a card

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: spDiscard[Tgt|Opp]

Postby Chris H. » 17 Jul 2010, 11:17

Looks good. :D Thank you.
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: spDiscard[Tgt|Opp]

Postby Chris H. » 17 Jul 2010, 12:14

Chris H. wrote:Looks good. :D Thank you.
`
I merged the new code from the SVN into my local copy and found an error in line 617 at CardFactory.java

Code: Select all
CardListUtil.sortByTextLen(dPChHand);
`
I checked CardListUtil and could not find this method. Did you forget to merge this part of your new code? :wink:
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: spDiscard[Tgt|Opp]

Postby Rob Cashwalker » 17 Jul 2010, 13:55

probably...

I just uploaded it.
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: spDiscard[Tgt|Opp]

Postby Chris H. » 17 Jul 2010, 14:19

Rob Cashwalker wrote:I just uploaded it.
`
Thank you. :)
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: spDiscard[Tgt|Opp]

Postby Chris H. » 18 Jul 2010, 00:17

Rob Cashwalker wrote:I just added the RevealYouChoose method to the the SVN.

Cards we already have:

Cards that can be added:
`
I merged this material into the SVN. :)
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: spDiscard[Tgt|Opp]

Postby Sloth » 10 Sep 2010, 09:26

Sorry to bring this up again Rob, but Wrench Mind still isn't fixed. If the AI uses it against you, you can discard any number of cards, it won't help unless you discard an artifact.
If you use it on the AI, compy will just ignore it, if it doesn't have any artifacts in hand.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: spDiscard[Tgt|Opp]

Postby Rob Cashwalker » 11 Sep 2010, 03:16

I think I've fixed this - r1973.

The number of cards to be discarded (if not type) was not being set.
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

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 28 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 28 users online :: 0 registered, 0 hidden and 28 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 28 guests

Login Form