Beispiel #1
0
 private void Start()
 {
     for (int i = 0; i < populationSize; i++)
     {
         MazeBrain brain = CreateBot();
         brain.Init();
         population.Add(brain);
     }
 }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < populationSize; i++)
     {
         GameObject b     = Instantiate(botPrefab, StartPosObj.transform.position, StartPosObj.transform.rotation);
         MazeBrain  brain = b.GetComponent <MazeBrain> ();
         brain.Init();
         population.Add(brain);
     }
 }
Beispiel #3
0
    private GameObject Breed(GameObject parent1, GameObject parent2)
    {
        GameObject offspring = Instantiate(botPrefab, startPos.transform.position, this.transform.rotation);
        MazeBrain  brain     = offspring.GetComponent <MazeBrain>();

        brain.Init();
        if (Random.Range(0, 100) == 1)
        {
            brain.dna.Mutate();
        }
        else
        {
            brain.dna.Combine(parent1.GetComponent <MazeBrain>().dna, parent2.GetComponent <MazeBrain>().dna);
        }
        return(offspring);
    }
Beispiel #4
0
    MazeBrain Breed(MazeBrain parent1, MazeBrain parent2)
    {
        GameObject offspring = Instantiate(botPrefab, StartPosObj.transform.position, StartPosObj.transform.rotation);
        MazeBrain  b         = offspring.GetComponent <MazeBrain>();

        if (Random.Range(0, 100) == 1)       //mutate 1 in 100
        {
            b.Init();
            b.Dna.Mutate();
        }
        else
        {
            b.Init();
            b.Dna.Combine(parent1.Dna, parent2.Dna);
        }
        return(b);
    }
Beispiel #5
0
    public MazeBrain Breed(MazeBrain parent1, MazeBrain parent2)
    {
        MazeBrain offspring = CreateBot();

        offspring.Init();

        if (Random.Range(0, 100) == 1)
        {
            offspring.dna.Mutate();
        }
        else
        {
            offspring.dna.Combine(parent1.dna, parent2.dna);
        }

        return(offspring);
    }
Beispiel #6
0
    protected override GameObject Breed(GameObject P1, GameObject P2)
    {
        GameObject offspring = Instantiate(botPrefab, this.transform.position, this.transform.rotation);
        MazeBrain  brain     = offspring.GetComponent <MazeBrain> ();

        if (Random.Range(0.0f, 100.0f) == 1.0f)
        {
            brain.Init();
            brain.GA.Mutate();
        }
        else
        {
            brain.Init();
            brain.GA.Combine(P1.GetComponent <MazeBrain> ().GA, P2.GetComponent <MazeBrain> ().GA);
        }

        return(offspring);
    }