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

Improve obtain_cost algorithm for pockets #40164

Open
KorGgenT opened this issue May 5, 2020 · 6 comments
Open

Improve obtain_cost algorithm for pockets #40164

KorGgenT opened this issue May 5, 2020 · 6 comments
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Items: Containers Things that hold other things (P5 - Long-term) Long-term WIP, may stay on the list for a while.

Comments

@KorGgenT
Copy link
Member

KorGgenT commented May 5, 2020

Is your feature request related to a problem? Please describe.

Right now the obtain cost is very simple: you add up all the base moves of the pockets and add the inventory handling multiplier on top.

Describe the solution you'd like

I would like to see the cost of grabbing an item from a pocket be based on the other items that are in that pocket, simulating rummaging through the pocket to find said item. The infrastructure is nominally in place in item_pocket::obtain_cost(), so that's where the algorithm would be for such a thing.

Describe alternatives you've considered

leave it as it is?

Additional context

my math skills are not strong enough to do something like this, and i could only do a "good enough for now" solution. As such, i thought i'd open up a feature request to hopefully let people know it's something that's desired, and for it not to get lost in my mind.

@KorGgenT KorGgenT added [C++] Changes (can be) made in C++. Previously named `Code` Items: Containers Things that hold other things <Enhancement / Feature> New features, or enhancements on existing labels May 5, 2020
@RoyBerube
Copy link
Contributor

My opinion is that this is a very low priority issue.

I don't think it affects game-play that much. Sure, it might reflect reality a little more. Large items such as tennis rackets are easier to find in a bag than tiny items like coins. But is the added complexity worth the trouble?

@KorGgenT
Copy link
Member Author

KorGgenT commented May 5, 2020

it might not be high priority, but i wanted it listed because i wasn't planning on being the one to implement it, as i have other things to do. any complexity added by this will likely be relegated to a single function that calculates moves, rather than just being a flat number that's always the same.

@stale
Copy link

stale bot commented Jun 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

@stale stale bot added the stale Closed for lack of activity, but still valid. label Jun 4, 2020
@anothersimulacrum anothersimulacrum added the (P5 - Long-term) Long-term WIP, may stay on the list for a while. label Jun 4, 2020
@stale stale bot removed the stale Closed for lack of activity, but still valid. label Jun 4, 2020
@I-am-Erk
Copy link
Member

OK so this is directly related to another issue I'd like to write, about furniture and vehicle container access time (rummaging), so I have been thinking about this a bit.

Initial thoughts:

  • number of items is generally more important than volume of items
  • what portion of the max volume of the pocket is full is important as well
  • at low 'fullness' it should always be quick to pull the item you want
  • at few number of items it should always be quick to pull the item you want
  • trickier: If your pocket is full of nails with one bullet in there, (a) you're nuts and (b) pulling a nail out should be quick, pulling a bullet should be slow. I will think about that last one but I suspect it's still easy to work.

@I-am-Erk
Copy link
Member

I-am-Erk commented Oct 20, 2020

OK so let's create a few variables:

  • total_count: total number of items in the pocket. Items in a container count as a single item.
  • this_count: Number of items identical to the one you're getting in the pocket
  • total_volume: Total volume of items in the pocket
  • this_volume: Total volume of items identical to the one you're getting in the pocket
  • pocket_size: Total capacity of the pocket
  • base_cost: JSON defined base cost of getting things out of the pocket. Should be the minimum time needed to get items in an ideal situation.
  • obtain_cost: The final cost of taking the item out.

First, go through a set of if statements to quickly catch common circumstances where the item would be easy to get.

  1. If total_items <= 2, obtain_cost = base_cost
  2. If total_items <= perception/2, obtain_cost = base_cost
  3. If this_count >= total_count/2, obtain_cost = base_cost
  4. If this_volume > pocket_volume/2, obtain_cost = base_cost
  5. If this_volume >= total_volume/2, obtain_cost = base_cost

If all those are false, ie. this is not the largest item in the container, doesn't occupy half the container, and is not the most numerous item in the container, and there are more than a tiny number of things in the container, then we should calculate a cost to remove the item.

`obtain_cost` = `base_cost` * ( AVG ( 
    [ ( `total_count` - `this_count` ) / `this_count` ) ],
    [ ( `total_volume` - `this_volume` ) / `this_volume` ) ] ), 
    MAX [ `pocket_volume` / `this_volume` ] 
)

The max obtain cost should cap at the time it would take to just dump out and repack the container.

The second max would allow for the possibility that if you're trying to find a USB key in a 60L drum filled with crafting scraps, you might just dump the drum out, find the key, and repack it, because the multiplier for rummaging around for it is going to be impossibly high. However we could leave that out if it's going to be proc expensive, and just let players decide for themselves.

We may want dexterity and perception to play a role in the final speed, if they don't already. We may want a set of proficiencies like quick draw and organized pockets that shorten draw time, perhaps based on the container flags (holster for quickdraw eg)

@actual-nh
Copy link
Contributor

Note the difference between finding something in places that you tried to organize, vs places you dumped stuff for later sorting (e.g., that 60L drum...). Admittedly, for someone with the Disorganized trait, it may not be very different... although I manage to be both good at packing things into limited spaces and disorganized in where I put things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Items: Containers Things that hold other things (P5 - Long-term) Long-term WIP, may stay on the list for a while.
Projects
None yet
Development

No branches or pull requests

5 participants