Exemple #1
0
    // Use this for initialization
    void Start()
    {
        senorPos = new Vector3[sensorNumber];

        /*
         * senorPos[0] = -Vector3.up;
         * senorPos[1] = -Vector3.right;
         * senorPos[2] = Vector3.right;
         * senorPos[3] = new Vector3(1, -1, 0);
         * senorPos[4] = new Vector3(-1, -1, 0);
         *
         * senorPos[0] = -Vector3.forward;
         * senorPos[1] = -Vector3.right;
         * senorPos[2] = Vector3.right;
         * senorPos[3] = new Vector3(1, 0, -1);
         * senorPos[4] = new Vector3(-1, 0, -1);
         */
        senorPos[0] = -Vector3.forward;
        senorPos[1] = Quaternion.Euler(0, -5, 0) * -Vector3.forward;
        senorPos[2] = Quaternion.Euler(0, 5, 0) * -Vector3.forward;
        senorPos[3] = Quaternion.Euler(0, -10, 0) * -Vector3.forward;
        senorPos[4] = Quaternion.Euler(0, 10, 0) * -Vector3.forward;
        senorPos[5] = Quaternion.Euler(0, -15, 0) * -Vector3.forward;
        senorPos[6] = Quaternion.Euler(0, 15, 0) * -Vector3.forward;

        pf          = GameObject.Find("Scripts").GetComponent <Generate>().GetPF();
        limbObjects = new List <GameObject>();

        FindLimbs(transform);


        hits = new float[sensorNumber];

        //time += Random.Range(-0.001f, 0.001f);//vary time a little so all the agents dont run the network at once
        gen   = GameObject.Find("Scripts").GetComponent <Generate>();
        gap   = gen.GetGap();
        agent = gameObject;
        //GeneTracker gt = new GeneTracker();
        neat = GameObject.Find("Scripts").GetComponent <Neat>();

        inputSize  = neat.GetInputSize();
        outputSize = neat.GetOutputSize();

        g1 = neat.InitGenome();
        if (neat.speciation)
        {
            GameObject.Find("Scripts").GetComponent <ImplementFunctions>().SetSpecies(gameObject);
        }


        Debug.Log(g1);
        oldVelocities    = new float[limbs * 3 + 3];
        oldVelocities[0] = 0.0f;
        oldVelocities[1] = 0.0f;
        oldVelocities[2] = 0.0f;

        for (int i = 0; i < oldVelocities.Length; i++)
        {
            oldVelocities[i] = 0.0f;
        }
        //Debug.Log( oldVelocities[0]);
        outputs = new float[outputSize];
    }