private void UpdateWeights() { if (parentWeights.Count == 0) { for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 0) { neuralNetwork[i].Weights = weightsGenerator.CreateRandomWeights(20); } } for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 1) { neuralNetwork[i].Weights = weightsGenerator.CreateRandomWeights(32); } } for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 2) { neuralNetwork[i].Weights = weightsGenerator.CreateRandomWeights(128); } } for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 3) { neuralNetwork[i].Weights = weightsGenerator.CreateRandomWeights(256); } } } else { for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 0) { neuralNetwork[i].Weights = geneticAlgorithm.CrossOverAndMutation(geneticAlgorithm.EvaluateFitness(neuralNetwork[i].Weights), neuralNetwork[i].Weights); } } for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 1) { neuralNetwork[i].Weights = geneticAlgorithm.CrossOverAndMutation(geneticAlgorithm.EvaluateFitness(neuralNetwork[i].Weights), neuralNetwork[i].Weights); } } for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 2) { neuralNetwork[i].Weights = geneticAlgorithm.CrossOverAndMutation(geneticAlgorithm.EvaluateFitness(neuralNetwork[i].Weights), neuralNetwork[i].Weights); } } for (int i = 0; i < neuralNetwork.Count; i++) { if (neuralNetwork[i].LayerNumber == 3) { neuralNetwork[i].Weights = geneticAlgorithm.CrossOverAndMutation(geneticAlgorithm.EvaluateFitness(neuralNetwork[i].Weights), neuralNetwork[i].Weights); } } } }