Print Page

Sunday, November 9, 2014

Working on a Dungeon Generator

Yesterday I started coding on a project that I have been mulling over for awhile. It's a JavaScript random dungeon generator that will produce both a graph linking location nodes with edges that are hallways or doors, and populate it, with OSR, D&D5e, Dungeon World and Barbarians of Lemuria as likely systems I would consider stocking for.

Here is an example of the current output using a branching algorithm to generate the edges. The names for nodes and edges are simply being randomized out of arrays so far and it is not yet stocking with monsters, traps, loot, and details. It will get smarter. I'm working now on an algorithm that will add some looping without making it too tangled.

Since I am using VisJS's graph drawing module, it will arrange itself with physics springs, with some manipulation available out of the box and with editing tweaks available, so you should be able to add/edit/move/remove links and rooms eventually.

It's pure JS/HTML/CSS, so I'll be able to put it up for you to play with pretty soon. I don't know yet the tech stack I'll be using beyond VisJS. I've been looking at Meteor lately, so that may be what I explore when I get to storage and server parts. Rails would be easiest for me serverside, but I'd like to do a project bigger than a toy that has a JavaScript server.

Here is the very rough plan, with the intention being that at the end of each sprint there is some usable new functionality, and if I should burn out, whatever is done can stand. The order of some pieces will likely change.

First sprint:
Generate a dungeon graph with some simple labelling on nodes and edges. Have a couple of selectable linking strategies, one that is more gridlike and one that builds clusters and adds sparse links between them.  Deploy to a web page for people to play with. This one is beyond half done. Should have a couple of decent algorithms for hooking things up by the end of the day.

Second sprint
Start stocking critters/traps/treasure. Include a table beneath the graph that lists the contents.  Push the repo to GitHub.

Third sprint
Flesh out editing so that changes get back to the models and include editing labels and descriptions.

Fourth sprint
Add local data saving and retrieval with an index listing of dungeons you have generated, so you can go back to them and use/edit them from the app.

Fifth sprint
Add a server layer and authentication so by making an account, you can save a dungeon to a server and retrieve it on another device. Publishing for shared/public editing?

Sixth sprint
Theming tables - modularize the randomization tables so that a level can be generated with themed sets, and add controls to dial up and down the ratios of empty/traps/monsters/treasure/features. Explore adjacency effects in the randomization, so that a level can have themed groups of areas with some coherency in how they are stocked, and possibly a layering of stuff that makes sense at the border vs the interior of a set, relations between neighbors, etc. Adding Wilderness hexcrawl theming tables would make great sense at this stage.

Seventh sprint
Open up random tables so users can create their own and "publish" tables that others could select for populating a dungeon. Or possibly hook to some of the other internet random dungeon population resources for contents, see if Abulafia has API access or accepts scraping, Dungeon Dozen links for specials, etc.

P.S. It is up and running at with most of Sprints 1 and 2 done. Further revision to balance treasure to monsters and allow level selection and refresh without page reload in the works. Also planning to make some of the rarer room and connection types be done deck of cards instead of dice table style so you can't get three gazebos like I saw once, and start towards theming by holding weaker monster types once rolled so they are more likely to reoccur. Then probably some fleshing out of the treasure and magic items tables before going on to sprints 3 and 4 for editing and saving.

No comments:

Post a Comment