Пример #1
0
        public static LemmingRunRecord Crossover(this LemmingRunRecord record1, LemmingRunRecord record2)
        {
            var random = new Random();
            var size   = Math.Max(record1.Size, record2.Size);
            var result = new LemmingMovementDirection[size];

            for (var i = 0; i < size; i++)
            {
                result[i] = random.Next(0, 2) == 0 ? record1[i] : record2[i];
            }
            return(new LemmingRunRecord(result));
        }
Пример #2
0
 public static void Mutate(this LemmingRunRecord record, int frameId, int previousFrameId)
 {
     record.MutateLastActions(frameId);
     if (WinnersTable.WinnersData.Any())
     {
         var data = WinnersTable.WinnersData[0].Data;
         Array.Resize(ref data, (int)(0.75 * data.Length));
         record = new LemmingRunRecord(data);
     }
     if (Math.Abs(frameId - previousFrameId) < _minimumFrameDistanceToForceMutation)
     {
         record.Mutate(0.2);
     }
 }