A word or two about world generation

(This post was contributed by my brother and partner-in-crime, Martin.)
My brother was quite correct in his statement regarding many moons ago. I initially started developing an interest in game development when I realized that chemical engineering as a career, or sitting on a petroleum plant for the rest of my life, wouldn't bode well for either my social life or my liver. I used to spend endless hours playing the old school games such as Sid Meier's Civilization and the various spin-offs such as Master Of Magic, Orion and the works — real old school. It got me going on a realistic, but completely random map/world/star system/galaxy/universe creation.
The advantages of a completely "random map" generation, and I quote that for a reason, is besides the boredom that sets in because of your game engine, at least your players will never grow bored of the same old landscape and the same old points of interest. This, in my opinion (and to some extent proven by popular titles), can increase the lifetime of a game because some gamers out there are slaves to the exploration aspect and the excitement that the unknown can present them with. Inevitably, players will grow bored of your game system and no amount of fancy world generation will reignite that first love of the game.
Typically when I approach a project that should reflect no real elements of reality except for Newton's laws is my inclination towards making it more real. Yes, I know, sounds weird. Anyway, my first attempt at a completely random world is best described by my younger ramblings on an old post. Note the 2001 and hence my brother's comments about the many lunar cycles. Even at that stage I had played enough games with "random" terrain generation and the limitations of borders. My philosophy behind the entire exercise was that if you generate an entire world, you can choose any section of the world as a rectangular map and not be constrained by border conditions that may arise out of the generation on a flat, rectangular surface. This would create a realistic map which, if chosen carefully, would provide enough points of interest for the player.
You may note the generation times I listed there on my trusty old Pentium III: NINE minutes. NowI don't know about you, but there is no way in hell I am waiting 9 minutes for a game to generate me a "realistic" map in a surrealistic genre. The reason for the slow generation time was that besides of the "trustry old Pentium III", I also took a sphere — cleverly disguised as a bunch of triangles — and bisected it a few thousand times raising one edge and dropping the other until it looked like a terrain. These days your fancy FPUs and even your GPUs can be harnessed to do all sorts of floating point calculations for you really quickly — exactly the type I was doing by brute force back then. But that's not the point. Your PCs are at least 50 times faster today than they were back then, so that leaves us with 10 seconds. Not so bad? No, but that doesn't count the additional computation of weather, civilisation structures, etc.
So in the moons specified I have put the project on the back-burner and let the trusty old God-given CPU let it sort it out in the background. My present opinion on the matter is that the above-mentioned method can still be used, however it produces such "normal" and "boring" terrains - everything is smooth! What you would typically do is take my algorithm mentioned above and run it for only a fraction of the number of iterations I specified back then. This will give you a resolution of thousands of kilometers for a typical earth-sized planet. To provide the rest of the detail you would typically employ Perlin noise — and yes, I can hear the moans. Why Perlin noise? Well, Perlin Noise was my second attempt at world generation to try and cut down on the 9 minutes of world generation. Perlin noise generation is really fast — even in terms of ol' faithful. I wrote a Perlin Noise generator where you could specify the function to use in each octave and a bidirectional polynomial fit to the generated points for smoothness. Sounds like a mouthful? Well, yes. It was — I stole my father's expression parser at the time (Thanks Dad!) — the mapping was not too difficult.
What you have at this point is a crude brute force random method (also sometimes referred to as a fractal method) to generate a crude terrain and a not so crude random method that can generate interesting terrain features based on specific mathematical functions applied (in reverence I post the following link that was my first introduction to said noise — note that Ken Perlin did this back in the Stone Age with a pair of sticks and a bit of string). Note the random — meaning all of this can technically be represented by only 4 bytes (or 4 billion possible outcomes). Depending on the resolution of the finer Perlin Noise, you can refine your map down to the closest metre or foot —just keep in mind that the more resolution you desire at an earlier state the more processing you have to dedicate to the solution.
This only covers the broad terms of a "realistic" height map. We now venture into the realm of weather and flora distributions, something which Toady One (be warned... "fun" lies that way) addressed. The way I understand it is that he used secondary terrains to present precipitation, temperature and foliage maps (I humbly stand corrected if I am spouting shite) which was then overlaid on the height map. This is all fine and well and leads to some pretty impressive maps. My venture however will delve into the more mundane...
I propose that only a height map needs to be generated with the addition of a sea-level factor. An additional factor is the type of sun in the relevant solar system. Climate is controlled by energy input to the oceans, which control to a greater or lesser extent evaporation which in turn controls density fluctuations across the globe. Pressure differences can then be calculated based on the density differences and once we have pressure differences, we have climate. Climate can then be used to determine precipitation and precipitation can be used to determine biological distributions. Throw in an axial shift on the planet and seasons (or extreme weather patterns :D) can be used to create exceptionally interesting worlds.
In conclusion to this article I can only wonder about the processing power required, however, it should provide for some reasonable distractions in the near future. More on my descent into madness (as mentioned above) later...
Posted by Mr Rho
Views