private List <ForceGene> GetCrossoverAndMutatedGene(GeneScore baseGene, List <GeneScore> crossoverCandidates) { GeneScore newGene = new GeneScore(baseGene.CreateForceGeneCopy()); GeneScore crossoverGene = new GeneScore(newGene.CrossOver(crossoverCandidates)); List <ForceGene> mutatedGene = new GeneScore(crossoverGene.Mutate()).CreateForceGeneCopy(); return(mutatedGene); }
private void CreateNewBot(int curBotId, Vector3 botPos, GeneScore baseGene, List <GeneScore> crossoverCandidates) { GameObject curBot = Instantiate(ragdoll, botPos, Quaternion.identity) as GameObject; RagdollController ragdollController = curBot.GetComponent <RagdollController>(); ragdollController.Initialize(this, "G" + curGeneration.ToString() + "B" + curBotId.ToString()); if (baseGene == null) { ragdollController.StartMoving(GetNewGene(ragdollController.GetNumOfJoints())); } else { if (curBotId == 0) { ragdollController.StartMoving(baseGene.CreateForceGeneCopy()); } else { ragdollController.StartMoving(GetCrossoverAndMutatedGene(baseGene, crossoverCandidates)); } } }