It is currently 12 Sep 2025, 09:22
   
Text Size

Cleanup and hoping to increase performance

Post MTG Forge Related Programming Questions Here

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

Re: Cleanup and hoping to increase performance

Postby Max mtg » 01 Aug 2012, 17:43

I am not that confident about the Rob's idea of learning winning strategies from people playing forge.
If someone does not like "svar" in front of "deckwants", it's ok to is just keep "DeckWants:" in card scripts. As long as its about pointing at some favourable cards, that would be enough.

There is a routine to filter CardLists in DeckWants class - it might be a good idea to replace it with a predicate lazy builder.
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

Postby mcrawford620 » 01 Aug 2012, 17:52

Yeah, I'll try to rewrite the DeckWants; the tests make it pretty easy to do so. It definitely can live in the CardPrinted instead of the Card since it would never be needed during a game.
I'd never heard of Predicates before so that's all new. I think I'm getting the hang of it, though.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Cleanup and hoping to increase performance

Postby Max mtg » 01 Aug 2012, 18:05

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.
fixed in r16400, though it was not related to Card lazy loading at all.
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

Postby Max mtg » 02 Aug 2012, 07:16

I made some more fixes regarding memory allocation mainly

The slowest part by now is really the GUI. See the picture below
Attachments
forge-slowdowns-3.png
actual launch times
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

Postby Chris H. » 02 Aug 2012, 15:38

I launched today's snapshot build by double clicking on the jar file rather than using the launcher. Forge launched without an increased java heap space.

I played a quick game and spent a little time in the deck editor. I did not get a java heap space error. :)
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: Cleanup and hoping to increase performance

Postby mcrawford620 » 02 Aug 2012, 19:45

Right now I'm getting this error when trying to add lands to the LimitedDeck:
Code: Select all
java.util.NoSuchElementException: Asked for card 'Swamp' from 'ARN': set found, but the card wasn't. :(
   at forge.item.CardDb.getCard(CardDb.java:281)
   at forge.item.CardDb.getCard(CardDb.java:254)
   at forge.game.limited.LimitedDeck.addLands(LimitedDeck.java:245)
Probably it was not being done the right way, but here's what it says:
Code: Select all
final CardPrinted cp = CardDb.instance().getCard(clrCnts[i].getColor(), aiPlayables.get(0).getEdition());
What should I do there instead?
Last edited by mcrawford620 on 02 Aug 2012, 20:43, edited 1 time in total.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Cleanup and hoping to increase performance

Postby Sloth » 02 Aug 2012, 20:41

mcrawford620 wrote:Right now I'm getting this error when trying to add lands to the LimitedDeck:
Code: Select all
java.util.NoSuchElementException: Asked for card 'Swamp' from 'ARN': set found, but the card wasn't. :(
   at forge.item.CardDb.getCard(CardDb.java:281)
   at forge.item.CardDb.getCard(CardDb.java:254)
   at forge.game.limited.LimitedDeck.addLands(LimitedDeck.java:245)
Probably it was not being done the right way, but here's what it says:
Code: Select all
final CardPrinted cp = CardDb.instance().getCard(clrCnts[i].getColor(), aiPlayables.get(0).getEdition());
Why don't you use this?
Code: Select all
final CardPrinted cp = CardDb.instance().getCard(clrCnts[i].getColor());
If aiPlayables.get(0) comes from a set without basic lands, the getCard you've used has to fail.
User avatar
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

Postby mcrawford620 » 02 Aug 2012, 20:47

Sloth wrote:Why don't you use this?
Code: Select all
final CardPrinted cp = CardDb.instance().getCard(clrCnts[i].getColor());
If aiPlayables.get(0) comes from a set without basic lands, the getCard you've used has to fail.
That's better, thanks. I think the original intent was to keep the "look" of the lands the same as the rest of the limited deck, pulling them from the same set. But also I didn't know what I was doing. :)

Is there a way to tell if a set has basic lands?
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Cleanup and hoping to increase performance

Postby Max mtg » 02 Aug 2012, 22:02

mcrawford620 wrote:Is there a way to tell if a set has basic lands?
  • Check isCardSupported(name, set) function to test card's presence in db.
  • Obtain a cardPrinted (from any set), then get CardRules and learn which sets contain the card (getSetsPrinted() )
  • FModel.editions has all editions with indices so that you can compare them and find the latest one but not exceeding ARN (or other target edition)
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

Postby Max mtg » 03 Aug 2012, 19:37

mcrawford620, please note that LimitedDeck class and its descendants do provide only some methods to build up a deck. They do not extend deck's functionality but rather act as a separate agent, who can be given a number of cards and return a deck.

This is why I removed base class of Deck from your LimitedDeck class.
Instead BuildDeck method is public now and returns a deck, and it is no called by constructor automatically.

I am sorry for having interferred into your code.
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

Postby mcrawford620 » 03 Aug 2012, 19:48

You're right, I should not have extended Deck. Thanks for cleaning it up. No apology needed!
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 13 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 13 users online :: 0 registered, 0 hidden and 13 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 13 guests

Login Form