Procedural Generation?

Hello,
I am currently attempting to make a true roguelike. Does anyone know how to make procedural generation, or at least partially randomly generated terrain? My goal is to have adjacent, connected rooms. Thanks!

1 Like
2 Likes

Could you help explain this to me? I understand completely how it works, but not how it is implemented. How could I implement the code into my own game, and how, if possible, can I make the rooms random sizes?

1 Like

Random sized rooms are pretty tricky for what my system does, I’m sure I could make a better version using lists but I don’t really have the time for that.

To implement it basically all you need to do is copy and paste the code, then change 2 Spawn behaviors

2 Likes

Okay, I love the ease of use and thank you so much for making that example.
However, I’m really annoying in that I really love learning how literally everything works. Could you explain how it works in brief? I want to make my own instead of copying and pasting, so I can understand it completely.

2 Likes

Brief being a relative term lol, this is gonna be interesting

1 Like

Sorry would have responded quicker but something in my house broke and I had to fix it.

(Also if you do plan to make your own I’m sure it can be much better than my own, I plan to remake this someday when I have some spare time. A system using Lists would be much more dynamic and flexible)

Ok, so for the random generation you need the start object.

  1. There is an input for the number of connections you want to have, what this does is it is basically a filter, a number is raised each time a connection is created, when this number is reached it will stop making connections.

  2. Ok, now for the generation. First you need to set the distance you want the generation to travel (This determines the room size). This is pretty is, basically you give a number and +/- the X/Y position.

  3. How I find a direction that is open I first send out 4 rays to make sure not to go in directions that it hits. if a ray does hit I remove a Number from a Number List (1 = up, 2 = right, etc.) Then when a direction is chosen I remove that number from the list so when it repeats that direction will be detected so closed.

  4. Now the generator spawns itself and the process is repeated.

  5. There is a global that raises by 1 each time a connection is made, this is done to ensure that the process ends and does not go on forever.

1 Like

For the rooms it’s pretty simple, it’s basically the distance between the Generation blocks/2 and +32 for the length of the room. I did some pretty funky math on this for some reason but it works good and I haven’t noticed any problems with it.

(The process of deleting the generation block is also pretty simple, just a proximity used to detect if there is another one on. If so it deletes itself.)

You can @me if you have any more questions about it. This is an oversimplification so there will be some parts missing and I made this awhile ago so it’s not fresh in my mind how it’s made.

1 Like

@CodeAlpaca Thank you so much for taking the time to respond. As this seems like a surmountable project, I will use your code as a placeholder and then begin work on making my own. Thanks for doing this! Also, where do you pick your variable size? I cannot find it within your code. I’m having trouble using the message blocks as well as whatever spawns new generators, I can’t find them anywhere. Are they in the same block?

1 Like


It should have a note saying this is the bundle with the Spawn in it.


Also for the walls all of these need to be changed (NOTE! They need to be different WALL objects, not GENERATOR objects)

1 Like

Lol wow, I thought all the disconnected blocks were just brainstorming ideas. This is… A lot, to say the least. I’ll do my best to understand it all.

1 Like

There are some disconnected blocks which were for brainstorming, those can be deleted

1 Like

I did delete them and it stopped generating anything.

Currently, corners are not even appearing at all. Any idea why?

which bundles did you delete?

1 Like

I never added the structure gen and the four connection bundles, which caused the entire system to not work. I pasted them in and it’s working fine, with the exception of corners, which just don’t appear.

What do you have the size of the room set as?

1 Like

I have not touched anything except to set the spawn blocks.

That’s really strange, would you mind sending the link? (I won’t be able to look at the game rn because I’m busy, but I’ll take a look later)

1 Like

The reason it doesn’t work is because of a weird glitch flowlab does when pasting code. It causes the outputs of bundles to either disappear or duplicate into non working outputs. If you create new outputs it will work

1 Like