The code for the first release of the jp_DungeonGenerator library is pretty much done, barring an unforseen bug. The only thing I've got left to do before it's really ready for release is write a helpfile, which I most certainly will be doing - I intend to do this library right. But if you're brave enough to fiddle around with some reasonably complicated and probably quite brittle code written by someone with an aversion to commenting, without a roadmap, here it is:
There are several examples provided in the demo for the generator, but they're currently uncommented (This will be fixed for release), and the general contract for the generator and the rooms is not explained anywhere so far (Which will be fixed for release). Violation of that contract can quite easily cause runtime errors, so it's probably best to hold off for now.
But I thought I should run through what the generator can do. So here are the examples:
We start off with a really simple example, called, unsurprisingly enough, 'simple':
All the 'simple' example does is generate a map consisting of a few rectangular rooms with the same size, and then ensure that they're all reachable. The map won't have any loops, nothing particularly exciting or interesting. But we've got to start somewhere, right?
A slightly more interesting example is 'loops'. It sets the generator up to add some extra link above and beyond those required for reachability, and ends up looking something like this:
Same rectangular rooms with the same sizes, but now there are a number of loops, if you look closely. Simple, reasonably fast, gets the job done, but not very exciting.
Let's spice up those rooms a bit - perhaps we want rooms with different shapes?
The 'rooms' example makes the dungeon with four different types of room - the square you've been seeing so much of, a circle, a cross, and finally a room I've created for the examples called 'deadend', which is one tile of floor, and ensures that a path will only ever enter it from one square - unsurprisingly, this causes dead-ends - you can see several of them in the screenshot.
Maybe if you had a big vault room and wanted some paths around the edge, you could do something like this:
The 'centered' example just places one large room and then draws a number of paths around the outside of it - could be quite useful in some circumstances. When two certain features are added to the generator later, this style will be much more useful - more on that on release.
All of the dungeons to date have looked somewhat clean, artificial - they look like rooms cut into rock by an intelligent being, not, say, a cave. Well, with a little bit of work, you can get something like this:
The 'cavern' example uses another room I wrote specifically for the demonstration (All these room datums are in the example source, by the way, so you can see how they work). It generates a few blobby masses using the 'cavern' room, then links them together, and then finally does a postprocessing step where it runs through every wall bordering a floor in the dungeon, and does an if(prob(EROSION_PROB)) new /turf/floor thing on it (EROSION_PROB is set to 30 in the example). That's a very simplistic implementation, of course, but it's more to demonstrate some of the postprocessing you could do to generator output.
All these dungeons are a little bare - there's nothing in them but floor and wall. So, I whipped up a few rooms that place some furniture and generated a dungeon with them:
The 'furnished' example places some rooms with a fountain in the middle, rooms with a few pillars near the middle, dead ends, and finally, some rooms that place doors on the entrances to the room. Excuse my pixel art, but you can get a fair idea of what's going on.
There should be a helpfile and a proper release in 48 hours at max. Until then, you'll just have to play with the code if you want to figure out how things work.
Copyright © 2015 BYOND. All rights reserved.