Exemple #1
0
    public Genes CrossGenes(Genes other, Genes out_)
    {
        //crosses all genes on object and puts result into out_
        List <Gene> newGenes = new List <Gene>();

        foreach (Gene gene in genes)
        {
            try
            {
                Gene matching = other.GetGene(gene.name);
                newGenes.Add(gene.CrossGene(matching, gene.name));
            }
            catch (ArgumentException e)
            {
                print(e);
                Debug.LogWarning(String.Format("'{0}' Could not find a matching gene for '{1}' in '{2}', skipping...", name, gene.name, other.gameObject.name), gameObject);
            }
        }

        out_.genes.Clear();
        foreach (Gene gene in newGenes)
        {
            out_.SetGene(gene);
        }

        return(out_);
    }