예제 #1
0
파일: PeterParker.cs 프로젝트: 11o9/NG
 public PeterParker(PeterParker parent, ParkingType type)
 {
     parkings = new List <Parking>(parent.parkings);
     parkings.Add(new Parking(type));
     totalLength = parent.totalLength;
     //baseCurve = parent.baseCurve;
 }
예제 #2
0
파일: PeterParker.cs 프로젝트: 11o9/NG
        public void Add(PeterParker parker)
        {
            if (collection.Count < 10)
            {
                collection.Add(parker);
                Sort();
            }

            else
            {
                if (collection[0].ParkingUnitCount().Sum() < parker.ParkingUnitCount().Sum())
                {
                    collection.RemoveAt(0);
                    collection.Add(parker);
                    Sort();
                }
            }
        }
예제 #3
0
파일: PeterParker.cs 프로젝트: 11o9/NG
        public static ParkingResult Calculate(double initialLength /*, Curve initialCurve*/)
        {
            PeterParker           origin = new PeterParker(initialLength /*, initialCurve*/);
            Queue <PeterParker>   wait   = new Queue <PeterParker>();
            PeterParkerCollection fit    = new PeterParkerCollection();

            wait.Enqueue(origin);

            while (wait.Count > 0)
            {
                PeterParker current = wait.Dequeue();
                for (int i = 0; i < (int)ParkingType.Max; i++)
                {
                    PeterParker temp = new PeterParker(current, (ParkingType)i);
                    if (temp.LeftLength() < 0)
                    {
                        //cull
                    }
                    else if (temp.LeftLength() > 0)
                    {
                        if (temp.LeftLength() < 5)
                        {
                            //fit
                            fit.Add(temp);
                        }
                        else
                        {
                            //re enqueue
                            wait.Enqueue(temp);
                        }
                    }
                }
            }

            //

            fit.collection.ForEach(n => n.FillRoads());
            var result = new ParkingResult(fit);

            return(result);
        }