It is currently 06 Jun 2024, 10:02
   
Text Size

New 2 Color Deck Generator

Post MTG Forge Related Programming Questions Here

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

Re: New 2 Color Deck Generator

Postby friarsol » 06 Oct 2010, 17:21

The code in here doesn't make sense:

Code: Select all
    else if (colors == 5)
    {
       out = list.filter(new CardListFilter()
       {
         public boolean addCard(Card c)
         { 
           return CardUtil.getColors(c).size() >= 2 && //only get multicolored cards
                  !c.isLand()                       && //no land
                  c.getSVar("RemAIDeck").equals("True")     || //OR very important
                  goodLand.contains(c.getName());
         }
       });
       
    }
It's only returning multicolored, nonLand cards, that RemAIDeck have been set to True. Shouldn't we be allowing any card except remAIDeck and lands?

The filter should probably be something like:
Code: Select all
return !(getColors(c).size() > 2 || c.isLand() || c.getSVar("RemAIDeck").equals("True"));
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New 2 Color Deck Generator

Postby Rob Cashwalker » 06 Oct 2010, 18:00

I thought about that too, so I checked the other generator where I removed the remove list. I now have:

Code: Select all
return CardUtil.getColors(c).size() <= 3 &&
                  !c.isLand()                       && //no land
                  !c.getSVar("RemAIDeck").equals("True")    || //OR very important
                  goodLand.contains(c.getName());
But it didn't make a difference.

As I was working on my generator, I ran into a issue, where I was getting no cards returned by the CardList.getColor. I dug into it, and realized it had been updated for the card color object, so I attempted to figure out how/why it worked, so that I could use it. But I couldn't, so I figured that from a deck generation point of view, the mana costs were just as good to filter from.
I suspect that the original generators are having issue with the card colors, and not enough cards are available to build the deck.
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: New 2 Color Deck Generator

Postby friarsol » 06 Oct 2010, 18:41

I can't tell exactly what the problem is, but I put a breakpoint in getColor(c) and the list of colors being returned looks right to me.

The last line of get5Colors(CardList in) seems suspect though.
Code: Select all
    out = filterBadCards(out, 3);
    return out;
filterBadCards seems to get called twice, once at 5 count in the beginning and once at 3 count at the end. It seems like the first time through it throws out a handful of things dropping it to about 3500 cards it can use. Then the second time through it hits the poor logic in get3Colors and throws basically everything else out.


For color related functions here is the best way to go. If you want to know if a Card is a color use this:
Code: Select all
CardUtil.isColor(card, colorString);
If you want to get an ArrayList of every color a card is use this:
Code: Select all
CardUtil.getColors(card);
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 59 guests


Who is online

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

Login Form