- fixed memory leaks introduced in previous revision

- removed incorrect casts of MTGCardInstance into Spell objects.
- AI Test system now allows you to put decks in ai/bakaA and ai/bakaB instead of ai/baka. This allows to let AIPlayerBaka and AIPlayerBakaB play with specific decks
- Test suite speed improvement. Improved the card name cache. Test suite now runs in 850 seconds instead of 950 on my machine.
- minor code cleanup
This commit is contained in:
wagic.the.homebrew
2011-09-22 04:43:05 +00:00
parent 997b154d46
commit ee4c7e23bd
15 changed files with 163 additions and 85 deletions

View File

@@ -107,7 +107,7 @@ class AIPlayerFactory{
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0);
#ifdef AI_CHANGE_TESTING
AIPlayer * createAIPlayerTest(MTGAllCards * collection, Player * opponent, int deckid = 0);
AIPlayer * createAIPlayerTest(MTGAllCards * collection, Player * opponent, string folder);
#endif
};

View File

@@ -210,7 +210,7 @@ public:
Player * lastActionController;
int setIsInterrupting(Player * player);
int count( int type = 0 , int state = 0 , int display = -1);
int getActionElementFromCard(MTGCardInstance * card);
Interruptible * getActionElementFromCard(MTGCardInstance * card);
Interruptible * getPrevious(Interruptible * next, int type = 0, int state = 0 , int display = -1);
int getPreviousIndex(Interruptible * next, int type = 0, int state = 0 , int display = -1);
Interruptible * getNext(Interruptible * previous, int type = 0, int state = 0 , int display = -1);

View File

@@ -37,12 +37,9 @@ public:
if (card) return card->X;
return 1; //this should only hapen when the ai calls the ability. This is to give it an idea of the "direction" of X (positive/negative)
}
WParsedInt(int value = 0)
{
intValue = value;
}
WParsedInt(string s, Spell * spell, MTGCardInstance * card)
private:
void init(string s, Spell * spell, MTGCardInstance * card)
{
if(!card)
return;
@@ -73,8 +70,7 @@ public:
}
if(s == "prex")
{
ManaCost * cX = NEW ManaCost(card->controller()->getManaPool()->Diff(card->getManaCost()));
int preX =
ManaCost * cX = card->controller()->getManaPool()->Diff(card->getManaCost());
intValue = cX->getCost(Constants::MTG_NB_COLORS);
delete cX;
}
@@ -220,6 +216,22 @@ public:
}
intValue *= multiplier;
}
public:
WParsedInt(int value = 0)
{
intValue = value;
}
WParsedInt(string s, Spell * spell, MTGCardInstance * card)
{
init(s, spell, card);
}
WParsedInt(string s, MTGCardInstance * card)
{
init(s, NULL, card);
}
int getValue()
{

View File

@@ -119,6 +119,11 @@ public:
map<string, CardPrimitive *> primitives;
MTGCard * _(int id);
MTGCard * getCardById(int id);
#ifdef TESTSUITE
void prefetchCardNameCache();
#endif
MTGCard * getCardByName(string name);
int load(const char * config_file, const char * setName = NULL, int autoload = 1);
int countByType(const char * _type);

View File

@@ -68,6 +68,7 @@ private:
bool forceAbility;
int summoningSickness;
int load(const char * filename);
void cleanup();
@@ -84,6 +85,7 @@ public:
int assertGame();
public:
int startTime, endTime;
int gameType;
unsigned int seed;
int nbFailed, nbTests, nbAIFailed, nbAITests;