Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     cpHit = gameObject.GetComponent<CheckpointHit>();
     ship = gameObject.GetComponent<ShipReferer>();
     lap = ship.currentLap;
     bestLap = int.MaxValue;
     //racingLine = new List<TrackTile>();
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        hasFailed = false;
        net = new NeuralNetwork(1, 5, 8, 2);

        RayCast_Length = 80.0f;

        origin = transform.position + Vector3.up * 0.2f;
        heading = transform.rotation.eulerAngles.y;
        float angle = heading / 180 * Mathf.PI;

        left = new Vector3(origin.x - RayCast_Length * Mathf.Cos(angle), origin.y, origin.z - RayCast_Length * Mathf.Sin(angle));
        frontleft = new Vector3(origin.x - RayCast_Length * Mathf.Sin(angle - Mathf.PI / 4), origin.y, origin.z + RayCast_Length * Mathf.Cos(angle - Mathf.PI / 4));
        front = new Vector3(origin.x - RayCast_Length * Mathf.Sin(angle), origin.y, origin.z + RayCast_Length * Mathf.Cos(angle));
        frontright = new Vector3(origin.x - RayCast_Length * Mathf.Sin(angle + Mathf.PI / 4), origin.y, origin.z + RayCast_Length * Mathf.Cos(angle + Mathf.PI / 4));
        right = new Vector3(origin.x - RayCast_Length * Mathf.Cos(angle), origin.y, origin.z + RayCast_Length * Mathf.Sin(angle));

        hit = gameObject.GetComponent<CheckpointHit>();
    }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        ga = new GeneticAlgorithm();
        int totalWeights = 5 * 8 + 8 * 2 + 8 + 2;
        ga.GeneratePopulation(15, totalWeights);
        currentFitness = 0.0f;
        bestFitness = 0.0f;

        net = new NeuralNetwork(1, 5, 8, 2);
        Genome genome = ga.GetNextGenome();
        net.FromGenome(genome, 5, 8, 2);

        testAgent = gameObject.GetComponent<Agent>();
        testAgent.Attach(net);

        hit = gameObject.GetComponent<CheckpointHit>();
        checkpointsNum = hit.checkpoints;
        defaultpos = transform.position;
        defaultrot = transform.rotation;
    }