- Modified DeckManager class to not use a global instance anymore when used within the game engine
- Modified DuelLayers to not use a global MTGPhaseGame instance anymore - Moved the reset of currentActionCard out of the ActionLayer render function : that fixes the remaing problematic tests in the multithreaded testsuite - Added a method in ActionLayer converting a card ability into a menu index - Used this new method in the game observer to log correctly AI ability actions - Added a DumpAssert method in the game observer, it can be used to dump the game and assert in order to easy crash reproduction - Cleaned up TargetList properties access - Added an optimisation in GuiMana to not compute update code if the rendering is not used (multi-threaded mode) - Added a deadlock detection in the test AI vs AI multithreaded mode - Fixed minor bugs in test AI vs AI multithreaded mode - Added a games/second counter in the test AI vs AI rendering
This commit is contained in:
@@ -284,12 +284,28 @@ void GameStateDuel::ThreadProc(void* inParam)
|
||||
while(instance->mGamePhase != DUEL_STATE_BACK_TO_MAIN_MENU)
|
||||
{
|
||||
GameObserver observer;
|
||||
int oldTurn = -1;
|
||||
int oldPhase = -1;
|
||||
int stagnationCounter = -1;
|
||||
|
||||
observer.loadPlayer(0, PLAYER_TYPE_TESTSUITE);
|
||||
observer.loadPlayer(1, PLAYER_TYPE_TESTSUITE);
|
||||
observer.startGame(instance->mParent->gameType, instance->mParent->rules);
|
||||
|
||||
while(!observer.gameOver)
|
||||
while(!observer.gameOver) {
|
||||
if(observer.turn == oldTurn && observer.currentGamePhase == oldPhase) {
|
||||
stagnationCounter++;
|
||||
} else {
|
||||
stagnationCounter = 0;
|
||||
oldTurn = observer.turn;
|
||||
oldPhase = observer.currentGamePhase;
|
||||
}
|
||||
if(stagnationCounter >= 1000)
|
||||
{
|
||||
observer.dumpAssert(false);
|
||||
}
|
||||
observer.Update(counter++);
|
||||
}
|
||||
|
||||
instance->handleResults(&observer);
|
||||
}
|
||||
@@ -441,22 +457,25 @@ void GameStateDuel::Update(float dt)
|
||||
else
|
||||
#endif
|
||||
#ifdef AI_CHANGE_TESTING
|
||||
if (mParent->players[0] == PLAYER_TYPE_CPU_TEST && mParent->players[1] == PLAYER_TYPE_CPU_TEST)
|
||||
{
|
||||
handleResults(game);
|
||||
End();
|
||||
Start();
|
||||
}
|
||||
if(mWorkerThread.empty())
|
||||
{ // "I don't like to wait" mode
|
||||
size_t thread_count = 1;
|
||||
#ifdef QT_CONFIG
|
||||
thread_count = QThread::idealThreadCount();
|
||||
#endif
|
||||
for(size_t i = 0; i < (thread_count-1); i++)
|
||||
mWorkerThread.push_back(boost::thread(ThreadProc, this));
|
||||
}
|
||||
if (mParent->players[0] == PLAYER_TYPE_CPU_TEST && mParent->players[1] == PLAYER_TYPE_CPU_TEST)
|
||||
{
|
||||
handleResults(game);
|
||||
End();
|
||||
Start();
|
||||
}
|
||||
if(mWorkerThread.empty())
|
||||
{ // "I don't like to wait" mode
|
||||
size_t thread_count = 1;
|
||||
startTime = JGEGetTime();
|
||||
|
||||
#ifdef QT_CONFIG
|
||||
thread_count = QThread::idealThreadCount();
|
||||
#endif
|
||||
for(size_t i = 0; i < (thread_count-1); i++)
|
||||
mWorkerThread.push_back(boost::thread(ThreadProc, this));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU)
|
||||
{
|
||||
@@ -566,6 +585,7 @@ void GameStateDuel::Render()
|
||||
if (game && totalTestGames)
|
||||
{
|
||||
char buf[4096];
|
||||
int currentTime = JGEGetTime();
|
||||
|
||||
if (totalTestGames < 2.5 * totalAIDecks)
|
||||
{
|
||||
@@ -580,7 +600,8 @@ void GameStateDuel::Render()
|
||||
mFont->SetColor(ARGB(255,255,0,0));
|
||||
if (ratio > 0.52)
|
||||
mFont->SetColor(ARGB(255,0,255,0));
|
||||
sprintf(buf, "Victories Player 2/total Games: %i/%i", testPlayer2Victories, totalTestGames);
|
||||
sprintf(buf, "Victories Player 2/total Games: %i/%i - Games/second: %f",
|
||||
testPlayer2Victories, totalTestGames, (float)(1000*totalTestGames)/(currentTime - startTime));
|
||||
mFont->DrawString(buf,0,SCREEN_HEIGHT/2);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user