public void Run(int numGenerations, List <TyDeckHeroPair> myDeck, List <TyDeckHeroPair> enemyDeck, AbstractAgent enemyAgent) { var myDeckName = TyDeckHeroPair.GetDeckListPrint(myDeck); var enemyDeckName = TyDeckHeroPair.GetDeckListPrint(enemyDeck); FileName = myDeckName + "Vs" + enemyDeckName + "_" + enemyAgent.GetType().Name; while (File.Exists(FileName + ".txt")) { FileName += "0"; } WriteGlobalToFile(); TyDebug.LogInfo(FileName); TyDebug.LogInfo("Generations: " + numGenerations); for (int step = 0; step < numGenerations; step++) { var startDate = DateTime.Now; Train(_currentPopulation, myDeck, enemyDeck, enemyAgent); var children = GiveBirth(SelectFittest(_currentPopulation), _random, step + 1); Train(children, myDeck, enemyDeck, enemyAgent); _currentPopulation = MixPopulations(_currentPopulation, children, step + 1); Log("Generation " + (step)); LogPopulation(_currentPopulation); var diff = DateTime.Now.Subtract(startDate); Log("Generation took " + diff.Minutes + " min, " + diff.Seconds + " s"); WriteCurrentToFile(FileName + ".txt"); _csvLog.WriteToFiles(FileName); } }
private void PrintFinalResults(double time, int matches) { TyDebug.LogInfo("Result: " + _agent0.GetType().Name + ": " + ((float)_agent0Wins / (float)_totalPlays) * 100.0f + "% vs " + _agent1.GetType().Name + ": " + ((float)_agent1Wins / (float)_totalPlays) * 100.0f + "%. " + matches + " matches took " + time.ToString("0.000") + "s"); }