Use the links in this post with caution, many of them may lead you into the field, starting to learn which, you will grow a beard and become an academician — A. Ragouline

Inside my head there is an opinion that absolutely all the people who decided to create a bagel, started with a map generator (and, most often, it is buried in this bottomless abyss for eternity). The idea is clear: you first need to make an interesting space, and then fill it with cats and axes!

In Null Mirror, there will be a carefully crafted cosmological system; that is the information about how the reality of the game world works and it should be always easily accessible to players. This system should also be described in great detail. This, however, is a topic for a separate post (or a couple). What is important to understand right now is that we will have maps of the surface of the world. And we need to understand what they will be. We will use procedural generation to create them — the computer will draw us any number of different maps according to the rules that we will establish.

Our maps will be flat, in other words 2D. This means that even if we want to represent, say, the entire planet, we will create a square on the screen, which will be a distorted projection of the surface of the ball onto a plane. We can simplify our task and not to craft any distortion, because anyway, we will not wrap planets with our maps. So, the worlds are flat and square.

Suppose that our universe consists of planets. Just like our favorite reality. How do the planets differ from each other (and why are they so interesting to explore in No Mans Sky)? Of course, each planet is a unique combination of many different factors. Such as: size (diameter), proximity to the star, the slope of its axis, the composition of the atmosphere, the presence of oceans, and so on. If we add to this the condition that any planet in our universe should be inhabited, and we can invent any living creature, then we will be satisfied with both the earth-like planet-paradise and the small dry rocky planetoid covered with lava lakes.

Let’s try to make an accurate list of the parameters of the worlds, which will not be too short and at the same time will not try to simulate space with the accuracy of a supercomputer.

  • Size – we need several different sizes, very different from each other, so we can create different types of spaces (layouts and such);
  • Relief (or heightmap) – where there will be mountains, how high, how many of them will be. Lowlands are, as you know, upturned mountains (oh, these programmers);
  • The theme — that we will discuss separately;
  • Climate — what exactly will be at the point with coordinates X and Y, desert or taiga;
  • Residents — who will try to survive in the world described above, and to what it will lead.

Size and Heightmap

You, probably, think, what can we tell about the sizes? After all, it is clear: make small, medium and large worlds. For a diversity.

Not so simple.

Many well-known (and not so much) creators of games are wondering how to make their maps interesting. And devote to this whole series of articles. They even write scientific papers. It’s not so easy to satisfy you, the players. If I give you a huge world in which you can ride a horse from one end to another for hours, you will die of boredom, because no developer will have enough time to fill such a world with nice content.

On the other hand, if I give you a very high-quality, but very small world, you will quickly learn it, and you simply will not have enough locations to satisfy the increased appetites for content.

You can’t go to extremes, but you also need variety. Finding a balance between these two things is a question of map sizes. But the actual size does not end there. The world can be gigantic, and yet interesting if given the opportunity to freely teleport from one end to the other. Or maybe you run faster then cheetah? Its a gameplay dependent issue too.

I will dedicate to this issue a separate post when we start writing a map generator. With some nifty tech, of course. And now we’ll dwell on the fact that, firstly, the size depends on the content that we will create. And secondly, different sizes of worlds should appear with different probabilities: the closer the world is to the average size (Earth), the more often such worlds will be created.

Themes

The themes of the world are like different types of planets in Warhammer, or different classical themes of game maps, for example: necropolis, hell, volcano, desert world, etc. In other words, this is the theme of the world in the literal sense; what the player will face. Our home planet is also a kind of theme, Earth-like. And if we say that the world is like Venus, it means that it is very hot there, and all sorts of fire monsters roam the back streets.

Themes are very often the main field for the creativity. Maps dedicated entirely to the sweets from Trove are a vivid example. In World of Warcraft you could wander through the mushroom forest.

But in the games listed above, only some of the areas of the worlds were so diverse. In our case, the theme will be applied to the whole world at once, but that will not exclude the intra-thematic variety of landscapes.

