예제 #1
0
        /// <summary>
        /// Normalises a strategy line on every lap.
        /// </summary>
        /// <param name="line">The line to normalise</param>
        /// <param name="normalisationTrace">The trace used for normalisation</param>
        /// <returns>The new normalised line</returns>
        StrategyLine GetNormalisedStrategyLine(StrategyLine line, StrategyLine normalisationTrace)
        {
            StrategyLine normalisedLine = new StrategyLine(line.DriverIndex);
            lapDataPoint tempPoint;

            int   normalisedDriver = normalisationTrace.DriverIndex;
            float lappedCarCyleLimit;

            float thisLapAdjust       = 0;
            float lappedCarAdjustment = 0;
            float actualTime          = 0;

            int lapIndex = 0;

            foreach (lapDataPoint p in line.Coordinates)
            {
                if (lapIndex == 0)
                {
                    lappedCarCyleLimit = normalisationTrace.Coordinates[lapIndex].time;
                }
                else
                {
                    lappedCarCyleLimit = normalisationTrace.Coordinates[lapIndex].time - normalisationTrace.Coordinates[lapIndex - 1].time;
                }
                thisLapAdjust = normalisationTrace.Coordinates[lapIndex].time;

                if (lapIndex == line.Coordinates.Count - 1)
                {
                    actualTime = p.time;
                }

                tempPoint.driver = p.driver;
                tempPoint.lap    = p.lap;
                tempPoint.time   = p.time - thisLapAdjust + lappedCarAdjustment;
                tempPoint.draw   = p.draw;

                if (tempPoint.time > (lappedCarCyleLimit / 2))
                {
                    lappedCarAdjustment -= lappedCarCyleLimit;
                    tempPoint.time      -= lappedCarCyleLimit;
                    tempPoint.draw       = false;
                }
                if (tempPoint.time < -(lappedCarCyleLimit / 2))
                {
                    lappedCarAdjustment += lappedCarCyleLimit;
                    tempPoint.time      += lappedCarCyleLimit;
                    tempPoint.draw       = false;
                }

                normalisedLine.AddPoint(tempPoint);
                ++lapIndex;
            }
            normalisedLine.TotalTime = actualTime;

            return(normalisedLine);
        }
예제 #2
0
        /// <summary>
        /// Normalises a strategy on an average time
        /// </summary>
        /// <param name="line">The line to normalise</param>
        /// <param name="adjustPerLap">The amount by which to adjust the trace each lap</param>
        /// <returns>The new normalised line</returns>
        StrategyLine GetNormalisedStrategyLine(StrategyLine line, float adjustPerLap)
        {
            StrategyLine normalisedLine = new StrategyLine(line.DriverIndex);
            lapDataPoint tempPoint;

            float lappedCarAdjustment = 0;
            float actualTime          = 0;

            int lapIndex = 0;

            foreach (lapDataPoint p in line.Coordinates)
            {
                //Sets the actual time taken for the strategy to complete,
                //before any adjustments are applied
                if (lapIndex == line.Coordinates.Count - 1)
                {
                    actualTime = p.time;
                }

                //set the properties of the new point
                tempPoint.driver = p.driver;
                tempPoint.lap    = p.lap;
                tempPoint.time   = (p.time - adjustPerLap * p.lap + lappedCarAdjustment);
                tempPoint.draw   = p.draw;

                //Deals with cars being lapped
                //Decreases the time if they are too slow, or increases them if
                //they are too fast
                if (tempPoint.time > (adjustPerLap / 2))
                {
                    lappedCarAdjustment -= adjustPerLap;
                    tempPoint.time      -= adjustPerLap;
                    tempPoint.draw       = false;
                }
                if (tempPoint.time < -(adjustPerLap / 2))
                {
                    lappedCarAdjustment += adjustPerLap;
                    tempPoint.time      += adjustPerLap;
                    tempPoint.draw       = false;
                }

                normalisedLine.AddPoint(tempPoint);
                ++lapIndex;
            }
            //Reset the total time for the strategy to the original time.
            normalisedLine.TotalTime = actualTime;

            return(normalisedLine);
        }