Tuesday, April 05, 2005

Guru of sorts

I've been playing with mazes as of late. Attempting to solve the secrets to creating one, actually. And there's a method to my madness, it's for level generation in my game. So, I'm learning to program mazes.

Anything I'm learning, I'm learning from this site, Think Labyrinth which truly is a great source for anything maze related. This guy really knows what he's talking about, and was even blurbed about on Ripley's Believe It or Not section of a newspaper .

I'm trying to code my own 'Hunt and Kill' agorithm, which basically, when no more rooms can be carved in a certain segment, scans the array of rooms and searches for the first available room that is not too crowded, which means there's room to start another segment of room creation.

Start at one location and carve a room. Next, choose an adjacent room at random. Test to see if that room is not too crowded. If it's not too crowded, place the room and choose another adjacent room at random. Test and repeat. If a room is too crowded, 'Hunt and Kill' to find the next available uncrowded room and continue from there.

A room is concidered too crowded if there are two rooms adjacent to that room. What you want to ensure is that every room you add is a continuation of only the preceding room. This ensures that there are no loops in the maze, which guarantees there is only one path to the exit. This is called a 'perfect' maze.

Admittedly, I've been having trouble with my program. But only because I did not understand these simple concepts. It took me the last two hours laying in bed for my brain to really dumb it down to something I could understand. And here I have crawled out of bed to make a note of it so I don't forget my brilliance in the morning.

-Because that's something I would do

No comments:

Followers