예제 #1
0
        public void Mutate()
        {
            const double mutationRate = 0.01;

            for (int i = 0; i < Directions.Length; i++)
            {
                if (mutationRate > _random.NextDouble())
                {
                    Directions[i] = DirectionsProvider.GetRandomDirection();
                }
            }
        }
예제 #2
0
 public static List <Dot> GetDots(int numberOfDots, Point goal) =>
 File.Exists(FilePath)
         ? File
 .ReadAllLines(FilePath)
 .Select(line =>
         new Dot(goal,
                 line.Split(';').Select(direction =>
                                        direction.Split(','))
                 .Select(parts => new Point(Convert.ToInt32(parts[0]), Convert.ToInt32(parts[1])))
                 .ToArray()
                 )
         )
 .ToList()
         : Enumerable.Range(0, numberOfDots).Select(_ => new Dot(goal, Enumerable.Range(0, Brain.Size)
                                                                 .Select(__ => DirectionsProvider.GetRandomDirection()).ToArray()))
 .ToList();