<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>random Pacman style grid?</title>
		<link>http://www.allegro.cc/forums/view/590486</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 12 Mar 2007 01:04:18 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have started to work on a Pacman style game and I want it to have randomly generated maps.  I quickly realized, however, that I don&#39;t really know how to make a randomly generated Pacman style map that looks good.  Does anybody on here have a Pacman game with a random map system that I could look at?</p><p>I know how to make randomly generated mazes, but since Pacman doesn&#39;t really have a &quot;maze&quot; the algorithms that make mazes don&#39;t produce good looking Pacman levels (in my opinion at least).</p><p>The main problem I realized is that you can&#39;t just randomly put a bunch of walls on the screen. I am trying to preserve one thing about the original Pacman game&#39;s walls:</p><p>The game only has one path of dots on the screen that can be followed.  In other words, you can think of the Pacman grid as being a system of tunnels that are only as big as Pacman and no bigger.  The walls interlock to form tunnels that are only as wide as Pacman.  If you randomly put a bunch of walls on the screen it&#39;s hard to preserve that feature.</p><p>What I currently have is a system that produces a bunch of walls like in the jpeg shown below:</p><p><span class="remote-thumbnail"><span class="json">{"name":"591485","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/9\/692858f501f5f82ca8ed39648c9a17d8.jpg","w":632,"h":477,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/9\/692858f501f5f82ca8ed39648c9a17d8"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/6/9/692858f501f5f82ca8ed39648c9a17d8-240.jpg" alt="591485" width="240" height="181" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kholdstayr)</author>
		<pubDate>Sat, 10 Mar 2007 22:28:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;ll need to make the walls thin and not tileset blocky.</p><p>You could do what you just did with the ground generation, then go through the map and see which directions you can move. For each of the tiles&#39; up|down|left|right; if it is impassible, then put a wall (line) there.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Sat, 10 Mar 2007 22:50:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Also remember that pacman maps are left-right symmetric.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Sat, 10 Mar 2007 23:35:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That may work well if you generate 1/4 of the map and mirror vertically and horizontally to make an entire map.  That would keep the symmetry there.  For example:<br /><span class="remote-thumbnail"><span class="json">{"name":"img","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/9\/a969d0f721a1e754b1a5d2d2edc68297.jpg","w":632,"h":477,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/9\/a969d0f721a1e754b1a5d2d2edc68297"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/a/9/a969d0f721a1e754b1a5d2d2edc68297-240.jpg" alt="img" width="240" height="181" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve Terry)</author>
		<pubDate>Sun, 11 Mar 2007 01:50:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the replies.  I think I will mirror the map like you two suggested.  I also changed my random block system a little to generate smaller blocks.  When I get my grid code finished I&#39;ll show you all what it looks like.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kholdstayr)</author>
		<pubDate>Sun, 11 Mar 2007 04:07:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here&#39;s my pacman-oriented random map generator. Comes from my unfinished project of a pacman clone <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>If you run t1.exe in /test you should get an image dump of the generated map. It looks like I wrote that in 2005, so I can&#39;t guarantee I can give much help about it, but comments are in the code and you can of course ask, I try to answer to my best <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>Included is the <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">Mersenne Twister</a>(downloaded at the time of coding) random number generator.</p><p>[edit]</p><p>It doesn&#39;t generate mirrored maps, and it supports any resolutions, but the map checking code for 1280x1024 can be a bit slow, the algorithm is very simple.</p><p>Here&#39;s an image of a generated map @ 640x480</p><p><span class="remote-thumbnail"><span class="json">{"name":"591503","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/7\/b792f1dd3909746045183a3d8c39aa80.png","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/7\/b792f1dd3909746045183a3d8c39aa80"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/b/7/b792f1dd3909746045183a3d8c39aa80-240.jpg" alt="591503" width="240" height="180" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marco Radaelli)</author>
		<pubDate>Sun, 11 Mar 2007 04:17:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t like the dead ends all over the place.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Sun, 11 Mar 2007 04:29:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Marco, did you post a link to your code?  I am not seeing any download links for your code in your post.</p><p>Anyway, I added a symmetrical setup now with a gap area where the ghosts&#39; &quot;base&quot; is going to be.  In the following screenshot there are no variations in the wall blocks because I got rid of some of my earlier code.  I am working on a new block making system where I have to hand design the blocks (the blocks are represented in the program by integers ).  Once I put a block in I can have the block randomly be flipped vertically, horizontally, or rotated to add some variations to make one block look like a different block.  Right now there is only one block type in the game.  Eventually I am going to put bitmaps in to make the blocks look a little better than a filled rectangle.</p><p><span class="remote-thumbnail"><span class="json">{"name":"591506 ","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/6\/66c62cb0f8dfff0e60f260cd840c900c.jpg","w":460,"h":443,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/6\/66c62cb0f8dfff0e60f260cd840c900c"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/6/6/66c62cb0f8dfff0e60f260cd840c900c-240.jpg" alt="591506 " width="240" height="231" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kholdstayr)</author>
		<pubDate>Sun, 11 Mar 2007 04:31:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I don&#39;t like the dead ends all over the place.
