/// <summary> /// Loads the currently stored Evolution settings. /// </summary> /// <returns>The evolution settings.</returns> private EvolutionSettings LoadEvolutionSettings() { var settingsString = PlayerPrefs.GetString(EVOLUTION_SETTINGS_KEY, ""); if (settingsString == "") { // Default settings return(new EvolutionSettings()); } return(EvolutionSettings.Decode(settingsString)); }
/// <summary> /// Loads the simulation from save file with the format version 2 /// </summary> /// <param name="filename">The Filename has to end on .txt .</param> /// <param name="content">The Content of the save file.</param> private static void LoadSimulationFromSaveFileV2(string filename, string content, SplitOptions splitOptions, CreatureBuilder creatureBuilder, Evolution evolution) { var creatureName = filename.Split('-')[0].Replace(" ", ""); var components = content.Split(splitOptions.SPLIT_ARRAY, System.StringSplitOptions.None); var evolutionSettings = EvolutionSettings.Decode(components[1]); var networkSettings = NeuralNetworkSettings.Decode(components[2]); var creatureData = components[3]; CreatureSaver.LoadCreatureFromContents(creatureData, creatureBuilder); var bestChromosomesData = new List <string>(components[4].Split(splitOptions.NEWLINE_SPLIT, StringSplitOptions.None)); var bestChromosomes = new List <ChromosomeStats>(); foreach (var chromosomeData in bestChromosomesData) { if (chromosomeData != "") { bestChromosomes.Add(ChromosomeStats.FromString(chromosomeData)); } } var chromosomeComponents = components[5].Split(splitOptions.NEWLINE_SPLIT, StringSplitOptions.None); var currentChromosomes = new List <string>(); foreach (var chromosome in chromosomeComponents) { if (chromosome != "") { currentChromosomes.Add(chromosome); } } var currentGeneration = bestChromosomes.Count + 1; evolution.Settings = evolutionSettings; creatureBuilder.ContinueEvolution(evolution, () => { CreatureSaver.SaveCurrentCreatureName(creatureName); evolution.ContinueEvolution(currentGeneration, evolutionSettings, networkSettings, bestChromosomes, currentChromosomes); }); }