Cleanup and hoping to increase performance
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
41 posts
• Page 2 of 3 • 1, 2, 3
Re: Cleanup and hoping to increase performance
by friarsol » 31 Jul 2012, 02:13
Looks like cards that start in play via Quests aren't being run through the cardfactory creation.
Eladamri's Vineyard isn't triggering at all from the Green Medium Quest. If I cast a Vineyard in constructed play, it triggers just fine.
Eladamri's Vineyard isn't triggering at all from the Green Medium Quest. If I cast a Vineyard in constructed play, it triggers just fine.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Cleanup and hoping to increase performance
by Sloth » 31 Jul 2012, 07:44
It's really fast now on my slow computer (not just the loading time, but during matches as well). I'm sure some of our users will be very happy about this.
Thumbs up Max.
Thumbs up Max.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Cleanup and hoping to increase performance
by Max mtg » 31 Jul 2012, 10:34
Yes, that must be related to cards that are placed on battlefield before the match starts. I'll check it todays evening.friarsol wrote:Looks like cards that start in play via Quests aren't being run through the cardfactory creation.
Eladamri's Vineyard isn't triggering at all from the Green Medium Quest. If I cast a Vineyard in constructed play, it triggers just fine.
Sloth, I would also appreciate if you pressed that special button (in the top-right corner of the post frame)
mcrawford620, please, consider refactoring LimitedDeck to use CardPrinted instances, not forge.Card(s)
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Cleanup and hoping to increase performance
by Chris H. » 31 Jul 2012, 13:33
Using today's snapshot build I see that the LQ pic downloading code wants to download over 2000 pics yet I should be up to date.
Let me run a test and see what happens.
Let me run a test and see what happens.
-

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: Cleanup and hoping to increase performance
by Chris H. » 31 Jul 2012, 13:47
Chris H. wrote:Using today's snapshot build I see that the LQ pic downloading code wants to download over 2000 pics yet I should be up to date.
Let me run a test and see what happens.
It is downloading three different forest pics and is naming them:
1.jpg
2.jpg
3.jpg
As the code downloads the 2403 pics it does not stop after writting these three files. It continues to download the same three pics and will replace the previously named pics with another copy.
After a period of time I see that these three files are no longer forest pics but it is now island pics. I assume that I will see mountains, plains and swamps before this is finished.
EDIT:
Once we have the three files named:
1.jpg
2.jpg
3.jpg
and then click on the download LQ pics button we will be told that all pics have been downloaded.
-

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: Cleanup and hoping to increase performance
by mcrawford620 » 31 Jul 2012, 17:38
I'd be glad to take a look.Max mtg wrote:mcrawford620, please, consider refactoring LimitedDeck to use CardPrinted instances, not forge.Card(s)
It looks like I should start from BoosterDraft.java? The sequence runs:
- BoosterDraft already has CardPrinted, but converts to Cards to send to BoosterDraftAI
- BoosterDraftAI picks from Cards and puts them into CardLists
- then sends them on to LimitedDeck to build the deck
The Booster and Limited code uses a lot of the CardList methods to filter down the available cards, based on colors, type of card, and so on. How should I go about refactoring those methods?
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Cleanup and hoping to increase performance
by Max mtg » 31 Jul 2012, 18:45
Booster draft AI AFAIR has not been refactored since CardPrinted introduction, yet it would be great to do so.mcrawford620 wrote:The Booster and Limited code uses a lot of the CardList methods to filter down the available cards, based on colors, type of card, and so on. How should I go about refactoring those methods?
There are methods to filter CardPrinted instances:
- Code: Select all
Itereable<CardPrinted> cards = CardDb.instance().getAllCards() // or whatever the source collection is;
// colors
List<CardPrinted> redCards = CardRules.Predicates.Presets.IS_RED.select(cards, CardPrinted.FN_GET_RULES);
// Type of cards
List<CardPrinted> creatures = CardRules.Predicates.Presets.IS_CREATURE.select(cards, CardPrinted.FN_GET_RULES);
List<CardPrinted> spells = CardRules.Predicates.Presets.IS_NONCREATURE_SPELL.select(cards, CardPrinted.FN_GET_RULES);
// AI playability
List<CardPrinted> goodForRandomDecks = CardRules.Predicates.IS_KEPT_IN_RANDOM_DECKS.select(cards, CardPrinted.FN_GET_RULES);
I will also be able to answer your questions right here (or in a dedicated thread)
Chris, this should be no longer an issue.Chris H. wrote:Using today's snapshot build I see that the LQ pic downloading code wants to download over 2000 pics yet I should be up to date.
Let me run a test and see what happens.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Cleanup and hoping to increase performance
by Sloth » 31 Jul 2012, 18:55
I want to point out that devSetupGameState() basically does the same thing (putting permanents onto the battlefield) and works fine. Maybe the quest setup can share some of its code.Max mtg wrote:Yes, that must be related to cards that are placed on battlefield before the match starts. I'll check it todays evening.friarsol wrote:Looks like cards that start in play via Quests aren't being run through the cardfactory creation.
Eladamri's Vineyard isn't triggering at all from the Green Medium Quest. If I cast a Vineyard in constructed play, it triggers just fine.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Cleanup and hoping to increase performance
by mcrawford620 » 31 Jul 2012, 19:07
Looks good, thanks for the help. I'll do what I can; not sure if I can finish by the end of the week.
It looks like CardPrinted has a CardRules, which seems to contain everything about a card? What about the actual Card object is so heavy?
It looks like CardPrinted has a CardRules, which seems to contain everything about a card? What about the actual Card object is so heavy?
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Cleanup and hoping to increase performance
by friarsol » 31 Jul 2012, 19:40
Don't worry about finishing by the end of the week. Just finish when you can.mcrawford620 wrote:Looks good, thanks for the help. I'll do what I can; not sure if I can finish by the end of the week.
It looks like CardPrinted has a CardRules, which seems to contain everything about a card? What about the actual Card object is so heavy?
Card objects are basically full Game objects with Abilities and Triggers etc attached.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Cleanup and hoping to increase performance
by Max mtg » 31 Jul 2012, 19:44
you are welcomemcrawford620 wrote:It looks like CardPrinted has a CardRules, which seems to contain everything about a card? What about the actual Card object is so heavy?
Exactly. CardPrinted is created for each variant of card printed in each set (4 islands in M13, 4 for M12, 2 from NPH and so on). This class is great for collection management. Each CardPrinted contains name, edition, rariry, picture index and a reference to CardRules object.
There is one and only CardRules object for each card name, regardless of number of its reprints. Here all the basic information is stored - type, color, manacost, oracle text (it is not parsed here into triggers or abilities). This class is good for deckbuilding.
Why is Card so heavy? You'd better have a look at the forge.Card class declaration
At the moment there are no Card instances when the game starts, that allows it to start a bit faster than before and cosume less memory.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Cleanup and hoping to increase performance
by Max mtg » 31 Jul 2012, 21:57
This problem emerges due to Card.resetUniqueNumber() call performed after cards to lay on the table at the beginning of a match had already been created (these were given ids 1-5 for instance), but before players' decks were to be materialized from CardPrinted. After that reset, all the new Cards recieve IDs starting from 1 again. In this manner we get a number of cards with same IDs.Sloth wrote:I want to point out that devSetupGameState() basically does the same thing (putting permanents onto the battlefield) and works fine. Maybe the quest setup can share some of its code.
In the mentioned case trigger on Eladamri's Vineyard (id=4) checks card's zone. To learn its zone, our code iterates over all players' zones looking for a card with Id = 4 there and finds a (goblin guide) with id = 4 in human's library. The code conclues that Eladamri's Vineyard is in a unsiutable place for the trigger to work and cancels it.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Cleanup and hoping to increase performance
by mcrawford620 » 01 Aug 2012, 06:10
It went more easily than I expected, I checked it in and it works. I left some little bits out for now -- I wasn't sure of the best way to use the SVars that I had been using from the Card objects. Add something to CardCharacteristics? Not sure.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Cleanup and hoping to increase performance
by Max mtg » 01 Aug 2012, 06:58
Which exactly svars do you need? Willmcrawford620 wrote:It went more easily than I expected, I checked it in and it works. I left some little bits out for now -- I wasn't sure of the best way to use the SVars that I had been using from the Card objects. Add something to CardCharacteristics? Not sure.
- Code: Select all
forge.card.CardRules.getDeckWants()
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Cleanup and hoping to increase performance
by mcrawford620 » 01 Aug 2012, 16:34
Perfect, thanks.
I go back and forth on whether this whole DeckWants thing is worth it but for now I'll keep it in there. I underestimated how many cards 11,000 is.
Ultimately I think Rob's idea in viewtopic.php?f=52&t=7510#p93635 is better for deckbuilding but it's a long way off.
I go back and forth on whether this whole DeckWants thing is worth it but for now I'll keep it in there. I underestimated how many cards 11,000 is.
Ultimately I think Rob's idea in viewtopic.php?f=52&t=7510#p93635 is better for deckbuilding but it's a long way off.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
41 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 17 guests