Hacker News new | comments | show | ask | jobs | submit login
Procedural Planet Generation (experilous.com)
224 points by mxfh on Dec 1, 2014 | hide | past | web | favorite | 37 comments



Really cool - I, too, have long been bothered by the cylindrical map in Civ and wondered what a spherical Civ would be like. (At least Civ V's switch to a hex grid solved the biggest pet peeve I had with the game's geometry, since with a square grid, moving diagonally was just as fast as moving orthogonally.)

However, the irregular tiles actually bother more than if it was a standard geodesic sphere which only had 12 pentagons. For one, the fact that tiles are different sizes looks kind of weird. More importantly, this tile layout could actually make an important strategic difference (much more than if there were only 12 pentagonal tiles). Assuming movement costs between adjacent cells are constant, a straight line may not be the fastest way between points anymore! Looking at the heavily distorted mesh example, I can see several places where a path through a few large cells has the same movement cost as the straightest path.

Also, a realistic simulation of global wind patterns isn't actually that hard. Since it's only long-term trends that matter (at least when it comes to shaping overall climate), it's not like you'd have to calculate detailed fluid mechanics models. A simple model of Hadley & Ferrel cells (which is key to having realistic deserts) would get you most of the way there. [1]

[1] http://en.wikipedia.org/wiki/Atmospheric_circulation


> Also, a realistic simulation of global wind patterns isn't actually that hard. Since it's only long-term trends that matter (at least when it comes to shaping overall climate), it's not like you'd have to calculate detailed fluid mechanics models. A simple model of Hadley & Ferrel cells (which is key to having realistic deserts) would get you most of the way there.

I enjoyed the entire article, but this was the main thing that stood out to me as well.

Fluid dynamics on a spheroid are extremely well documented, and incorporating them will help derive a lot of familiar features that are a necessary consequence of them. Trade winds, Hadley cells, predominant ocean currents (etc), these are all things that can be easily applied to the appropriate model.

Particularly when you look at precipitation, the reason we have massive bands of dry and wet areas is because we live on a giant spinning ball.

In any case, really interesting to read!


> However, the irregular tiles actually bother more than if it was a standard geodesic sphere which only had 12 pentagons. For one, the fact that tiles are different sizes looks kind of weird. More importantly, this tile layout could actually make an important strategic difference (much more than if there were only 12 pentagonal tiles). Assuming movement costs between adjacent cells are constant, a straight line may not be the fastest way between points anymore! Looking at the heavily distorted mesh example, I can see several places where a path through a few large cells has the same movement cost as the straightest path.

I would say there is nothing wrong with strategic differences, so long as they are irregularly distributed. Regular or predictable distribution would cause strategic ruts. Also, irregular movement costs are a feature. Ancient spice trading routes and deer paths in the woods rarely follow straight lines either.


Irregular movement costs would be there anyway, due to forests, hills, and other terrain. The fact that "this space is arbitrarily bigger" isn't really a good justification, especially when the game is doing this in an effort to be more realistic.

I also think this could lead to a whole bunch of balancing issues that might not immediately be obvious. Although some random-but-fair differences in balance such as this are okay, they should be based on the terrain, resources, and other features that mirror the real world, not "this tile is just bigger".


It wouldn't be too hard to give it some justification. The smaller tiles could have hills or forests that would naturally slow down movement. Or perhaps go back and redistribute the smaller tiles after terrain generation?


I guess you can cheat your way thru by placing all distorted tiles in seas, oceans and lakes.


Games wind up using cylinders because of the hairy ball theorem

http://en.wikipedia.org/wiki/Hairy_ball_theorem

There are always going to be points on a sphere that map poorly to 2D - if you've played Spore, think of the in-planet spaceship map, you wind up zooming through parts of the map and crawling through others while still going the same speed in-game.


I don't think this is relevant in this case; I don't see how vector fields matter in a turn-based strategy game where all movement is quantized.


A unit's movement options are vectors. As it's designed, you've got vectors in the due directions and the medians between those, each scaled to be the size necessary to make the grid work as mapped from a sphere for the particular location. So the east vector at 45 N is root(2)/2 the size it is at the equator.

So if you've got an east vector for every square that is a function of the location, that means there's an east vector field. Same goes for the other seven options. Might as well make a zero at the poles, since one zero is weird, zeroes that don't line up are weird, and no one wants to settle at the poles anyway.


