Exemplo n.º 1
0
    // Initialize with pre-existing xml data
    public void Initialize(string xmlData)
    {
        /*** Initialize experiment ***/
        experiment = new PCGNeatExperiment() as INeatExperiment;
        // Null because not reading settings from xmlFile
        experiment.Initialize("PCG Conetent EA", null);

        /*** Load population of genomes from xml string ***/
        List <NeatGenome> genomeList;

        using (XmlReader xr = XmlReader.Create(new StringReader(xmlData)))
        {
            genomeList = experiment.LoadPopulation(xr);
        }

        if (genomeList.Count == 0)
        {
            Debug.LogError("No genomes loaded from XML data from network. Check data is being read correctly.");
            return;
        }
        else
        {
            Debug.Log("Loaded " + genomeList.Count + " Genomes");
        }

        /*** Create the algorithm interface ***/
        contentEA = experiment.CreateEvolutionAlgorithm(genomeList[0].GenomeFactory, genomeList);
    }
    // Initialize with pre-existing xml data
    public void Initialize(string xmlData, PCGSharpHighLevelFeatures originalFeatures)
    {
        /*** Initialize experiment ***/
        experiment = new CPPNRepairExperiment() as INeatExperiment;
        // Null because not reading settings from xmlFile
        experiment.Initialize("PCG Conetent EA", null);

        /*** Load population of genomes from xml string ***/
        List <NeatGenome> genomeList;

        using (XmlReader xr = XmlReader.Create(new StringReader(xmlData)))
        {
            genomeList = experiment.LoadPopulation(xr);
        }

        if (genomeList.Count == 0)
        {
            Debug.LogError("No genomes loaded from XML data from network. Check data is being read correctly.");
            return;
        }
        else
        {
            Debug.Log("Loaded " + genomeList.Count + " Genomes");
        }
        Debug.Log(".........Population loaded");

        ((CPPNRepairExperiment)experiment).SetOriginalFeatures(originalFeatures);
        Debug.Log("........Original features added to experiment");

        /*** Create the algorithm interface ***/
        contentEA = experiment.CreateEvolutionAlgorithm(genomeList[0].GenomeFactory, genomeList);
        Debug.Log("........Content EA created");
    }
    // Initialize with pre-existing xml data
    public void Initialize(string xmlData)
    {
        /*** Initialize experiment ***/
        experiment = new PCGNeatExperiment() as INeatExperiment;
        // Null because not reading settings from xmlFile
        experiment.Initialize("PCG Conetent EA",null);

        /*** Load population of genomes from xml string ***/
        List<NeatGenome> genomeList;
        using(XmlReader xr = XmlReader.Create(new StringReader(xmlData)))
        {
            genomeList = experiment.LoadPopulation(xr);
        }

        if(genomeList.Count == 0) {
            Debug.LogError("No genomes loaded from XML data from network. Check data is being read correctly.");
            return;
        }
        else
            Debug.Log("Loaded " + genomeList.Count + " Genomes");

        /*** Create the algorithm interface ***/
        contentEA = experiment.CreateEvolutionAlgorithm(genomeList[0].GenomeFactory, genomeList);
    }