1
\$\begingroup\$

I'm working on a game that I want dungeon generating in, but I plan on having ranged weapons in it, so I want it a bit more open. I'd like to avoid corridors and I don't want to use a grid of custom rooms.

I don't want to use perlin noise and make it like random blotches, so that's not an option.

All I need is a summary of how the ideal algorithm for this works.

EDIT: Something that gives a result like this: example

It doesn't need to be so rounded. The point is that there aren't really corridors.

I'm also fine with a modular approach where the areas are hand made as long as it's still not on a grid. The issue is that if it's not on a grid, the areas are normally connected by corridors.

EDIT2: I made this a while ago, which works when it comes to shape, but it works with a modular system and it looks like this because I intentionally put rooms on top of other rooms. This causes problems if I start decorating the rooms and filling them with interesting stuff.

\$\endgroup\$
1
\$\begingroup\$

What you're asking for is more of a feature or aspect of a procedural dungeon generator, rather than a generator itself. There are two ways to achieve more spacious layouts:

Generate spacious features

Are you using a traditional rooms-and-corridors generator? Instead of digging 1-tile-wide corridors, create wider corridors1. Adjust other features too, like wider doors.

Does your generator place random obstacles or walls onto open space? Ensure that there is enough space around the obstacle, so you do not create narrow passages.

Having such features ensures that you do not generate cramped layouts in the first place.

Another method is to run a generator on a larger scale. This would naturally create spacious layouts. Then add fine details to mask the scale.

Modify/reject closed layouts

Are you using a generator where it's difficult to avoid cramped spaces, like a noise-based generator (e.g. Perlin)? You can deal with this by detecting cramped features, and either modify the layout (e.g. enlarging the choke-points) or reject the layout entirely and generate again using a different random seed.

There are different ways to detect cramped features, like this one.

You could also accept some cramped areas and go for a good-enough approach. The cellular automata algorithm is generally good at avoiding 1-tile-wide features.


1 Example here. This algorithm generates corridors that are 3-tiles-wide.

\$\endgroup\$
1
\$\begingroup\$

When you want to generate cave-like maps, you should usually use a cellular automata. You can find the long version here, but I'll summarize it.

First, the map is filled in randomly with walls and air, then for each wall or air, you check how many of its neighbours are walls. If the current tile is a wall, and there are at least 4 other walls around it, then it stays the same, otherwise it turns into air. If it's air and has at least 5 wall neighbours, then it becomes a wall, otherwise it stays air.

After you repeat this for every tile multiple times you get a pretty organic looking map. It might have multiple sections (open spaces) in it though. To circumvent this, try using a floodfill alogorithm on every unchecked air block, and if it finishes, but leaves other air blocks on the map, then that means there are multiple rooms. Try finding them and either connecting them or filling the smaller one in with walls.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.