Another idea for folk who want to generate equally spaced points on a sphere for things like this - a while back I did an answer on codegolf.stackexchange: http://codegolf.stackexchange.com/a/24961/16869 for showing a daylight map of the earth. You need to store a map of the earth to do this, but I didn't want to waste storage on the poles as you would with most projections, and couldn't be bothered calculating tilings; so the path I took was to use a spiral sampling of the surface of the earth giving approximately equal area, then flood filling.

I hadn't seen this approach before, but guessed someone would have thought of it so hunted down a discussion; The spiral I used is taken from here: https://groups.google.com/forum/#!msg/sci.math/CYMQX7HO1Cw/t... (see the rest of the thread, their motivation is minimising the potential energy of charged particles on the sphere).


Hello, Slartibartfast! I look forward to playing a "race to the south pole" rts. Brilliant work.



Thanks


Very nice! This goes into my (small) collection of proc-gen bookmarks. I've taken a (side) interest into this field, which, inspite of classics like perlin noise, still seems quite young. I've been reading about plate tectonics last week and it's good to see it working for someone else. Maybe I should give them a try as well.


Do you have that collection of bookmarks posted/shared anywhere? Always curious to see more stuff like this.



I use some of my spare time to hack around on proc gen stuff - mainly targeted toward generating starfields & planets using GPU's. Here's something I worked on recently regarding generating realistic nebulas and starfields http://www.junkship.net/News/2014/02/02/my-god-its-full-of-s...


This is awesome. Those starfields are beautiful.


i have fond memories of playing with terragen back in the day. no idea what techniques they used, but they got startlingly good results.


If memory serves, Terragen also used Perlin noise by default, unless you imported your own bitmaps or selected a different algorithm. :)


Yeah, in Terragen 1&2 it was just a simple heightmapl, but Terragen 3 was a huge rewrite - not sure what they use now.


Would be interested in such a list if you can share it :)


Mee too, please share in pastebin or somewhere.


This is excellent, though I wonder what it would take to do a simulation from the beginning and change over time as opposed to a fixed state. Then let the features, biomes and weather patterns arise naturally from the given physics (and perhaps some nudging).


It would be pretty cool if the game actions could effect the environment too - global warming, pollution, nuclear disasters, that kind of thing.


Awesome work.

I really sympathize with his "Why did they use Javascript instead of Lua" point. Of course I mostly do embedded programming so this might be my biases talking but every time I find myself using Javascript I keep wishing it was more like Lua.


Why Lua? I was just reading through the Red Blob Games articles, and on the subject of scripting languages, he says something to the effect of 'if you have to use a general purpose scripting language, just go for Lua', written as if this is kind of self-evident. What is it about Lua that makes it attractive?


Isd assume it's because luajit is very lightweight when compared to javascript systems, which tend to be very memory hungry.


Performance, it's one of the fastest scripting languages.


It looks like there is supposed to be an interactive demo. Doesn't work on the google cache. Is there a mirror of that anywhere?



It'd be rad if you could elevate individual tiles proportionately to their mean elevaton - kind of a Causeway of Giants effect, it would give a sense of the elevation in any of the other modes (esp. in terrain mode!)


I was bugged by games not having proper polar regions too a while back. One solution I thought of (but never got around to implementing) was to use a cube map to represent the surface of the sphere. I thought it'd be easier to work with six flat faces than to figure out how to index the tiles on a soccer ball...


A similar but different idea is the TOAST projection. However here it starts with an octahedron instead of a cube. The benefit is the texture can all be stored on a square and is argued has a more uniform sampling that equirectangular projection.

http://www.worldwidetelescope.org/docs/worldwidetelescopepro...


As a huge Civ fan the idea of having a game take place on a truly spherical world is very appealing.


Also check out [Elite: Dangerous][ed] for some awesome procedural planet generation.

[ed]: http://hypertexthero.com/logbook/2014/07/elite-dangerous-edu...


reminds me of this article: http://www.pyxisinnovation.com/pyxwiki/index.php?title=Mathe...

And: "Climate Modeling with Spherical Geodesic Grids" from Sept/Oct 2002 - Computing in Science & Engineering




Applications are open for YC Winter 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: