/// <summary> /// Loads the best genome into all of the agents. /// </summary> void LoadBestGenomes() { JsonWriterReader.GenomeData data = LoadBestGenome(); NeuralNetwork neuralNetwork = new NeuralNetwork(); if (data != null) {//if the data isn't null //create the best genome Genome genome = _geneticAlgorithm.CreateGenomeFromData(LoadBestGenome()); //set up a neural network with that genome neuralNetwork.SetupFromGenome(genome, _networkStructure); for (int i = 0; i < _agents.Count; i++) {//set each member with that network _agents[i].InitializeNeuralNetwork(neuralNetwork); } } else {//otherwise create a new neural network for each memeber. for (int i = 0; i < _agents.Count; i++) { neuralNetwork.Create(_networkStructure); _agents[i].InitializeNeuralNetwork(neuralNetwork); } } }
void SetupBestGenomes() { FileIO.GenomeData data = LoadBestGenome(); NeuralNetwork neuralNetwork = new NeuralNetwork(); if (data != null) { Genome genome = geneticAlgorithm.CreateGenomeFromData(LoadBestGenome()); neuralNetwork.SetFromGenomes(genome, neuralNet); for (int i = 0; i < nnAgents.Count; i++) { nnAgents[i].InitializeNeuralNetwork(neuralNetwork); } } else { for (int i = 0; i < nnAgents.Count; i++) { neuralNetwork.Create(neuralNet); nnAgents[i].InitializeNeuralNetwork(neuralNetwork); } } }