On Sun, 2 Feb 1997, Daniel Koepke wrote: > > A B C D E > 1 o--o--o--o--o > | | | > 2 o--o o o o > | | > 3 o o o o--o > | | > 4 o--o o o o > | | > 5 o--o--o--o--o > > Then we go horizontally, starting at A2 (first part of the interior), > we move to B2, C2, D2. We either make a link to the east, or we decide > to make a turn. If we make a turn, we go the square either north/south > of the current one. Then we keep going in that same direction until we > decide to turn again. That would give us a random patch through the > grid. But then we'll have many unlinked rooms. What to do about them? > Make a cleanup sweep and link any rooms that aren't presently linked? > Some code demonstrating generation of a maze would be nice (I'm trying > to get the major parts of a pkill MUD done before next week)... > > Thank you for any assistance you are willing to give, Perhaps you should thing about it like this: Start the generator, and read in a list of valid (or invalid) locations in the maze to an array. Now, define a real maze array, and start your traversal. Start at 0,0 or whatever, and say the first direction defaults to east. Move east (0,1) and link the two rooms. Now check all directions from this room. North is invalid because it goes beyond the boundaries of the array. So your possible valid directions are east, south, and west. Now here is where it gets tricky. You can either save all the valid directions in this square to a stack, and traverse each direction to its end, then back up and traverse again, or you can do a sort of breadth-first-search (quick, run to your algorithims book! :P ) simultaneously traversing each path to its end. Oh, back at the beginning of all this, I said you'd need a list of valid or invalid locations from someplace. Try reading all the invalid locations into a stack, and then before you preform a move, check the move against the whole stack. This was written in the mailer, of course, and I've been sick recently, so if this isn't what you're looking for, sorry. I think I have working code of a maze program similar to this though; I'll dig around for it. Rich +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST