Beispiel #1
0
 /// =================================================
 /// <summary>
 /// Resets all the values with random values between -amplitude and amplitude
 /// </summary>
 ///
 /// <param name="amplitude"></param>
 public void Randomize(float amplitude = 1.0f)
 {
     for (int i = 0; i < this.values.Length; i++)
     {
         this.values[i] = StaticRandom.NextBilinear(amplitude);
     }
 }
Beispiel #2
0
        /// =================================================
        /// <summary>
        /// Randomly changes some gene
        /// </summary>
        ///
        /// <param name="chance"></param>
        /// <param name="amplitude">The amplitude used to generate the mutation. Range: (-amplitude, amplitude)</param>
        public void Mutate(float chance, float amplitude = 1f)
        {
            for (int i = 0; i < this.Genes.Length; i++)
            {
                float dice = StaticRandom.Next();

                if (dice < chance)
                {
                    this.Genes[i] = StaticRandom.NextBilinear(amplitude);
                }
            }
        }