Exemplo n.º 1
0
void ResearchEngine::doSingleResearch(Point *start, Point *end, int type, int populationSize, float f, float cr, int movementSteps, int epochs, bool showResult){
	Environment env(*start, *end, type, populationSize, f, cr, movementSteps);

	vector<float> results;
	for(currentEpoch = 0; currentEpoch < epochs; currentEpoch++){
		results.push_back(env.evolutionCycle());
	}

	Worm * worm = env.getBestWorm();
	worm->saveToFile(createFileName("", "_worm.txt", start, end, type, populationSize, f, cr, movementSteps, epochs));
	saveResultsToFile(createFileName("", "_results.txt", start, end, type, populationSize, f, cr, movementSteps, epochs), results);

	if(showResult){
		SDLInterface inteface;
		inteface.displayWorm(worm);
	}

	env.clear();
}
Exemplo n.º 2
0
void MainWindow::startTests()
{
   if (cursorList.size()+1 == roundNum) // Finished Testing, go to results
   {
      setCursor(Qt::ArrowCursor);
      thankUser();
      saveResultsToFile();
      close();
   }
   else
   {
      rndNum->setText(QString::number(roundNum));
      setCursor(cursorList[roundNum-1]);

      QMessageBox msg(QMessageBox::Information,"Information", QString("Now beginning round %1.\n Click OK to begin.").arg(roundNum),QMessageBox::Ok, this);
      
      try //Catch infinite loop
      {
      if (roundNum<=5)
      {
         msg.move(QPoint(testArea->geometry().x()+(testArea->geometry().width()/2), testArea->geometry().y()+(testArea->geometry().height()/2)));
         msg.exec();
         testArea->start();
      }  
      else
      {
         msg.move(QPoint(testArea2->geometry().x()+(testArea2->geometry().width()/2), testArea2->geometry().y()+(testArea2->geometry().height()/2)));
         msg.exec();
         testArea2->start();
      }
      } catch (QString temp)
      {
         qDebug() << temp;
      }
      roundNum++;
   }
}