public void generateStationsOnOneSide(int[,] possibleLocationsForExits, int nPickStation, int nReplenishmentStations, int nElevators, int rowDiffEntry, int columnDiffEntry, int rowDiffStation, int columnDiffStation, HashSet <Coordinate> coordinatesStationEntrances) { int[,] exits = selectLocations(possibleLocationsForExits, nPickStation + nReplenishmentStations + nElevators); int entranceCounter = 0; for (int whichStation = 0; whichStation < exits.GetLength(0); whichStation++) { int exitRow = exits[whichStation, 0]; int exitColumn = exits[whichStation, 1]; int entryRow = exits[whichStation, 0] + rowDiffEntry; int entryColumn = exits[whichStation, 1] + columnDiffEntry; int stationRow = exits[whichStation, 0] + rowDiffStation; int stationColumn = exits[whichStation, 1] + columnDiffStation; waypointTypes typeOfStation = whichStation < nPickStation ? waypointTypes.PickStation : whichStation < nPickStation + nReplenishmentStations ? waypointTypes.ReplenishmentStation : waypointTypes.Elevator; int activationID = 0; switch (typeOfStation) { case waypointTypes.PickStation: activationID = obtainNextOStationActivationID(); break; case waypointTypes.ReplenishmentStation: activationID = obtainNextIStationActivationID(); break; default: break; } buildStationAndBuffer(exitRow, exitColumn, entryRow, entryColumn, stationRow, stationColumn, typeOfStation, coordinatesStationEntrances, entranceCounter, activationID); entranceCounter += lc.nEntrancesPerStation(); } }
public Tile(directions d, Waypoint wp, waypointTypes type) { this.direction = d; this.wp = wp; this.type = type; if (type.Equals(waypointTypes.StorageLocation) && !d.Equals(directions.EastNorthSouthWest)) { throw new ArgumentException("something went wrong with storage locations"); } if (d.Equals(directions.Invalid)) { throw new ArgumentException("direction invalid"); } if (wp == null) { throw new ArgumentException("wp is null"); } }
public void buildStation(waypointTypes typeOfStation, int row, int column, directions d, List <Waypoint> bufferPaths, int activationOrderID) { switch (typeOfStation) { case waypointTypes.PickStation: buildPickStation(row, column, d, bufferPaths, activationOrderID); break; case waypointTypes.ReplenishmentStation: buildReplenishmentStation(row, column, d, bufferPaths, activationOrderID); break; case waypointTypes.Elevator: buildElevator(row, column, d, bufferPaths); break; default: throw new ArgumentException("should built station, but typeOfStations is: " + typeOfStation); } }
public void checkValidityInputArgumentsBuildStationAndBuffer(int exitRow, int exitColumn, int entryRow, int entryColumn, int stationRow, int stationColumn, waypointTypes typeOfStation) { //check validity input arguments if (exitRow < 0 || stationRow < 0 || entryRow < 0 || exitColumn < 0 || stationColumn < 0 || entryColumn < 0) { throw new ArgumentException("something went wrong while constructing the station, one or more are negative, exitRow: " + exitRow + ", stationRow: " + stationRow + ", entryRow: " + entryRow + ", exitColumn: " + exitColumn + ", stationColumn: " + stationColumn + ", entryColumn: " + entryColumn); } if (exitRow != stationRow && exitColumn != stationColumn) { throw new ArgumentException("something went wrong while constructing the station, exitRow != stationRow && exitColumn != stationColumn, exitRow: " + exitRow + ", stationRow: " + stationRow + ", exitColumn: " + exitColumn + ", stationColumn: " + stationColumn); } if (exitRow != entryRow && exitColumn != entryColumn) { throw new ArgumentException("something went wrong while constructing the station, exitRow != entryRow && exitColumn != entryColumn, exitRow: " + exitRow + ", entryRow: " + entryRow + ", exitColumn: " + exitColumn + ", entryColumn: " + entryColumn); } if (exitRow == stationRow && exitColumn == stationColumn) { throw new ArgumentException("something went wrong while constructing the station, exitRow == stationRow && exitColumn == stationColumn, exitRow: " + exitRow + ", exitColumn: " + exitColumn); } if (exitRow == entryRow && exitColumn == entryColumn) { throw new ArgumentException("something went wrong while constructing the station, exitRow == entryRow && exitColumn == entryColumn, exitRow: " + exitRow + ", exitColumn: " + exitColumn); } if (stationColumn == entryRow && stationColumn == entryColumn) { throw new ArgumentException("something went wrong while constructing the station, stationRow == entryRow && stationColumn == entryColumn, stationRow: " + stationRow + ", stationColumn: " + stationColumn); } if (!typeOfStation.Equals(waypointTypes.PickStation) && !typeOfStation.Equals(waypointTypes.ReplenishmentStation) && !typeOfStation.Equals(waypointTypes.Elevator)) { throw new ArgumentException("!typeOfStation.Equals(waypointTypes.PickStation) && !typeOfStation.Equals(waypointTypes.ReplenishmentStation) && !typeOfStation.Equals(waypointTypes.Elevator)"); } }
public void buildStationAndBuffer(int exitRow, int exitColumn, int entryRow, int entryColumn, int stationRow, int stationColumn, waypointTypes typeOfStation, HashSet <Coordinate> coordinatesStationEntrances, int entranceCounter, int activationOrderID) { checkValidityInputArgumentsBuildStationAndBuffer(exitRow, exitColumn, entryRow, entryColumn, stationRow, stationColumn, typeOfStation); int lengthSegment = Math.Max(Math.Abs(exitRow - stationRow), Math.Abs(exitColumn - stationColumn)) + 1; int nSegments = Math.Max(Math.Abs(exitRow - entryRow), Math.Abs(exitColumn - entryColumn)) + 1; int rowDiffToNextTile = exitRow > stationRow ? -1 : exitRow < stationRow ? 1 : 0; int columnDiffToNextTile = exitColumn > stationColumn ? -1 : exitColumn < stationColumn ? 1 : 0;; int rowDiffToNextSegment = entryRow > exitRow ? -1 : entryRow < exitRow ? 1 : 0;; int columnDiffToNextSegment = entryColumn > exitColumn ? -1 : entryColumn < exitColumn ? 1 : 0; if (lengthSegment <= 0 || lengthSegment != lc.WidthBuffer) { throw new ArgumentException("something went wrong while constructing the station, lengthSegment <= 0 || lengthSegment != lc.WidthBuffer, lengthSegment: " + lengthSegment); } if (nSegments <= 0 || nSegments % 2 != 0) { throw new ArgumentException("something went wrong while constructing the station, nSegments <= 0 || nSegments % 2 != 0, nSegments: " + nSegments); } List <Waypoint> bufferPath = new List <Waypoint>(); int row = entryRow; int column = entryColumn; bool stationWasBuilt = false; for (int segment = 0; segment < nSegments; segment++) { if (segment % 2 == 0) { coordinatesStationEntrances.Add(new Coordinate(row - rowDiffToNextTile, column - columnDiffToNextTile)); } for (int place = 0; place < lengthSegment; place++) { directions d = determineDirection(place, segment, lengthSegment, nSegments, rowDiffToNextTile, columnDiffToNextTile, rowDiffToNextSegment, columnDiffToNextSegment); if (row == stationRow && column == stationColumn) { buildStation(typeOfStation, row, column, d, bufferPath, activationOrderID); stationWasBuilt = true; } else { createTile_Buffer(row, column, d); } Waypoint location = tiles[row, column].wp; semaphoreGenerator.update(row, column, segment, place, lengthSegment, nSegments, tiles[row, column], rowDiffToNextTile, columnDiffToNextTile, rowDiffToNextSegment, columnDiffToNextSegment); addToBufferPath(stationWasBuilt, tiles[row, column], bufferPath); row += place == lengthSegment - 1 ? 0 : rowDiffToNextTile; column += place == lengthSegment - 1 ? 0 : columnDiffToNextTile; } rowDiffToNextTile = rowDiffToNextTile != 0 ? -rowDiffToNextTile : rowDiffToNextTile; columnDiffToNextTile = columnDiffToNextTile != 0 ? -columnDiffToNextTile : columnDiffToNextTile; row += rowDiffToNextSegment; column += columnDiffToNextSegment; } if (!stationWasBuilt) { throw new ArgumentException("!stationWasBuilt"); } }