Exemplo n.º 1
0
    public void PerformCrossover(ref Population sourcePopulation)
    {
        Population newPop = sourcePopulation.CopyPopulationSettings();

        if(numFactions > 1) {

            Population[] sourceFactions = sourcePopulation.SplitPopulation(numFactions);
            Population[] newFactions = new Population[numFactions];
            for(int i = 0; i < numFactions; i++) {
                // Make a Genome array of each faction
                // Then BreedAgentPool on each Array?
                // Then Add those genomes to new Population masterAgentArray?
                //newFactions[i] = sourceFactions[i].CopyPopulationSettings();
                Debug.Log ("FactionSize: " + sourceFactions[i].populationMaxSize.ToString());
                newFactions[i] = BreedPopulation(ref sourceFactions[i]);
            }
            // Add them back together!
            newPop.SetToCombinedPopulations(newFactions);

        }
        else {
            newPop = BreedPopulation(ref sourcePopulation);
        }
        sourcePopulation = newPop;
    }