Don't hate me for this

OK. I was wondering the other day when surfing the web, how mazes would be achieved during gameplay. I did a little bit of searching, but I couldn’t come up with anything definite which would work.

Don’t worry, before you spam this page with mazes hatemail, I hate mazes as much as you likely do. I’m just looking for a practical method, not game implementation.

What kind of approach are you looking for? The simplest way is probably to code in a bunch of rooms by hand – if you want the classic “twisty little passages” maze I think you’d have to make their printed names identical. This would be annoying to code, but it seems only fair that a maze should annoy the programmer as well.

The TWIFComp entry SWEDUN has one of the most elegantly programmed mazes I’ve seen – a seven-room maze programmed in 140 characters – though it’s in I6 and I don’t understand it.

At the risk of having a bunch of angry villagers head in my direction with pitchforks and torches, I would mention that I have used a fake maze – an area that is designed to make the player’s heart sink when he wanders in and gets the impression that he has entered a maze, when in fact there is no such thing. Specifically, I have a single room named something like “endless desert.” There are only two real exits from the room; one leads back to where the player entered, the other to a place he needs to get to. Every other direction from the desert leads right back to the same desert room.

I added a couple of other features to enhance the illusion: First, I block any attempt to drop objects (explaining that the shifting sands would likely cover any dropped objects and they would be lost forever). This precludes the player from trying to map the “maze” by dropping things, which would immediately expose the illusion. Second, on every turn in the desert there is a chance that a randomly chosen mirage might appear (so that there is some variability in the description). To be fair (although some might argue that the whole idea is unfair), when the player first enters the desert I give him a warning that in desert conditions sometimes the light plays tricks with one’s eyes.

Ultimately, once you find the direction which takes you out, the whole thing becomes trivial. However, if you start off in the wrong direction, you could wind up wandering around for a while before you realize what’s going on.

(In my own defense, I will state that I did not do anything like having a built-in mechanism which causes the player to die of thirst if he wanders too long and doesn’t have an adequate supply of water; basically, the desert can be very annoying but it’s not lethal.)

Robert Rothman

If you’re using I7, you can have something like:

A maze room is a kind of room. The printed name of a maze room is usually “Twisty Passages”. The description of a maze room is usually “Twisty passages, all alike, no doubt put here by an evil sadist.”

But like Matt said, the approach depends a lot on what you want the maze to look like and do.

That’s what I would suggest too. I used a scheme like this for a small “maze” in a forest.

I’m not sure what you mean by “achieved,” but if you’re talking about actually computing the maze, there are some algorithms you may find useful. The actual details of the implementation would vary, of course.

The source code for Hunter, In Darkness includes a maze created using a homebrew pseudorandom number generator.