It will be like this: take, for example, the metallic planets from Total Annihilation. It said that such planets are the legacy of some ancient race that terraformed them to giant factories, and metals were the main source of their life activity. Imagine that our Earth has turned into such a metallic planet. It still has mountains, forests, swamps, deposits of minerals, clouds, and more. But now everything is made of metals. For example, if we are moving closer to the hot equator, zinc columns replace the forest. In middle latitudes one can see the intricate weave of copper bushes, and in the completely frozen north there is just one straight lead desert. There is almost no moisture in such a world: water reacts with many metals and turns into other chemical compounds.

Have you imagined? So, this is the theme of the world “metal”.

Climate

Why do we need climate at all? Well, surely many of you went on a vacation some time ago. And you either left a very cold country to a very warm one (as I usually do), or vice versa, you wanted to ski in the Alps or swimming in the fjords of Norway when live in Italy. This is a very natural desire, which is to change the climatic conditions, which entails changing the picture before your eyes: instead of frozen pine trees, you want to look at palm trees. What determines it will grow here a pine tree or a palm tree? A climate. And pine trees and palm trees are different types of forest, which is so called biome (a single plant-animal environment).

In order for our worlds to have different areas (both with pine trees and palm trees), we need to decide (or rather, explain to the machine) where to place them on the maps. To do this, the easiest way (ha ha) to take the Earth’s climate with its rules as a basis.

Many scientists are still puzzled over how to simulate the Earth’s climate. And there are two problems.

The first problem is that climate is a huge and multifactorial system, where everything has an impact on everything, and where the time factor is an integral part of the system. In other words, whether it rains today in your city is determined by the millions of events happening all over the planet, and all these events have a length in time — in a static system there is no climate and its changes. So, in a very, very deep cave, there is no water cycle, the pressure changes are so insignificant that they do not affect anything, there is no sunlight — all this leads to the fact that the world is at a standstill. He is not dead, of course. But you definitely do not want to spend a vacation there. Repeating such a complex system on a computer is a task so complex that several lifetimes are not enough for it, if you describe everything manually.

The second problem lingers inside modern computers. They are weak for such tasks. A glass of water contains 66*10^23 water molecules. Imagine how many glasses of water in the Pacific? How to model with real accuracy the current that crosses this ocean? True, no way. Even if you collect the RAM from all computers in the world, so many numbers will not fit into it. It can be fine, if I were a major scientist at the University of Massachusetts and I would have access to computing power comparable to Google. But no, the server on which I can conduct development is weaker than the machine on which I am writing this post (and Im writing it on a 11-y.o. desktop machine).

But I want to make a good map generator. Such good, so Tarn Adams (the creator of Dwarf Fortress — author’s note) will not be ashamed of it. So, there is a task: to repeat the climate of the Earth. And then, having pushed off from him, to create many new types of worlds, still unexplored and inviting. Ok, let’s begin to solve this task.

The solution

We have just stuck into two big problems that world scientists cannot cope with. Brilliant.

But there is a way.

Both problems are solved as one. It is necessary to simplify the climate model to such a level that it is interesting to play, and at the same time a weak machine can process it in a reasonable time. We will not create worlds the size of Earth, because you definitely do not want to walk on foot around all Africa (this is … long). Let’s do less. The temperature range is taken not from -273 Celsius to plus infinity, but from -50 to +50. We are not going to play for alien amoebas that can survive at a million degrees.

And here is the final set of factors that we will take into account when generating:

  • The tilt of the axis of rotation of the world relative to the source of solar radiation
  • World rotation speed
  • The physical size of the world
  • Elevation map (relief)
  • Pressure belts
  • Pressure itself
  • Air currents (winds)
  • Sea currents
  • Humidity
  • Precipitation
  • The location of freshwater reservoirs (rivers and lakes)
  • The location of the salt water (oceans)
  • Temperature

But this set will use when we have a little more time to develop, and our hardware will not consist of a single weak server. We begin with simple, and will gradually complicate.

Since our ultimate goal #1 in climate modeling is to obtain the final biome at every point in our world, initially we will need three factors: topography, temperature, and precipitation. These three things are enough to determine the pine or palm tree.

And our next step will be to start learning how to identify that damn tree.

But what about the inhabitants?

Oh, this is another deep and beautiful topic. About which we will talk with you next time. We have to go through several trips at once: worlds, rational beings, not very rational beings, occupations, professions, magic, weapons, construction and how to put all this into practice.

Good luck and do not switch!