Exemplo n.º 1
0
    /// <summary>
    /// Makes a mutation of the current node
    /// </summary>
    /// <returns>Muscle</returns>
    public Muscle modify(int nodeNum, float mutability, float mutationChance, List <Node> nodes)
    {
        // makes a new instance of the parent1, parent2 and axon values
        Node newp1   = p1;
        Node newp2   = p2;
        int  newAxon = axon;

        if (Random.Range(0f, 1f) < mutationChance)
        {
            newp1 = nodes[Random.Range(0, nodeNum)];
        }

        if (Random.Range(0f, 1f) < mutationChance)
        {
            newp2 = nodes[Random.Range(0, nodeNum)];
        }

        if (Random.Range(0f, 1f) < mutationChance)
        {
            newAxon = getNewMuscleAxon(nodeNum);
        }

        float newRigidity = Mathf.Min(Mathf.Max(rigidity * (1 + Creature.randGet() * 0.9f * mutability), 0.01f), 0.08f);
        float newLenght   = Mathf.Min(Mathf.Max(length + Creature.randGet() * mutability, 0.4f), 1.25f);

        Muscle newMuscle = new Muscle();

        newMuscle.SetInitiationValues(newAxon, newp1, newp2, newLenght, newRigidity);
        return(newMuscle);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Makes a copy of the current muscle
    /// </summary>
    /// <returns>Muscle</returns>
    public Muscle copy()
    {
        Muscle muscle = new Muscle();

        muscle.SetInitiationValues(axon, p1, p2, length, rigidity);
        return(muscle);
    }