[MUD-Dev] Re: AFAP: As fast as possible, non linear...
Mik Clarke
mikclrk at ibm.net
Tue Dec 15 23:22:11 CET 1998
quzah [softhome] wrote:
>
> Hiya all.
>
> I'm finishing up a tiny maze generator, and all I need is a
> tad bit of a speed gain. (Or more than a tad. :) I'm using
> a 10x10x10 cube, generated a plane at a time (10x10). I am
> linking them through one exit per plane (up/down), with the
> bottom level's exit leading "out". Here's the basic rundown:
>
> void mazePunch( char startX, char startY, char startZ, bool nuke){
> static char path[100];
> static char used;
>
> /* if nuke, zero the path, simple linear for() loop */
> /* then trash 'used' */
>
> /*
> startX and startY determine this planes 'current' location.
> {
> If any neighbor is zero (unused), note it (valid).
> Pick from the list of valid neighbors at random to use.
> Knock out the wall, them to us.
> Increment 'used'.
> If current == 0, increment 'used'.
> Knock out the wall, us to them.
> }
> {
> If no neighbors were zero, and we are zero, punch a hole
> from us to any valid neighbor (valid this time being an
> in bounds coord.) Increment 'used' since we are no longer
> zero.
> }
> if( used < 100 )
> recursive call with new coords for x and y.
> else return
> */
> }
>
> That about does it. The only thing I don't like about it is that
> that I have a crappy way of getting the new coords for the next
> recursive call. I'm currently using:
>
> mazePunch( number_range(0,9), number_range(0,9), FALSE );
Thinking about it, I'm not convinced that your algorythm will always
generate a solvable maze. Condiser:
A-O-O-O O-O
| | | | |
O-O-O O-O
| |
O-O O-O-O
| | | | |
O-O O-O-O-B
I think this would meet your loop exit crietria (used = 100), but it is
not possible to get from A to B. This could pose something of a problem
for your players...
Mik
--
http://www.geocities.com/SoHo/Cafe/2260
More information about the mud-dev-archive
mailing list