Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Procedural Generation for Dungeon Crawler  (Read 5414 times)

0 Members and 1 Guest are viewing this topic.

R23MJ

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Procedural Generation for Dungeon Crawler
« on: November 20, 2015, 01:34:23 am »
I recently decided to start working on a rogue-lite dungeon crawler, all was going well; Movement, collision detection, and even the art are all almost complete. Then I got to the level generation part, I have looked into several methods including Perlin Noise; however, all of the common methods seem to be for island generation. My goal is to generate a single room per floor, I'm not asking for code or examples, but if anyone knows of an efficient method for tile-based room generation please do share it's name so I can look into it. Thank you.



R23MJ

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Procedural Generation for Dungeon Crawler
« Reply #3 on: November 20, 2015, 02:46:23 pm »
Thank you both for the links, I read through most of them (which is the reason for the late response). They all seem to be for generating a floor or dungeon filled with rooms. My game, on the other hand, only has one room per floor. I am simply trying to generate the room. The current algorithm I am using generates the below room. Where you can walk on white, the player is red, the exit is green, and the blue is a blocked space.

http://i66.tinypic.com/swbcc0.jpg

To generate that, I simply "walk" a path from the start to the exit then re-roll all blue squares touching a white one. This doesn't yield the result I was hoping for though. I was looking for something more of a square room, with a wall of two placed somewhere at random, here is an image I found only the resembles what I want.


FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Procedural Generation for Dungeon Crawler
« Reply #4 on: November 20, 2015, 03:25:02 pm »
Two more links about procedural generation, second is a library even.
http://blendogames.com/news/?p=55
http://nothings.org/gamedev/herringbone/

I'd start with an empty room and add walls and items to it as long as the exit is not blocked by them (I never made random generator of levels so I might be wrong but that seems the most intuitive to me).
Back to C++ gamedev with SFML in May 2023

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Procedural Generation for Dungeon Crawler
« Reply #5 on: November 20, 2015, 05:36:23 pm »
Very simple algorithm I came up with:

- Fill your dungeon floor.
- For each corner, place a room of random dimensions (up to 3/4 of the floor's width/height).
- The bottom left one is at least wide/high enough to touch the top right one.
- The bottom right one is at least wide/high enough to touch the top left one.

While leaving lots of room for optimization, this gives you rather neat and simple results, some examples I hacked together in a quick PHP snippet (I'm aware that my offsets are wrong and some rooms are "drawn" with 0 width/height, but it still looks good as a proof of concept):

##########
#        #
#        #
#        #
#        #
#####    #
#        #
#        #
#        #
##########

##########
#####    #
#####    #
#        #
#        #
#    #####
#    #####
#        #
#        #
##########

##########
#      ###
#      ###
#      ###
#        #
#        #
#        #
#        #
#        #
##########

##########
#   #### #
#   #### #
#   #### #
#        #
#        #
#        #
#        #
#        #
##########

##########
#    #####
#    #####
#        #
#        #
#        #
#        #
#        #
#        #
##########

##########
#        #
#####    #
#####    #
#####    #
#####    #
#####    #
#        #
#        #
##########

##########
#        #
#        #
#        #
#        #
#####    #
#        #
#        #
#        #
##########

##########
####     #
####     #
#        #
#        #
#        #
#        #
#        #
#        #
##########

##########
# ####   #
# ####   #
#        #
#        #
#        #
#        #
#        #
#        #
##########

##########
#        #
#        #
#        #
###      #
#        #
#        #
#        #
#        #
##########

R23MJ

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Procedural Generation for Dungeon Crawler
« Reply #6 on: November 20, 2015, 07:37:10 pm »
Thank you Mario! That is exactly what I was looking for!

 

anything