Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4

Author Topic: Job Priorities Discussion  (Read 34483 times)

Grendus

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #30 on: July 30, 2009, 05:25:59 pm »

Ok, so here's a thought. Although it might take some work to revise, having dwarves pick jobs instead of jobs pick dwarves would make this problem simple to solve.

The first stage would be to sort all the jobs into their related labors: item hauling jobs would be in a list of other item hauling jobs, armorsmithing jobs would be in a list of armorsmithing jobs, etc.

Each dwarf has labors enabled and prioritized. Whenever a dwarf goes to "no job" status, he goes to his highest priority task and goes into the list of jobs related to that labor - for example, a weaponsmith would search the weaponsmithing list. He then chooses the nearest task in that list and goes to work. If there are no weaponsmithing tasks, he goes to his second highest labor and does the same until he finds a job he can do.

The downside to this is it would be a TON of work, Toady would basically be rewriting a major portion of the game's AI. However, if it would reduce lag and increase productivity, it might be worth the effort.
Logged
A quick guide to surviving your first few days in CataclysmDDA:
http://www.bay12forums.com/smf/index.php?topic=121194.msg4796325;topicseen#msg4796325

ArPharazon

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #31 on: August 14, 2009, 05:10:12 am »

I got the idea while posting in another thread, but currently the way the jobs are assigned effectively with "for each dwarf if job=idle then assign job to dwarf".

What if we had a priority designations, similar to the traffic designation, with levels Low, Normal, High, Urgent?  They way it works is:

