Automated Map Generation, Version 0.1

The first post on this topic is here.

I changed my approach somewhat. I decided to make it all simpler and rely on “happy accidents”.

First, I select randomly two or three entrances. These are always along the same side of the image. I decided to have at least two, because it seemed to provide interesting looking maps. The entrances can be in widely different parts of the map, but if they converge, and they often do, its pretty nice looking. After this, I add one to three other starting points to the map. I don’t know if this is the right number, but it feels like it.

After this, I start to draw lines around imaginary ellipses, which line up from these starting points. They move into a direction, but will deviate from that direction randomly. There’s a 4% (1 in 25) chance that a larger room is drawn and one is also drawn at the end of each tunnel.

dungeons-sketch

After all this is done, I fill the imaginary ellipses with white, thus eradicating most of the lines within the rooms and the tunnels. This leaves plenty of garbage (as you can see), but I haven’t quite figured out a better way to get rid of them. I can probably adjust numbers here and there to make them look better, but its hard to find right number, as if I lower it too much, the white filled ellipses will cut some of the outlines and leave whitespace within the walls. Maybe I can live with that. You tell me:

dungeons-final

dungeons-clean

One problem with this right now is with browsers. At least my browser will reload the picture when I try to save the picture, meaning that it will redo the whole thing. The above ones are done with the random seed of 1 (thus not really random at all, if you know how these work).

Here’s the code (zipped, because attaching PHP-code is not allowed by the software): Dungeons. It’s the latter version of the above and it has the preset seed of 1, which you can comment out or change as you will.

One thought on “Automated Map Generation, Version 0.1

  1. Pingback: My #mapvember | Guild Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.