Bed Interactions and Sleep Phases

Today was cut a bit short by some errands, including a trip to the vet for our cat, Brak. Unfortunately, it looks like he has some sort of genetic dental decay, and some more teeth are going to have to come out. He was not pleased with the poking, prodding, and general indignities of the vet's. And I fear he'll be no more pleased in a month when he visits again only to wake-up with massive jaw ache. Poor little guy.

On the up side, the new food he was prescribed was a hit. He plowed through a whole bowl in one sitting, which is unusual! And if this surgery is anything like the last, a few days of mending will mean he's like a new cat.

During the time I did get to work today, it was on the bed, sleep, and interaction code.

One of the first things I did was to update the interaction data type to add required/forbidden conditions for "them," in addition to the existing "us" fields. This allows me to be a bit more selective about how interactions are applied. Interactions are kinda like the battlemoves in NEO Scavenger, only more general-use.

And the first application of this new field is going to be sleeping interactions with the bed. The crew checks periodically for things on their priorities list, and for each of those, checks to see if someone or something on the ship can help. In the case of sleep deprivation, they're looking for something to restore the sleep stat. Enter the bed.

The crew will then query the bed for any interactions that might improve the sleep stat, and finding one, will initiate the "SeekSleepN1" interaction. This interaction lasts about 15 minutes and has a possible outcome of "SleepAllowN1" or "SleepDenyN1." If allowed, actual sleeping will begin with phase N1, lasting another 15 minutes. Once that's up, a similar interaction exchange happens ushering in phase N2, N3, N4, and REM phases, before starting the cycle all over again.

Why the multiple phases? For one thing, I wanted to make sleeping more realistic. People don't always drop like a sack of bricks for 8 hours and wake up refreshed. Many times, people try to sleep and can't, or sleep for a while and wake themselves up. This 15-minute phase system allows for the sleeping process to self-interrupt when the conditions require it.

It also allows me to mimic the way humans sleep by differentiating phases where the human is lightly sleeping vs. deeply sleeping, and how much to restore any lost sleep during each phase. The initial phase offers no sleep bonus, while REM offers double. Therefore, getting longer stretches of sleep is more valuable than shorter naps.

Getting back to the "us" vs. "them" fields I added, this was to facilitate the interaction between crew and beds. The crew asks the bed to interact, and the bed chooses between "allow" or "deny." This choice will be controlled by whether the crew is tired enough to sleep or not. If the crew is not tired, the choice is "deny." The crew, in this case, is "them" from the bed's point of view. So the interactions "allow" and "deny" will have "tired" and "not tired" among their required conditions, respectively.

I know this seems a bit weird, the bed making decisions about if a person can sleep. But it's the way the interaction system works. Each interaction has an "us" and "them," effects it applies to both "us" and "them," and zero or more possible interaction outcomes. So one way or the other, the bed is going to be "interacting" with the crew.

It might be possible to add filler interactions on the bed's side that automatically bounce back to the crew to make the decision. I'll have to think about that.

As of now, however, I can get crew to go to sleep on a bed when tired, and cycle through the sleep phases, decreasing the sleep deprivation stat.

I should also mention that this will use different data than NEO Scavenger. In NEO Scavenger, sleep and fatigue were on the same scale, which caused some simulation shortfalls. I had to make the thresholds for things like sleep deprivation much higher than real life, since both sleep and fatigue counted against it. In this prototype, however, it'll be pure sleep, and probably another scale for fatigue.

Other than sleep, I managed to fix a few minor bugs in the prototype. Item positions were changing incorrectly when switching from crew sim to ship build mode multiple times, and a few pieces of code had to be updated to include items where they only included crew before.

I guess it was a rather productive day, after all! Just compressed into a smaller timespan than usual. Have a good night, all!

Comments

linibot's picture
linibot

While the benefits of napping are potentially questionable for the actual game, I highly advise them for the humans playing/making the game. ;) 5 seconds of googling tells me that a thing called The National Sleep Foundation agrees with me. :D

And always glad to hear of cats getting a healthy appetite back!


NEO Scavenger: FAQ
10 Ways (not) to Die - A beginner's guide

matsy's picture
matsy

The big question I'm sure we are all asking, will cats be in the game?

dcfedor's picture
dcfedor

I definitely avail myself of naps frequently, so I agree! I read somewhere else that 30 minutes is the idea nap duration, as anything less or more leads to grogginess. So it's encouraging to see the NSF found similar.

Technically, I think the current game data would reward a napping crewmember with some sleep benefit per-nap. But I think they'd need to nap more hours to get equivalent benefits to a solid sleep cycle.

As for cats, we'll have to see! They certainly have earned their place in spaceship sci-fi, with such famous examples as Ripley's Jonesy and Data's Spot.

Dan Fedor - Founder, Blue Bottle Games