Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Priority Data Structure?  (Read 930 times)

Argembarger

  • Bay Watcher
    • View Profile
    • Not quite yet
Priority Data Structure?
« on: January 18, 2013, 01:12:19 pm »

I wasn't sure which forum was most appropriate for this. It seems a little too specific (and possibly too technical?) for general discussion, and it isn't necessarily limited to one mode or the other. Since Future of the Fortress is reserved for current development, it's technically a suggestion?

It's also kind of rambly and perhaps not as focused as a proper question should be, so just fair warning there.

So I'm relatively aware of what people seem to want, or complain about, in terms of wanting their dwarves to prioritize jobs more efficiently. Most of this seems to be hard-coded at the moment. I recall a Dwarf Fortress Talk where Toady spelled out a basic hierarchy of dwarven needs... Avoid Danger > Find Child > Drink > Eat > Sleep > Job, or something like that.

Now, I'm not sure exactly how the jobs are broken down here. This seems to be under the purview of the Job Priorities thread on the Eternal Suggestions board. I can assume the jobs have a hardcoded priority, with Rescue Wounded somewhere near the top, Produce Item somewhere in the middle, and Haul Item somewhere near the bottom.

What I want to know is, how do dwarves keep track of their jobs? Do they store them in a stack? Or can they only remember one thing at a time, like a goldfish? When a dwarf gets interrupted, say, by a monster, or by a desire for booze, when that interruption is resolved, does the original task come back, or do they have to receive a "new" request to do that job?

I suspect that they really can only remember one thing at a time, and my evidence is largely anecdotal and based on casual observation. Most of the time, it doesn't factor in, as the job is constantly pinging for a dwarf to do it (like a designation) and they will get re-pinged when it is time, or else some other dwarf takes care of it in the interim. Also, because of notification spam.

I just wonder what it would be like if every dwarf kept a priority-sorted queue of tasks. With this, it would be nice if "distance to the task" was factored in to the priority calculation, and if the priorities were recalculated every-so-often. And time-sensitive tasks could slowly increment in priority, leading to much more natural decision-making.

I'm thinking of a situation where a dwarf is tasked with constructing a wall. Maybe there are some blocks at the construction site, but some are still down by the mason's workshops deep in the earth. How it works currently, the dwarf is as likely as anything to pick a very inconvenient time to decide s/he wants to get something to drink. S/he will stop what s/he is doing, walk all the way to the food storage area, drink some booze, and walk all the way back. All because this need to drink crossed some arbitrary threshold, making it the most important thing in the dwarf's world.

What if that "drink" job was always in the dwarf's head, so long as they weren't completely quenched, but it had such a low priority that they just usually never thought about it? They would slowly get thirstier and thirstier, and eventually it would be an overwhelming compulsion, yes, but what if, at some point when they were just moderately thirsty, they could compare the distance to their current job and the distance to the booze, and decide that now would be a convenient time to step over and have a drink? You could potentially see a dwarf, on the way to the job site, step over and grab a quick drink before continuing the journey, instead of waiting until they were totally dying of thirst and downing a whole gallon at once.

Maybe something like this is already in place, but if not, it seems to me to be the way to do it. Dwarves would make decisions based on convenience, like real people do, rather than jerked along by the chain of global job priorities, distance be damned.

tl;dr: ITT: why are dwarves doing things?
« Last Edit: January 19, 2013, 07:19:30 pm by Argembarger »
Logged
Quote from: penguinofhonor
Quote from: miauw62
This guy needs to write a biography about Columbus. I would totally buy it.
I can see it now.

trying to make a different's: the life of Columbus

FuzzyZergling

  • Bay Watcher
  • Zergin' erry day.
    • View Profile
Re: Priority Data Structure?
« Reply #1 on: January 18, 2013, 02:48:09 pm »

I don't think anyone here, other than Toady himself, would really be able to answer your questions.
Logged

sprawl15

  • Bay Watcher
    • View Profile
Re: Priority Data Structure?
« Reply #2 on: January 18, 2013, 03:11:39 pm »

tl;dr: ITT: why are dwarves doing things?

Alcohol.
Logged

Babylon

  • Bay Watcher
    • View Profile
Re: Priority Data Structure?
« Reply #3 on: January 18, 2013, 03:28:42 pm »

I think this belongs in the suggestions section.
Logged

Rutilant

  • Bay Watcher
    • View Profile
Re: Priority Data Structure?
« Reply #4 on: January 18, 2013, 03:54:18 pm »

Just from personal experience Rescue Wounded seems to be priority none.

Like, I set aside a team of paramedics whose only job is to go get wounded and do -nothing- else and they still leave them sitting up there for a week, even with a high "helping others" score.


