Generating dungeons....

Posted by death on Aug. 2, 2012, 9:30 p.m.

is killing me. I can't seem to do it. I've looked up so much info on this, played with examples and it seems my low math skills and lack of programming experience cause me to fail every time. The only thing i need to do to finish my rpg is finish the dungeon generating code. I've tried different methods multiple times and i can't get the results i need. i can hardly understand most examples i found on the GMC. The BSP method made the most sense to me but i suck at using data structures such as grids which are needed. i can only write the most basic of code with them.

I don't think i can even ask for help at this point… again another project of mine comes crashing down completely due to my lack of skill… i really don't know what to do. i REALLY wanna finish this game but i just don't know what i can do. it's one of the most frustrating experiences i've forced myself into.

Everything else is done for the game too. Town generating, all the graphics, items, weapons, classes, etc. All i need is to generate dungeons, it can't be a full game without it and at this point, i can't hand make the dungeons - that would contradict every thing else in the game.

Does anyone have any good advice for randomly generating dungeons, or no of tutorials or examples for idiots like me?

Comments

LAR Games 12 years, 4 months ago

I think my lack of math skills is what kills me as well.

Cesque 12 years, 4 months ago

I suck at math and I can write a dungeon generator. Your argument is invalid.

In all seriousness, though, I've never written a proper one in GM. I've never used grids either.

The simplest way of generating dungeons: generate a single rectangular room which checks available space in all four directions (with some randomisation as to where it wants to generate more rooms and what size they should be). Every room generated this way does the same thing (check for space to generate more rooms), until you run out of space.

Iasper 12 years, 4 months ago

The one I've found the easiest is creating a grid and dividing it into squares/rectangles of the same size, then generating a room in one rectangle, generating another one in another rectangle and then connecting the two centers of the rooms with a road, then generating another room and connecting the second room with the new one, etc. Make sure rooms can overlap because that'll allow rooms to have 2 roads connected.

Rob 12 years, 4 months ago

That's more just Computer Science/programming than math… which is what you're going to college for anyways…

Rez 12 years, 4 months ago

Rob, you're a jerk.

Charlie Carlo 12 years, 4 months ago

I am equally suck at doing such things. However, I successfully did this once. My system went like this:

1) Populate every gridspace with a wall.

2) Create object that destroys walls at a random position. Let's call that object Jeff.

Jeff creates the player at his starting location, you could put the exit there as well, like stairs up or some shit.

3) Jeff then goes on a wall-murdering spree, going in a straight line and turning a random direction at random times.

4) When Jeff destroys a wall, he has a random chance to drop a random object (chests, doodads, monsters) at his postition.

5) The walls along the border of the room are off-limits to Jeff, so he just gives them the evil eye as he murders their brethren.

6) Then Jeff dies of a sudden heart attack at a random time, and drops an exit on his corpse. His death causes the room to become playable.

7) And all this happens really quickly, but not instantly, so I just covered it up with a "loading screen."

I know, I'm the greatest coder of all time.

HXC for life.

JuurianChi 12 years, 4 months ago

Logic is the first step to learning how exactly to code something.

You probably just need another day to mull over it.

death 12 years, 4 months ago

@Charlie Carlo: that method would end up with a bunch of randomness, it wouldn't be a legit dungeon, just a mess of walls and open space.

@lasper: that's similar to the BSP method i attempted, i only got as far as splitting the leafs multiple times but couldn't figure out how to randomize the actual room tiles and create good corridors to connect the rooms.

Quote:
That's more just Computer Science/programming than math… which is what you're going to college for anyways…
Yeah which is why i can't wait to get into the REAL courses. Though i'm afraid of not doing well or even worse, not improving/learning enough.

@Cesque: hmm do you have an example by any chance? sounds simple but i'm not sure if i understand fully. I think i had a similar idea of creating one room at a time and than a corridor to the next room and repeat the process but it's still a pain in the ass to code along with how my tiles/objects work.

Iasper 12 years, 4 months ago

I first create the full dungeon floor in a ds_grid, then turn it into objects and make the objects give themselves random tiles and adapt to their environment, so my ds_grid only has 2 values (0 for floor and 1 for wall). For corridors, I just take the center of the two rooms, then first create a line until the X value is the same, then a line from there to the center of the second room. The dungeon is simple and fairly easy but it works. I can give you the code of a generator if you want.

Cesque 12 years, 4 months ago

Quote:
@Cesque: hmm do you have an example by any chance? sounds simple but i'm not sure if i understand fully. I think i had a similar idea of creating one room at a time and than a corridor to the next room and repeat the process but it's still a pain in the ass to code along with how my tiles/objects work.

I have a Python example… so let's just say I don't have one. I've never used lists or grids in GM.

But I think you could even do it without a grid in GM, if you make walls objects and use their (non)presence to determine if there's a room in a particular spot. Of course, that would be really basic.