31

Oct

2013

While still in the design phase for a couple of games I’m working on, I have been learning and experimenting with procedurally generated content. One of the most well known and documented examples is the creation of roguelike dungeons, so this was a good place to start. I thought I’d go into a bit of detail about how I’m creating these if anyone is interested.

 

After looking through many examples and taking bits and pieces from different places, I came up with a couple of methods of generating different kind of tile-based 2D environments. Firstly there’s the standard roguelike setup with rectangular rooms and snaky corridors connecting them. Here’s an example of one being generated:

 

dungeon_4

 

 

Firstly a number of rooms are added at random locations in a specified area. Many of them will overlap by chance. The overlapping ones show up in red. Separation is done by finding the centre of any intersecting rooms and moving them away from that point. Once all rooms are separated, the tiles are laid.

 

The edges of the rooms are filled in first, with wall tiles, and one doorway at the middle of each wall. Then the interior is filled in with floor tiles. Then the remaining tiles are filled in around the rooms. Corridors are added by using basic pathfinding techniques to move from the centre of each room to the centre of the room closest to the middle of the dungeon. Wall tiles cannot be passed through, so the corridors find one of the shortest paths available. There are multiple shortest paths so the direction taken is randomised at each tile to create a winding path.

 

Finally walls are added around the corridors and unreachable terrain is removed. There’s still much to be done to expand on this. Such as improving the ways that corridors are created so they aren’t all just reaching to the centre room, differently shaped rooms, and populating them with objects and enemies.

 

This may be used in conjunction with the method I’ve used to create cave systems, which I will cover in a later blog post.

 

caves_5

 

 

 

If you’d like to see some more gifs of dungeons and caves being generated, I’ve created galleries on imgur, here and here.

5 Comments

5 Comments

  1. Jason says:

    Are you still doing this? BTW, I’m loving your Let’s Plays.

    • Jim says:

      Thanks! Sorry about the absurdly late reply. I just did a big spam purge and found your comment among them. Unfortunately I have to have comments set to approval or the site gets inundated with crap. But yes I am still working on this game. I hope to have something to show off sometime this year, perhaps by the summer, but no promises ;)

  2. Paul Brown says:

    Any updates on the new game? Is it going to feature some of this, procedural generation? Keep rockin’ it.

    • Jim says:

      Thanks! It’s coming along slowly but surely. I’m waiting to release anything substantial about it until it’s a bit closer to being done. I want to make a good first impression and not keep people waiting too long once the hype is up. I’ll be using a different form of procedural generation to this one. The long narrow corridors aren’t really suitable for the mechanics of the game. I’m planning to rework the whole site when I’m ready to show more of the game, and I’ll surely make some videos when the time comes, so stay tuned :)

      • Paul Brown says:

        Good to hear it’s still coming along and can’t wait to see it. I know you’re keeping it close to the chest but that won’t stop me from pestering you every once in a while :D