Exemple #1
0
        public ResContainer(int ApproachDistance, Ride _Ride, bool Bonus, Points Point, int waitTime)
        {
            this.waitTime = waitTime;
            this.ApproachDistance = ApproachDistance;
            this._Ride = _Ride;
            this.Bonus = Bonus;
            this.TimeOfDrive = ApproachDistance + _Ride.Distance + this.waitTime;
            this.PointsEarned = _Ride.Distance;
            this._point = Point;

            if (Bonus)
                this.PointsEarned += Program.B;

            TimeProportion = (double)this.TimeOfDrive / (double)(ApproachDistance + waitTime);

        }
Exemple #2
0
        public List<ResContainer> FindBestRidesFromPos(int Y, int X, int CurrentTime, int TimeToEnd, Ride SkipRide, out int MinApproachDistance) 
        {
            List<ResContainer> Results = new List<ResContainer>();
            int ApproachTime = 0, RidesChecked = 0, temp, waitTime;
            MinApproachDistance = Program.Atlas.R + Program.Atlas.C;

            foreach (Points Point in Program._Points)
            {
                if (_Map[Point.Y, Point.X].Count != 0)
                {
                    foreach (Ride _ride in _Map[Point.Y, Point.X])
                    {
                        RidesChecked++;

                        if (_ride.Equals(SkipRide))
                            continue;

                        ApproachTime = Math.Abs(Y - Point.Y) + Math.Abs(X - Point.X);
                        temp = ApproachTime + CurrentTime;
                        waitTime = _ride.EarliestStart - temp;

                        if (ApproachTime < MinApproachDistance)
                            MinApproachDistance = ApproachTime;

                        if (waitTime < 0)
                            waitTime = 0;

                        if (_ride.LatestFinish <= CurrentTime + ApproachTime + _ride.Distance + waitTime)
                            continue;

                        if (ApproachTime >= TimeToEnd)
                            goto AfterLoop;

                        if (TimeToEnd >= ApproachTime + _ride.Distance)
                        {
                            
                            if (temp == _ride.EarliestStart)
                                Results.Add(new ResContainer(ApproachTime, _ride, true, Point, 0));
                            else if(temp < _ride.EarliestStart && _ride.EarliestStart - Program.B >= temp)
                                Results.Add(new ResContainer(ApproachTime, _ride, true, Point, waitTime));
                            else
                                Results.Add(new ResContainer(ApproachTime, _ride, false, Point, 0));
                        }
                            
                        if(RidesChecked >= Program.N)
                        {
                            goto AfterLoop;
                        }
                    }
                }
            }

            AfterLoop:

            Results.Sort((a, b) => b.TimeProportion.CompareTo(a.TimeProportion));

            if (Results.Count < 6)
                return Results;

            return new List<ResContainer> { Results[0], Results[1], Results[2], Results[3], Results[4] };

        }
Exemple #3
0
 public void RemoveRide(int a, int b, Ride r)
 {
     _Map[a, b].Remove(r);
 }