示例#1
0
 public static float[] CrossAvg(OrgStats f, OrgStats s, float mutRate, int mutChances)
 {
     float[] gene  = new float[4];
     float[] first = f.Gene(), second = s.Gene();
     for (int i = 0; i < 4; ++i)
     {
         gene[i] = (first[i] + second[i]) / 2;
     }
     return(Mutate(gene, mutRate, mutChances));
 }
示例#2
0
 public static OrgStats[] NewStats(int size)
 {
     OrgStats[] stats = new OrgStats[size];
     for (int i = 0; i < size; ++i)
     {
         stats[i]        = new OrgStats();
         stats[i].angle  = Random.Range(MIN_ANGLE, MAX_ANGLE);
         stats[i].range  = Random.Range(MIN_RANGE, MAX_RANGE);
         stats[i].speed  = Random.Range(MIN_SPEED, MAX_SPEED);
         stats[i].rSpeed = Random.Range(MIN_RS, MAX_RS);
     }
     return(stats);
 }
示例#3
0
 public static float[] CrossAlternate(OrgStats f, OrgStats s, bool start, float mutRate, int mutChances)
 {
     float[] gene  = new float[4];
     float[] first = f.Gene(), second = s.Gene();
     for (int i = 0; i < 4; ++i, start = !start)
     {
         if (start)
         {
             gene[i] = first[i];
         }
         else
         {
             gene[i] = second[i];
         }
     }
     return(Mutate(gene, mutRate, mutChances));
 }