Terasology / ClimateConditions

A module for managing temperature, humidity, and other climate factors
0 stars 6 forks source link

Climate Effects at World-Gen and Play Time #55

Open jdrueckert opened 3 years ago

jdrueckert commented 3 years ago

Goal and Background

Fifth paragraph here suggests that the player's actions should impact the world. To make this happen, some sort of world management system that makes modifications to the world based on a variety of variables should be implemented. The same system can be expanded upon to increase the WeatherManager's impact on the world.

Notes

ClimateConditions already has some temperature/humidity maps. It hasn't been updated for a few years, and it doesn't appear to do anything besides generate the maps. Still, it might be a good starting point. Additionally, ClimateConditions might end up being a good storage location for more complex variables or changes (or ClimateConditions could be migrated to Core, though that seems against the spirit of modularity).

General Ideas and Influencing Factors

Notes

Of all of the factors listed above, erosion requires the most consideration. It needs to occur very gradually, but still frequently enough that it is present. It needs to specifically account for the direction which it is occurring (downward, in the case of water, but also at different angles according to wind). Most importantly, a careful balance needs to be struck between frustrating players and letting them suffer the natural consequences of building their house out of sand.

Step 1: Variable Maps Upon World Generation

Layers of noise besides those simply used for should be generated at the start of the game. One layer will be generated for each variable (see the Variable Ideas card), and the layers will be tied into the biome selection that has already occurred - desert blocks will have less humidity and higher temperature, for example. There can also be some element of randomness.

Notes

ClimateConditions is important for this step, at least. The way that the temperature and humidity components are generated in that module should be examined more closely. If that method cannot be used to create the secondary noise layers (or would be better improved upon), it should be altered in ClimateConditions to match whatever better method is selected.

It seems that basing the new noise maps loosely off of the current world gen maps, rather than the other way around, is the best option. I think it would be fairly straightforward to look at the biomes that are currently in place - and possibly include some other variables, like nearby biomes, altitude of block, or deterministic randomness - and create other maps based off of them. It will take some research to determine the values of the variables for each biome.

Tasks

Step 2: Update Variable Maps When Conditions Change

Once the variable maps are constructed, they should be updated when something occurs that could change the conditions. This could be spontaneous, such as change caused by wind. (Wind goes from high-pressure to low-pressure zones, and temperature/humidity could move with the wind.) It could also be due to player actions - if a player builds an extensive railroad system, pollution could lead to a general warming of global temperatures.

Notes

Timing is the most important factor here. Changes to the world should take time, some more than others. It takes years for the climate to permanently change due to pollution, but temperature changes significantly multiple times a year due to the normal orbit of the earth. A good balance needs to occur between making the change impactful/noticeable/fun and making the change realistic.

Move Wind Maps

Wind is the most crucial map to create and then to alter, since it will lead to changes in temperature, humidity, and pollution, and cause erosion itself. Therefore, all changes to wind should occur first, and then those changes can alter the other maps accordingly. Air pressure is also affected by temperature, though.

Tasks

Move Erosion Maps

Erosion will be most critical for steps 3 and 4, so moving this map must be done with care. Erosion will be based on the height and material of blocks on the surface of the world - sand dunes erode more easily than grassy fields, and sand in the middle of a pit doesn't have anywhere else to go. The direction of wind in a given area also contributes significantly to erosion, as does precipitation, but erosion due to precipitation will primarily be handled through the WeatherManager.

Tasks

Move Other Wind-Based Maps

Wind can transport air-based pollution and usher in colder/warmer temperatures and higher/lower humidities. This goal encompasses changes to temperature, humidity, and erosion. Note that humidity maps will also be changed by precipitation changes (through WeatherManager), temperature will be changed based on pollution, and pollution will be based on player actions or technologies (consider creating a new module to handle pollution, since some modules that will cause pollution fall significantly outside the scope of ClimateConditions).

Tasks

Step 3: Change the World Based on Variable Maps

