- 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

@@ -21,13 +21,24 @@ namespace wagic
using std::vector;
using std::queue;
int randValuesCursor = -1;
vector<int> randValues;
int RandomGenerator::random()
{
int result;
if (!loadedRandomValues.size() || !log)
{
result = rand();
}
else
{
result = loadedRandomValues.front();
loadedRandomValues.pop();
}
if(log)
usedRandomValues.push(result);
return result;
}
queue<int> loadedRandomValues;
queue<int> usedRandomValues;
ostream& saveRandValues(ostream& out)
ostream& RandomGenerator::saveUsedRandValues(ostream& out)
{
while(usedRandomValues.size())
{
@@ -41,7 +52,21 @@ ostream& saveRandValues(ostream& out)
return out;
}
void loadRandValues(string s)
ostream& RandomGenerator::saveLoadedRandValues(ostream& out)
{
while(loadedRandomValues.size())
{
out << loadedRandomValues.front();
if(loadedRandomValues.size() >= 1)
out << ",";
loadedRandomValues.pop();
}
return out;
}
void RandomGenerator::loadRandValues(string s)
{
while(loadedRandomValues.size())
loadedRandomValues.pop();
@@ -66,26 +91,9 @@ void loadRandValues(string s)
}
}
ptrdiff_t MRand (ptrdiff_t i)
{
return WRand(true)%i;
}
int WRand(bool log)
{
int result;
if (!loadedRandomValues.size() || !log)
{
result = rand();
}
else
{
result = loadedRandomValues.front();
loadedRandomValues.pop();
}
if(log)
usedRandomValues.push(result);
return result;
return rand();
}
int filesize(const char * filename)