It is currently 27 Apr 2024, 10:08
   
Text Size

Scry

Post MTG Forge Related Programming Questions Here

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

Scry

Postby Rob Cashwalker » 20 Jan 2010, 04:30

One of the new spPumpTgt cards I want to add is Ferocious Charge. Simple, except for the Scry 2.

I have spent the evening devising a method which I think should work. I would like to propose that it shall be handled similarly to the "Draw a card." revision. There are a few cards that use Scry in an odd way, (damn Future Sight) but complex cards can always be hardcoded and still make use this generic scry method.

It uses a very simplistic AI to dig past basic lands and creatures if there are more than 5 of either of them in play.

I haven't put this into the SVN yet, I wanted to post it for review first.

GameAction.java
Code: Select all
  public void scry(String player, int numScry)
  {
     CardList topN = new CardList();
     PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
     for (int i = 0; i < numScry; i++)
     {
        topN.add(library.get(0));
        library.remove(0);
     }
    
     int N = topN.size();
    
     if (player.equals(Constant.Player.Human))
     {
        for (int i = 0; i < N; i++)
        {
           Object o;
           o = AllZone.Display.getChoiceOptional("Choose a card to put on the bottom of your library.", topN.toArray());
           if (o != null)
           {
              Card c = (Card)o;
              topN.remove(c);
              library.add(c);
           }
           else   // no card chosen for the bottom
              break;
        }
        N = topN.size();
        if (N > 0)
           for (int i = 0; i < N; i++)
           {
              Object o;
              o = AllZone.Display.getChoice("Choose a card to put on the top of your library.", topN.toArray());
              if (o != null)
              {
                 Card c = (Card)o;
                 topN.remove(c);
                 library.add(c, 0);
              }
              // no else - a card must have been chosen
           }

     }
     else // computer
     {
        for (int i = 0; i < N; i++)
        {
           boolean b = false;
           if (topN.get(i).getType().contains("Basic"))
           {
              CardList bl = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
              bl = bl.filter(new CardListFilter()
              {
                 public boolean addCard(Card c)
                 {
                    if (c.getType().contains("Basic"))
                       return true;

                    return false;
                 }
              });
             
              if (bl.size() > 5) // if control more than 5 Basic land, probably don't need more
                 b = true;
           }
           else if (topN.get(i).getType().contains("Creature"))
           {
              CardList cl = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
              cl = cl.filter(new CardListFilter()
              {
                 public boolean addCard(Card c)
                 {
                    if (c.getType().contains("Creature"))
                       return true;

                    return false;
                 }
              });
             
              if (cl.size() > 5) // if control more than 5 Creatures, probably don't need more
                 b = true;                
           }
           if (b == true)
           { 
              library.add(topN.get(i));
              topN.remove(i);
           }
        }
        N = topN.size();
        if (N > 0)
           for (int i=0; i<N; i++) // put the rest on top in random order
           {
              Random rndm = new Random();
              int r = rndm.nextInt(topN.size());
              library.add(topN.get(r), 0);
              topN.remove(r);
           }
     }
  }
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: Scry

Postby DennisBergkamp » 20 Jan 2010, 20:05

I think it looks good, add it! It would also allow for a bunch of new cards that could be coded exclusively through keywords.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Scry

Postby Rob Cashwalker » 20 Jan 2010, 20:56

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: Scry

Postby DennisBergkamp » 20 Jan 2010, 20:58

That's it ? Aw. Well, at least I could use the keyword for hardcoding the others.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Scry

Postby Marek14 » 20 Jan 2010, 21:16

Maybe you could do fateseal as well when you're at it :)
Marek14
Tester
 
Posts: 2761
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 297 times

Re: Scry

Postby lord of 13 » 20 Jan 2010, 21:24

You guys forgot Lose Hope! And Forsee. The rest of the cards probably have to be hardcoded
><><><><><><><
Currently developing Mindgames, for playing a rules-enforced game of MtG.
RECENT PROJECTS
->XMLScript
->Zwiel Platformer
User avatar
lord of 13
DEVELOPER
 