If anyone in my fort is at risk of dying from blood loss... They'll still die from blood loss.  Once the wounds have scabbed over my dwarves might go pick them up.
Logged

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: Priority Data Structure?
« Reply #5 on: January 18, 2013, 07:08:17 pm »

When a dwarf gets interrupted, say, by a monster, or by a desire for booze, when that interruption is resolved, does the original task come back, or do they have to receive a "new" request to do that job?
No, it's as though they were never working on it in the first place. Sometimes they'll retake the job they were on because they're the closest dwarf who's not occupied, but this desirable outcome doesn't happen intentionally.
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Kaos

  • Bay Watcher
    • View Profile
Re: Priority Data Structure?
« Reply #6 on: January 18, 2013, 08:51:59 pm »

Just from personal experience Rescue Wounded seems to be priority none.

Like, I set aside a team of paramedics whose only job is to go get wounded and do -nothing- else and they still leave them sitting up there for a week, even with a high "helping others" score.


If anyone in my fort is at risk of dying from blood loss... They'll still die from blood loss.  Once the wounds have scabbed over my dwarves might go pick them up.
Actually it seems to be affected by their empathy and helpfulness traits, you know the lines that say: "doesn't care for the suffering of others" "enjoys helping others" and so on...


For the OP, their job list seems to be 1 at the time, since whatever they are doing if affected by a higher priority job, gets cancelled and then a new job is reissued if needs be, and most likely another dwarf will pick the new job.


What people do is segregate dwarves by jobs, for example a carpenter would only have the carpenter job active so they keep making wood items non-stop (except for basic needs) instead of getting distracted by hauling or other jobs.
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: Priority Data Structure?
« Reply #7 on: January 19, 2013, 01:43:11 am »

I can give a little bit of answer about this, and that is that right now it isn't the dwarf that picks the job, but rather the job that picks the dwarf. So when a task is created it takes a look around at all of the dwarves available for the task (i.e. not partying, eating, drinking, sleeping, or doing some other task) and then filters out all of the ones with proper labors, and then picks whichever one is closest. As such if the dwarf cancels a task there is a chance that the job might pick him again, or it might pick a different dwarf. Also dwarves will prefer to stay on the same task if possible. This is the reason why miners or engravers that are mining/smoothing tiles will do large stretches of just mining or smoothing even if there are other jobs they could do that are closer to them. Also dwarves that are working in workshops will attempt to stay pick a new task from their current workshop if one is available rather then going to a different task.

And right now dwarves are much better at eating and drinking then they used to be. Right now dwarves will usually finish the current task they are working on, even if they move into the "hungry" or "thirsty" stages (there was actually a point back in early 31.x where the desire to finish the task was so great that people were having dwarves on long tasks actually die of dehydration!). Back in 40d as soon as a dwarf became either hungry or thirsty they would immediately cancel the task for the drink or eat jobs.

And just a final note, but right now job priority is more like this:
"Me tasks" (eating, drinking, on break, etc. prevent getting other tasks) > produce items/haul items >> retrieve wounded > feed/water prisoners
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Argembarger

  • Bay Watcher
    • View Profile
    • Not quite yet
Re: Priority Data Structure?
« Reply #8 on: January 19, 2013, 07:15:19 pm »

I think this belongs in the suggestions section.

Okay, thanks
Logged
Quote from: penguinofhonor
Quote from: miauw62
This guy needs to write a biography about Columbus. I would totally buy it.
I can see it now.

trying to make a different's: the life of Columbus

GreatWyrmGold

  • Bay Watcher
  • Sane, by the local standards.
    • View Profile
Re: Priority Data Structure?
« Reply #9 on: January 20, 2013, 01:38:10 pm »

I think this belongs in the suggestions section.
Not particularly, it's not a suggestion. It's a question.
Logged
Sig
Are you a GM with players who haven't posted? TheDelinquent Players Help will have Bay12 give you an action!
[GreatWyrmGold] gets a little crown. May it forever be his mark of Cain; let no one argue pointless subjects with him lest they receive the same.

sockless

  • Bay Watcher
    • View Profile
Re: Priority Data Structure?
« Reply #10 on: January 21, 2013, 05:11:38 am »

I think this belongs in the suggestions section.
Not particularly, it's not a suggestion. It's a question.

And a suggestion at the same time.

From my observations, dwarves have only one job in mind, and when that's finished, they decide what job to do next. That's why it gets irritating when they get interrupted by animals. I'm not sure what the priority is, but party seems to be right up the top, and clean right down the bottom (I've seen it happen like twice).
Logged
Iv seen people who haven't had a redheaded person in their family for quite a while, and then out of nowhere two out of three of their children have red hair.
What color was the mailman's hair?