コード例 #1
0
    void Move()
    {
        float move = 0, turn = 0;

        if (seeGround)
        {
            //The value of the first gene is evaluated
            if (dna.GetGene(0) == 0)
            {
                move = 1; timeTravelled += PopulationManager_Sense.timeElapsed;
            }
            else if (dna.GetGene(0) == 1)
            {
                turn = -90;
            }
            else if (dna.GetGene(0) == 2)
            {
                turn = 90;
            }
        }
        else
        {
            //If the ground is not seen, then the other gene is evaluated for its value
            //The value of the first gene is evaluated
            if (dna.GetGene(1) == 0)
            {
                move = 1;
            }
            else if (dna.GetGene(1) == 1)
            {
                turn = -90;
            }
            else if (dna.GetGene(1) == 2)
            {
                turn = 90;
            }
        }

        //Move the capsule
        transform.Translate(new Vector3(0, 0, move * 0.1f));
        transform.Rotate(new Vector3(0, turn, 0));
    }