You designate a (L)ow, (N)ormal, (H)igh, (U)rgent zone, which flashes the letter like traffic zones, and you can select which jobs the zone affects through an interface like the labors list. You need a room dug out now? Designate the room high, select mining and stone hauling, it gets prioritized. You want this magma flood lever to be super important? Designate a 1-square urgent zone with none of the labors on the list selected (that's how it works for dwarves right?) and dwarves will treat as jobs not fitting in any of the standard labor categories (including lever pulling) as very important and do them first.

How does that work? While the current job assigner grabs the dwarf if he is idle, this one would grab if the dwarf's current job is of a lower priority. A low priority zone would grab idlers, a normal zone grabs idlers and steals low priority workers, an urgent zone steals everyone not already on an urgent job.

This won't allow you to designate the same area to be a low priority farm but high priority stone hauling, but for that you could make it a bit more complicated by having High Hunting like tsen suggested.
Logged

AngleWyrm

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #32 on: May 05, 2010, 02:55:09 am »

(I realize this is an old thread, but it's connected to a popular item on the Eternal Suggestions, so I'm refreshing it

I am assuming based on what I remember of discussions elsewhere that the job code at the moment works something like:
* Periodically check the jobs list
* For each job, check if there is a suitable dwarf available.
* If so, assign job to dwarf

So what it seems like is how can we structure the quoted AI behavior, so that the player specifies their preference per dwarf and/or globally.

First up, there already must exist a list of dwarves, in order for the job engine to search for a suitable dwarf. It could be as simple as the list of all player dwarves, and will probably contain about 7~200 entries -- a tiny search space. By tiny, I mean that there is no significant speed gain from implementing an O(log N) type search, instead of a simple O(N) scan. Overhead consumes the difference.

Second, the list very likely has the property of ranking the dwarves. First dwarf looked at, second dwarf, last dwarf. And ranking the dwarves is what we really want to do, yeah? So all that is required is to gather the dwarves into a list, and then sort that list on some property (we'll get to that in a minute), so that a dwarf is favored to do a job by being at the top of the list, or is unlikely to be selected because other eligible dwarves are above on the list.

For a given dwarf there are many jobs he can do (sorted in order of player preference), and for a given job there are many dwarves that can do it. In database terminology this is called a Many-To-Many relationship.

When a given job goes searching for a dwarf, it finds a dwarf and looks at that dwarf's priorities (or the global one if the dwarf doesn't have a specific set). The job finds itself named on the dwarf's job list or skips the dwarf. the Rank is how far down the dwarf's priority list that job is located.

The job that is looking for a worker makes a temporary table, listing each dwarf and the priority rank the dwarf gave that job (1st position, 2nd choice, 3rd in list, and so on). Then sort the temporary table on rankings, and pick the dwarf who gave that job the highest priority (lowest number).

The temporary tables would only need to be updated when there is a change in dwarves and/or their priorities.

-Cheers,
AngleWyrm

« Last Edit: May 05, 2010, 03:44:04 am by AngleWyrm »
Logged

onipanda

  • Escaped Lunatic
    • View Profile
Re: Job Priorities Discussion
« Reply #33 on: May 11, 2010, 06:22:23 am »

Came here thanks to the eternal suggestions also.

I think this should probably be broken down into a short, mid, and long term fix. What's the easiest patch in the short term to make it work better? The jobs list clearly has a method in which it's populated, so as it's been said, being able to reorder that list would make things go smoother and should be incredibly simple to implement. For the mid term, if the jobs list picks the closest dwarf then checks for applicable skill then a patch for that also shouldn't be so hard. Make the dwarf labor list be able to be prioritized just like trading, and based on what you have set would increase the distance of the dwarf to the job. Then you go on to long term having a much more elegant method of letting your dwarves prioritize jobs.
Logged

AngleWyrm

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #34 on: May 18, 2010, 09:25:04 pm »

A simple way to prioritize jobs would be to allow the player to order the list of labors the dwarf can do. The labor list could have an eXpand list option, which switches from grouped list of labors to a long list of labors. From there, the player 'P'rioritizes a given labor by bumping it up the list. When the list is eXpanded a second time, so that it goes back to grouped labors, each labor could have a number next to it showing it's priority rank, as well as the dwarf's current skill.

Miner-3 (2) means that this dwarf has skill level 3 in mining, and there is one labor above it on the prioritized labors view.
Logged

konzill

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #35 on: October 11, 2010, 05:55:59 pm »

I second this idea. If there are Job  priorities then it would make sense to sortable profiles. It would also make sense to link these to profession. (or should that be desired profession).

A possible related solution would be the ability to create profile templates that are saved permanently and importable/exportable. Each template would act as a combination labor enabler/disabler and job priority setter. So "Farmer" might look like:

High Plant Seed
Mid  Harvest Plant
Low Mill
Low Process Plant

High priority takes the first job of that type as normal. Mid waits X job cycles for a new "High" task to come up, and Low waits say 3x job cycles. Got a new Milker/Cheesemaker?  Apply a template and forget about him/her instead of taking 30 minutes to micromanage the tasks of your new immigrants.

Something else that could prove useful would be assigning specific tasks to the templates as well, so for example we could have:

Glassmaker
High Make Glass
Mid  Collect Sand

Also, a "Universal" template for all dwarves to do if the AI has used their normal template and they're still idle would help a lot.

Lastly and only peripherally related is being able to designate 2 or more levels of priority to areas that affect the priority of hauling tasks so important areas can stay clear while the outer reaches of the fort get things done more slowly.
Logged

harborpirate

  • Bay Watcher
  • cancels eat: job item lost or destroyed.
    • View Profile
Re: Job Priorities Discussion
« Reply #36 on: October 14, 2010, 02:52:38 pm »

Job priorities should be settable in the raws. Priorities by profession would be nice to have but are not as immediately pressing as being able to set "pull lever" to the number one priority job type.
Logged

Jake

  • Bay Watcher
  • Remember Boatmurdered!
    • View Profile
    • My Web Fiction
Re: Job Priorities Discussion
« Reply #37 on: October 14, 2010, 07:19:23 pm »

Job priorities should be settable in the raws. Priorities by profession would be nice to have but are not as immediately pressing as being able to set "pull lever" to the number one priority job type.
I was thinking along similar lines, at least as a stepping stone. It might actually be all most players need; setting priorities by profession wouldn't enable anything that can't already be done with the existing workshop and labour settings, albeit with a bit more fiddling about than is ideal, and I'm not convinced it would cut CPU load by enough to justify the effort.
Logged
Never used Dwarf Therapist, mods or tilesets in all the years I've been playing.
I think Toady's confusing interface better simulates the experience of a bunch of disorganised drunken dwarves running a fort.

Black Powder Firearms - Superior firepower, realistic manufacturing and rocket launchers!

blur

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #38 on: January 04, 2011, 03:23:32 pm »

If the priority of a certain labor would be the same as his skill, and if it was possible to change the imaginary skill level of jobs like hauling or cleaning in the orders menu, it would make things much easier. Imagine setting the priority level of hauling to 10 causing everyone who hasn't another job in which he isn't at least accomplished, to store that useless stone in a quantum stockpile. It would even be possible that idling dwarves with military skills go to an unscheduled individual combat drill.
As an advanced goal, I recommend adding variables to the job priority in a "Labor" section in the z-screen. So, you could set the variable for blacksmithing to "+5", and your legendary+1 mason and master blacksmith will go to the forge instead of creating rock tables. Best would be the ability to write a function for job priority, e.g. 3*level-12. This would stop all workers below proficient from doing these jobs, since their priority is below or equal zero. Proficient workers have a quite low priority of 3, equal to a competent skill in another job. They will work instead of idling, but not block the workshop. Talented workers have normal priority, while experts are called with the priority that is equal to a normal master. This  function would be useful when creating platinum statues, since it keeps out low-skilled workers and attracts high-level dwarves.
For making blocks, you could set the masonry function to e.g. -2*skill+7 to get low-skilled workers
When two jobs have the same priority, the closer one is chosen. If two dwarves apply for a certain job, the one with the higher personal priority will be chosen.
Logged

thistleknot

  • Bay Watcher
  • Escaped Normalized Spreadsheet Berserker
    • View Profile
Re: Job Priorities Discussion
« Reply #39 on: November 06, 2011, 10:12:44 am »

It would be nice if one could prioritize a job in the jobs screen.  Maybe set it from inactive to active (or queued) so it becomes started on immediately or next if not started.  Similar to the managers screen, yet build construction jobs can't be prioritized.  I was gonna vote on the et suggestion page, but saw a job priority was already in there.

RabidAnubis

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #40 on: November 08, 2011, 05:00:59 pm »

Whatever it is, needs to be done....
Logged
Dwarf Fortress: Your game is working on giving NPC's lives. Our game is working on giving them a working nervous system.
Aahhh I can't find the fish cakes in the bunny level, they keep getting enraged and I don't have any holy hand grenades
The Age of Myth: Goldenhold

Kogut

  • Bay Watcher
  • Next account: Bulwersator
    • View Profile
Re: Job Priorities Discussion
« Reply #41 on: December 10, 2011, 08:43:25 am »

[PRIORITY:RESPONSIBILITY:TRADE:IMPORTANT]
[PRIORITY:RESPONSIBILITY:HEALTH_MANAGEMENT:CRITICAL]

[PRIORITY:REACTION:TAN_A_HIDE:CRITICAL]
[PRIORITY:REACTION:SCREW_PRESS:NORMAL]

[PRIORITY:JOB:ANIMAL_TRAINER:IDLE]
[PRIORITY:JOB:WOODCRAFTER:NORMAL]

[PRIORITY:HAULING:ITEM_TOY_PUZZLEBOX:IDLE]
[PRIORITY:HAULING:MARBLE:NORMAL]
[PRIORITY:HAULING:ADAMANTINE_WAFFRES:IMPORTANT]
Mockup of RAWs of global priorities.

My addition, to allow interrupting less important jobs

Code: [Select]
[PRIORITY:RESPONSIBILITY:HEALTH_MANAGEMENT:CRITICAL:IMPORTANT]
Priority critical, interrupt jobs set as IMPORTANT or below.

Logged
The worst bug - 34.11 poll
Tired of going decades without goblin sieges? Try The Fortress Defense Mod
Kogut, the Bugfixes apostle of Bay12forum. Every posts he makes he preaches about the evil of Bugs.

TheBeardyMan

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #42 on: January 10, 2012, 12:26:36 pm »

Some more thoughts on how job priorities could work:

Each dwarf could have four numbers for each labour: static priority, initial dynamic priority, incremental dynamic priority, and current dynamic priority. Lower values in these numbers would make jobs more important.

When a dwarf becomes available for a new job, the first numbers to be considered are the static priorities. A dwarf will always choose a job for which he has a labour with a lower static priority over one for which he has a labour with a higher static priority.

When multiple jobs are tied for static priority, dynamic priorities are considered. These work as follows:

  • The initial dynamic priorities and incremental dynamic priorities are visible to the player, but the current dynamic priorites are not.
  • Initially, a dwarf's current dynamic priority for each labour is equal to his initial dynamic priority for that labour.
  • When a dwarf performs a job, his current dynamic priority for each labour that allows that job is incremented by his incremental dynamic priority for that labour, and his current dynamic priority for each labour that does not allow that job is reset to his initial dynamic priority for that labour.
  • When considering jobs that are tied for static priority, the travel cost of each job is multiplied by the dwarf's highest current dynamic priority for a labour that allows the job, and the dwarf chooses the job with the lowest adjusted travel cost.
  • A dwarf will tend to prefer jobs for which his labours have lower intial dynamic priority, but not to the exclusion of other labours.
  • The larger the incremental dynamic priorites of a dwarf's labours compared to the initial dynamic priorites, the more frequently the dwarf will change jobs.

Examples of how this could be used:
  • If your miner is also your engraver, and you want him to finish mining out one room before starting on smoothing another room that he mined out earlier, give him low incremental dynamic priorities for the labours.
  • If your mason is also your mechanic, and you need steady production of furniture and mechanisms without a glut of either, build the two workshops close together, give him high incremental dynamic priorities for the labours, and he will alternate between them.

Logged

Jake

  • Bay Watcher
  • Remember Boatmurdered!
    • View Profile
    • My Web Fiction
Re: Job Priorities Discussion
« Reply #43 on: January 10, 2012, 12:43:15 pm »

[PRIORITY:RESPONSIBILITY:TRADE:IMPORTANT]
[PRIORITY:RESPONSIBILITY:HEALTH_MANAGEMENT:CRITICAL]

[PRIORITY:REACTION:TAN_A_HIDE:CRITICAL]
[PRIORITY:REACTION:SCREW_PRESS:NORMAL]

[PRIORITY:JOB:ANIMAL_TRAINER:IDLE]
[PRIORITY:JOB:WOODCRAFTER:NORMAL]

[PRIORITY:HAULING:ITEM_TOY_PUZZLEBOX:IDLE]
[PRIORITY:HAULING:MARBLE:NORMAL]
[PRIORITY:HAULING:ADAMANTINE_WAFFRES:IMPORTANT]
Mockup of RAWs of global priorities.

My addition, to allow interrupting less important jobs

Code: [Select]
[PRIORITY:RESPONSIBILITY:HEALTH_MANAGEMENT:CRITICAL:IMPORTANT]
Priority critical, interrupt jobs set as IMPORTANT or below.

I'd use a number rather than a category, something like the precedence scale in noble positions. And doing it by individual reaction would exceedingly annoying to configure for no especially good reason; you could accomplish the same thing by making it possible to adjust the priority of work orders through the manager screen after they'd filtered down to the workshops.
Logged
Never used Dwarf Therapist, mods or tilesets in all the years I've been playing.
I think Toady's confusing interface better simulates the experience of a bunch of disorganised drunken dwarves running a fort.

Black Powder Firearms - Superior firepower, realistic manufacturing and rocket launchers!

Silverionmox

  • Bay Watcher
    • View Profile
Re: Job Priorities Discussion
« Reply #44 on: January 10, 2012, 12:58:13 pm »

We seem to be forgetting that micromanaging the priorities of 200+ dwarves will crush the spirit of even the greatest OCD'ers in the player base. We need an intermediate level between everyone and the individual. Let's call it a crew.

Crews would be groups of dwarves, somewhat like squads. You could assign them to burrows, mass enable or disable their skills, and set the priorities for the whole crew at once. This will:
- allow you to direct crews to the place where they are needed (by assigning them to a burrow)
- allow you to direct crews to the tasks that are urgent (by changing their priority)
- open up possibilities of apprenticeship within the crew, a way to allow your novices to gain skill without screwing up the mayor's room with subpar engravings
- fit in nicely with the details screen and other parts of the game (as planned, or to be returned, like guilds) eg. "Urist Ralgodok is a member of the Paddles of Haunting, a mining crew in Glorypeak."
- make it possible to tell your miners to equip helmets, your smiths leather aprons, etc.

Normally, a hierarchical system would be preferable (crew settings override fortress settings, individual settings override crew settings), but since people will start out with messing with the individual settings and create crews later, it's probably better to let crews override individual settings, and individual settings override general settings.
Logged
Dwarf Fortress cured my savescumming.
Pages: 1 2 [3] 4