Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weather realism #34515

Merged
merged 14 commits into from
Oct 31, 2019
Merged

Weather realism #34515

merged 14 commits into from
Oct 31, 2019

Conversation

Kodiologist
Copy link
Contributor

@Kodiologist Kodiologist commented Oct 6, 2019

Summary

SUMMARY: Balance "More realistic temperature, precipitation, humidity, and pressure"

Purpose of change

Closes #34139 - More realistic precipitation and temperature.

Describe the solution

The generation of temperature, humidity, and pressure using time and simplex noise has been overhauled to more closely match real 2010s data from New England, particularly Concord, New Hampshire, since New Hampshire is roughly in the middle of New England. I also edited the humidity and pressure thresholds for the various precipitation types so that the rate at which the player sees light precipitation (Drizzle, Flurries) or moderate precipitation (Rain, Snowing, etc.) is similar to the real data. Finally, I've added tests for temperature and precipitation realism.

I've moved the default INITIAL_DAY to Spring 60, which has a typical low around 35 °F, since a typical low on Spring 30 is now around 25 °F (from 35 °F before this PR).

While I've changed the amount of rainfall produced by generic_wet and generic_very_wet, I haven't adjusted the other effects (field decay and player wetness) because I don't know how to relate them to real weather data.

Some downstream gameplay effects:

  • Funnels are much less useful, both because rain is much less frequent and because rainfall rates are lower. (But, they already weren't very useful in a game full of rivers, swamps, and swimming pools.)
  • Also because rain is much less frequent, rain gear is less important and fire is more useful.

Describe alternatives you've considered

It's clear that many more changes could be made, such as:

  • Properly linking temperature to sun position
  • Generating absolute humidity instead of relative humidity
  • Making precipitation stochastic instead of a deterministic function of pressure and humidity
  • Representing rainfall as continuous instead of discrete (not wet vs. wet vs. very wet)

But I think the PR I'm proposing improves things, without requiring lots of code changes.

Additional context

An example weather log is attached. Here are some results from my analysis script:

``` TEMPERATURE (°F)

Mean absolute running difference - lows
CONCORD, NH 2014 - 6.385
CONCORD, NH 2015 - 6.432
CONCORD, NH 2016 - 6.134
BOSTON, MA 2014 - 4.261
BOSTON, MA 2015 - 4.514
BOSTON, MA 2016 - 4.414
CARIBOU, ME 2014 - 6.423
CARIBOU, ME 2015 - 6.016
CARIBOU, ME 2016 - 5.942
Cata - 5.866

Mean absolute running difference - highs
CONCORD, NH 2014 - 6.319
CONCORD, NH 2015 - 6.457
CONCORD, NH 2016 - 6.841
BOSTON, MA 2014 - 6.772
BOSTON, MA 2015 - 6.72
BOSTON, MA 2016 - 7.066
CARIBOU, ME 2014 - 6.162
CARIBOU, ME 2015 - 6.637
CARIBOU, ME 2016 - 6.419
Cata - 6.149

Mean within-day range
CONCORD, NH 2014 - 22.501
CONCORD, NH 2015 - 24.353
CONCORD, NH 2016 - 24.098
BOSTON, MA 2014 - 14.866
BOSTON, MA 2015 - 15.773
BOSTON, MA 2016 - 15.366
CARIBOU, ME 2014 - 18.781
CARIBOU, ME 2015 - 19.214
CARIBOU, ME 2016 - 19.421
Cata - 19.637

Extreme window center - lows
CONCORD, NH 2014 - 2
CONCORD, NH 2015 - 52
CONCORD, NH 2016 - 43
BOSTON, MA 2014 - 22
BOSTON, MA 2015 - 45
BOSTON, MA 2016 - 43
CARIBOU, ME 2014 - 2
CARIBOU, ME 2015 - 34
CARIBOU, ME 2016 - 352
Cata - 40

Extreme window center - highs
CONCORD, NH 2014 - 180
CONCORD, NH 2015 - 210
CONCORD, NH 2016 - 205
BOSTON, MA 2014 - 181
BOSTON, MA 2015 - 211
BOSTON, MA 2016 - 205
CARIBOU, ME 2014 - 180
CARIBOU, ME 2015 - 228
CARIBOU, ME 2016 - 194
Cata - 214

PRECIPITATION

Proportion of days with ≥1 mm of precipitation
CONCORD, NH 2014 - 0.293
CONCORD, NH 2015 - 0.266
CONCORD, NH 2016 - 0.238
BOSTON, MA 2014 - 0.26
BOSTON, MA 2015 - 0.258
BOSTON, MA 2016 - 0.235
CARIBOU, ME 2014 - 0.342
CARIBOU, ME 2015 - 0.342
CARIBOU, ME 2016 - 0.361
Cata - 0.212

Proportion of hours with light precip or more
CONCORD, NH 2014 - 0.039
CONCORD, NH 2015 - 0.031
CONCORD, NH 2016 - 0.028
BOSTON, MA 2014 - 0.039
BOSTON, MA 2015 - 0.032
BOSTON, MA 2016 - 0.029
CARIBOU, ME 2014 - 0.046
CARIBOU, ME 2015 - 0.035
CARIBOU, ME 2016 - 0.041
Cata - 0.039

Proportion of hours with heavy precip
CONCORD, NH 2014 - 0.014
CONCORD, NH 2015 - 0.012
CONCORD, NH 2016 - 0.01
BOSTON, MA 2014 - 0.016
BOSTON, MA 2015 - 0.01
BOSTON, MA 2016 - 0.012
CARIBOU, ME 2014 - 0.011
CARIBOU, ME 2015 - 0.006
CARIBOU, ME 2016 - 0.013
Cata - 0.015

Total precip per year (cm)
CONCORD, NH 2014 - 116.796
CONCORD, NH 2015 - 96.603
CONCORD, NH 2016 - 84.102
BOSTON, MA 2014 - 115.09
BOSTON, MA 2015 - 88.416
BOSTON, MA 2016 - 84.082
CARIBOU, ME 2014 - 114.754
CARIBOU, ME 2015 - 89.606
CARIBOU, ME 2016 - 111.868
Cata - 71.05

A plot of relative humidity (orange), vs. Concord in 2014 (blue):

graph 1

A plot of pressure (hPa, orange), vs. Concord in 2014 (blue):

graph 2

@Kodiologist Kodiologist changed the title Weather realism [WIP] Weather realism Oct 6, 2019
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Game: Balance Balancing of (existing) in-game features. Mechanics: Weather Rain, snow, portal storms and non-temperature environment labels Oct 7, 2019
@ghost
Copy link

ghost commented Oct 8, 2019

Looks good to me!

// Greatest absolute change from a day's average temperature, in kelvins
constexpr double seasonality_magnitude_K = 15;
// Greatest absolute change from the year's average temperature, in kelvins
constexpr double noise_magnitude_K = 8; // 2;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 2 commented-out previous code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's the kind of code cleanup I'll do.

@kevingranade
Copy link
Member

Will need some decent play testing, but in broad strokes this is IMO a drastic improvement that I'd love to have in the game.

@Kodiologist
Copy link
Contributor Author

Awesome, I'll finish this up, then. @kevingranade, what is your opinion on the issue of moving the game start date?

ret.base_humidity = jo.get_float( "base_humidity", 50.0 );
ret.base_pressure = jo.get_float( "base_pressure", 0.0 );
ret.base_acid = jo.get_float( "base_acid", 0.0 );
ret.base_wind = jo.get_float( "base_wind", 0.0 );
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked over the data output, and I saw that windspeed average was significantly lower than usual, and had far less variability over the year.

Infact the highest windspeed for the entire year was 13mph

Would this be due to this change? and also above to peaks and variation, and also the change to W = algorithm in get_weather() ? you didn't specify any rationale for change in windpower, although the changes to humidity pressure and precipitation look perfect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I simply haven't looked at wind data or adjusted the wind code in this PR, so it relates to pressure the same way it used to. Should I overhaul wind, too?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You set base_wind, base_wind_distrib_peaks, and base_wind_season_variation to 0, in this block of code. and changed the algorithm for W = in get_weather().

Wind , as far as I can tell, dosnt need overhauling because it was set to new england data in the same way as you are doing for pressure and humidity. it could be that your changes to pressure are resulting in a flatter and lower wind distribution, due to the relationship that it previously had with the pressure value.

Could you output the data , but with no changes to those wind variables?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, actually those are default loaded values if regional settings dont specify any. so it should still be the same, assuming you are using the standard regional settings.

It must be the pressure to wind relationship is different now.... may require some tweaking to get the previous wind behaviour with the new pressure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right: the default region settings are just less redundantly specified now. And the change on the line with the assignment to W is just a variable rename. The pressure-to-wind relationship is the same, but pressure is different, so wind is different.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's up to you, wind is not vastly broken after this or anything, but it would be nice if you could find a relationship between wind and the new pressure that preserves as much of the old wind data distribution as possible - as that was matched to real-world data as close as possible in a previous PR.

If you want to do that in a separate PR, that would be fine, imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, let's focus on the other variables for now and maybe I'll do wind in a new PR.

@ghost
Copy link

ghost commented Oct 9, 2019

This is wind-speed per-hour in winter , before this change :-
51535400-496aff80-1e40-11e9-828c-5a7aae8ed8dc

After your changes, this is wind-speed per-20 minute interval in winter ( so similarish intervals. )

image

@Kodiologist Kodiologist changed the title [WIP] Weather realism Weather realism Oct 19, 2019
@Kodiologist
Copy link
Contributor Author

Okay, this PR should be good to go now.

@Kodiologist Kodiologist force-pushed the weather-realism branch 4 times, most recently from 7c66f0d to 44a7b81 Compare October 25, 2019 14:49
@Kodiologist Kodiologist force-pushed the weather-realism branch 2 times, most recently from 595bcf7 to c24bde2 Compare October 26, 2019 21:11
@kevingranade kevingranade merged commit 25a44aa into CleverRaven:master Oct 31, 2019
@AlexMooney
Copy link
Contributor

AlexMooney commented Nov 1, 2019

@Kodiologist do you happen to have the data on rain fall handy for another chart? I'd love to see the pre- and post-PR CATA precipitation versus the real world data.

@Kodiologist
Copy link
Contributor Author

Yes, in the form of the weather log linked to above.

@kevingranade
Copy link
Member

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/never-any-rain/21901/5

@kevingranade
Copy link
Member

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/missing-weather/23427/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Game: Balance Balancing of (existing) in-game features. [JSON] Changes (can be) made in JSON Mechanics: Weather Rain, snow, portal storms and non-temperature environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More realistic precipitation and temperature
4 participants