</p></div></div><p>
Personal taste <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /> IIRC there were in the original PacMan, don&#39;t they?</p><p>[edit]</p><div class="quote_container"><div class="title">kholdstayr said:</div><div class="quote"><p>

Marco, did you post a link to your code? I am not seeing any download links for your code in your post.
</p></div></div><p>
It&#39;s attached in my previous post <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marco Radaelli)</author>
		<pubDate>Sun, 11 Mar 2007 04:31:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
there were in the original PacMan, don&#39;t they?
</p></div></div><p>

That&#39;s just the thing; there weren&#39;t. There are no dead ends in Pacman.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Sun, 11 Mar 2007 04:36:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Marco, the program stuff you attached is missing the &quot;map.c&quot; file.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kholdstayr)</author>
		<pubDate>Sun, 11 Mar 2007 04:47:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
That&#39;s just the thing; there weren&#39;t. There are no dead ends in Pacman.
</p></div></div><p>
Cool <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> So mine could have a special feature <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>[edit]</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Marco, the program stuff you attached is missing the &quot;map.c&quot; file.
</p></div></div><p>
Sorry, attached here the right package.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marco Radaelli)</author>
		<pubDate>Sun, 11 Mar 2007 04:48:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here&#39;s a tip. Start with a basic map that has no walls, but all the intersections laid out. (Thus a map made entirely of 4-way intersections except for the map boundaries.) Now, add walls at random, making sure to maintain symmetry, but before you add a wall, check the two spaces the wall will affect. If either of those spaces already has two walls around it, <i>do not</i> place the new wall and move on. This will prevent dead ends from forming.</p><p>Keep this process up until you have a suitable number of 2-way, 3-way, and 4-way intersections. Also make sure to have a bailout in case it becomes impossible to construct more walls without breaking the randomization limitations.</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Sun, 11 Mar 2007 06:35:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Part of the problem is that I started by coding the walls as blocks that are drawn from an array.  The walls are blocks and not actual walls.  Generally, when making a maze using a maze algorithm you assign vertical or horizontal walls to each cell in the maze.  However, I wanted to try something a little different so my walls are not actual walls but instead are blocks.  I had started out doing it like that because I realized that Pacman doesn&#39;t use a maze and I didn&#39;t want to have to tweak a standard wall drawing algorithm to make a good Pacman level.</p><p>I am kind of getting some neat results now, this is a recent screenshot with only two different block types implemented:</p><p><span class="remote-thumbnail"><span class="json">{"name":"591540 ","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/1\/8155214619a3533f0730ea0c0b5c58e0.gif","w":483,"h":429,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/1\/8155214619a3533f0730ea0c0b5c58e0"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/8/1/8155214619a3533f0730ea0c0b5c58e0-240.jpg" alt="591540 " width="240" height="213" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kholdstayr)</author>
		<pubDate>Sun, 11 Mar 2007 23:03:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I could add my own 2 cents here...</p><p>Looking at your original snapshot, you could probably reproduce a random map by having several 9x9 grids pre-defined (I think you need about 32, IIRC.  This comes from a <a href="http://www.gamedev.net/reference/articles/article934.asp">post</a> about tile transitions.  About halfway down (Figure 3), he shows several &quot;corners&quot; and &quot;sides&quot; together.</p><p>If you were to take this approach, and randomly select any of the tiles (0..31), you could create a map very similar to what you originally posted here, and do some simple checks to make sure you don&#39;t have any boxed-in areas.  Then when your map is fully generated, erase the &quot;ghost house&quot; in the middle, and go from there.</p><p>As you would only need to randomly generate the map before the level starts (like in a menu screen, waiting for user-input), all your expensive tests could be done before the map is even shown to the player.</p><p>You could also combine this with a pathfinding (like A*) algorithm to test that all &quot;routes&quot; are accessible for PacMan as well as for the Ghosts.</p><p>Although, I do like Marco&#39;s blue PacMan map quite a bit...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeamTerradactyl)</author>
		<pubDate>Mon, 12 Mar 2007 01:04:18 +0000</pubDate>
	</item>
</rss>
