Example #1
0
    /// <summary>
    /// Initialisation of an organism.
    /// </summary>
    protected virtual void Initialisation()
    {
        // Defining the genotype.
        Genotype = new Genotype(new Extension(new GeneticData()));

        // Adding extra parameters.
        ExtendGenotype();

        // Getting the prefab data into the genotype.
        DeductGenotype(transform, Genotype.Root);

        if (!haveParents())
        {
            // First time mutation to add noise and whatever.
            Genotype.Mutate(PreSpawnMutation());
        }

        // Applying it to the phenotype.
        ChangePhenotype(Genotype);

        graphic.Init(this);
    }
Example #2
0
    /// <summary>
    /// Applies the genotype to the phenotype.
    /// </summary>
    /// <param name="g">The genotype.</param>
    public virtual void ChangePhenotype(Genotype g)
    {
        ModifyElement(transform, g.Root);

        if(phenotypeData == null) {
            phenotypeData = new PhenotypeData();
        }
        phenotypeData.LifeDuration = (int)((WFloat)g.Root.GeneticData.Get("lifeduration")).Value;
    }