Example #1
0
    public void Save()
    {
        //genomes.Clear();
        //species.Clear();
        //for (int i = 0; i < agents.Count; i++)
        // {

        //  genomes.Add(agents[i].GetComponent<Brain>().GetGenome());
        // }
        if (neat.speciation)
        {
            List <Species> species = neat.GetSpecies();
            SpeciesWrapper sw      = new SpeciesWrapper();
            sw.species    = species;
            sw.generation = neat.GetGeneration();
            sw.gt         = neat.GetTracker();
            Debug.Log(sw.species.Count);
            string json = JsonUtility.ToJson(sw);
            Debug.Log(json);
            //PlayerPrefs.DeleteKey("Genomes");
            PlayerPrefs.SetString("Genomes", json);
            Debug.Log(json);
            Debug.Log(neat.GetGenomes()[0]);
        }
        else
        {
            List <Genome> genomes  = new List <Genome>();
            List <Genome> genomes2 = neat.GetGenomes();
            for (int i = 0; i < genomes2.Count; i++)
            {
                genomes.Add(genomes2[i].Copy());
            }
            Debug.Log(genomes.Count);
            GenomesWrapper gw = new GenomesWrapper();
            gw.genomes    = genomes;
            gw.generation = neat.GetGeneration();
            gw.gt         = neat.GetTracker();
            string json = JsonUtility.ToJson(gw);
            //PlayerPrefs.DeleteKey("Genomes");
            PlayerPrefs.SetString("Genomes", json);
            Debug.Log(json);
        }
        impf.OnSave();
    }