Random Generation

Hi there, I don’t know if anyone will actually be able to help me.

I am attempting to create a randomly generated dungeon exploring game. In a way like Binding of Isaac. I am currently building a bunch of rooms and was wondering, if someone knows how I can make it so when the game starts it will choose a bunch of them and piece them together like a puzzle to create a dungeon.

Any help to getting this working is greatly appreciated as I have been looking around for quiet some time now with no luck.

Thanks, Luke

Hello, what you are asking for is a lot. Generating random dungeon that you are able to explore is no easy task. I googled something similar you a looking for. Here is the link :

This one should give you the idea of how to generate stuff on the go:

This should take you in the right path. If you are new to programming it will be a challenge but I am not saying it is not possible. However I doubt there is someone that will code it for you in their free time :slight_smile:

One solution would be to use L-systems. You create replacement rules that convert doorway tokens, call them D(x,y), to rooms.

You initially start with one token, and then iteratively apply a replacement rule.

For example, Room One would look like this:
T(x,y) → R1, D(x+4,y+2), D(x+8, y-2)

R1 is the room itself, and it has two new doorway tokens with relative offsets that can further be expanded into new rooms. You need a rule like this for each room you create (possibly, 4 rules for each if you want to rotate the rooms randomly as well). You will also need a “terminal” room that is simple a piece of wall that terminates all tokens that don’t have enough space to fit a room.

For each replacement step you need to:

  • Select a token
  • Find all rules that can be applied here (you will need to exclude rooms that cannot physically fit)
  • Randomly select a valid rule (or apply a special probability functions to influence the output)

The more rooms you have the better. You can also create tokens for other aspects of your dungeon: T for treasure, X for traps, A for a doorway that create a different styles of rooms, etc., etc. You create replacement rules for these as well.

An advantage of this method is that you always know that the player can traverse the entire dungeon since it is built as a tree. It takes a lot of rules to make non-repetitious dungeons, and can be tricky to control the output if you want to tweak the way dungeons are generated.