public void GeneticSaveLoad2() { // ARRANGE string path = Application.dataPath + "/Test/testWeights4.text"; List <double[][]> weights = new List <double[][]>(); double[][] w1 = new double[][] { new double[] { 1.0, 3.0, 5.0, 7.0, 9.67 }, new double[] { 0.0, 2.0, 4.0, 6.0, 11.0 }, new double[] { 0.0, 2.89, 4.0, 6.0, 11.0 }, new double[] { 0.45, 2.0, 4.3, 6.0, 11.65 }, new double[] { 0.0, 2.0, 4.0, 6.67, 11.0 }, new double[] { 0.34, 2.0, 4.0, 6.0, 11.65 } }; weights.Add(w1); // ACT SaveWeights.WriteToFile(path, weights); GeneticWeights prop = new GeneticWeights(); prop.layers = new int[] { 6, 5 }; prop.lengthLayers = 2; List <double[][]> weightsSaved = prop.LoadWeights(path); // ASSERT Assert.That(weightsSaved, Is.EqualTo(weights)); }
public void GeneticSaveLoad1() { // ARRANGE string path = Application.dataPath + "/Test/testWeights3.text"; List <double[][]> weights = new List <double[][]>(); double[][] w1 = new double[][] { new double[] { 1.0, 3.5 }, new double[] { 0.1, 2.0 }, new double[] { 0.4, 2.3 }, new double[] { 0.6, 2.0 } }; weights.Add(w1); // ACT SaveWeights.WriteToFile(path, weights); GeneticWeights prop = new GeneticWeights(); prop.layers = new int[] { 4, 2 }; prop.lengthLayers = 2; List <double[][]> weightsSaved = prop.LoadWeights(path); // ASSERT Assert.That(weightsSaved, Is.EqualTo(weights)); }
//Initialise objects void Start() { Rigidbody = GetComponent <Rigidbody>(); Outputs = new List <double>(); Car = new GeneticNetwork(); saveLoad = new GeneticWeights(); controller = new CarController(); Rigidbody.GetComponent <CarPhysics>().driver = Driver.AI; position = new ResetPosition(); LoadChild(); }
//Initialise various methods and arrays void Start() { fitnessMeasure = LearningModeScript.fitnessMeasure; Population = LearningModeScript.Population; Probability = LearningModeScript.Probability; nextChild.onClick.AddListener(NextChild); Rigidbody = GetComponent <Rigidbody>(); controller = new CarController(); saveLoad = new GeneticWeights(); Rigidbody.GetComponent <CarPhysics>().driver = Driver.AI; Fitness = new double[Population]; Outputs = new List <double>(); Position = transform.position; //Create cars of size population Cars = new GeneticNetwork[Population]; //Initiate list of weights of size pupulation for (int i = 0; i < Population; i++) { Cars[i] = new GeneticNetwork(); } }