Posts: 79
Joined: 06 Jan 2010, 01:36
Has thanked: 0 time
Been thanked: 0 time

Re: Scry

Postby Rob Cashwalker » 21 Jan 2010, 00:14

We'll get around to doing the -x/-y spells as a keyword at some point. Doing a discard keyword sometime soon is not out of the question.

But the one where the scry occurs before a keywordable effect would make it difficult.
And there's one that's like Scry 1, scry 2, and then scry 3...

On the other hand, with the return to Mirrodin, the keyword may have a comeback.

I'll add it into GameAction now. Then I'll work out adding it to the code where we put the Cantrip handler. It may be tricky - I don't want to clog up that section with parsing code to determine N in "Scry N".
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: Scry

Postby Chris H. » 26 Jan 2010, 14:52

Rob Cashwalker wrote:It uses a very simplistic AI to dig past basic lands and creatures if there are more than 5 of either of them in play.
`
Looks interesting.

As far as digging past creatures if there are more than 5 of them in play ... would it be worth keeping the creature if it was one of the few big creatures in the deck. I am thinking that we could test for

Code: Select all
getNetAttack() + getNetDefense() >= 8
`
this might let the computer swing the balance at this stage if the computer and the human were at a stage of equilibrium.
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: Scry

Postby Rob Cashwalker » 26 Jan 2010, 23:53

Yeah, there's probably a number of criteria to key off of....

Why not simply make it that if the creature is bigger than all those in play, then it leaves it on top. Again, avoiding hard-coded numbers.
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: Scry

Postby Chris H. » 27 Jan 2010, 00:47

That is a better idea. You had mentioned that you were using a simplistic AI to dig and your suggestion should only require a few additional lines of code.
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: Scry

Postby Rob Cashwalker » 27 Jan 2010, 17:45

on second thought....

that's not much better... if the creature is going to be too expensive to reliably cast given current mana in play plus any in hand. In that case it needs to keep the land on top too...

With the computer land-stacking, I know the top 7 cards are land, but are the rest of the lands re-distributed among the remainder of the library? (so if there's no hope of casting any big spells, then it should go on bottom)
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: Scry

Postby zerker2000 » 28 Jan 2010, 04:23

I think "remainder" is something along the lines of 3 more land over the consecutive 8 or so turns, with the rest of the land being moved to the bottom.
However, "no hope of casting any big spells" isn't really guaranteed: a) Land stacking isn't necessarily on and b) any number of cards shuffle a library. If you scry a big spell and have nearly the amount of mana needed to cast it(and I'm almost sure there is an AI util for that), you probably don't want to reject it, at least in the case that is the only big spell in your scry+hand, and/or you could put enough land on top of it to cast it when such opportunity is given. Opponent milling capabilities should also...sorry I'll try to stay within reasonable limits(though a Millstone or two under opponent control Is something to consider).
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Scry

Postby DennisBergkamp » 28 Jan 2010, 21:50

You could always take into account whether land has been stacked... (if (Constant.Smooth[0]) .. ). Then again, the deck might've been shuffled by some effect already, so scratch that.

Another possibility is to be evil :twisted: and just cheat: check what the next few cards will be. A lot of people are against this approach (mommy, the AI just cheated! ), but personally I'm all in favor of giving the severely crippled AI whatever help it can get.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Scry

Postby zerker2000 » 29 Jan 2010, 02:28

Son, get out of the debugger, you have better things to do :). I do agree that is not the way to go though.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Scry

Postby Rob Cashwalker » 29 Jan 2010, 03:49

Making these abilities function is one thing.... Coming up with some logical rules to make educated plays is insanity.
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

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 109 guests


Who is online

In total there are 109 users online :: 0 registered, 0 hidden and 109 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 109 guests

Login Form