Hey Folks! Hope everyone had a good weekend. Ours was mercifully light on chores and errands, for once. We even socialized with outsiders. Almost like normal people!
Back in space, I tried to focus on getting the toilets working, and I think they're sorted. It's a simple interaction for now. AI decides they need to poop, seeks a toilet, and for now, the toilet always allows pooping, so they proceed. There's room for variation there, of course. Things like a malfunction, or health condition preventing poop. But this was mainly about getting another physiological need operating, and that's done.
After testing a ship out with 4 beds, 2 stocked fridges, and 2 toilets, I was starting to see some AI patterns. And my first obstacles.
First of all, AI loves food. Like, no matter what is highest on their priority list, if food is in the top 3-4, it's what they go for first. I know you're probably thinking, "duh," but this isn't working as designed. Something is causing AI to think satisfying a greater need isn't as important as a lesser need, which is concerning.
One possibility is the various interactions have inconsistent hint data. Each interaction has a list of things it promises to an AI. What they get depends on if the interaction succeeds. But for the purposes of deciding what to do next, the AI needs to know which interactions might give them what they want. And which ever one promises the most for a high priority wins. So maybe food is promising too much.
It could also be something less obvious, so I'll need to debug to know for sure.
A second thing I noticed had to do with the data editing. When I specify the results of an interaction, I list the condition triggers that are applied. They'll be things like +1 achievement stat, or -1 food. Provided the trigger passes its test, the specified condition changes by the specified amount.
The problem with this is that adding/subtracting something like +5 to a stat means I have to either:
1) Create a condition trigger that's +5 to the stat, or
2) List the +1 stat condition 5 times
And if I want to subtract 5, I need a separate copy that's -5 or 5 copies of the -1. And ditto for +/-10, 15, 20, etc. And when you start to do this for each stat, you end up with long lists of almost redundant data and bloated condition trigger definitions.
I'm thinking a better way to do this is to just have a single condition for each stat and let the condition trigger multiply it by +1, -1, +5, -5, etc. as needed. This way, the "EatFood" interaction can just apply a "Hunger x-20" instead of listing "HungerDown" 20 times.
And in fact, as I was looking this over, I realized this is basically a copy of the new loot system I put into place. E.g. "Fridge01" is shorthand for 10-30 yellow food packets, so I only have to list "Fridge01" in the data, and the game knows that's referring to a loot table entry. I should be able to do this for conditions, as well, and maybe that'll simultaneously give me lots of versatility, reduce data complexity/redundancy, and reuse code.
I'll have to see if there are any gotchas to that approach, and if the refactoring is as worth it as it seems. But I've been meaning to do an optimization like this for a while, so I don't think this need is going away soon.