-
Notifications
You must be signed in to change notification settings - Fork 214
[immortal-cravings] prioritize high-value meals #1475
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
base: master
Are you sure you want to change the base?
Conversation
immortal-cravings.lua
Outdated
@@ -13,6 +13,27 @@ function distance(p1, p2) | |||
return math.max(math.abs(p1.x - p2.x), math.abs(p1.y - p2.y)) + math.abs(p1.z - p2.z) | |||
end | |||
|
|||
---find best item in an item vector (according to some metric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems to me that findClosest
is findBest
but with a specific metric (distance) and so findClosest
could be written as a specialization of findBest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are of course right. I realized this at some point and then forgot about it. I just tried it, but the result is barely simpler and less efficient, because one now needs to compute the position (xyz2pos(dfhack.items.getPosition(item))
) separately for the metric and the accessibility check. I can do it, but I don't think it is worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ab9rf Do you insist on this change or are there any other things that block this from getting merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, i don't insist on this, it was an observation only. you know how i feel about repetitive code :)
If there are no more required changes, can we get this merged? |
Now that this has been sitting here for a while, I went ahead and made a few additional changes:
|
... and don't go eating or drinking on a full stomach
fixes: DFHack/dfhack#5401