Example #1
0
 public void Mutate()
 {
     if (RandomGenerator.NextDouble() < Constants.Con.mutate_weights_chanse)
     {
         //Debug.Log("mutate");
         OutputLayer.Mutate();
         foreach (var neuron in HiddenLayers)
         {
             neuron.Value.Mutate();
         }
     }
     if (RandomGenerator.NextDouble() < Constants.Con.mutate_new_neuron_chanse)
     {
         //Debug.Log("mutate");
         if (AllSynapses.Count == 0)
         {
             return;
         }
         AddNeuron();
     }
     if (RandomGenerator.NextDouble() < Constants.Con.mutate_del_neuron_chanse)
     {
         //Debug.Log("mutate");
         if (AllSynapses.Count == 0)
         {
             return;
         }
         DelNeuron();
     }
     if (RandomGenerator.NextDouble() < Constants.Con.mutate_new_synapse_chanse)
     {
         //Debug.Log("mutate");
         AddSynapse();
     }
     if (RandomGenerator.NextDouble() < Constants.Con.mutate_del_synapse_chanse)
     {
         //Debug.Log("mutate");
         DelSynapse();
     }
 }