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)); }
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); }
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)); }