Warning! Math is in here, be warned. I try to make it not that bad. If you want to see how storms influence gameplay without reading the math, skip to the section with the plots and pictures!
I decided it may be easier to create a mathematical model that outputted procedurally generated weather functions in a program known as MATLAB before implementing it in UE4. This proved to be a very good idea as it quickly complicated, and MATLAB allowed me to very easily tune parameters and generate storm profiles.
Here’s the underlying way in which we generate storm profiles for Paleo Playground.
I have a point that always remains at zero during sunny weather which defines storm intensity. As the game runs, a clock constantly monitors this point and at some interval of time in the future it will suddenly decide to start brewing a storm. When this happens, the storm intensity function is generated procedurally in real-time, and its behavior is governed by a series of conditionals that guide random number generators over a rough course. These random number generators will have either a positive bias, a negative bias, or no bias, depending on the stage of the storm.
When a storm has been seeded, two points are calculated randomly in the future. The first determines over what time the storm will be generated by positive luck; that is, random number generation that favors positive or increasing conditions. The second bounds the time interval by which the storm will have neutral luck, or a government by a series of random numbers with no bias in either an increasing or decreasing condition. The last interval is unbounded in time, but past this point the storm is governed by a series of biased, randomly generated numbers that tend to decrease the storm in severity. I’ll go into this a bit more here.
There are four intervals of storm behavior that are governed by randomly generated numbers of different flavor, and each successive randomly generated point on a storm that defines intensity lies 36 seconds in the future of the previous. These are discrete points that govern the storm shape through time. If intensity ever goes below zero, the storm is over, and the weather returns sunny until another storm decides to manifest.
Stage One : Storm Infancy
The first stage is static in length, always allowing the first three and a half minutes of a storm to slowly, but steadily increase in intensity such that no storm will die immediately without chance to cumulate into some reasonable threshold of severity. These are governed by purely positive random number generation, where the next point of intensity in the storm is equal to the previous point, plus a randomly selected number between 0 and 0.25.
Stage Two : Storm Front:
Once a storm passes infancy where failure of the storm is not possible, it is left to a less forgiving interval of chance. Each successive point on a storm, 36 seconds after the previous point, will equate to the previous point plus a randomly selected number between 0.6 and -0.4 The goal here is that for this stage of the storm, most storms will tend to increase in an erratic and randomized manner but some may stay equal or even decrease. This interval could last anywhere from one to 24 new storm points, translating into 36 to 864 seconds of positive bias on the storms generated profile. Some storms, however, will die in this interval due to generating many numbers that lie below zero, and fail to cumulate into a glorious tempest. This is by design, as a variety of storms is desired and 5-10 minute, gentile storms that peter out are part of our desired variety profile.
Stage Three : Storm Culmination:
Should a storm pass the previous stage, it will then be met by another interval of a randomly generated duration. This stage has fair number generation that does not, on average, favor increases or decreases in intensity. This interval may last anywhere from 1 to 36 additional points, or 36 to 1296 additional seconds of unbiased storm generation. Most storms, provided they got off the ground during the previous two intervals, will generate jagged but relatively unbiased profiles during this time window, though some dramatically increase in intensity, have bimodal peaks, or peter out due to many numbers generating in one direction or the other.
Stage Four : Storm Death
Ultimatley we do wish for our storms to die. If bounded indefinitely by fair chance and unbiased random number generation, some storms could last a great deal of time, way longer than would be good for gameplay purposes. Here, we kill the storms. They are governed by a death interval that pulls the storm intensity back down to zero with a negatively biased series of random numbers. Each successive peak on the storm here equates to the previous plus a random number between -0.5 and 0.5, then minus an additional kill term, which is -0.01 * how many points past the beginning of this window we have traveled. For example, if we are 20 points, or 720 seconds past the beginning of the kill window, the random numbers generated will lie between 0.3 and -0.7. This increasingly negative bias ensures no storms continue to propagate for very long periods of time.
This may have been a lot to take in, and I did my best to explain our storm intensity algorithm above. Intensity, however, is just the first step of the process I created to procedurally generate storms. Our storms have many criteria that govern the look of Paleo Playground’s weather. These are:
- Sky Color
- Cumulous Cloud Cover
- Rain Intensity
- Lightning Frequency
- Wind Intensity
- Fog Thickness
- Storm Surge
All of the above are immediate computations off of the storm intensity. I won’t go into tremendous detail explaining how each of these was computed, but some are integral terms, others are in direct scalar porportion to intensity, and others are differential terms.
Sky Color, Rain Intensity, Cumulous Cloud Cover, and Lightning Frequency are scalar porportions or piecewise linear functions of storm intensity. Rain, for example, ranges from 0 to 1 as intensity ranges 0 to 2, but increases in severity from 1 to 5 as intensity continues from 2 to 4. This gives a sharp increase in rain for the most intense parts of a storm but the function is ultimately two linear equations pieced together.
There is only one integral term for our procedurally generated storms. This is Storm Surge. As weather is severe over a long duration of time, storm surge will gradually rise. Absence or lulls in severe weather will cause exponential decay of storm surge when not being fed by the storm. This term is volatile, and can explode severely if a storm reaches very high levels of intensity for long durations of time, as it actually integrates the square of rain intensity over time. Gentile and moderate storms will have little to no noticeable storm surge, but extremely severe storms could cause surges of ten meters or more! We better hope these don’t hit at high tide as yes, the map can indeed flood from a serious storm surge.
Wind Intensity and Fog Intensity have differential elements. The wind and fog are both in direct porportion to the sum of the rate of change of the rain, of the cloud cover, and then summed with a direct term of cloud cover as well. This creates wind and fog that change dramatically in intensity over the course of a storm, as in a real storm wind is not constant. The fog’s purpose is more to provide a mist from wind blowing the rain in these scenarios. Future procedurally generated foggy days may be done differently. These profiles will be jagged and erratic during the most intense parts of storms.
When these are all summed together, we can generate storm profiles such as these:
Small Storm Example
The image above contains procedurally generated functions of all seven storm criteria plus the underlying intensity function for a relatively small storm. Notice that for a small storm, there is no lightning, deliberately so. This is because lightning only occurs when rain intensity exceeds 2.0. There is also very little fog and wind. There is very little surge and no cumulous cloud cover. A storm like this would likely appear to be a gentle drizzle and a bright grey sky. It lasted twelve minutes, and likely would be hardly more than scenic rain for players on the map. Ignore the surge here, as I was just testing things out. That surge was not a result of this tiny storm.
Medium Storm Example
The above generated storm is about average, not being particularly small or large. It has a modest storm surge of 1 meter, a small episode of lightning with infrequent strikes, and a moderately grey sky. It lasted 23 minutes. This storm would likely drop light to moderate comfort levels for players who decided not to take refuge, but it would not pose a large threat to an unsheltered player who decided to stay outside. There is a small risk of lightning strike during some intervals of the storm, but it should be quite rare as the bolts are only striking once every 20-30 seconds, even during the worst of it.
Large Storm Example
This is the extreme of our weather generating system. This storm has, 30 minutes in, a pitch black sky, very frequent lightning strikes, the highest rain, and high wind, fog, and cumulous cover. It is followed quickly by a heavy storm surge that reaches almost 6 meters. It lasted 40 minutes. The worst of this storm would have looked like this:
If you stayed outside during this storm at its worst (between 25 - 35 minutes into the storm), you would die. This will severely drop comfort levels to the point where health begins to decay and also poses substantial risk for being struck by lightning. A high storm surge also poses a risk for flooding the low-lying terrain on the map, and there will be rip currents as well.
Storms and Gameplay
So what do these storms do? We want a large storm to force players to seek shelter over significant risk, but also do not want a significant portion of gameplay to be spent seeking shelter from 40 minute storms. Thus, storms will have an analog influence on player comfort as well as direct danger during the worst tempests. Comfort drop will likely be in direct porportion to both wind and rain summed together, where a small storm with gentle drizzles will drop comfort a very small amount, but getting caught in a monsoon will drop comfort significantly to the point of lethality. Surges with rip currents pose risk of dragging players out to sea who get stranded by rising water levels. Lightning also has a chance to target and strike players and it does kill, so be warned, seek to the caves if the sky turns black!