Search
]
Date:
[ Previous
| Next
]
Thread:
[ Previous
| Next
]
Index:
[ Author
| Date
| Thread
]
[MUD-Dev] AFAP: As fast as possible, non linear...
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 );
Now, I know there has to be a much faster, non linear way to do
this, but I haven't thought of it yet, so I though it time I got
a bit of help for this snippet. :) The rest I'm pretty pleased
with. I'm thinking it should be pretty fast if I get around the
coord picking I'm using now. So, does anyone have a quick way
to grab a zero coord? (Oh, hmm, I just thought of a way I'll
try, but I'll post this anyway. I'll just run the list of used
and grab a random one of those with a zero neighbor. -- Anyway
while I try that, does anyone have any other faster/better ways
to do the coord grabbing?)
Thanks in advance.
Quzah.
- Thread context:
- [MUD-Dev] Re: Graphic design, client questions, (continued)
- [MUD-Dev] Re: AFAP: As fast as possible, non linear...,
quzah [softhome] quzah#softhome,net, Tue 15 Dec 1998, 12:30 GMT
- <Possible follow-up(s)>
- [MUD-Dev] Re: AFAP: As fast as possible, non linear...,
quzah [softhome] quzah#softhome,net, Wed 16 Dec 1998, 12:29 GMT
- [MUD-Dev] Re: AFAP: As fast as possible, non linear...,
quzah [softhome] quzah#softhome,net, Tue 29 Dec 1998, 08:27 GMT
- [MUD-Dev] AFAP: As fast as possible, non linear...,
quzah [softhome] quzah#softhome,net, Mon 14 Dec 1998, 06:41 GMT
- [MUD-Dev] Re: AFAP: As fast as possible, non linear...,
Mik Clarke mikclrk#ibm,net, Tue 15 Dec 1998, 04:05 GMT
- [MUD-Dev] Re: AFAP: As fast as possible, non linear...,
Dan Shiovitz dbs#cs,wisc.edu, Tue 15 Dec 1998, 06:18 GMT
- [MUD-Dev] Re: AFAP: As fast as possible, non linear...,
Jon Leonard jleonard#divcom,slimy.com, Tue 15 Dec 1998, 07:27 GMT
[ Other Periods
| Other mailing lists
| Search
]