Skip to content

[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

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

Conversation

chdoc
Copy link
Member

@chdoc chdoc commented Jul 4, 2025

... and don't go eating or drinking on a full stomach

fixes: DFHack/dfhack#5401

@@ -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)
Copy link
Member

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

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change immortal-cravings to prefer high-value meals
2 participants