AI Needs and Shifts

Hey Folks! Since I have a few more days before the announcement kicks-off, I decided to do some more dev today. And one of the higher priorities I've set for myself is to get crew management up and running. My thinking is that the core game loop is going to hit this system a lot (possibly more than anything), so I should make sure it's operational. And ideally fun to tinker with/watch.

Up until now, the AI did a pretty good job of fulfilling its needs. It would look at current needs, check its memory to see if any known interactions would help, and then see if any of those can be repeated with items on the current ship.

Failing that, it'll then grab a few interactions at random from a list of knowns, and see if any of those can be performed on items nearby (including self). And as part of the "human-like" programming, it'll also try to avoid using an interaction it used very recently.

The result is fairly convincing. Within a few random actions, the AI starts logically satisfying its needs much of the time. And it keeps a nice variety of actions cycling.

However, gaps start to form where the AI is ignoring a deep need (like sleep) and going off to do something else. This is due to the above design, where it tries for interactions it remembers first, and then random ones. And in cases where it has no memory that covers a current need (sleep in this case), it latches on to something it knows works instead (like eating). Eventually, it'll probably satisfy all needs it can with memorized stuff, and randomly stumble upon a gapped need. But that's not ideal.

So to address that, I'm going to give AI at least a rudimentary survival memory. An artificial set of memories that it can rely upon to know that, for example, sleeping on a bed restores sleep. Or using a toilet relieves one's bladder. Like, really basic stuff. And I'll probably start each memory off with some nominal effect. E.g. sleep provides -1 tiredness, even though in reality, sleeping is more like -4 or more.

I'm hoping what this does is to give them a little nudge at the early game to know how to handle basic survival things. Their real-world experience will quickly overtake these nominal values, as their AI keeps track of average effects per interaction. And their behaviors will still differ based on where they did their learning, so we should still see some variation. Almost like personalities or quirks. (E.g. John did a lot of his learning in a place with no beds, so he associates sleeping on clothes piles with sleep more than a bed.)

That's the theory, anyway. I'm getting the code ready for that now.

The other thing I tackled today was getting the needs system to be a bit more dynamic. Previously, all crew had the same tolerances for discomfort. After, say, 15 hours without sleep, AI would start to want sleep. This is separate from physical effects like drowsiness. This is just their desire to do something about it.

As part of the crew management UI, where we can set sleep/work/free time shifts, I wanted to see if I could make this change AI via the needs system mentioned above. And the best I came up with was to let these shifts alter those tolerances. During sleep shifts, the desire to fulfill sleep needs is higher. During work, it's lower. During free time, no change.

This way, AI should feel compelled to ignore their drowsiness while on a working shift, and just keep working. Similarly, a non-tired AI might be enticed to try sleeping during the sleep shift, despite not being drowsy.

I actually added this code first today. But I quickly ran into the needs decision issue above when I was testing it. Basically, my AI was feeling like it should sleep more during sleep time, but couldn't ever figure out how unless they got lucky and tried it randomly in the past.

So there we are. A revisit to one of the first systems added to this game. The over-engineered AI system which was intended to produce binge-worthy TV in your spaceship game. It doesn't, of course. And I'm not sure if it ever will. But it's actually not that bad of a stab at it. And after reading a few papers on how Sims handles this sort of thing, it actually seems pretty in-line with the normal way of doing it. The big difference here, it seems, is that whole memory thing. A cool iteration on the idea if it ends up working!

Tags: Ostranauts


Asthepanda2iscool2's picture

"...And one of the fondest memories I have of crewing the shipping lanes between Ganymede and Mars was that John refused to sleep on his cot, and would always end up in the ships laundry hold. What a strange man."
Or when you put the ships only fridge in the bathroom and the crew decides meals are to always be held in latrines. Some rudimentary knowledge for the crew is no doubt a good idea, though I hope it won't spoil any crew quirkiness.

Rar! Rar rar rar! Thanks for reading :)

Aint_Easy's picture

you are my hero!!! i will buy your new game three times! promised!!!

dcfedor's picture

@Asthepanda2iscool2, yeah, I'd hate to lose the quirkiness, too. I'll try to nurture it as long as I can.

@Aint_Easy, thanks! I'll do my best to make the game worth it!

Dan Fedor - Founder, Blue Bottle Games