Elevators are the biggest map elements. They must have an entrance, a door, an interior and walls to contain all this. A single elevator uses 8 cells of the map and I believe this is the reason why they are created before anything else. Their creation is forbidden before map 3 and a maximum of 5 shafts is allowed.
The shaft is created by placing the bottom elevator at a random location of the map. Being a random position means that the elevator can start at any floor level. The generator ensures that each cell required for the elevator does not exceed the edge of the map and does not belong to an unconditional wall. The cells are set only when it is considered to be valid. When all the cells of the elevator are done, the generator moves to the floor above and repeats the process to create an identical elevator until it has reached the top floor. It's possible that an elevator created on a floor level can't be created on a floor above because invalid cells can be found there. When this would happen, the generator would need to undo everything it has done for this shaft. To make it easier, the generator creates the shafts in 2 rounds. The first round only simulates the creation of the elevator shaft without changing any cells. If all the cells of every elevator entrance of the shaft are valid, the exact same process is done in a second round, but this time the cells are modified.
Notice that elevators only face the left or right sides of the map. It would have been possible to duplicate the creation process to create shafts with elevators facing the top or bottom edges, but I assume the programmer didn't feel up for it. |