<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>natewm.com &#187; dungeon</title>
	<atom:link href="http://natewm.com/blog/tag/dungeon/feed/" rel="self" type="application/rss+xml" />
	<link>http://natewm.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 26 Jul 2010 19:43:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Procedural Adventure Map Generation</title>
		<link>http://natewm.com/blog/2009/04/26/procedural-adventure-map-generation/</link>
		<comments>http://natewm.com/blog/2009/04/26/procedural-adventure-map-generation/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 20:40:47 +0000</pubDate>
		<dc:creator>Nate</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[adventure]]></category>
		<category><![CDATA[dungeon]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[procedural]]></category>
		<category><![CDATA[world]]></category>

		<guid isPermaLink="false">http://natewm.com/blog/?p=99</guid>
		<description><![CDATA[A few days ago I was thinking about how to procedurally generate interesting maps for an adventure game.  I did not want them to look like they were generated by an algorithm, but instead would be convincing enough to appear as if it had been designed by a human.  I wanted the maps to both [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I was thinking about how to procedurally generate interesting maps for an adventure game.  I did not want them to look like they were generated by an algorithm, but instead would be convincing enough to appear as if it had been designed by a human.  I wanted the maps to both have a natural appearance and a nice flow of game-play similar to a Zelda game.</p>
<p>This article will outline how such a procedurally generated map could be made.  Note, I have not yet written the program.  All the illustrations shown here were hand-drawn, but the results of a real implementation of this generater should be the same.</p>
<h3>Room Seeds</h3>
<div id="attachment_100" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-100" title="map_gen_01" src="http://natewm.com/blog/../media/blog/2009/04/map_gen_01.png" alt="Starting locations for rooms to grow from." width="320" height="320" /><p class="wp-caption-text">Starting locations for rooms to grow from.</p></div>
<p>The first thing to do is to randomly select starting locations to grow rooms from, as indicated as green circles.  These locations will be stored in a list of grid cells.</p>
<h3>Grow Rooms</h3>
<div id="attachment_101" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-101" title="map_gen_02" src="http://natewm.com/blog/../media/blog/2009/04/map_gen_02.png" alt="Rooms grown to fill cells." width="320" height="320" /><p class="wp-caption-text">Rooms grown to fill cells.</p></div>
<p>A cell will be randomly selected from the list of active cells.  If the cell has empty neighboring cell that will be activated, given the same room id, and added to the active cell list.  If the cell has no available empty neighboring cell it would be removed from the list.  This loops until all of the cells are filled, defining the shapes of each of the rooms.  The growth pattern is shown as blue lines and the room boundaries are indicated as black lines.</p>
<h3>Connectivity</h3>
<div id="attachment_102" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-102" title="map_gen_03" src="http://natewm.com/blog/../media/blog/2009/04/map_gen_03.png" alt="Finding how the rooms are connected." width="320" height="320" /><p class="wp-caption-text">Finding how the rooms are connected.</p></div>
<p>The cells of neighboring rooms will be noted and a list of possible door locations will created.  These possible door locations are indicated as short red lines.</p>
<p>A separate list will be generated noting what rooms are accessible to each other room.  The links between rooms are shown here as pale yellow lines.  No spacial information is needed, but for illustration purposes I&#8217;m using the room seeds to make the connectivity easier to see.</p>
<h3>Flow of game-play</h3>
<div id="attachment_105" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-105" title="map_gen_041" src="http://natewm.com/blog/../media/blog/2009/04/map_gen_041.png" alt="Flow of game-play connectivity." width="320" height="320" /><p class="wp-caption-text">Flow of game-play connectivity.</p></div>
<p>A starting location will be selected.  If this is the game&#8217;s over-world then the starting point may be any random room.  If this is an interior location, such as a castle, an outer room may be a better choice.  The starting location is shown as a little star here.</p>
<p>Starting from the start location connecting paths between rooms will be defined.  A running inventory of items obtained in rooms will be kept track of, such as the collecting of keys.  If a key is available then a locked door between rooms may be defined.  This will result in the creation of a new room group.  The room groups are shown as colored lines with the group id and group depth level also indicated.</p>
<p>Interlinking between rooms of the same group may be fairly common.  Cross linking between rooms of the same group depth level should be more rare to make sure rooms or whole groups are not skipped too often.</p>
<p>Keys will keep track of what room group id they were obtained in.  Keys should only be used in room groups of greater or equal group id to make sure the player doesn&#8217;t get stuck by choosing a different order of game-play &#8212; since any key can open any door and the key dissappears after use.  Use-once and infinite-use items do not need as much care since there is no risk of cutting off access to pathways.</p>
<h3>Defining Doors</h3>
<div id="attachment_104" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-104" title="map_gen_05" src="http://natewm.com/blog/../media/blog/2009/04/map_gen_05.png" alt="Choosing where doors will go." width="320" height="320" /><p class="wp-caption-text">Choosing where doors will go.</p></div>
<p>Doors will be selected from the possible door locations list.  In the above illustration unlocked doors are white and locked doors are yellow.  I also shown where keys may be obtained.</p>
<p>Doors do not need to be a single space.  Several doors may be selected, whole walls removed, or any other pattern of connectivity could be used depending on situation and desired result.</p>
<h3>Using room growth info</h3>
<div id="attachment_107" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-107" title="map_gen_061" src="http://natewm.com/blog/../media/blog/2009/04/map_gen_061.png" alt="Using room growth information." width="320" height="320" /><p class="wp-caption-text">Using room growth information.</p></div>
<p>Dead ends in the room growth process can be useful.  As long as the cell is not in front of a door, we know the player does not need to cross through these cells to reach other areas in the game.  These cells can safely be blocked off if we wanted them to be.</p>
<h3>Beautification</h3>
<div id="attachment_110" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-110" title="map_gen_071" src="http://natewm.com/blog/../media/blog/2009/04/map_gen_071.jpg" alt="Final map." width="320" height="320" /><p class="wp-caption-text">Final map.</p></div>
<p>We can now use all the information we had gathered in the previous steps to generate the final map.  Here I filled in the spaces between the rooms and the dead ends with trees.  I also added a few other decorations just to make it not look so sparse.</p>
<p>And there you have it &#8212; an intersting procedurally generated map ready to be explored.</p>
]]></content:encoded>
			<wfw:commentRss>http://natewm.com/blog/2009/04/26/procedural-adventure-map-generation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
