- Added poison counter check into the testsuite

- Decorelated the testsuite AI timer from the game timer to be able to have reproduceable results with AI tests.
- Created a random generator wrapper class
- Used two seperate instances of this random generator for AI and for the game
- Added methods to load randoms into AI from a testcase
- Fixed a probleme with undo and premade decks introduced in r4035
- Added basic test to test AI proliferate code
- Cleaned up goblin_artillery test
- Added AI tests into the testsuite test list
- Fixed looping bug into the multi target AI code
This commit is contained in:
Xawotihs
2011-10-30 14:31:27 +00:00
parent 53b9bc412f
commit 2f4dd4cd2a
19 changed files with 195 additions and 98 deletions

View File

@@ -77,7 +77,7 @@ int TestSuiteAI::displayStack()
int TestSuiteAI::Act(float dt)
{
observer->gameOver = NULL; // Prevent draw rule from losing the game
observer->gameOver = NULL; // Prevent draw rule from losing the game
//Last bits of initialization require to be done here, after the first "update" call of the game
if (suite->currentAction == 0)
@@ -88,9 +88,10 @@ observer->gameOver = NULL; // Prevent draw rule from losing the game
if (playMode == MODE_AI && suite->aiMaxCalls)
{
float static counter = 1.0f;
suite->aiMaxCalls--;
suite->timerLimit = 40; //TODO Remove this limitation when AI is not using a stupid timer anymore...
AIPlayerBaka::Act(dt);
AIPlayerBaka::Act(counter++);//dt);
}
if (playMode == MODE_HUMAN)
{
@@ -341,6 +342,10 @@ void TestSuite::initGame(GameObserver* g)
AIPlayerBaka * p = (AIPlayerBaka *) (g->players[i]);
p->forceBestAbilityUse = forceAbility;
p->life = initState.players[i]->life;
p->poisonCount = initState.players[i]->poisonCount;
stringstream stream;
stream << initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream);
p->getRandomGenerator()->loadRandValues(stream.str());
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
MTGGameZone * loadedPlayerZones[] = { initState.players[i]->game->graveyard,
initState.players[i]->game->library,
@@ -430,7 +435,13 @@ int TestSuite::assertGame(GameObserver* g)
Log(result);
error++;
}
if (!p->getManaPool()->canAfford(endState.players[i]->getManaPool()))
if (p->poisonCount != endState.players[i]->poisonCount)
{
sprintf(result, "<span class=\"error\">==poison counter problem for player %i. Expected %i, got %i==</span><br />", i,
endState.players[i]->poisonCount, p->poisonCount);
Log(result);
error++;
} if (!p->getManaPool()->canAfford(endState.players[i]->getManaPool()))
{
sprintf(result, "<span class=\"error\">==Mana problem. Was expecting %i but got %i for player %i==</span><br />",
endState.players[i]->getManaPool()->getConvertedCost(), p->getManaPool()->getConvertedCost(), i);
@@ -611,7 +622,6 @@ void TestSuite::cleanup()
initState.cleanup(this);
endState.cleanup(this);
actions.cleanup();
loadRandValues("");
}
int TestSuite::load(const char * _filename)
@@ -623,7 +633,6 @@ int TestSuite::load(const char * _filename)
sprintf(filename, "test/%s", _filename);
std::string s;
loadRandValues("");
int state = -1;
@@ -655,11 +664,6 @@ int TestSuite::load(const char * _filename)
seed = atoi(s.substr(5).c_str());
continue;
}
if (s.find("rvalues:") == 0)
{
loadRandValues(s.substr(8).c_str());
continue;
}
if (s.find("aicalls ") == 0)
{
aiMaxCalls = atoi(s.substr(8).c_str());