本文整理汇总了C#中Population.GetNextSpeciesID方法的典型用法代码示例。如果您正苦于以下问题:C# Population.GetNextSpeciesID方法的具体用法?C# Population.GetNextSpeciesID怎么用?C# Population.GetNextSpeciesID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population
的用法示例。
在下文中一共展示了Population.GetNextSpeciesID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BreedPopulation
//.........这里部分代码省略.........
newChildAgent.bodyGenome = childBodyGenome;
if (useMutation) {
// BODY MUTATION:
PerformBodyMutation(ref childBodyGenome, ref childBrainGenome);
}
}
newChildAgent.brainGenome = childBrainGenome;
//newChildAgent.brainGenome.nodeNEATList = childNodeList;
//newChildAgent.brainGenome.linkNEATList = childLinkList;
BrainNEAT childBrain = new BrainNEAT(newChildAgent.brainGenome);
childBrain.BuildBrainNetwork();
newChildAgent.brain = childBrain;
//Debug.Log("NEW CHILD numNodes: " + newChildAgent.brainGenome.nodeNEATList.Count.ToString() + ", #Neurons: " + newChildAgent.brain.neuronList.Count.ToString());
//newChildAgent.bodyGenome.PreBuildCritter(0.8f);
// Species:
if (useSpeciation) {
float randAdoption = UnityEngine.Random.Range(0f, 1f);
if (randAdoption < adoptionRate) { // Attempts to Found a new species
bool speciesGenomeMatch = false;
for (int s = 0; s < childSpeciesPoolsList.Count; s++) {
float geneticDistance = GenomeNEAT.MeasureGeneticDistance(newChildAgent.brainGenome, childSpeciesPoolsList[s].templateGenome, neuronWeight, linkWeight, weightWeight, normalizeExcess, normalizeDisjoint, normalizeLinkWeight);
if (geneticDistance < speciesSimilarityThreshold) {
speciesGenomeMatch = true;
//agent.speciesID = speciesBreedingPoolList[s].speciesID; // this is done inside the AddNewAgent method below v v v
childSpeciesPoolsList[s].AddNewAgent(newChildAgent);
//Debug.Log(" NEW CHILD (" + newChildIndex.ToString() + ") SortAgentIntoBreedingPool dist: " + geneticDistance.ToString() + ", speciesIDs: " + newChildAgent.speciesID.ToString() + ", " + childSpeciesPoolsList[s].speciesID.ToString() + ", speciesCount: " + childSpeciesPoolsList[s].agentList.Count.ToString());
break;
}
}
if (!speciesGenomeMatch) {
SpeciesBreedingPool newSpeciesBreedingPool = new SpeciesBreedingPool(newChildAgent.brainGenome, sourcePopulation.GetNextSpeciesID()); // creates new speciesPool modeled on this agent's genome
newSpeciesBreedingPool.AddNewAgent(newChildAgent); // add this agent to breeding pool
childSpeciesPoolsList.Add(newSpeciesBreedingPool); // add new speciesPool to the population's list of all active species
//Debug.Log(" NEW CHILD (" + newChildIndex.ToString() + ") SortAgentIntoBreedingPool NO MATCH!!! -- creating new BreedingPool " + newSpeciesBreedingPool.speciesID.ToString() + ", newChildAgentSpeciesID: " + newChildAgent.speciesID.ToString());
}
}
else { // joins parent species automatically:
SpeciesBreedingPool newSpeciesBreedingPool = sourcePopulation.GetBreedingPoolByID(childSpeciesPoolsList, parentAgentBreedingPool.speciesID);
newSpeciesBreedingPool.AddNewAgent(newChildAgent); // add this agent to breeding pool
//Debug.Log(" NEW CHILD (" + newChildIndex.ToString() + ") NO ADOPTION SortAgentIntoBreedingPool speciesIDs: " + newChildAgent.speciesID.ToString() + ", " + newSpeciesBreedingPool.speciesID.ToString() + ", speciesCount: " + newSpeciesBreedingPool.agentList.Count.ToString());
}
}
else { // joins parent species automatically:
SpeciesBreedingPool newSpeciesBreedingPool = sourcePopulation.GetBreedingPoolByID(childSpeciesPoolsList, parentAgentBreedingPool.speciesID);
newSpeciesBreedingPool.AddNewAgent(newChildAgent); // add this agent to breeding pool
}
newChildAgent.parentFitnessScoreA = sourcePopulation.masterAgentArray[newChildIndex].fitnessScore;
newAgentArray[newChildIndex] = newChildAgent;
newChildIndex++; // new child created!
newChildrenCreated++;
}
}
/*Debug.Log("Finished Crossover! childSpeciesPoolsList:");
for (int i = 0; i < sourcePopulation.speciesBreedingPoolList.Count; i++) {
string poolString = " Child Species ID: " + sourcePopulation.speciesBreedingPoolList[i].speciesID.ToString();
for (int j = 0; j < sourcePopulation.speciesBreedingPoolList[i].agentList.Count; j++) {
poolString += ", member# " + j.ToString() + ", species: " + sourcePopulation.speciesBreedingPoolList[i].agentList[j].speciesID.ToString() + ", fitRank: " + sourcePopulation.speciesBreedingPoolList[i].agentList[j].fitnessRank.ToString();
}