Example #1
0
    /// <summary>
    /// Returns a new mutated copy genome that is a mix of both parents genome
    /// </summary>
    /// <param name="otherGenome"></param>
    /// <param name="mutationFactor"></param>
    /// <param name="mutationChance"></param>
    /// <returns></returns>
    public Genome CrossGenome(Genome otherGenome, float mutationFactor, float mutationChance)
    {
        SexGene      newSex      = sex.CrossGene(otherGenome.Sex);
        ColorGene    newColor    = color.CrossGene(otherGenome.Color, mutationFactor, mutationChance);
        HeightGene   newSize     = height.CrossGene(otherGenome.Height, mutationFactor, mutationChance);
        SpeedGene    newSpeed    = speed.CrossGene(otherGenome.Speed, mutationFactor, mutationChance);
        BehaviorGene newBehavior = behavior.CrossGene(otherGenome.Behavior, mutationFactor, mutationChance);

        return(new Genome(newSex, newColor, newSize, newSpeed, newBehavior));
    }