public void NextTestSubject() { genAlg.SetGenomeFitness(currentAgentFitness, genAlg.GetCurrentGenomeIndex()); currentAgentFitness = 0.0f; Genome genome = genAlg.GetNextGenome(); neuralNet.FromGenome(genome, 5, 8, 2); transform.position = defaultpos; transform.rotation = defaultrot; testAgent.Attach(neuralNet); testAgent.ClearFailure(); //reset the checkpoints CPs = GameObject.FindGameObjectsWithTag("Checkpoint"); foreach (GameObject c in CPs) { Renderer tmp = c.gameObject.GetComponent <Renderer>(); tmp.material = normal; Checkpoint p = c.gameObject.GetComponent <Checkpoint>(); p.passed = false; } }
// 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(); }
public void NextTestSubject() { genAlg.SetGenomeFitness(currentAgentFitness, genAlg.GetCurrentGenomeIndex()); currentAgentFitness = 0.0f; Genome genome = genAlg.GetNextGenome(); neuralNet.FromGenome(genome, controller.inputCount, controller.hiddenNeuronsCount, controller.outputCount); transform.position = defaultpos; transform.eulerAngles = controller.clockwise ? controller.clockwiseRotation : controller.inverseClockwiseRotation; testAgent.Attach(neuralNet); testAgent.ClearFailure(); //reset the checkpoints CPs = GameObject.FindGameObjectsWithTag("Checkpoint"); foreach (GameObject c in CPs) { Renderer tmp = c.gameObject.GetComponent <Renderer>(); tmp.material = normal; Checkpoint p = c.gameObject.GetComponent <Checkpoint>(); p.passed = false; } }
public void NextTestSubject() { genAlg.SetGenomeFitness(currentAgentFitness, genAlg.GetCurrentGenomeIndex()); currentAgentFitness = 0.0f; Genome genome = genAlg.GetNextGenome(); neuralNet.FromGenome(genome, NO_OF_INPUTS, NO_OF_HIDDEN, NO_OF_OUTPUTS); carObject.transform.position = prevprevprevCentreRoad; carObject.transform.rotation = Quaternion.identity; carObject.transform.Rotate(new Vector3(0, prevprevTheta * (180 / Mathf.PI), 0), Space.World); testAgent.Attach(neuralNet); testAgent.Reset(); }
// 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; }
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; }