예제 #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]);
     }
 }
예제 #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);
 }
예제 #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);
 }