Beispiel #1
0
 public StationGenerator(Tier tier, Instance instance, LayoutConfiguration layoutConfiguration, Tile[,] tiles, Dictionary <Tuple <double, double>, Elevator> elevatorPositions, Dictionary <Elevator, List <Waypoint> > elevatorWaypoints, SemaphoreGenerator semaphoreGenerator, Func <int> obtainNextOStationActivationID, Func <int> obtainNextIStationActivationID)
 {
     this.tier                           = tier;
     this.instance                       = instance;
     this.lc                             = layoutConfiguration;
     this.tiles                          = tiles;
     this.elevatorPositions              = elevatorPositions;
     this.elevatorWaypoints              = elevatorWaypoints;
     this.semaphoreGenerator             = semaphoreGenerator;
     this.obtainNextOStationActivationID = obtainNextOStationActivationID;
     this.obtainNextIStationActivationID = obtainNextIStationActivationID;
 }
Beispiel #2
0
        public void fillTiers()
        {
            int        iStationActivationID       = 0;
            int        oStationActivationID       = 0;
            Func <int> obtainIStationActivationID = () => { return(iStationActivationID++); };
            Func <int> obtainOStationActivationID = () => { return(oStationActivationID++); };

            foreach (var tier in instance.Compound.Tiers)
            {
                //the stations are generated first, so that generator that makes the storage area and halls knows where the entrances and exits are of the stations.
                //however, the semaphores of the stations can only be created after the halls, because the semaphores need the waypoints that from the halls

                Tile[,] tiles = new Tile[lc.widthTier(), lc.lengthTier()]; //this keeps track of all the waypoints, their directions and type. This is handy for construction of the layout but also to for example display information in the console during debugging
                SemaphoreGenerator semaphoreGenerator = new SemaphoreGenerator(tiles, lc, instance, elevatorSemaphores);
                StationGenerator   stationGenerator   = new StationGenerator(tier, instance, lc, tiles, elevatorPositions, elevatorWaypoints, semaphoreGenerator, obtainOStationActivationID, obtainIStationActivationID);
                stationGenerator.generateStations();
                StorageAreaAndHallsGenerator storageAreaAndHallsGenerator = new StorageAreaAndHallsGenerator(tier, instance, lc, rand, tiles, stationGenerator);
                storageAreaAndHallsGenerator.createStorageAreaAndHalls();

                if (_logInfo)
                {
                    WriteAllDirectionsInfo(tiles);
                    WriteAllTypesInfo(tiles);
                }

                generatePods(tier);
                semaphoreGenerator.generateAllSemaphores(); //depends on info from both stationGenerator and storageAreaAndHallsGenerator, therefore construction of semaphores is delayed until here
                connectAllWayPoints(tiles);
                connectElevators();
                generateRobots(tier, tiles);
                instance.Flush();
                locateResourceFiles();
            }
            // Re-order activation sequence (stations on the lowest floor go first, then the ones next to the tier's center and lastly the ones with the lowest ID - this should break all ties)
            int currentActivationID = 1;

            foreach (var station in instance.InputStations.OrderBy(s => s.Tier.ID).ThenBy(s => Metrics.Distances.CalculateEuclid(s.X, s.Y, s.Tier.Length / 2.0, s.Tier.Width / 2.0)).ThenBy(s => s.ID))
            {
                station.ActivationOrderID = currentActivationID++;
            }
            currentActivationID = 1;
            foreach (var station in instance.OutputStations.OrderBy(s => s.Tier.ID).ThenBy(s => Metrics.Distances.CalculateEuclid(s.X, s.Y, s.Tier.Length / 2.0, s.Tier.Width / 2.0)).ThenBy(s => s.ID))
            {
                station.ActivationOrderID = currentActivationID++;
            }
        }