//Similarly generate abled pirates private void GenerateAbledPirates(PirateLogic[] abledPirateParents) { _activeAbledPirates = new List <PirateLogic>(); List <GameObject> objects = abledPirateGenerator.RegenerateObjects(); foreach (GameObject obj in objects) { PirateLogic pirate = obj.GetComponent <PirateLogic>(); if (pirate != null) { _activeAbledPirates.Add(pirate); if (abledPirateParents != null) { PirateLogic pirateParent = abledPirateParents[Random.Range(0, abledPirateParents.Length)]; pirate.Birth(pirateParent.GetData()); } pirate.Mutate(mutationFactor, mutationChance); pirate.AwakeUp(); } } }
private void GeneratePiratesArithmeticCrossover(PirateLogic[] pirateParents) { _activePirates = new List <PirateLogic>(); List <GameObject> objects = pirateGenerator.RegenerateObjects(); foreach (GameObject obj in objects) { PirateLogic pirate = obj.GetComponent <PirateLogic>(); if (pirate != null) { _activePirates.Add(pirate); if (pirateParents != null) { PirateLogic firstPirateParent = pirateParents[Random.Range(0, pirateParents.Length)]; PirateLogic secondPirateParent = pirateParents[Random.Range(0, pirateParents.Length)]; pirate.BirthArithmeticCrossover(firstPirateParent.GetData(), secondPirateParent.GetData()); } pirate.Mutate(mutationFactor, mutationChance); pirate.AwakeUp(); } } }