Hauling Tasks

Hey Folks! A little bit of progress today between admin stuff. Focusing on the hauling task.

My initial attempts to solve hauling involved writing code to search for storage zones, and do special handling whether there was a matching item to stack on, or empty space in the zone. It involved generating special interactions to fetch the haul item and direct it to the destination stack, or else creating a placeholder and pretending it would be installed in an empty space.

Most of the way through this, I realized it was a bad idea. And I wasn't even sure how to go the final mile. But then it hit me: why am I going through all the trouble?

Since the AI is just asking for the next task, and then assigning an interaction defined inside that task, why don't I just add a bit more destination info to the task, and let the AI sort it out? Basically, instead of queueing a single interaction defined by a normal task, hauling tasks will assign 3:

1 - Pick up the hauled item.
2 - Walk to the destination zone.
3 - Drop the hauled item in the zone.

#1 will automatically handle walking to the item to pick it up. And I have that target info inside the task. #2 is the new bit of info I'll store inside the task, used only in this case. We'll have the AI walk to the destination after #1 is done. Then, #3 will use a function I setup a while ago for dropping items nearby, which either stacks on nearby items if it can, or otherwise drops it on open floor nearby.

I'm sure there are a few edge cases this will break on. Things like getting interrupted, or running out of drop space. But the code is simpler than my first approach, and might even be more reliable as a result.

So far, I've got the code written and it doesn't crash, but the AI is failing the testing phase where it decides if the task is possible. So it never takes the tasks. I'll have to dig into that tomorrow!

Tags: Ostranauts