Example #1
0
        public int ScoreRide(Car car, int currentStep)
        {
            int score = 0;
            int rideStart;
            int carArrives = SelfDriving.GetDist(car.Location, StartLocation) + currentStep;

            if (carArrives <= EarliestStart)
            {
                score     = bonus;
                rideStart = EarliestStart;
            }
            else
            {
                rideStart = carArrives;
            }


            int       downTime      = rideStart - currentStep;
            const int MAX_DOWN_TIME = 1000000000;

            score += (MAX_DOWN_TIME - downTime); //invert, so lower downtime gives higher score

            int rideFinish = rideStart + Raw_score;

            if (rideFinish <= LatestFinish && rideFinish <= totalSteps)
            {
                return(score);
                //return downTime;
            }
            else
            {
                return(0);
            }
        }
Example #2
0
        static List <List <int> > IO_in(string filePath)
        {
            // below IF no line split
            //string text = System.IO.File.ReadAllText(filePath);


            string[] lines = File.ReadAllLines(filePath);

            //Iterate over lines and split
            int lineNo = 1;

            int[] fl; //First line
            List <List <int> > rides = new List <List <int> >();

            foreach (string line in lines)
            {
                if (lineNo == 1)
                {
                    fl = Array.ConvertAll(line.Split(), st => int.Parse(st));
                    lineNo++;
                    continue;
                }
                rides.Add(Array.ConvertAll(line.Split(), st => int.Parse(st)).ToList());
            }
            return(SelfDriving.Solve(fl[0], fl[1], fl[2], fl[3], fl[4], fl[5], rides));
        }
Example #3
0
        public void TakeRide(Ride ride, int currentStep)
        {
            int carArrives = SelfDriving.GetDist(Location, ride.StartLocation) + currentStep;
            int rideStart  = (carArrives <= ride.EarliestStart)? ride.EarliestStart: rideStart = carArrives;

            _activeTill = rideStart + ride.Raw_score;
            _location   = ride.EndLocation;
        }
Example #4
0
 public Ride(List <int> rideDeets, int ind)
 {
     Index         = ind;
     StartLocation = new Tuple <int, int>(rideDeets[0], rideDeets[1]);
     EndLocation   = new Tuple <int, int>(rideDeets[2], rideDeets[3]);
     EarliestStart = rideDeets[4];
     LatestFinish  = rideDeets[5];
     Raw_score     = SelfDriving.GetDist(StartLocation, EndLocation);
 }