public NeatCentralizedQTableBase(RLClientBase client, int numTeammates, int myUnum) { m_client = client; m_rows = client.EnvRows; m_cols = client.EnvCols; m_numTeammates = numTeammates; m_myUnum = myUnum; m_numActions = SoccerAction.GetActionCount(Params.MoveKings, m_numTeammates); this.PerformanceNetworkToEvaluate = new NeatPlayerPerformanceStats(); if (NeatExpParams.SaveFitnessGrowth) { m_eaLogger = new PerformanceLogger(String.Format("EALogs/{0}-{1}-{2}", m_client.MyTeamName, m_myUnum, m_client.PerformanceLoggerMethodName), false); m_eaLogger.WriteLine("% Generation BestFitness MeanFitness AvgComplexity"); } Thread evoThread = new Thread(EvolutionaryThread); evoThread.Start(); m_eventNewNetReady.WaitOne(); }
private void EvolutionaryThread() { m_exp = CreateExperiment(); var idgen = new IdGenerator(); m_evoAlg = new EvolutionAlgorithm( new Population(idgen, GenomeFactory.CreateGenomeList(m_exp.DefaultNeatParameters, idgen, m_exp.InputNeuronCount, m_exp.OutputNeuronCount, m_exp.DefaultNeatParameters.pInitialPopulationInterconnections, NeatExpParams.PopulationSize)), m_exp.PopulationEvaluator, m_exp.DefaultNeatParameters); while (!m_shouldQuit) { Console.WriteLine("::::: Performing one generation"); Console.WriteLine(); m_evoAlg.PerformOneGeneration(); if (NeatExpParams.SaveFitnessGrowth) { m_eaLogger.WriteLine(String.Format("{0,-10} {1,-20} {2,-20} {3,-20}", m_evoAlg.Generation, m_evoAlg.BestGenome.Fitness, m_evoAlg.Population.MeanFitness, m_evoAlg.Population.AvgComplexity)); } m_curBestGenome = m_evoAlg.BestGenome as NeatGenome; if (m_evoAlg.BestGenome.Fitness > m_overalBestFitness) { m_overalBestFitness = m_evoAlg.BestGenome.Fitness; m_overalBestGenome = m_curBestGenome; if (NeatExpParams.SaveEachGenerationChampionCPPN) { try { var doc = new XmlDocument(); XmlGenomeWriterStatic.Write(doc, (NeatGenome)m_evoAlg.BestGenome); var oFileInfo = new FileInfo(Path.Combine( NeatExpParams.EALogDir, String.Format("BestIndividual-{0}-{1}.xml", MyUnum, m_evoAlg.Generation.ToString()))); doc.Save(oFileInfo.FullName); } catch { } } } if (EAUpdate != null) { EAUpdate.Invoke(this, EventArgs.Empty); } } }
public HyperNEATQTable(RLClientBase client, int numTeammates, int myUnum) { m_client = client; m_rows = client.EnvRows; m_cols = client.EnvCols; m_numTeammates = numTeammates; m_myUnum = myUnum; m_numActions = SoccerAction.GetActionCount(Params.MoveKings, m_numTeammates); if (NeatExpParams.SaveFitnessGrowth) { m_eaLogger = new PerformanceLogger(String.Format("EALogs/{0}-{1}", m_client.MyTeamName, m_myUnum), false); m_eaLogger.WriteLine("% generation bestfitness"); } Thread evoThread = new Thread(EvolutionaryThread); evoThread.Start(); m_eventNewNetReady.WaitOne(); }