Example #1
0
    GameObject Breed(GameObject Parent1, GameObject Parent2)
    {
        Vector3    StartingPos = new Vector3(this.transform.position.x + Random.Range(-2, 2), this.transform.position.y, this.transform.position.z + Random.Range(-2, 2));
        GameObject offspring   = Instantiate(BotPrefab, StartingPos, this.transform.rotation);

        // Gets Access to the Brain
        WalkingBrain B = offspring.GetComponent <WalkingBrain>();

        // Mutates 1 out of 100
        if (Random.Range(0, 100) == 1)
        {
            B.Init();
            B.Walkingdna.Mutate();
        }
        else
        {
            B.Init();
            // Generation of OffSpring
            B.Walkingdna.OffSpringGen(Parent1.GetComponent <WalkingBrain>().Walkingdna, Parent2.GetComponent <WalkingBrain>().Walkingdna);
        }
        return(offspring);
    }
Example #2
0
 void Start()
 {
     Movement = GetComponent <WalkingBrain>();
 }