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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: How to generate random terrain

31 点作者 alaricsp超过 15 年前
When I was a kid in the 1980s, I read a library book on the topic of writing military strategy sim games, and it had an entire chapter on producing random terrain. It started with the usual fractal techniques for producing contours, but then it went on to use weighted random walks to produce roads and rivers, lakes, bridges, and cities.<p>I've tried recreating the algorithms from what little I remember of them, but they never produce anything that looks very good. Online I've found plenty of references to ways of generating the contours, but never realistic-looking roads, rails, and waterways...<p>Does anybody know an online reference to that sort of thing?<p>Thanks!

14 条评论

wlievens超过 15 年前
What kind of scale of terrain are you looking for? Continent maps or battlefield scale?<p>I got some stuff I rolled here <a href="http://flywheel.be/examples/" rel="nofollow">http://flywheel.be/examples/</a><p>All random generated. But probably not what you're looking for.
评论 #823438 未加载
评论 #821971 未加载
bigsassy超过 15 年前
Game development websites are a good place to look. Try these links:<p><a href="http://www.gamedev.net/reference/list.asp?categoryid=45#188" rel="nofollow">http://www.gamedev.net/reference/list.asp?categoryid=45#188</a> <a href="http://www.gamasutra.com/search/index.php?search_text=terrain+roads&#38;submit=Search" rel="nofollow">http://www.gamasutra.com/search/index.php?search_text=terrai...</a>
slmbrhrt超过 15 年前
For generating roads or waterways, try coming up with rules similar to the way they're created in real life. For example, water flows downhill and pools when it finds a local minimum. Roads, on the other hand, tend to avoid steep grades when they can, typically moving straight and branching at right angles at regular intervals.<p>Read up on L-Systems, too. They're great for creating organic structures, be they leaves, trees, or river-tributary systems.<p>Oh and this may be useful: <a href="http://roguebasin.roguelikedevelopment.org/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels" rel="nofollow">http://roguebasin.roguelikedevelopment.org/index.php?title=C...</a>
评论 #822220 未加载
dovyski超过 15 年前
You can take a look at my master thesis (Charack: Pseudo-infinite 3D virtual world generation). It's in a pre-alpha stage, but I think you can find something useful (besides the wide range of similar tools and works I found during my research).<p>Project link: <a href="http://code.google.com/p/charack/" rel="nofollow">http://code.google.com/p/charack/</a>
评论 #822947 未加载
评论 #822224 未加载
allenp超过 15 年前
If you have a heightmap, the roads should be fairly easy. Pick start and end points (cities?) and use a pathfinding method like A* to plot the road. If you want something more stylized, you could select a handful of points from that method and then use beizer curves or something between them.
评论 #823431 未加载
jharsman超过 15 年前
For waterways, just simulate rain and erosion. Let's say you model your terrain as a height field.<p>1. Add rain in random locations 2. Have the rain absorb some of the soil from the square it starts in. 3. Let the water flow in the direction of the gradient. 4. Deposit som e of the picked up soil (maybe only with some probability based on the flow velocity?) 5. Repeat<p>If you just want rivers and lakes you can skip the erosion step and just simulate the water flowing. If you wanted you could add sources manually and have water always flow from there.
afiske超过 15 年前
Here's an article on adding rivers to procedurally generated terrain - <a href="http://www.gamedev.net/reference/programming/features/randomriver/" rel="nofollow">http://www.gamedev.net/reference/programming/features/random...</a>. Searches for "procedurally generated [roads/rivers/waterways/etc] seemed to be the most promising.
jwecker超过 15 年前
google erosion simulation algorithms (or derivations)- some brilliant stuff mostly developed for geography simulations that would make absolutely amazing terrains.
stevejohnson超过 15 年前
I did some work on random terrain once. You can see the results here:<p><a href="http://steveasleep.appspot.com/pyworldgen" rel="nofollow">http://steveasleep.appspot.com/pyworldgen</a><p>If this is what you're looking for, I can try to explain it.
评论 #823439 未加载
zeckalpha超过 15 年前
Perchance recall the book? I'm semi-interested in retro approaches to the problem.
评论 #821942 未加载
elcron超过 15 年前
The freeciv map generator is pretty good if your looking for sample code for a world scale map.
jules超过 15 年前
For waterways you could try to place random water sources and follow the gradient from there.
jacquesm超过 15 年前
Search for 'Mandelbrot' or 'Peitgen' and 'fractal landscape'.
bendotc超过 15 年前
<a href="http://lmgtfy.com/?q=terrain+generation&#38;l=1" rel="nofollow">http://lmgtfy.com/?q=terrain+generation&#38;l=1</a><p>Seriously, I'm all for discussion of particular techniques, but your question is way too broad right now. Go read some papers or even just online tutorials or descriptions of how other software does it, and then lets have a discussion.
评论 #821752 未加载