Got stuck with a Roguelike Game

Hi,

I got stuck figuring out how to generate dungeons in a Roguelike game. I don’t understand how to make dungeon rooms be close to each other so that there are no long passageways between them. (like here)

I fond this guide but it seems too difficult to grasp.

I also found that most of the algorithms are way more complicated than we need.

I can’t help you with making rooms very close together because mine were a bit further apart. But here is how I did it. It might give you some ideas

  • define the minimum and maximum size for a room.

CREATE ROOM:

  • choose a starting point at random and try to create a random-size room. The starting point is the top left corner, and make sure all the points of the potential room are available / exist. If not, don’t create the room. If all is well, create the room, and save one random point from that room into an array.

  • repeat a number of times (I think I did 100) - most of the rooms will fail, but you will end up with a good number of room. Play around with the number of trials and the size of the rooms until you get good results.

CREATE CORRIDORS:

  • Once that is done, you are left with an array containing one point from every room that was created. Using this array, create a path from the first point to the second. Then from the second to the third, etc.
    Some paths will cross other rooms, but you are guaranteed that all the rooms are connected by at least one path.

You might be able to minimize the long corridors by allowing overlap between the rooms, or making more trials to create rooms to minimize empty space. Allowing for very small rooms might help too.

1 Like