Page 1 of 1

PlayMain1 cards

PostPosted: 31 May 2010, 04:16
by Rob Cashwalker
Recent discussion on how best to make sure that my pump spells were actually considered by the AI, revealed that there was a hard-coded list of cards the AI would choose to play during Main1.

My suggestion was to modify the bit of AI code that utilized the list, having it search for cards with a property to be played during Main1.

ComputerAI_General:
Code: Select all
    private SpellAbility[] getMain1() {
        //Card list of all cards to consider
        CardList hand = new CardList(AllZone.Computer_Hand.getCards());
       
        hand = hand.filter(new CardListFilter() {
           // Beached As Start
            public boolean addCard(Card c) {
                //Collection<Card> play = playMain1Cards;
               if (c.getSVar("PlayMain1").equals("TRUE"))
                  return true;
               
                if(c.isLand()) return false;
                if(c.isCreature() && c.getKeyword().contains("Haste")) return true;
                CardList Vengevines = new CardList();
......
This approach should actually speed up the AI slightly by not searching the list for each loop and frees up a few kB of memory, by not having to store the list.

The list was certainly incomplete, so add the following wherever necessary:
Code: Select all
card.setSVar("PlayMain1", "TRUE");
Could probably add it to cards.txt instead...:
Code: Select all
SVar:PlayMain1:TRUE
There are some cards (and the list probably is missing a number of them) that are not listed in CardFactory, they are implemented elsewhere, as static pumps, like the Anthems. So I added this to CardFactory: (I hadn't considered the cards.txt approach)
Code: Select all
      //*************** START ********** START *************************
        if (cardName.equals("Finest Hour") || cardName.equals("Gaea's Anthem") ||
              cardName.equals("Glorious Anthem")) 
           // no card factory code, cards handled elsewhere,
        {
           card.setSVar("PlayMain1", "TRUE");
        }//*************** END ************ END **************************       

Re: PlayMain1 cards

PostPosted: 31 May 2010, 10:24
by Chris H.
Nice work Rob. I have not yet had a chance to really think about it … but I guess that we will likely want to add this SVar to the spPump, spDestroy, and the enPump, eqPump cards.

Re: PlayMain1 cards

PostPosted: 31 May 2010, 12:13
by Rob Cashwalker
Already done. There were already a few cards from all those keywords on the list. Now ALL cards from those keywords will benefit.