Beispiel #1
0
 public void InitCreature(pruebaDNA newDna, Vector3 _target, int id)
 {
     dna                = newDna;
     target             = _target;
     nextPoint          = transform.position;
     hasBeenInitialized = true;
     identifier         = id;
 }
Beispiel #2
0
 public pruebaDNA(pruebaDNA parent, pruebaDNA partner, float mutationRate = 0.01f)
 {
     for (int i = 0; i < parent.genes.Count; i++)
     {
         float mutationChance = Random.Range(0.0f, 1.0f);
         if (mutationChance <= mutationRate)
         {
             genes.Add(new Vector3(Random.Range(-1.0f, 1.0f), 0f, Random.Range(-1.0f, 1.0f)));
         }
         else
         {
             int chance = Random.Range(0, 2);
             if (chance == 0)
             {
                 genes.Add(parent.genes[i]);
             }
             else
             {
                 genes.Add(partner.genes[i]);
             }
         }
     }
 }