public override void ea_UpdateEvent(object sender, EventArgs e) { Utility.Log(string.Format("gen={0:N0} bestFitness={1:N6}", _ea.CurrentGeneration, _ea.Statistics._maxFitness)); Fitness = _ea.Statistics._maxFitness; Generation = _ea.CurrentGeneration; GameObject.Find("TrialNumber").GetComponent <Text>().text = "Expirament " + SubExpiramentNumber.ToString(); GameObject.Find("Genome").GetComponent <Text>().text = string.Format("Generation: {0}\nFitness: {1:0.00}", Generation, Fitness); if (NodeViewer != null) { XmlWriterSettings _xwSettings = new XmlWriterSettings(); _xwSettings.Indent = true; // Save genomes to xml file. DirectoryInfo dirInf = new DirectoryInfo(Application.persistentDataPath); if (!dirInf.Exists) { Debug.Log("Creating subdirectory"); dirInf.Create(); } using (XmlWriter xw = XmlWriter.Create(popFileSavePath, _xwSettings)) { experiment.SavePopulation(xw, _ea.GenomeList); } // Also save the best genome using (XmlWriter xw = XmlWriter.Create(champFileSavePath, _xwSettings)) { experiment.SavePopulation(xw, new NeatGenome[] { _ea.CurrentChampGenome }); } NodeViewer.GetComponent <GenomeViewController>().UpdateXml(); } // Utility.Log(string.Format("Moving average: {0}, N: {1}", _ea.Statistics._bestFitnessMA.Mean, _ea.Statistics._bestFitnessMA.Length)); }
public void Initialize() { Utility.DebugLog = true; experiment = new AgarExpirament(); XmlDocument xmlConfig = new XmlDocument(); TextAsset textAsset = (TextAsset)Resources.Load(configName); xmlConfig.LoadXml(textAsset.text); experiment.SetOptimizer(this); experiment.Initialize("Car Experiment", xmlConfig.DocumentElement, NUM_INPUTS, NUM_OUTPUTS); champFileSavePath = Application.persistentDataPath + string.Format("/{0}.champ.xml", expiramentName + SubExpiramentNumber.ToString()); popFileSavePath = Application.persistentDataPath + string.Format("/{0}.pop.xml", expiramentName + SubExpiramentNumber.ToString()); print(champFileSavePath); }
public override void NewFile() { champFileSavePath = Application.persistentDataPath + string.Format("/{0}.champ.xml", expiramentName + SubExpiramentNumber.ToString()); popFileSavePath = Application.persistentDataPath + string.Format("/{0}.pop.xml", (expiramentName + SubExpiramentNumber.ToString())); print(champFileSavePath); }