Sleep Prototype Iteration, and OOO Tomorrow

Hey Folks! Hope everyone had a good weekend. We had some much-needed rain here, and some cool temperatures to go with it. I got re-hooked on Cities Skylines, and was hell-bent on creating the perfect traffic pattern for a dense city. I managed to do okay so far, but I think there could be better...

Back on the prototype, I've been trying to get the sleep cycle running in a semi-realistic way.

Up until now, I've been able to get my crew to sleep when they need it, and wake when they're done. So far, so good. However, the AI's opinion of "done" wasn't very realistic. If I told them they preferred to be awake for 16 hours, they would fall asleep at 16 hours of sleep debt, sleep a tiny bit, wake for about an hour, and repeat.

Conversely, if I told them they preferred to be completely rested (i.e. 0 hours of sleep debt), they'd sleep until rested, wake, and continue sleeping and waking rapidly around 0.

What I wanted was for them to prefer being awake 16 hours, sleep for 8, and be fully-rested when done. And this meant that there probably had to be more than a single sleep counter switching sleep on and off.

So I started doing some research. What makes humans sleep? Why do we sleep for long periods at night, and can nap during the day? As it turns out, our hormone systems pump us with melatonin during night cycles, which promotes sleeping (among other things). During the day, melatonin isn't being produced, so we stay awake easily. And at night, it kicks-in again, making us sleepy (and stay asleep).

So I decided to try making a sleep condition that does just that: every 24-hours, it triggers an 8-hour period of high sleep comfort, making it both easy to fall asleep and stay asleep. So even when the crew sleeps for, say, 1.5 hours and their sleep debt reaches well-rested (~16 hours), they stay under for a while longer, until their sleep debt reaches 0 (i.e. a full-night's sleep).

So far, this seems to work pretty well. And interestingly, I can make a minor tweak to it such that this hormone sleep cycle condition can change times of day if the crew enters deep sleep outside of their normal time. (E.g. they stay awake 24 hours and sleep much later than usual, like adjusting to jet lag) Neat!

Also, since this sleep cycle condition basically uses a "sleep comfort" stat similar to NEO Scavenger, I can still do things like waking AI prematurely if temperatures change, alarms go off, etc.

The only down side now is that there seems to be a slight out-of-phase timing of actual sleep and this sleep cycle condition, meaning the sleepiness feeling continues a few hours after waking in the morning (and starting a few hours late). I want to make sure that's not a bug in the system.

And in the business of space travel, sleeping isn't so simple. It might be interesting to see if the values could be tweaked to simulate these shorter/polyphasic periods. But that's just icing. I think this may have been a successful test of the conditions system. It seems pretty robust!

Out of Office Tomorrow

Also, as a heads-up, I will be out of town tomorrow. It's a short errand, and I should be back tomorrow night (Tuesday). As such, I probably won't be checking email/messages until Wednesday morning.

Have a good one, all!