In this assignment you will write a little ASCII-maze generator in Unicon,
of the sort we would use if we were writing a roguelike game.
Roguelike games are text-terminal ASCII-art turn-based games in which
you, the intrepid adventurer represented on-screen by the symbol
@
must fight your
way through a dungeon (for example, to escape).
For the purposes of this class, generate a maze structure on a grid of cells 78 wide and 24 high. Think of the maze as a list of 24 strings, each 78 characters in size. Each cell represents a location that is either solid rock, or a traversible location that your character (or a monster) can inhabit. An example maze from a roguelike game might look like:
Note that in a roguelike, the player is not shown the whole map initially; they only discover it one turn at a time as they move through the map. But your job is to generate a map that would be legal and playable when fed in to such a game.
Starting from a map in which the entire grid consists of solid rock, the maze is constructed semi randomly by inserting "rooms" and connecting those rooms to each other using corridors. The rooms are rectangles and range in size from 2x2 cells to 5x20 cells. The rooms are denoted in the string using the period character (.). The rectangle of cells immediately around a room consist of either horizonal walls (-), vertical walls (|).
Connecting rooms is done as follows: every room at least 1 door; it has 50% probability of having 2 doors. A door is created in the grid by replacing one of the - or | characters around the room with a + character. Outside the door, a corridor consisting of # characters must be extended until it connects the room to another room (hitting a - or | and turning it into a door) or to another corridor (reaching a #).
Constraints: for your maze to be valid, it must have two or more rooms. They must all be connected and reachable to each other. They must not overlap. There should be a designated start room, in which a character < is placed to indicate a stairway upwards, and an end room in which a > is placed to indicate a stairway downwards.
Extra credit: add as much roguelike game functionality as you feel like, and as you have time for.
L := list(24, repl(" ", 78))