Stockpile direction gradient optimization

Started by Robc, June 28, 2018, 05:59:30 PM

Previous topic - Next topic

Robc

Stockpile optimization is a hot topic.  I appreciate that many suggestions offered by players do not achieve a positive cost/ benefit analysis for developer time and/ or processor cycles/ resources to QoL or gameplay benefits.  I believe the following suggestion to have only moderate benefits to stockpile management and it does not provide the benefits offered in more complex optimization suggestions.  However, I believe the method should be very simple to implement so might be worth a look: 

Because of the nature of stuff storage in RW, stockpiles can become fairly large chunks of real estate across the map.  Players become very aware of and sensitive to hauling distance and hauling optimization in their colony layouts and spend real effort to optimize their stockpile and haul route layouts.  Even small inefficiencies loom large in the mind of the players as you well understand.

Setting the recently implemented stockpile stuff re-stacking code aside for the moment, it appears that pawns when selecting where to place an item in a stockpile, if after failing to find a suitable existing stack to add to, they then select a random spot in the stockpile to drop their cargo.  This often results in players watching their pawns cross numerous suitable empty spots to place their item in a distant corner.  This would be a minor annoyance and not worth another thought except for the frequency with which this inefficient behavior is observed in every game.  Players currently shrug it off as a "cost of doing business" and perhaps that is ok, no development resources required to fix it, working as designed.  An exceedingly simple improvement comes to mind however:

Most stockpiles have an optimal direction on the compass from which they could be filled/emptied which would greatly reduce this inefficiency.  If players could assign a preferred fill direction for every stockpile ( a 1 byte parameter attached to each stockpile object ) as follows  (0 = random (default), 1 - North, 2 - East, 3 - South, 4 - West) then pawns could load into and retrieve items from the stockpile by sorting and then selecting the largest or smallest X or Y value of empty (or full, for picking stuff up) storage positions inside the stockpile.   I believe a button adjacent to the current stockpile settings "Priority" button with the option to select your preferred fill/empty gradient direction from a pull down list would suffice as a simple GUI for this approach. 

The code is a little harder for picking stuff out of a stockpile following a gradient since you undoubtedly just search for the closest stack right now and you may not want to make this task any more complicated.  If you incorporate this gradient following behavior into the restacking algorithm you need not check the gradient at all when picking stuff up, most of the time the stockpile would still work more efficiently.  If you did nothing at all to the algorithms for restacking or picking stuff up, I still think this gradient following algorithm for dropping things into a stockpile would result in significantly improved hauling and storage behavior and your players would greatly appreciate the benefits.

In summary, filling or emptying a stockpile using this relatively simple gradient following mechanism is more efficient for pawns than random alone, and players will perceive that much less time is wasted in unnecessarily long hauling tasks.  I think this would become a very much appreciated augmentation of pawn behavior.  Although I don't know the code base to be modified I believe it to be a relatively simple solution, at least for the case of dropping things into a stockpile.  The processor cost of one or two additional sorting steps is a cumulative load on the game resources certainly, but I think if you gave it a try you would find player perceptions and gameplay improvement significant enough to justify it.  Expansion to include NE, NW, SE, and SW compass points would be even better and only slightly more difficult to implement.

Cheers.


Klomster

This suggestion is nice. I approve.

I recall something i get annoyed with as well.
When colonists create new piles without filling up existing ones.

Got a pile of 26 steel? Nah, make a new pile next to it. Wasting space.

I know this probably has to do with item health or similar.
What i'd like is to have the option "ignore item health in this stockpile" perhaps with a blurp saying "this option might worsen the durability of some materials" or something along those lines.
Because i myself don't care much for several of the materials health.
Steel, wood, stone. Don't care, as long i can make walls and floors i'm good. IIRC several of those don't even have HP, so i don't know why they don't finish stacks.
I don't even care with medicine, as long as they put the medicine in it designated pile i don't care if the estimated shelf life is halved or something, i'm freezing it anyway.
And even with that i don't want colonists to clutter up my accidentally too small freezer which lost power again with 8 piles of 4-6 herbal medicines.

