I've been putting off the level generator for a long time. Every now and then I'd pick it up, get discouraged and push it aside for awhile. But it's been constantly bothering me because if I never get it done, I'll never be able to release anything and I know that I'm a bit overdue for a release now. It's still quite a way off, but now it's one step closer as I think I've almost got something I might be satisfied with.
I started off generating a few intersecting rectangles and creating a grid based on that:
After some more splitting, I started to combine rooms. Hallways will always combine as long as they are connected on a short side. Larger rooms combine if they can form a room under a certain size. I came up with something like this:
Still not good enough, so I added some more random variation...
It was starting to look pretty good, so I added doors!
It's still not complete. I need to work on the door placement and then I need to integrate it with the actual game map, but I think I'm done with the hard part at least.
I know I haven't released anything in a very long time (that's what rewrites do, sorry), but don't give up hope. I am constantly working, and tons of other stuff has been worked on that I haven't posted about. I'm just trying to do things right this time around and school is also getting in the way.
Hey man, those doors don't look so bad. From what I can tell, you are able to access every room in the building.
ReplyDeletePerhaps a high-tech wall-tunneling lazer gizmo could be invented too? Or explosives are always fun... :)
Wow that algorithm works rather nicely! I don't think I've ever seen building interiors in a RL that look so complex and realistic at the same time. Two questions: how do you decide what's a corridor? And what's the data structure behind that, a grid of tiles, a grid of room blocks, or something else?
ReplyDeleteWell I use several layers of data structures. On the lowest level there is a list of what I call "Sectors" which are the rectangles that make up the grid. Each sector has a pointer to its neighbors.
ReplyDeleteFrom there I pick a Random sector and create a new Room, which is a structure that holds a collection of Sectors. I then add adjacent Sectors to the Room until it reaches its randomly selected ideal size. If a room starts with a hallway "candidate" (any Sector with a dimension of 2), then it automatically adds adjacent hallways until there are no more. Once a Room is complete, I pick a new Sector until all Sectors are occupied.
That should answer your questions if I made it clear enough (which I probably didn't :P).
Anyway if I ever actually get this in a releasable state, you'll be able to examine the sloppily thrown together map generator yourself! :D
"Anyway if I ever actually get this in a releasable state, you'll be able to examine the sloppily thrown together map generator yourself"
ReplyDeleteSince you posted this comment in 2010, I'm wondering if it is still true? =D
Great work on the algorithm!