quote:
Originally posted by Bas Cost Budde:
<STRONG>I have done a similar, albeit simpler, problem recently, trying to assign a starting point for mail delivery agents who live in their own delivery town. This is a highly static problem, as opposed to the hauling, but nevertheles not quite straightforward to solve.
Toady, would it help to reverse the order of pile hauling tasks? As it is now, you do have some sort of individual starvation, or 'stack rot' as we said in class; maybe a queue is more fair to the hauled items than a stack.</STRONG>
Queue comes with similar problems I think because with queues you can end up with countless unimportant jobs blocking the important ones.
---
A possibility I think which could help things a bit is a job-"pending" system. Items etc. would designate where they want to go (provided there is free space in the target stockpile), the stockpile is informed of the intention but not actual allocations are made yet. This could partially solve the "starvation problem" as pending jobs could be overridden by other pending jobs (food is waiting to be stored, hungry dwarf creates "eat food" job, once he arrives at the food and proceeds to eat it the "store me" job is cancelled)
Only when a job changes from "pending" to "accepted/claimed" by being worked on by a dwarf actual capacy in stockpiles is reserved.
Of course this could lead to several odd interactions, like horde of hungry dwarfes racing to a single foodstuff, ignoring those that are only slightly further away, but this also could be dealt with the "intent" notifications. If a job is seeking for a destination (eat food, store me) it checks the nearest destinations for the number of intent declarations vs free capacy and decides based upon a mixture of distance and "overcrowding".
Finally regarding the "doing" of jobs, I think we can leave it in the hands of capable dwarfs to actually select the next job to do, by a mixture of skill level (I'm a legendary weaponsmith and dabbling engraver, so I'll ignore that engraving job and do that slightly father away weaponmaking job instead), distance (how far do I have to run to get there), personal preference (RUBIES? I LOVE Rubies!!!), estimated length of job (to encourage the completion of short jobs first) , elapsed waiting time (so all jobs have a chance for completion, may be merged with job priority instead) and job priority (the ability to give jobs the "do this NOW, maximum priority" marker - i.e. your fortress is flooding and you dwarfs are rather hauling stones than pulling the lever to close the floodgate)
If the "free capacy" of an destination decreases all those that intend to go there are informed and might recalculate their destinations.
The intent-sending of course also works with job themselves, so if a dwarf goes to a certain job they do not "claim" it until they actually start doing it - so if another dwarf much closer than the first one becomes jobless and looks for something to do they might also select the job (they are deterred by the "overcrowding" - there is space for 1 dwarf and 1 dwarf already announced his intent, but perhaps they are highly skilled in the job and extremely close and there are no other good jobs nearby) and - naturally - arrive much earlier, claim it, the first dwarf gets informed of a capacy change (0 dwarf can do this job now) and goes looking for a new one.
Of course there are lots of ways to further expand that system (at the cost of processing power) by having dwarfs on the way to a job periodically check if there any jobs they would rather do, having new jobs created inform nearby dwarf, triggering a re-check of what they are wanting to do, allowing dwarfs to abandon jobs they are doing also for non-interrupt everything jobs (eat, drink, being startled, dangerous terrain) but at a high penealty (dwarfs prefer to finish whatever they are doing) modelling current "interrupt" jobs (drink/eat/sleep) to work similarily (if the dwarf is slightly tired he might work on, he he is tired he probably will go to bed if he does not have a job already, but he won't just drop everything and go to be, only if he can hardly stay upright the "sleep" job will be imporant enough to overcome the "wants to finish current job" penealty)
[ April 17, 2007: Message edited by: CharonX ]