Once the noise maps change a certain amount, the world should be altered to fit with the new maps. The best way to do this, I think, would be to send an event every 15-30 seconds (more or less, depending on what rate seems to play out the best) to check if the world should be updated and, if it should, where/how it should be updated.

Determining if the world should be updated will be fairly straightforward. An older version of the noise maps - from when the world was last changed at each given point/chunk/area because of them - will be stored. The current noise maps will be compared to the older ones. If an area has changed significantly, the world will be altered to fit the new map, and that section of the new map will replace the older section on the older maps.

How, exactly, the world will be altered is more complicated. The different factors will each alter the world in a different way. Some may primarily alter other variable maps (for example, pollution's main effect would be an increase temperature - this is handled under Step 2), while others directly impact the world (erosion can wear down mountains). In each area that is affected, different patterns will be considered. In the case of erosion, blocks will slowly migrated from higher areas to lower ones. In the case of humidity and temperature, biomes will gradually migrate. Each factor will need to be dealt with individually.

Notes

Alternatively, it might be possible to just adjust the world every time a map changes significantly, rather than at set time intervals. That would likely be less efficient that just updating the world every so often, as changes would need to be constantly monitored. As Terasology already has somewhat bad performance, I would like to avoid this option if possible.

Store and Monitor Changes in Noise Maps

This topic is mostly explained in this column's general explanation. It's copied below for more information:

Once the noise maps change a certain amount, the world should be altered to fit with the new maps. The best way to do this, I think, would be to send an event every 15-30 seconds (more or less, depending on what rate seems to play out the best) to check if the world should be updated and, if it should, where/how it should be updated.

Determining if the world should be updated will be fairly straightforward. An older version of the noise maps - from when the world was last changed at each given point/chunk/area because of them - will be stored. The current noise maps will be compared to the older ones. If an area has changed significantly, the world will be altered to fit the new map, and that section of the new map will replace the older section on the older maps.

The above is the method that I'll use for determining biome changes based on temperature/humidity. For erosion, however, the difference between old and new maps shouldn't matter, and erosion maps will be consistently updated (no old/new). It'll just be that areas of high erosion will move toward areas of low erosion.

Tasks

Migrate Blocks as Erosion

Erosion maps will physically move different blocks to different locations. It will occur step-by-step, with each block being moved a minimal amount each time. It might be possible to move blocks in small increments (such making a block into two half-block shapes to move it) later on, but I think that moving whole blocks will work better for now, since partial blocks or different block shapes generally don't naturally occur in Terasology at the moment. Areas with increased or high erosion will erode first, with the block at the surface point being moved to a location one (or more, if necessary) blocks down.

Migrate Biomes with Temperature & Humidity

The basic process for migrating biomes was given earlier. A different range of temperature/humidity values should be established for each biome. When temperature/humidity values at a given block drift too far away from that block's biome, the block will become part of a different biome. It should also change into a different block of that biome's default (grass block might become a sand block when the plains biome becomes a desert). This can occur gradually, from the surface down, such that biome changes occur in layers.

Tasks

Step 4: Start World Evolution before Spawn

Using the system that will be created above, it will be easy to start world evolution before the player actually appears. This world generation will occur for as long as the player designates on the world creation screen. The modification will occur through the (heat, humidity, wind, etc.) maps that are generated, which will then be used to alter the world all at once as the player is spawning.

Fast-Forward Climate Effects Altering Maps

Maps should be altered based on one another. This can occur at a rapid pace, as opposed to artificially slowly as they would normal proceed while a game is being played. A slider may need to be added to or fixed in the advanced game settings to make this work and allow the player to specify how long to fast-forward for.

Tasks

Update World Based on Maps

The world can be updated all at once based on the maps. The most crucial change will be to the biomes and blocks, which will occur similarly as in Step 3, but through comparison of the "old (original) world" to the "new world" (world after generation is complete).

Tasks

jdrueckert commented 3 years ago

Extracted from @RatMoleRat's TSoC Board