Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 public void Mutate()
 {
     for (int i = 0; i < Dna.Length; i++)
     {
         if (MutationRnd.NextDouble() < MutationChance)
         {
             Dna[i] = MutateByPercentage(Dna[i]);
         }
         // if (MutationRnd.NextDouble() < MutationChance)
         //   Dna[i] = MutateBySign(Dna[i]);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public double MutateByNumber(double value)
 {
     return(value + MutationRnd.NextDouble() * MutationRnd.Next(0, 1) == 0 ? -1 : 1);
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public double MutateByPercentage(double value)
 {
     //Plus ou moins de 5 a 15 pourcent de la valeur du nombre
     value += value * (0.05 + (MutationRnd.NextDouble() / 10)) * MutationRnd.Next(0, 1) == 0 ? -1 : 1;
     return(value);
 }