public void Mutate_AddNeurons() { //Add Neurons if (NeuronAddChance.Value > Pseudo.Random.NextDouble()) { int neuronCount = Pseudo.Random.Next((int)Math.Round(HiddenNeuronGenes.Count * MaxNeuronAdding.Value)); for (int n = 0; n < neuronCount; n++) { HiddenNeuronGenes.Add(GetRandomNeuronGene("Hidden RMP_Neuron")); } } }
public void Mutate_AddNeurons() { //Add Neurons if (NeuronAddChance.Value > Pseudo.Random.NextDouble()) { int neuronCount = 1; for (int n = 0; n < neuronCount; n++) { var neuronGene = GetRandomNeuronGene(); ConnectRandomly(neuronGene, false); HiddenNeuronGenes.Add(neuronGene); } } }
public override void CreateRandom(int eyeNeurons, int inputs, int outputs, int hidden) { MutationGenes.Clear(); MutationGenes.Add(new DoubleGene("NeuronAddChance", 0, 1, 0.1)); MutationGenes.Add(new DoubleGene("NeuronRemoveChance", 0, 1, 0.1)); MutationGenes.Add(new DoubleGene("MaxNeuronRemoving", 0, 1, 0.1)); MutationGenes.Add(new DoubleGene("MaxNeuronAdding", 0, 1, 0.1)); MutationGenes.Add(new DoubleGene("ConnectionAddChance", 0, 1, 0.1)); MutationGenes.Add(new DoubleGene("ConnectionRemoveChance", 0, 1, 0.1)); EyeRNeuronGenes.Clear(); EyeGNeuronGenes.Clear(); EyeBNeuronGenes.Clear(); DistanceNeuronGenes.Clear(); for (int i = 0; i < eyeNeurons; i++) { EyeRNeuronGenes.Add(GetRandomNeuronGene("Red")); } for (int i = 0; i < eyeNeurons; i++) { EyeGNeuronGenes.Add(GetRandomNeuronGene("Green")); } for (int i = 0; i < eyeNeurons; i++) { EyeBNeuronGenes.Add(GetRandomNeuronGene("Blue")); } for (int i = 0; i < eyeNeurons; i++) { DistanceNeuronGenes.Add(GetRandomNeuronGene("Distance")); } HiddenNeuronGenes.Clear(); InputNeuronGenes.Clear(); OutputNeuronGenes.Clear(); for (int n = 0; n < hidden; n++) { HiddenNeuronGenes.Add(GetRandomNeuronGene("Hidden Neuron")); } for (int n = 0; n < inputs; n++) { InputNeuronGenes.Add(GetRandomNeuronGene("Input Neuron")); } for (int n = 0; n < outputs; n++) { OutputNeuronGenes.Add(GetRandomNeuronGene("Output Neuron")); } foreach (var gene in EyeRNeuronGenes) { ConnectRandomly(gene, true); } foreach (var gene in EyeGNeuronGenes) { ConnectRandomly(gene, true); } foreach (var gene in EyeBNeuronGenes) { ConnectRandomly(gene, true); } foreach (var gene in DistanceNeuronGenes) { ConnectRandomly(gene, true); } foreach (var gene in HiddenNeuronGenes) { ConnectRandomly(gene, false); } foreach (var gene in InputNeuronGenes) { ConnectRandomly(gene, true); } }