// Use this for initialization void Start() { menu = SceneManager.GetActiveScene().name == "menu"; if (!menu) { // Grab reference to the controller script C = Camera.main.GetComponent <ctrl>(); // Sets the max lap according to the controller lap.y = C.mLaps; } else { nn.IniWeights(new float[] { 3.472079f, 1.762525f, -2.266208f, 0.8920379f, -3.915989f, -1.762377f, -2.844904f, 3.381477f, 1.12464f, -3.086241f, 3.320154f, 0.1941123f, 0.1791953f, -3.122393f, 0.8971314f, 0.1158746f, 3.512217f, 1.440832f, 3.3429f, -3.377463f, -2.171291f, 1.523072f, -2.242229f, -2.650826f, 3.01321f, -3.341551f, 3.746894f, -1.755286f, -0.3875917f }); } // Grab ref to ridgid body component rb = GetComponent <Rigidbody>(); // Set rotation constraints so Forrest doesn't fall over rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; // Grab ref to collider col = GetComponent <Collider>(); // tag = "Active"; // Set the laps to 1 instead of 0 at every start no matter what lap.x = 1; }
private void SetHighest() { // We'll need a reference to the highest Forrest in our finished Forrest list ForrestCTRL tF = startFatt[ReturnHighest(startFatt)]; float avgFitTemp = GetAverageFitness(startFatt); // This saves a record of the fitness performances fits.Add(tF.fitness); // This saves a record of the fitness average performances avgs.Add(avgFitTemp); // If this new Forrest beat the Highest Forrest make him the new highest if (tF.fitness > highestFit.fitness) { // Create a new NN to store the highest brain from the training session highestFit = new NN(tF.nn.inputs, tF.nn.hL); // Set that fitness to the new record Forrest which is tF highestFit.SetFitness(tF.fitness); // Then set the weights to the new record Forrest tF highestFit.IniWeights(tF.nn.GetBrain()); // Finally change the highest fit brain string to our new record weights highestFitBrain = highestFit.ReadBrain(); } // If this new Forrest beat the Highest Forrest make him the new highest if (avgFitTemp > highestAvg) { highestAvg = avgFitTemp; } }