// Use this for initialization
    void Start()
    {
        genAlg = new GeneticAlgorithm();
        genAlg.GenerateNewPopulation(POPULATION_SIZE, TOTAL_WEIGHTS);
        currentAgentFitness = 0.0f;
        bestFitness         = 0.0f;

        neuralNet = new NNet();
        neuralNet.CreateNet(1, NO_OF_INPUTS, NO_OF_HIDDEN, NO_OF_OUTPUTS);
        Genome genome = genAlg.GetNextGenome();

        neuralNet.FromGenome(genome, NO_OF_INPUTS, NO_OF_HIDDEN, NO_OF_OUTPUTS);

        //Road Generation
        currCentreRoad = TrackStart.transform.position;
        currLeftRoad   = currCentreRoad + new Vector3(0, 0, ROAD_WIDTH / 2);
        currRightRoad  = currCentreRoad + (currCentreRoad - currLeftRoad);
        currTheta      = TrackStart.transform.eulerAngles.y * Mathf.PI / 180;  //convert to radions;

        carObject = Instantiate(car, currLeftRoad + ((currRightRoad - currLeftRoad) / 2), Quaternion.identity);
        carObject.transform.Rotate(new Vector3(0, currTheta * (180 / Mathf.PI), 0), Space.World);

        testAgent = carObject.GetComponent <Agent> ();
        testAgent.Attach(neuralNet);

        GameObject     cam    = GameObject.Find("Main Camera");
        CameraMovement camMov = cam.GetComponent <CameraMovement> ();

        camMov.Target = carObject.transform;

        BuildNextRoadSegment();
        BuildNextRoadSegment();
        BuildNextRoadSegment();
        BuildNextRoadSegment();
    }
Пример #2
0
    void Start()
    {
        hasFailed = false;

        neuralnet = new NNet();
        neuralnet.CreateNet(2, 8, 8, 8);

        _GDB = GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalDB>();
        _SEL = GameObject.FindGameObjectWithTag("MainUI").GetComponent <Select>();
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        hasFailed = false;

        neuralnet = new NNet();
        neuralnet.CreateNet(1, 5, 8, 2);
        raycast = gameObject.GetComponent <RayCast> ();
        l       = raycast.dis_l;
        fl      = raycast.dis_fl;
        f       = raycast.dis_f;
        fr      = raycast.dis_fr;
        r       = raycast.dis_fr;

        leftForce  = 0.0f;
        rightForce = 0.0f;
        leftTheta  = 0.0f;
        rightTheta = 0.0f;

        hit = gameObject.GetComponent <hit> ();
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        genAlg = new GA();
        int totalWeights = 5 * 8 + 8 * 2 + 8 + 2;

        genAlg.GenerateNewPopulation(15, totalWeights);
        currentAgentFitness = 0.0f;
        bestFitness         = 0.0f;

        neuralNet = new NNet();
        neuralNet.CreateNet(1, 5, 8, 2);
        Genome genome = genAlg.GetNextGenome();

        neuralNet.FromGenome(genome, 5, 8, 2);

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

        hit         = gameObject.GetComponent <hit>();
        checkpoints = hit.checkpoints;
        defaultpos  = transform.position;
        defaultrot  = transform.rotation;
    }
Пример #5
0
    void Start()
    {
        controller = MainController.Instance;

        hasFailed = false;

        neuralnet = new NNet();
        neuralnet.CreateNet(1, controller.inputCount, controller.hiddenNeuronsCount, controller.outputCount);
        raycast = gameObject.GetComponent <RayCast> ();

        l  = raycast.dis_l;
        fl = raycast.dis_fl;
        f  = raycast.dis_f;
        fr = raycast.dis_fr;
        r  = raycast.dis_fr;

        leftForce  = 0.0f;
        rightForce = 0.0f;
        leftTheta  = 0.0f;
        rightTheta = 0.0f;

        hit = gameObject.GetComponent <hit> ();
    }
Пример #6
0
    void Start()
    {
        controller = MainController.Instance;

        genAlg = new GA();
        int totalWeights = (controller.hiddenNeuronsCount + 1) * (controller.inputCount + controller.outputCount);

        genAlg.GenerateNewPopulation(controller.genomeCount, totalWeights);
        currentAgentFitness = 0.0f;
        bestFitness         = 0.0f;

        neuralNet = new NNet();
        neuralNet.CreateNet(1, controller.inputCount, controller.hiddenNeuronsCount, controller.outputCount);
        Genome genome = genAlg.GetNextGenome();

        neuralNet.FromGenome(genome, controller.inputCount, controller.hiddenNeuronsCount, controller.outputCount);

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

        hit         = gameObject.GetComponent <hit> ();
        checkpoints = hit.checkpoints;
        defaultpos  = transform.position;
    }
Пример #7
0
 public Genome(int nInput, int nHiddenLayer, int nHiddenLayerNeurons, int nOutput, int genomeID)
 {
     net = new NNet();
     net.CreateNet(nInput, nHiddenLayer, nHiddenLayerNeurons, nOutput);
     this.ID = genomeID;
 }