Exemplo n.º 1
0
 public RacePlan(CarState carState)
 {
     CarStates = new List <CarState> {
         carState
     };
     TotalTime = new TimeSpan();
 }
Exemplo n.º 2
0
 public CarStateTree(CarState beginningCarState)
 {
     BeginningCarState = beginningCarState;
     CreateGrabbingBag();
     CarStates = new HashSet <CarState>();
     CarStates.Add(BeginningCarState);
     CreateCarStateTree();
 }
Exemplo n.º 3
0
 public void GrabSuccessors(CarState grabber, int onLap)
 {
     foreach (var cs in GrabbingBag)
     {
         if (grabber.UsedRequiredTypesOfTyres)
         {
             if (!cs.UsedRequiredTypesOfTyres)
             {
                 continue;
             }
             if (cs.TyreSet.IsBrandNew)
             {
                 cs.OnLap = onLap;
                 grabber.AddSuccessor(cs);
                 CarStates.Add(cs);
             }
             if (cs.TyreSet.State == grabber.TyreSet.State + 1 &&
                 cs.TyreSet.IsTheSameTyreType(grabber.TyreSet))
             {
                 cs.OnLap = onLap;
                 grabber.AddSuccessor(cs);
                 CarStates.Add(cs);
             }
         }
         else
         {
             if (cs.UsedRequiredTypesOfTyres)
             {
                 if (cs.TyreSet.IsBrandNew &&
                     !cs.TyreSet.IsTheSameTyreType(grabber.TyreSet))
                 {
                     cs.OnLap = onLap;
                     grabber.AddSuccessor(cs);
                     CarStates.Add(cs);
                 }
             }
             else
             {
                 if (!cs.TyreSet.IsTheSameTyreType(grabber.TyreSet))
                 {
                     continue;
                 }
                 if (cs.TyreSet.IsBrandNew || cs.TyreSet.State == grabber.TyreSet.State + 1)
                 {
                     cs.OnLap = onLap;
                     grabber.AddSuccessor(cs);
                     CarStates.Add(cs);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        public static TimeSpan GetLapTimeUsingCarStates(CarState fromCarState, CarState toCarState)
        {
            if (toCarState.TyreSet.State == (toCarState.TyreSet is SoftTyreSet ? toCarState.Car.Race.SuggestedLapsForSoftTyres : toCarState.Car.Race.SuggestedLapsForHardTyres))
            {
                return(new TimeSpan(1, 1, 1, 1));
            }

            double fuelInfluence    = 5e-5 * (fromCarState.Car.Race.NumberOfLaps - toCarState.OnLap);
            double BestLapTimeTicks = toCarState.Car.PerformanceSet.BestLapTime.Ticks;

            double lapTimeTicks = y * BestLapTimeTicks + fuelInfluence * BestLapTimeTicks + fromCarState.TyreSet.GetCurrentInfluenceForPerfomance() * BestLapTimeTicks + BestLapTimeTicks;

            long     longAverageTicks = Convert.ToInt64(lapTimeTicks);
            TimeSpan lapTime          = new TimeSpan(longAverageTicks);

            if (toCarState.TyreSet.State == 0)
            {
                lapTime += fromCarState.Car.Race.PitStopTime;
            }

            return(lapTime);
        }
Exemplo n.º 5
0
 public void AddSuccessor(CarState carState)
 {
     this.Successors.Add(carState);
     carState.Predecessors.Add(this);
 }
Exemplo n.º 6
0
 public void AddCarState(CarState carState)
 {
     CarStates.Add(carState);
     CalculateTime();
 }