コード例 #1
0
        /// <summary>
        /// Writes a list of genomes to the save file fitting the experiment name and the ExperimentFileType.
        /// </summary>
        private static bool WriteGenomes(INeatExperiment experiment, IList <NeatGenome> genomeList, ExperimentFileType fileType)
        {
            XmlWriterSettings _xwSettings = new XmlWriterSettings();

            _xwSettings.Indent = true;

            string filePath = GetSaveFilePath(experiment.Name, fileType);

            DirectoryInfo dirInf = new DirectoryInfo(Application.persistentDataPath);

            if (!dirInf.Exists)
            {
                Debug.Log("ExperimentIO - Creating subdirectory");
                dirInf.Create();
            }
            try
            {
                using (XmlWriter xw = XmlWriter.Create(filePath, _xwSettings))
                {
                    NeatGenomeXmlIO.WriteComplete(xw, genomeList, false);
                    Debug.Log("Successfully saved the genomes of the '" + fileType.ToString() + "' for the experiment '" + experiment.Name + "' to the location:\n" + filePath);
                }
            }
            catch (Exception e1)
            {
                Debug.Log("Error saving the genomes of the '" + fileType.ToString() + "' for the experiment '" + experiment.Name + "' to the location:\n" + filePath);
                return(false);
            }
            return(true);
        }
コード例 #2
0
ファイル: Experiment.cs プロジェクト: ricksiple/sharpneat
        public void SavePopulation()
        {
            Debug.Assert(_GenomeList != null);

            XmlWriterSettings xwSettings = new XmlWriterSettings();

            xwSettings.Indent = true;
            using (XmlWriter xw = XmlWriter.Create(_GenomeFile, xwSettings))
            {
                NeatGenomeXmlIO.WriteComplete(xw, _GenomeList, false);
            }
        }
コード例 #3
0
        public void SavePopulation(string filename)
        {
            XmlWriterSettings _xwSettings = new XmlWriterSettings();

            _xwSettings.Indent = true;

            Directory.CreateDirectory(Application.dataPath + HelperConstants.saveDirectory);

            using (XmlWriter xw = XmlWriter.Create(Application.dataPath + HelperConstants.saveDirectory + filename, _xwSettings))
            {
                NeatGenomeXmlIO.WriteComplete(xw, _ea.GenomeList, false);
            }
            SaveLoad.Load();
        }
コード例 #4
0
ファイル: TetrisAI.cs プロジェクト: acliffa/IntelligentTetris
        public void Save()
        {
            var previouslyTraining = evolutionAlgorithm.RunState == RunState.Running;

            if (previouslyTraining)
            {
                PauseTraining();
            }
            using (var writer = XmlWriter.Create("SavedProgress.xml"))
                NeatGenomeXmlIO.WriteComplete(writer, evolutionAlgorithm.GenomeList, true);
            if (previouslyTraining)
            {
                StartTraining();
            }
        }
コード例 #5
0
 public void SavePopulation(XmlWriter xw, IList <NeatGenome> genomeList)
 {
     NeatGenomeXmlIO.WriteComplete(xw, genomeList, false);
 }
コード例 #6
0
 /// <summary>
 /// Save a population of genomes to an XmlWriter.
 /// </summary>
 public void SavePopulation(XmlWriter xw, IList <NeatGenome> genomeList)
 {
     // Writing node IDs is not necessary for NEAT.
     NeatGenomeXmlIO.WriteComplete(xw, genomeList, false);
 }
コード例 #7
0
 public void SavePopulation(XmlWriter xw, IList <NeatGenome> genomeList)
 {
     NeatGenomeXmlIO.WriteComplete(xw, genomeList, true); //true for hyper neat false for reg
 }