TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Rooms and Mazes: A Procedural Dungeon Generator

332 点作者 dustinlakin超过 10 年前

15 条评论

ralfn超过 10 年前
A long time ago i also wrote a maze generator. It&#x27;s helpfull to understand the algebra of (fully accessible) mazes:<p>1. Every wall may intersect with some other wall at most once. (this includes the outer wall)<p>With the above rule in mind, you can create mazes with any type of random proccess (without the need for backtracking or bookkeeping). You don&#x27;t have to check wether places are still accessible -- they just always are and will be. Back in those days (qbasic on a 268) just drawing randomly from some point in random directions was about ten times faster than the common path walking (backtracking) style algorithms. Taking two seconds instead of a full minute.<p>Don&#x27;t take my word for it. Grab a pencil. Start drawing random lines. They may only cross some other line at most once. You&#x27;ll end up with a fully accessible maze.<p>The maze may be complicated -- the walls in a proper maze are not. Its a great example of how understanding the invariants and rules that govern your problem domain will help you write faster and simpler code.
评论 #8784333 未加载
doomlaser超过 10 年前
Another cheap and very effective technique for procedural level and maze generation is to create a &quot;walker&quot; or series of walkers that start at some point, walk in a direction and then turn at random intervals, leaving a path of corridors and occasionally rooms in their wake. This is how Vlambeer&#x27;s Nuclear Throne generates its levels, and there&#x27;s a good article from Jan Willem Nijman, it&#x27;s developer, here: <a href="http://www.vlambeer.com/2013/04/02/random-level-generation-in-wasteland-kings/" rel="nofollow">http:&#x2F;&#x2F;www.vlambeer.com&#x2F;2013&#x2F;04&#x2F;02&#x2F;random-level-generation-i...</a><p>If you&#x27;d like a more academic look into procedural 2d game generation, there&#x27;s a nice research paper here, that describes a method and talks about Spelunky a lot (the king of procedural 2d level generation, in my book): <a href="http://games.soe.ucsc.edu/sites/default/files/cig10_043CP2_115.pdf" rel="nofollow">http:&#x2F;&#x2F;games.soe.ucsc.edu&#x2F;sites&#x2F;default&#x2F;files&#x2F;cig10_043CP2_1...</a><p>Additionally, Derek Yu open sourced the code to the original Spelunky, and Darius Kazemi created a great breakdown of its level generation techniques here, also with interactive examples: <a href="http://tinysubversions.com/spelunkyGen/index.html" rel="nofollow">http:&#x2F;&#x2F;tinysubversions.com&#x2F;spelunkyGen&#x2F;index.html</a><p>The action roguelike genre, particularly the roguelike FPS, is a vital new area being explored by indie game developers. It reminds me of the way 2D platformers were mined, explored, and iterated upon starting around 7 or 8 years ago.<p>Right now, it doesn&#x27;t take much to stand out from the herd, as many of the most popular games in the genre don&#x27;t do much beyond generating a bunch of square rooms and connecting them with doors and short, straight corridors. In my opinion, developers in the genre should take more cues from Doom, and less from original Zelda dungeons moving forward.<p>And, from a more holistic perspective, nobody <i>really</i> cares about mazes, room placement on a grid, and connective corridors when playing a game, beyond a brute mechanical level. A more useful framework for thinking of generating levels might be to go one level of abstraction higher. Think about a level as a story for your player, and generate setpieces or &#x27;acts&#x27; that you want the player to experience as they play. Keep in mind the basics of a good story: an escalation in tension and difficulty, spaced with breathers for rhythm and flow. Place those sets on a path in a map, then figure out a way to connect them together at the lower level with rooms, objects, enemies, and corridors.
评论 #8783366 未加载
评论 #8783998 未加载
评论 #8782621 未加载
评论 #8783358 未加载
akanet超过 10 年前
I think this article is a fantastic example of how you can blend prose with working interactive examples. The examples make you really trance out watching dungeons being carved out of nothing.<p>I think an often-discounted aspect of JavaScript&#x27;s appeal is its ability to breathe life into a bunch of fascinating but otherwise dry concepts. Another terrific example is this page by the prolific Mike Bostock: <a href="http://bost.ocks.org/mike/algorithms/" rel="nofollow">http:&#x2F;&#x2F;bost.ocks.org&#x2F;mike&#x2F;algorithms&#x2F;</a>
评论 #8783318 未加载
otikik超过 10 年前
The best series of maze generation that I know is in Cogmind&#x27;s dev blog:<p><a href="http://www.gridsagegames.com/blog/2014/06/procedural-map-generation/" rel="nofollow">http:&#x2F;&#x2F;www.gridsagegames.com&#x2F;blog&#x2F;2014&#x2F;06&#x2F;procedural-map-gen...</a>
gavanwoolery超过 10 年前
Looks good! I found this to be a great resource on Maze generation:<p><a href="http://weblog.jamisbuck.org/2011/2/7/maze-generation-algorithm-recap" rel="nofollow">http:&#x2F;&#x2F;weblog.jamisbuck.org&#x2F;2011&#x2F;2&#x2F;7&#x2F;maze-generation-algorit...</a>
评论 #8785023 未加载
steeve超过 10 年前
Pretty neat is also Laurent Victorino&#x27;s maze generator that can generate mazes with patterns: <a href="http://www.gamasutra.com/blogs/LaurentVictorino/20141202/231321/Mazes_hidden_beauty.php" rel="nofollow">http:&#x2F;&#x2F;www.gamasutra.com&#x2F;blogs&#x2F;LaurentVictorino&#x2F;20141202&#x2F;231...</a>
fit2rule超过 10 年前
That was a very pleasant article and fills me with inspiration .. which is what I came here for, mostly, in the first place. I don&#x27;t have many applications for twisty mazes in my space at the moment, but one thing that I always thought would be interesting is to use the dependency graphs&#x2F;use-counts of various system libraries as inputs to a maze generator. Sort of like Fsn (<a href="http://en.wikipedia.org/wiki/Fsn" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fsn</a>) but with a lot more twisty, bendy mazes between the ldd details .. huh, yet another bit of bait for the bucket ..
gus_massa超过 10 年前
&gt; <i>It’s not perfect, though. It tends to produce annoyingly windy passages between rooms.</i><p>One possibility is to straight some corridors in a new final step, but I don&#x27;t know how well this work in the actual mazes. For example, transform:<p><pre><code> -+ +- ==&gt; ----- +-+ </code></pre> and<p><pre><code> | | | +- ==&gt; +--- +-+</code></pre>
评论 #8783474 未加载
mseepgood超过 10 年前
Labyrinth generator in a single line of code: <a href="http://www.slate.com/articles/technology/books/2012/11/computer_programming_10_print_chr_205_5_rnd_1_goto_10_from_mit_press_reviewed.html" rel="nofollow">http:&#x2F;&#x2F;www.slate.com&#x2F;articles&#x2F;technology&#x2F;books&#x2F;2012&#x2F;11&#x2F;compu...</a>
评论 #8784679 未加载
jmartinpetersen超过 10 年前
It is an amazing article. The &quot;fluff&quot; prose is well written and the visualizations are awesome. Kudos.<p>An honest question, though, is maze generation generally useful? Other than for generating mazes and dungeons, obviously, not that isn&#x27;t a worthy goal in and of it self.
评论 #8782742 未加载
评论 #8782763 未加载
Pfhreak超过 10 年前
Maze generators are a lot of fun to play with, but don&#x27;t always come up with the most compelling gameplay environments.<p>One of the techniques I&#x27;ve heard works well is to step up the abstraction level one click, and create interesting environments and set pieces, then combine those to create a compelling environment for your players. One approach to do this uses herringbone Wang tiles to place various precreated environment tiles in a random, pathable way.<p><a href="http://nothings.org/gamedev/herringbone/" rel="nofollow">http:&#x2F;&#x2F;nothings.org&#x2F;gamedev&#x2F;herringbone&#x2F;</a><p>The results are similar, but allow the developer to inject a little bit of human direction along the way.
评论 #8786728 未加载
rout39574超过 10 年前
Needs an Xscreensaver demo. :)
评论 #8783305 未加载
pavel_lishin超过 10 年前
Any thoughts on letting the rooms overlap sometimes, to generate dungeons that have non-rectangular rooms?
评论 #8784319 未加载
moomin超过 10 年前
One of the developers of DCSS said that the hardest problem of procedural dungeon creation was avoiding generating a swastika by accident.
_lce0超过 10 年前
man it broke both my phone and tablet every time I opened .. but it worth taking the time to looking at desktop!<p>good work