Same with meat and rice.
Some people will care, but i'd like the option to utilize as much as possible of my precious storage space.

Ambaire

Quote
Most stockpiles have an optimal direction on the compass from which they could be filled/emptied which would greatly reduce this inefficiency.  If players could assign a preferred fill direction for every stockpile ( a 1 byte parameter attached to each stockpile object ) as follows  (0 = random (default), 1 - North, 2 - East, 3 - South, 4 - West) then pawns could load into and retrieve items from the stockpile by sorting and then selecting the largest or smallest X or Y value of empty (or full, for picking stuff up) storage positions inside the stockpile.   I believe a button adjacent to the current stockpile settings "Priority" button with the option to select your preferred fill/empty gradient direction from a pull down list would suffice as a simple GUI for this approach. 

+1. This would be a very appreciated QOL change. I'm imagining my pawns filling a stockpile left to right, top to bottom, and it's making me all tingly.

Robc

Further...  while I am mostly advocating the simplest application of this method, ie, change behavior of stockpile filling first because you get the greatest bang for the buck on hauling efficiency.  I had the following additional thought:

For an investment of 2 bytes per stockpile you could have a "fill from" compass direction and a "take from" compass direction.  This would give players a pseudo LIFO/FIFO type control over resource use from stockpiles.  I think some would drool for this ability, I know I would because it would reduce micromanagement of expiring food resources (set stockpile to FIFO and forget about it, FIFO = for example "fill from N, take from N") .  It would not work perfectly because vacancies would disrupt stacks that were previously sorted by age along a specific vector but might work a little better than the current random algorithm and give the illusion of better stockpile control anyway.  It could be made to work even better if the re-stacking algorithm was re-designed to sort stuff along a vector by item expiration/age, but now I'm going down a rabbit hole and I don't think you want to go there.

Cheers.

PS(FIFO = First in - first out, LIFO = Last in - first out, these are standard inventory control and accounting terms)

AileTheAlien

+1 for this

(Assuming it's easy enough to add, with how the rest of the game systems are set up. The extra bytes for the player-customization per stockpile would be trivial; It's the actual search/behaviour changes that might get tricky.)

cactusmeat

why not just have pawns drop stuff in the closest open space of a stockpile?

Ambaire

Quote from: cactusmeat on June 30, 2018, 12:04:45 AM
why not just have pawns drop stuff in the closest open space of a stockpile?

Heh, nice. Good way to condense a multi hundred word post down to a single sentence. Agreed.

Robc

Quote from: cactusmeat on June 30, 2018, 12:04:45 AM
why not just have pawns drop stuff in the closest open space of a stockpile?

Yes, that would be the easiest approach, but...   the reason this is slightly less efficient and not as useful is because the pawn might be bringing something in from the field, say a bunch of berries, or a load of rice.  If he drops them in the closest space to the field then that space might be the furthest away from your kitchen.  You want the pawn to drop the berries in the farthest space in this case (the space closest to the kitchen) so that a later pawn hauling to the kitchen is more efficient. 

As I say, most stockpiles have an optimum direction from which to fill that the player has in mind when creating the pile.   It is almost trivial to sort the open storage spaces in the stockpile and have the pawn fill from one optimum direction.   Thus the suggestion.

Jenyaza01

QuoteFor an investment of 2 bytes per stockpile
Not even 2, only one. Byte is value from 00 to FF (hex), we can use first number as input, second as output direction.
0 - none/default, 1-4, or even 1-8 directions (north, north-east, east and so on)
See it as additional checkbox, when non-checked - means 00, if checked - can select as directions, or write those two numbers in textbox appeared

Robc

#9
Yup, using binary bitwise operators.  Anyway, the additional array/object sort on each delivery (and perhaps each pickup) is the more important resource use, not memory.  But I think that to be minor also.  I'm sure the requested feature list overflows though, so I don't know if this will rise above the "nice to have" but not essential pile, hope so.