It is currently 09 Sep 2025, 04:40
   
Text Size

PlayMain1 cards

Post MTG Forge Related Programming Questions Here

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

PlayMain1 cards

Postby Rob Cashwalker » 31 May 2010, 04:16

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 **************************       
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: PlayMain1 cards

Postby Chris H. » 31 May 2010, 10:24

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.
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: PlayMain1 cards

Postby Rob Cashwalker » 31 May 2010, 12:13

Already done. There were already a few cards from all those keywords on the list. Now ALL cards from those keywords will benefit.
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


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 51 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 51 users online :: 0 registered, 0 hidden and 51 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 51 guests

Login Form