I am writing a game containing a randomly generated map.
It would consist of a map with rooms, each having one or none of the following : - An east, west, north and south exit.
Not all the potential rooms in say, a 10*10 grid, would be used, but whichever ones are need to be connected.
I currently have some AWFUL code written to make the map (too long to post here, but I may attach it tommorow if I remember to bring it in).
It basically creates a room, then an exit, then a room in that direction (if possible, i.e. it is not at the boundaries). Then it creates an exit between the two, then loops and starts on the newly created room.
If a room has no valid exits, a random, already existing room is chosen, and the loop starts again.
I doubt any of that made sense, please ask if it needs clarifying.
Is there a better way than this?
Thanks!