How do I do random generation?

0 favourites
  • 8 posts
From the Asset Store
Template for dungeon/maze generation, using wave function collapse
  • I would like to learn how to create rougelike games, but have no idea where to start with the random generation. Can anybody give me some tips, or tutorial for getting to know, and learning to do random dungeon generation? Also on creating an infinite world generation.

  • Im currently working on a dungeon generator, but im far from an expert on the subject.

    But I started out trying to make one with path finding.

    Demo of the dungeon generator - Alpha: Demo of the dungeon generator - using path finding

    1. Path finding

    The idea behind it was to add X amount of rooms at random locations with random sizes. Each room then get a minimum of 1 door and as far as I remember the larger the room the more doors. These doors then work as connection points, which are added to a list. When all the doors have been added, it take a random door and path find to another random door on the list. And it just keep doing that until there are no more doors. The path that the path finder find between the doors are then turned into halls, and when its done it create walls around all floor tiles. The problem with this one, was that I found it a bit slow, even though I could have optimized it. But it also was quite complex to make and it does contain some problems where certain rooms might end up not being reachable. So I dropped it due to these things and then because it didn't really fit what I wanted for my game when I thought about it.

    2. Node system

    So I took a different approach which is a node system, that is easier to make. The idea is that each tile only have so many possibilities when it comes to how you can actually place them.

    To start the dungeon I start a random place, and then expand the dungeon from there.

    And it will keep expanding that way.

    Then I added a functionality that will either force the dungeon to stop expanding or force it to keep growing, which is done so im able to create different sizes.

    Then when its done making the whole dungeon, there are actually a lot of tiles that are messed up, because you cant be sure how it expand, so I complete it by running a clean up that correct all tiles. And when this is done its pretty simply to pick random tiles and replace them with room tiles since I only need rooms that are one tile I don't need to worry about where the rooms are connected as they will always be connected correctly, compared to the one with path finding, where im not sure where the doors will actually be placed.

    Demo of the dungeon generator version 2.1 - Alpha: Demo of the dungeon generator version 2.1 - node system

    But for both types or any time I think, its pretty much about setting up restrictions and rules for how things should work. But a good idea I think, at least it helped me a lot, is to take a piece of paper and then try to draw how you imagine it should work or make the tiles and just add them manual on a tilemap while trying to figure out what rules should apply and how you want it to work. But personally I think its one of the most difficult things to do, because there are so many rules and when bugs happen it can be quite hard to figure out what wrong.

  • nimos100, that's seriously cool. It's times like this that I wish these forums had a +rep/thanks button.

    You've already been very informative, but is there any chance you'd be keen on writing a formal tutorial with a capx? Or perhaps two tutorials - one with the pathfinding and another with the node-based technique?

  • nimos100, that's seriously cool. It's times like this that I wish these forums had a +rep/thanks button.

    You've already been very informative, but is there any chance you'd be keen on writing a formal tutorial with a capx? Or perhaps two tutorials - one with the pathfinding and another with the node-based technique?

    I guess I could do it. But don't think ill make one for the first, it was my first attempt to make one and it contain to many bugs, which i see no reason to introduce into a tutorial

    But the node based technique I guess I could as it works pretty solid from what I can see, even though Im pretty sure its not optimized. But it could serve as a good starting point for someone else that can maybe improve it into something better.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sweet room generation, man. Keep us posted on your progress. Keen to see how you go about populating these meaningfully, procedural level design ftw

  • Sweet room generation, man. Keep us posted on your progress. Keen to see how you go about populating these meaningfully, procedural level design ftw

    This is the latest version and the one ill do the tutorial based on, as its more complete and functional, as it uses line of sight and player can move around with WSAD.

    Demo of the dungeon generator version 2.2 - Alpha: Demo of the dungeon generator version 2.2

    I don't really plan on populating the dungeon in the sense you would see in a normal rogue style game, as the one I need for my game is more a zoomed out map. As combat is not actually taking place on this map, but in a separate one which is a tactical combat. So if the player encounter a group of monster they are taken to another layout to fight, so I don't need to populate it with things. But I don't think its a huge problem to do it, you could just copy/paste how the rooms are generate or how the player is placed and just make it work with monsters and items. Also think it would be fairly easy to expand the design so the room generator makes bigger rooms that are more like a normal rogue style game. But someone else will have to make that part

  • nimos100, that's seriously cool. It's times like this that I wish these forums had a +rep/thanks button.

    You've already been very informative, but is there any chance you'd be keen on writing a formal tutorial with a capx? Or perhaps two tutorials - one with the pathfinding and another with the node-based technique?

    I have made a tutorial for the node based dungeon generator and it was rough i have to admit, takes a lot longer time than you would think, so pretty sure it will be some time before ill do that again.

    You can find it here:

    https://www.scirra.com/tutorials/999/random-dungeon-generator-node-based

  • Thank you so much nimos100

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)