Exemplo n.º 1
0
 public static void Clean(IRun run, TimingMethod method, CleanUpCallback callback = null)
 {
     var predictions = new TimeSpan?[run.Count + 1];
     CalculateSumOfBest(run, 0, run.Count - 1, predictions, true, false, method);
     int segmentIndex = 0;
     TimeSpan? currentTime = TimeSpan.Zero;
     foreach (var segment in run)
     {
         currentTime = predictions[segmentIndex];
         foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue))
         {
             var prediction = TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method);
             CheckPrediction(run, predictions, prediction.Time[method], segmentIndex - 1, prediction.Index - 1, nullSegment.Key, method, callback);
         } 
         segmentIndex++;
     }
 }
Exemplo n.º 2
0
        public static void Clean(IRun run, TimingMethod method, CleanUpCallback callback = null)
        {
            var predictions = new TimeSpan?[run.Count + 1];

            CalculateSumOfBest(run, 0, run.Count() - 1, predictions, true, method);
            int      segmentIndex = 0;
            TimeSpan?currentTime  = TimeSpan.Zero;

            foreach (var segment in run)
            {
                currentTime = predictions[segmentIndex];
                foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Time[method].HasValue))
                {
                    var prediction = TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Index, method);
                    CheckPrediction(run, predictions, prediction.Time[method], segmentIndex - 1, prediction.Index - 1, nullSegment.Index, method, callback);
                }
                segmentIndex++;
            }
        }
Exemplo n.º 3
0
 private static void CheckPrediction(IRun run, TimeSpan?[] predictions, TimeSpan? predictedTime, int startingIndex, int endingIndex, int runIndex, TimingMethod method, CleanUpCallback callback)
 {
     if (predictedTime.HasValue && (!predictions[endingIndex + 1].HasValue || predictedTime < predictions[endingIndex + 1].Value))
     {
         var segmentHistoryElement = run[endingIndex].SegmentHistory.FirstOrDefault(x => x.Index == runIndex);
         var parameters = new CleanUpCallbackParameters
         {
             startingSegment = startingIndex >= 0 ? run[startingIndex] : null,
             endingSegment = endingIndex >= 0 ? run[endingIndex] : null,
             timeBetween = segmentHistoryElement.Time[method].Value,
             combinedSumOfBest = predictions[endingIndex + 1].HasValue ? (TimeSpan?)(predictions[endingIndex + 1].Value - predictions[startingIndex + 1].Value) : null,
             attempt = run.AttemptHistory.FirstOrDefault(x => x.Index == runIndex),
             method = method
         };
         if (callback == null || callback(parameters))
         {
             run[endingIndex].SegmentHistory.Remove(segmentHistoryElement);
         }
     }
 }
Exemplo n.º 4
0
 public static void Clean(IRun run, CleanUpCallback callback = null)
 {
     Clean(run, TimingMethod.RealTime, callback);
     Clean(run, TimingMethod.GameTime, callback);
 }
Exemplo n.º 5
0
 private static void CheckPrediction(IRun run, TimeSpan?[] predictions, TimeSpan?predictedTime, int startingIndex, int endingIndex, int runIndex, TimingMethod method = TimingMethod.RealTime, CleanUpCallback callback = null)
 {
     if (predictedTime.HasValue && (!predictions[endingIndex + 1].HasValue || predictedTime < predictions[endingIndex + 1].Value))
     {
         var segmentHistoryElement = run[endingIndex].SegmentHistory.FirstOrDefault(x => x.Index == runIndex);
         var parameters            = new CleanUpCallbackParameters
         {
             startingSegment   = run[startingIndex],
             endingSegment     = run[endingIndex],
             timeBetween       = segmentHistoryElement.Time[method].Value,
             combinedSumOfBest = predictions[endingIndex + 1].Value - predictions[startingIndex + 1].Value,
             runElement        = run.RunHistory.FirstOrDefault(x => x.Index == runIndex),
             method            = method
         };
         if (callback == null || callback(parameters))
         {
             run[endingIndex].SegmentHistory.Remove(segmentHistoryElement);
         }
     }
 }
Exemplo n.º 6
0
 private static void CheckPrediction(IRun run, TimeSpan?[] predictions, TimeSpan?predictedTime, int startingIndex, int endingIndex, int runIndex, TimingMethod method, CleanUpCallback callback)
 {
     if (predictedTime.HasValue && (!predictions[endingIndex + 1].HasValue || predictedTime < predictions[endingIndex + 1].Value))
     {
         Time segmentHistoryElement;
         if (run[endingIndex].SegmentHistory.TryGetValue(runIndex, out segmentHistoryElement))
         {
             var parameters = new CleanUpCallbackParameters
             {
                 startingSegment   = startingIndex >= 0 ? run[startingIndex] : null,
                 endingSegment     = endingIndex >= 0 ? run[endingIndex] : null,
                 timeBetween       = segmentHistoryElement[method].Value,
                 combinedSumOfBest = predictions[endingIndex + 1].HasValue ? (TimeSpan?)(predictions[endingIndex + 1].Value - predictions[startingIndex + 1].Value) : null,
                 attempt           = run.AttemptHistory.FirstOrDefault(x => x.Index == runIndex),
                 method            = method
             };
             if (callback == null || callback(parameters))
             {
                 run[endingIndex].SegmentHistory.Remove(runIndex);
             }
         }
     }
 }
Exemplo n.º 7
0
 public static void Clean(IRun run, CleanUpCallback callback = null)
 {
     Clean(run, TimingMethod.RealTime, callback);
     Clean(run, TimingMethod.GameTime, callback);
 }