void Start()
    {
        _target    = Goal.GetPosition2D();
        _bloops    = new GameObject[TotalPopulation];
        Population = new IDna <Vector2> [TotalPopulation];

        for (var i = 0; i < TotalPopulation; i++)
        {
            Population[i] = new VectorDna(LifeSpan);
            _bloops[i]    = Instantiate(BloopPrefab, transform);
        }
    }
Beispiel #2
0
    public IDna <Vector2> Crossover(IDna <Vector2> partner)
    {
        var child    = new VectorDna(Genes.Length);
        var midpoint = Convert.ToInt32(Random.value * Genes.Length);

        for (var i = 0; i < Genes.Length; i++)
        {
            if (i < midpoint)
            {
                child.Genes[i] = Genes[i];
            }
            else
            {
                child.Genes[i] = partner.Genes[i];
            }
        }

        return(child);
    }