public Dna Crossover(Dna otherParent) { var childGenes = new Vector2[Genes.Length]; //for (int i = 0; i < Genes.Length; i++) //{ // childGenes[i] = Random.Range(0.0f, 1.0f) < 0.5f ? Genes[i] : otherParent.Genes[i]; //} //return new Dna(_lifetime, childGenes); int midPoint = Random.Range(0, Genes.Length); for (int i = 0; i < Genes.Length; i++) { if (i < midPoint) { childGenes[i] = Genes[i]; } else { childGenes[i] = otherParent.Genes[i]; } } return(new Dna(_lifetime, childGenes)); }
public void ConstructorWithDna(Dna dna) { _geneCounter = 0; _completionTime = 0; _hitTarget = false; _hitObstacle = false; Dna = dna; }
public void ConstructorWithoutDna(int lifetime, float maxForce) { _lifeTime = lifetime; _maxForce = maxForce; Dna = new Dna(_lifeTime, _maxForce); }