Exemple #1
0
        private void AssignRideToCar(Ride ride, Car car)
        {
            ride.GotBonus = BonusCalculator.CalculateBonus(car, ride, _problemData.PerRideBonus) > 0;

            car.Rides.Add(ride);
            car.OccupiedUntil = StepCalculator.CalculateStepAfterRide(car, ride);
            car.CurrentColumn = ride.RideFinishColumn;
            car.CurrentRow    = ride.RideFinishRow;


            _problemData.RidesToDo.Remove(ride);
        }
Exemple #2
0
        public void CalculateMagicRatio(Car car, ProblemData problemData)
        {
            var stepsToGoToRideStart = StepCalculator.CalculateStepsFromCarToRideStart(car, this);
            int waitTime             = StepCalculator.CalculateWaitTime(car, this);
            var endRideStep          = StepCalculator.CalculateStepAfterRide(car, this);

            // Si le trajet peut etre fini avant la fin de la simu
            // ou si le trajet peut etre fini avant la fin du ride
            if ((endRideStep >= problemData.NumberOfSteps) ||
                (endRideStep >= RideLatestFinish))
            {
                MagicNumber = 0;
                return;
            }

            var   bonus       = BonusCalculator.CalculateBonus(car, this, problemData.PerRideBonus);
            var   totalPoint  = RidePointsWithoutBonus + bonus;
            var   totalTime   = stepsToGoToRideStart + waitTime + RidePointsWithoutBonus;
            var   wastedTime  = stepsToGoToRideStart + waitTime;
            float ponderation = 1F / (1F + wastedTime);

            MagicNumber = (totalPoint / (float)totalTime) * ponderation;
        }