The Winter Dragon: It's a season for code blogs
Posted: Sat Oct 01, 2022 4:53 am
Now that the taint is ravaging the land, I'll start another code blog (mostly at Itesh's prompting). This time: seasons and the weather.
Why, you ask? Glad you asked: there's a circuitous answer for that. You see, we were talking in the staff about new players and daytime/nighttime. It is very confusing for new players who get lost in the dark! Then we got to asking pointed questions about why it is that you can't see in the dark at night (unless there's no moon, of course). Then we got to wondering why there is no moon. And moon cycles. And so I said hrm, we can probably do something interesting there with light levels in the dark, and the moon. Well, not THAT interesting gameplay-wise since it's mostly passive, but interesting atmosphere-wise. And plus Brown Ajah and other explorer types love figuring that sort of obscure mechanic out. So why not.
Well, why not indeed. I open up the weather code to look at how day and night work. Actually - I am kidding, of course. This discussion was several months ago now. But I am looking through the coding backlog and want to eventually get to it. And Flash has been reviewing some code so I feel less bad about piling more code changes on top of his queue. I am worried it might soon shrink to a size where he starts to see the light at the end of the tunnel. So here we are.
Why is day and night code located in the weather file? An excellent question, one for the ages. If you stare at WoTMUD's code long enough, the code begins to stare back at you and threaten to devour your sanity, and so you soon learn not to ask these very good and right questions. Moving on.
Ok, I've located day and night and the weather changing code. It is all jumbled together. Hrm, this is interesting. One, I feel like it was written by an insane person (this person is Eileen, circa 2000). Two, I notice that there are really just two seasons here: summer and "everything else".
Well, no wonder it is always freezing cold in Randland: it's almost always "everything else" season.
So I go searching around for where summer is defined (it uses a definition like "IS_SUMMER" and you pass in the current month and it tells you whether it is summer or not). I presume there are definitions for the other seasons, and if there aren't I can add them easily.
Oh, delightful. The other seasons do already exist. But I notice these seasons are assuming a 16-month calendar. This does not sound right at all. And it is not: this is stock CircleMUD! However the Wheel of Time (and indeed our game) uses a 13-month calendar. And, this definition of seasons assumes that the start of the year is spring. But in Wheel of Time's calendar, the last day of the year is the winter solstice. So the start of the year should be winter. So the seasons make no sense. At all. On any dimension. Fun! This is about par for the course with WoTMUD.
Ok, so I have adjusted the definitions of the seasons to match our 13-month calendar. You'll no doubt cleverly point out that 13 months do not divide into 4 seasons, which is entirely true. So I just shove an extra month into one of the lucky seasons. A proper solution would be to calculate the season based on the day of the year instead of the month, but it is late and I am tired and cannot be bothered. I make a mental note to update that... someday. Yes, someday.
Next, I go back to the weather code and break apart "everything else" into a proper winter, fall and spring. For winter, I leave the current freezing temperatures. For spring and fall, I add in a new, more moderate climate. I compile and run this code and it works. A win!
I decide to go review how natural temperature changes occur to make sure I have not missed anything. Hrm here too. I notice that, among an overly complex calculation for how air pressure impacts the temperature, it is mostly deciding at random whether it gets warmer or colder (within the appropriate range) on any given hour. Deserts excepted. Not very realistic there either. It should generally get warmer during the daylight hours, and colder during nighttime hours. So I put a slight thumb on the scale there to make it more likely it turns colder at night and warmer during the day.
And this compiles and works also.
So now we have:
- Seasons that map to the Wheel of Time calendar
- Seasons that make sense, at all
- Fall and Spring, in addition to Summer and "Permanent Ice Age"
- Temperatures that will trend colder at night and warmer during the day
And I still have not gotten to the moon or levels of light, which was the entire original thrust of the conversation. Newbies will have to continue to suffer in the dark when they drop their torches. Oh well, a problem for another day.
Why, you ask? Glad you asked: there's a circuitous answer for that. You see, we were talking in the staff about new players and daytime/nighttime. It is very confusing for new players who get lost in the dark! Then we got to asking pointed questions about why it is that you can't see in the dark at night (unless there's no moon, of course). Then we got to wondering why there is no moon. And moon cycles. And so I said hrm, we can probably do something interesting there with light levels in the dark, and the moon. Well, not THAT interesting gameplay-wise since it's mostly passive, but interesting atmosphere-wise. And plus Brown Ajah and other explorer types love figuring that sort of obscure mechanic out. So why not.
Well, why not indeed. I open up the weather code to look at how day and night work. Actually - I am kidding, of course. This discussion was several months ago now. But I am looking through the coding backlog and want to eventually get to it. And Flash has been reviewing some code so I feel less bad about piling more code changes on top of his queue. I am worried it might soon shrink to a size where he starts to see the light at the end of the tunnel. So here we are.
Why is day and night code located in the weather file? An excellent question, one for the ages. If you stare at WoTMUD's code long enough, the code begins to stare back at you and threaten to devour your sanity, and so you soon learn not to ask these very good and right questions. Moving on.
Ok, I've located day and night and the weather changing code. It is all jumbled together. Hrm, this is interesting. One, I feel like it was written by an insane person (this person is Eileen, circa 2000). Two, I notice that there are really just two seasons here: summer and "everything else".
Well, no wonder it is always freezing cold in Randland: it's almost always "everything else" season.
So I go searching around for where summer is defined (it uses a definition like "IS_SUMMER" and you pass in the current month and it tells you whether it is summer or not). I presume there are definitions for the other seasons, and if there aren't I can add them easily.
Oh, delightful. The other seasons do already exist. But I notice these seasons are assuming a 16-month calendar. This does not sound right at all. And it is not: this is stock CircleMUD! However the Wheel of Time (and indeed our game) uses a 13-month calendar. And, this definition of seasons assumes that the start of the year is spring. But in Wheel of Time's calendar, the last day of the year is the winter solstice. So the start of the year should be winter. So the seasons make no sense. At all. On any dimension. Fun! This is about par for the course with WoTMUD.
Ok, so I have adjusted the definitions of the seasons to match our 13-month calendar. You'll no doubt cleverly point out that 13 months do not divide into 4 seasons, which is entirely true. So I just shove an extra month into one of the lucky seasons. A proper solution would be to calculate the season based on the day of the year instead of the month, but it is late and I am tired and cannot be bothered. I make a mental note to update that... someday. Yes, someday.
Next, I go back to the weather code and break apart "everything else" into a proper winter, fall and spring. For winter, I leave the current freezing temperatures. For spring and fall, I add in a new, more moderate climate. I compile and run this code and it works. A win!
I decide to go review how natural temperature changes occur to make sure I have not missed anything. Hrm here too. I notice that, among an overly complex calculation for how air pressure impacts the temperature, it is mostly deciding at random whether it gets warmer or colder (within the appropriate range) on any given hour. Deserts excepted. Not very realistic there either. It should generally get warmer during the daylight hours, and colder during nighttime hours. So I put a slight thumb on the scale there to make it more likely it turns colder at night and warmer during the day.
And this compiles and works also.
So now we have:
- Seasons that map to the Wheel of Time calendar
- Seasons that make sense, at all
- Fall and Spring, in addition to Summer and "Permanent Ice Age"
- Temperatures that will trend colder at night and warmer during the day
And I still have not gotten to the moon or levels of light, which was the entire original thrust of the conversation. Newbies will have to continue to suffer in the dark when they drop their torches. Oh well, a problem for another day.