PeepBrain NewBrain() { GameObject tGO = Instantiate(PeepPrefab, RandomPosition(), Quaternion.identity); PeepBrain tBrain = tGO.GetComponent <PeepBrain>(); tBrain.Init(); return(tBrain); }
private void Init() { mTimeAlive = TimeLimit; mPeeps.Clear(); for (int i = 0; i < PopulationSize; i++) { PeepBrain tBrain = NewBrain(); mPeeps.Add(tBrain); } }
PeepBrain Breed(PeepBrain vParent1, PeepBrain vParent2) { PeepBrain tBrain = NewBrain(); if (Random.Range(0, 100) == 1) { tBrain.mDNA.Mutate(); } else { tBrain.mDNA.Combine(vParent1.mDNA, vParent2.mDNA); } return(tBrain); }