I've been working on a dungeon generator, so I thought I'd share what I've done so far.
Here's a
load of examples.
Here's a
screenshot of the application.
Most of the examples are intentionally far bigger than I would use in a real game, because it's easier for me to test with larger maps and more stuff can be seen.
It's written in Visual Basic 6 in about 1,500 lines of code. The steps go like this:
1. Generate a perfect maze, which is a maze where every square can reach every other, with no loops. (
image)
2. Depending on the size of the area, we may allocate some large spaces for mazes, caves or prisons. The bigger the area, the higher than chance of more being created. (
image)
3. Overlay lots of rooms. 10% are circular. 90% are rectangular. Rectangular rooms may have additional bits carved out of the corners of them to make them less boring. (
image)
4. All dead ends are removed. (
image)
5. Doors are added everywhere that a corridor meets a room. (
image)
6. Any corridors that loop back to the room they exited from are removed. (
image)
7. If two rooms have multiple non-intersecting corridors between them, all but one is removed. (
image)
8. The contents of the special rooms is created. (
image)
9. Corridors are shortened. (
image)
The basic code is almost complete, except for two things. The first is that only some corridors get shortened. Intersection-to-intersection and intersection-to-cave corridors aren't shortened yet, because the shortening code uses doors to find the corridors. The second is that the flood fill code needs to be rewritten from the first method
here to one of the others.
Once the dungeon generator is done and optimised, I can work out the purpose of each room (wizards lab, barracks, food store, shop, creature lair, etc). Then I just need to make the creatures, magic, items, combat, high scores, inventory, gods, interface, minimap, quickbar, skills, conducts, ai, difficulty levels, harvesting, story...