Re: [Code] [More Mazes] [question]

From: Michael Gesner (dabion@WPI.EDU)
Date: 03/01/01

Sorry... misunderstood the post... been up too long...
:o)  <-- asks for forgiveness...

I haven't actually added the code, so I'm not the best resource, but from
the looks of the way things are... it looks like the algorithm counts on it
being a 2d maze...

One comment before I do this...
I'd use these defines for your directions
/*already defined in structs.h*/

#define NORTH          0
#define EAST           1
#define SOUTH          2
#define WEST           3
#define UP             4
#define DOWN           5

To start making it 3d, you would add a z, and then you would have to do the

add z to the first line of ints

in the for loop with test... you need to make the check for 600... if I'm
reading this right...
so that it will check 6 directions rather than 4

you will also need to add a clause for z which will come after y

so after y you have...
temp = temp - (y*10);

z = temp;

the room equation also has to take z into the picture, as z is now a part
of the equation.
From the way that the code looks, each room is assigned a unique value with
y as the indicator.  So, in order to incorporate z into the equation, you
can do the following:
room = (vnum * 1000) + (x*100) + (y*10) + z;

what that does, is just add another factor of 10 to the equation.  By doing
so, everything still has a unique value.

in the chain of if's here:

if ((x == 0) && (dir == 0))
    if ((y == 9) && (dir == 1))
    if ((x == 9) && (dir == 2))
    if ((y == 0) && (dir == 3))

change it to the following
if ((x == 0) && (dir == NORTH))
    if ((y == 9) && (dir == EAST))
    if ((x == 9) && (dir == SOUTH))
    if ((y == 0) && (dir == WEST))
    if ((z == 0) && (dir == DOWN))
    if ((z == 9) && (dir == UP))

Take note that this assumes a z of 0 is the floor... (so your left hand
corner room, basement level would be 0,0,0)

So on and so forth...

As I said... I haven't put this code in myself... but it looks like you
just have to reformat a little for things to work with 3 dimensions...

Hope this helps a little,

Michael Gesner
Co-Admin of Rhu-Dina'ar 17777

PS: This is mailer code... it may not work... I'm a bit tired... but I did
it for the general algorithm... feel free to mail me personally and we can
work it out if this doesn't work...

   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/04/01 PST