public AIChromossome(AIChromossome father, AIChromossome mother, float ANOMALY_CHANCE) { int cutting_point = Random.Range(0, SIZE); // MemMax -------------------------------- if (Random.Range(0f, 1f) < ANOMALY_CHANCE) { RandMemMax(); } else if (cutting_point > 0) { MemMax = father.MemMax; } else { MemMax = mother.MemMax; } // MemChanceSelf -------------------------- if (Random.Range(0f, 1f) < ANOMALY_CHANCE) { RandMemChanceSelf(); } else if (cutting_point > 1) { MemChanceSelf = father.MemChanceSelf; } else { MemChanceSelf = mother.MemChanceSelf; } // MemChanceOther -------------------------- if (Random.Range(0f, 1f) < ANOMALY_CHANCE) { RandMemChanceOther(); } else if (cutting_point > 2) { MemChanceOther = father.MemChanceOther; } else { MemChanceOther = mother.MemChanceOther; } // ForgetChance -------------------------- if (Random.Range(0f, 1f) < ANOMALY_CHANCE) { RandForgetChance(); } else if (cutting_point > 3) { ForgetChance = father.ForgetChance; } else { ForgetChance = mother.ForgetChance; } }
// the chosen speciment breeds with another random speciment private void Breed(ref List <AIPlayer> breeders, AIPlayer speciment, int index) { // remove the speciment from the list, // so it will not breed with itself if (breeders.Count > 1) { breeders.Remove(speciment); } AIChromossome c1 = speciment.Chromossome; AIChromossome c2 = breeders[Random.Range(0, breeders.Count)].Chromossome; AIChromossome c_child = new AIChromossome(c1, c2, ANOMALY_CHANCE); next_gen.Add(new AIPlayer("S" + "-" + generation + index, c_child)); }
public AIPlayer(string name, AIChromossome chromossome) { this.Name = name; this.Chromossome = chromossome; }
public AIPlayer(string name, bool rand) { this.Name = name; Chromossome = new AIChromossome(rand); }