🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #482

Re: WANTED : Maze Algorithm extension

#482
From: Robert Schmidt
Date: Fri, 07 Aug 1992 17:12
69 lines
3426 bytes
In article <1992Aug6.225108.572@ccu1.aukuni.ac.nz>, rossw@ccu1.aukuni.ac.nz (Ross Williamson) writes:
 >     OK a slight extension to the question I asked.
 > I also want every possible room to be connected ......
 > And I don't want to enter the maze from one point and exit at another
 > I just need it so that it generates a set of connections between all 
 > rooms :(    it's a bit of a dog but it's something I need to solve.
 > 
 > Can anyone help at all ??

I'll try:

Initializing:
1. start with an array sized sx, sy filled with walls.
   coordinates outside array return walls too.
   sx and sy are ODD numbers!
2. go to a random position (x,y) in range (1..sx, 1..sy)
   make sure the x and y of the position are EVEN numbers!
   set it to a corridor.

Start of loop:
3. choose a random direction that won't lead you outside the array in
   two steps.
   note: i'm talking primary directions N, S, W and E here.
4. move one step in the dir from 3) and set cell to a room
5. do it one more time
6. now for the timeconsuming part:
   repeat 
     select a random position
     same restrictions to x and y as in 2.
   until you're in a corridor (not in a wall)
7. goto 3 till no more space for corridors.
   the number of times you repeat this is of course dependant on sx and sy
   (sx*sy/4  +/- something)

This will make a labyrinth with walls as thick as a corridor (as in
wolf3d), no entrance or exit (but those can easily be placed).

Most important, all corridors are connected, due to point 6.

I'd like to hear from anyone about suggestions on the random corridor selection
generator in 6.

For completeness, this algorithm was spun from the bottom of my head, as I
remember Acorn User magazine used it in their 3D MAZE game for the BBC micro 
some years ago...

I even 'ported' this game to 8086 and CGA (using Turbo Pascal), so if anyone
is interested I could post it to the net.  Please tell me via e-mail.
I guess I won't break any laws, as the BBC BASIC source was available in the
very magazine.

As I was probably 12-13 years old at the time, I want no flames for coding
peculiarities... ;)

 > +-----------------------------------------+--------------------+
 > | Name   : Ross Williamson                |Auckland University | 
 > | E-Mail : rossw@ccu1.aukuni.ac.nz        |    New Zealand     |
 > | Of course these opinions are my own and thank !! for that    |
 > +--------------------------------------------------------------+
 > "Oh Zaphod he's in his cabin signing photos of himself, 'To 
 > myself with frank admiration" Arthur Dent - From the Hitchhikers
 > Guide To The Galaxy.

-- 
Cheers from Robert Schmidt, aka Ztiff Zox, aka Buuud (IRC).  E-mail to 
robert@solan.unit.no, snail-mail to Stud.techn. Robert Schmidt, Stud.post 170,
Norwegian Institute of Technology, 7034 Trondheim, NORWAY          

Warlords: Now do you think my .sig is boring enough?
Technical Details
Message-ID: <1992Aug7.171250.5076@ugle.unit.no>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!aun.uninett.no!ugle.unit.no!solan1.solan.unit.no!robert
References: <1992Aug6.225108.572@ccu1.aukuni.ac.nz>

Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!aun.uninett.no!ugle.unit.no!solan1.solan.unit.no!robert
From: robert@solan.unit.no (Robert Schmidt)
Subject: Re: WANTED : Maze Algorithm extension
Message-ID: <1992Aug7.171250.5076@ugle.unit.no>
Sender: news@ugle.unit.no (NetNews Administrator)
Organization: Norwegian Institute of Technology
References:  <1992Aug6.225108.572@ccu1.aukuni.ac.nz>
Date: Fri, 7 Aug 92 17:12:50 GMT
Lines: 69