Games::RolePlay::MapGen::Generator::SparseAndLoops - The basic corridor generator
use Games::RolePlay::MapGen; my $map = new Games::RolePlay::MapGen; $map->set_generator( "Games::RolePlay::MapGen::Generator::SparseAndLoops" ); generate $map;
This is the sparseness and looping portion of Jamis Buck's Dungeon Generator.
1. Start with Jamis Buck's perfect maze
2. Look at every cell in the maze grid. If the given cell contains a corridor that exits the cell in only one direction (in otherwords, if the cell is the end of a dead-end hallway), "erase" that cell by removing the corridor.
3. Repeat step #2 sparseness times (ie, if sparseness is five, repeat step #2 five times).
4. Look at every cell in the maze grid. If the given cell is a dead-end cell (meaning that a corridor enters but does not exit the cell), it is a candidate for "dead-end removal."
4a. Roll d% (ie, pick a number between 1 and 100, inclusive). If the result is less than or equal to the "deadends removed" parameter, this deadend should be removed (4b). Otherwise, proceed to the next candidate cell.
4b. Remove the dead-end by performing step #3 of Games::RolePlay::MapGen::Generator::Perfect, above, except that a cell is not considered invalid if it has been visited. Stop when you intersect an existing corridor.