예제 #1
0
    public void NotifyDeath(Car_Behaviour car, bool endReached)//Used by the Car Behaviours to notify when inactive
    {
        nActiveCars--;

        if (car.GetFitness() > fitCurGen)
        {
            fitCurGen = car.GetFitness();
        }

        if (endReached)
        {
            carsReachedObjective++;
        }
    }
예제 #2
0
    Car_Behaviour InstantiateCar(Vector3 spawnPoint, NN nN, string name)
    {
        Car_Behaviour behaviour = Instantiate(carPrefab, spawnPoint, Quaternion.identity).GetComponent <Car_Behaviour>();

        if (nN != null)
        {
            behaviour.ActivateBrain(nN);
        }
        else
        {
            behaviour.ActivateBrain();
        }

        behaviour.transform.name = name;
        behaviour.objective      = trackCtrl.trackEnd.position;

        behaviour.active       = true;
        behaviour.AIControlled = true;

        return(behaviour);
    }
예제 #3
0
    Car_Behaviour InstantiateCar(Vector3 spawnPoint, float[][] hlWeights, float[] hlBiases, float[] OWeights, float OBiases, string name)
    {
        Car_Behaviour behaviour = Instantiate(carPrefab, spawnPoint, Quaternion.identity).GetComponent <Car_Behaviour>();

        behaviour.active       = true;
        behaviour.AIControlled = true;

        if (hlWeights != null || hlBiases != null)
        {
            behaviour.ActivateBrain(hlWeights, hlBiases, OWeights, OBiases);
        }
        else
        {
            behaviour.ActivateBrain();
        }

        behaviour.transform.name = name;
        behaviour.objective      = trackCtrl.trackEnd.position;

        return(behaviour);
    }
예제 #4
0
    Car_Behaviour InstantiateCar(Vector3 spawnPoint, string brain, string name, NN.TYPE brainType)
    {
        Car_Behaviour behaviour = Instantiate(carPrefab, spawnPoint, Quaternion.identity).GetComponent <Car_Behaviour>();

        behaviour.active       = true;
        behaviour.AIControlled = true;

        behaviour.transform.name = name;
        behaviour.objective      = trackCtrl.trackEnd.position;
        //behaviour.type = brainType;

        if (brain != null)
        {
            behaviour.ActivateBrain(brain);
        }
        else
        {
            behaviour.ActivateBrain();
        }

        return(behaviour);
    }
예제 #5
0
    private void Update()
    {
        mostFitCar = gameCtrl.GetMostFitCar();
        if (Input.GetKeyUp(KeyCode.C) && mostFitCar != null)
        {
            if (mostFitCar != null)
            {
                mainCam.SetTarget(mostFitCar.transform);
            }
        }

        /*if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Tab))
         * {
         *  mainCam.enabled = !mainCam.enabled;
         * }*/


        if (mostFitCar != null)
        {
            outputSlider.value            = mostFitCar.steering;
            topdownCam.transform.position = new Vector3(mostFitCar.transform.position.x, 10, mostFitCar.transform.position.z);
        }
    }