12

I'm creating a game and need to create a random 2d map of a castle or a similar building. It should look like blueprints, i.e. shot from above and only lines are used.

I'm looking for some algorithm that does this. I'm not so interested in the code, but the algorithm itself. Where to start and how to fill the desired area?

2 Answers 2

13

There are a lot of different algorithms that have been developed over the last 30 to 40 years, and they all produce quite different results.

Check out this wiki:

http://pcg.wikidot.com

Particularly these pages:

That site seems to have links to algorithms on pretty much any procedural content generation you'd want to do.

4
  • Thanks, the "dungeon generation" link does give some good ideas where to start. Aug 26, 2011 at 21:45
  • 2
    If you want blueprint-like behavior, then a 2d simplification of the algorithms in this article might be a good place to start. This could give you basic room layouts within a house, then you could apply things like splitting, etc. and randomize the connection placements. This would probably give you better results than the dungeon generation algorithms I've read about before, because it would better represent the shapes in above-ground buildings, rather than dug-out shapes. Aug 26, 2011 at 22:00
  • @MerlynMorgan-Graham that link seems to be dead wayback link here web.archive.org/web/20110830033753/http://www.vision.ee.ethz.ch/… Oct 13, 2014 at 13:57
  • dl.acm.org/citation.cfm?id=1141931 is the official link, which has a paywall. I can't find the article for free from a reputable source. The PCG page on City Generation has a link to a whitepaper version of the same (whether it is from a legit source or not is hard for me to determine). Not sure if it is identical, but it seems to be the same research. Oct 13, 2014 at 23:21
0

A maze best describes a random 2D map of an internal structure. What you need is a maze generation algorithm. After implementing the basics you could add your own implementation of random "room" placement etc.

5
  • Mazes are different than castles. Castles need to have rooms, with many doors, allowing free movement. BTW, I already have a different level with maze in this game and that Wikipedia page was my starting point while making it ;) Aug 26, 2011 at 21:34
  • there's more than one way to do it. a maze works pretty well for dungeon generation, but a castle interior is different... I'd fire my architect if they made my house look like a maze with rooms slapped in it.
    – lunixbochs
    Aug 26, 2011 at 21:34
  • This isn't a bad approach, but you may want to do it the other way around. Make the rooms first, then bore semi-random tunnels between them. Aug 26, 2011 at 21:39
  • 1
    Well, most of the rooms in a castle are usually symmetric. Aug 26, 2011 at 22:04
  • 1
    @Milan: In a castle, you might want to generate content, pick at random whether you have 2-way or 4-way symmetry, throw out all but 1/4 or 1/2 the content, and mirror it. Then you could add back to it if you wanted, having achieved the basic symmetry. You would do this before creating doorways, though, or you could end up with some funky looking narrow double-doors :) Aug 26, 2011 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.