Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Change how staff find work #2133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mugmuggy
Copy link
Contributor

This is a proposal to address these issues. The fix has had some funky behaviour in scenarios where a Dr calls to the room, patient leaves for toilet, before call is completed, then the staff member leaves the room and heads to the next room, where the same thing occurs and ended up returning to the same first room.

There is also a change to prefer wandering staff but not sure how effective that is at the moment to get them, due to the weighting of fatigue beforehand. For when excess staff are employed and they leave staff room after rest and there is no call, they start wandering, but they'll have near 0 fatigue and all else being equal is a distance difference of 10 tiles to have the staff leave the room instead.

Fixes #1582/#2060

Describe what the proposed change does

  • Penalise finding work if in a room over a doctor that is wandering
  • Move the find work call outside of the dealtWithPatient process

@lewri lewri linked an issue Apr 20, 2022 that may be closed by this pull request
Comment on lines -209 to 205
--! Checks if the room still needs the staff in it and otherwise
-- sends them away if they're needed somewhere else.
function Room:findWorkForStaff()
-- If the staff member is idle we can send him/her somewhere else
for humanoid in pairs(self.humanoids) do
-- Don't check handymen
if class.is(humanoid, Staff) and humanoid.humanoid_class ~= "Handyman" and humanoid:isIdle() then
self.world.dispatcher:answerCall(humanoid)
end
end
end
Copy link
Member

@lewri lewri Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still like the idea of having an immediate find work at the end of the consult. Is there a specific consequence if we left this in with the new code?

I suppose the worst of it in removing this code is that the staff member takes a day to find new work.

Copy link
Member

@lewri lewri Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reflection I think I prefer the balance you have chosen, so happy to dismiss my above comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did toss up leaving it in as well, hence leaving it more as a proposal. The original has decisions and logic processed on part day ticks. I assume so some logic doesn't run every tick but also some more frequently than once per day. This probably sits in one of those in the original.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually doesn't this function only get called from GP Office?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per above. Only GP Office used this function. Maybe that was part of the problem too.

lewri
lewri previously requested changes Apr 20, 2022
Copy link
Member

@lewri lewri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handyman issue needs addressing. In the current test build they aren't answering calls to repair.

CorsixTH/Lua/hospitals/player_hospital.lua Show resolved Hide resolved
@lewri lewri dismissed their stale review April 20, 2022 20:59

Can't replicate

@lewri
Copy link
Member

lewri commented May 3, 2022

I would like to see this one make the next release, as it does offer quite a marked improvement to finding work.

@lewri lewri added this to In progress in 0.67 Release via automation May 21, 2022
@lewri
Copy link
Member

lewri commented Oct 19, 2022

The fix has had some funky behaviour in scenarios where a Dr calls to the room, patient leaves for toilet, before call is completed, then the staff member leaves the room and heads to the next room, where the same thing occurs and ended up returning to the same first room.

Is this significant to occur; or would it have a significant impact on gameplay if it happened?
Also any blocking factor regarding RFC? I'm happy with this as is.

@lewri lewri moved this from In progress to Missed/Postponed in 0.67 Release Jul 1, 2023
@lewri lewri added this to In progress in 0.68 Release Jul 1, 2023
Comment on lines +513 to +517
for _, staff in ipairs(self.staff) do
if staff:isIdle() then
self.world.dispatcher:answerCall(staff)
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reinspecting some code, we do use idle a fair bit for some actions as a wait (I found vaccinate and multi-use object). Would these likely get misinterpreted by this code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just judging by the question, it seems to me that isIdle is ambiguous. So one step is to decide yes or no on your question and then document it with isIdle, possibly also improving the name of the function to better match its use.

Also, you may want to split its use between 2 or more functions with different names, so it becomes easier to get the right function. To assist the programmer, it's likely a good idea to mention the related functions in lua doc and/or put them close together, to improve the chance the right function gets found.

As for the functionality, in the calls dispatcher you added not staff:getRoom() as condition, which apparently means "a wandering staff member". While I'd prefer an explicit function for that notion, eg hasNoWork or so, that check may possibly be good here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add a new function for the latter, please also add a link to that in the lua doc of getRoom to avoid further spreading of the getRoom function for this purpose.

Another measure that can be done is to make the getRoom private, although that has much larger consequences (it should be called with self only), not sure if that is feasible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isIdle is actually quite a hefty function to determine a true idle state now that I got round to reading it. It is definitely much more than the mere IdleAction I thought it was. It's documented inside nicely enough in the function, not for doc though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
0.68 Release
  
In progress
0.67 Release
  
Missed/Postponed
3 participants