Haul suggestion: round-robin oldest of each type (initial target)

Started by SLAKslayer, January 27, 2017, 10:47:22 PM

Previous topic - Next topic

SLAKslayer

I read quite a few of the hauling suggestion threads and i didn't find this suggestion so apologies if this has been covered before.

Algorithm when a hauler is looking for something:
  1) if pickup list empty: walk world, store [ age, (x,y) ] of the oldest of each material, sort by age
  2) next hauler picks oldest material one off list as target to walk to, remove that material entry from the list

Note this is *NOT* worker picks up oldest metal, then walks to 2nd oldest metal, etc...
rather it is worker heads to oldest metal, picks up all the metal in that local area, then heads back. This is just for selecting the next destination (when empty).

I was thinking about that annoying issue where you have a farmer picking harvesting and the hauler picks up one of the dropped plant and then walks back to the store and in the meantime the farmer has picked another making that the new target. Thus the hauler is always picking up 1 or 2 of the newest items and never getting to any other type on the map.

I thought about suggesting that the haulers should always pick the *furthest* item, but that seems to add more cpu overhead by sorting by distance. Then it occurred to me that you really want your haulers to pick up the oldest item available. But then you have the problem of all the haulers going to the same old drop of materials, so then i thought to fix that you want them to round robin each material for the oldest.

The round-robin-oldest-type method should mean that if you have a drop of pods a distance away then it will get picked up in a reasonable time. It should also mean that if you have more than 1 hauler then they will be given different targets.

Im not sure how the internal structure of the game is so i dont know what performance impact this would have. I know the world is broken into regions so maybe you can build the global 'oldest by type' list from a sublist for each region or maybe there is some smarter algorithm to do with region.

It seems to me that with workers picking up items and then other items of the same type in that area that you want to leave recalculating the list until a new worker is looking for a target rather than recalculating it when the oldest item is picked up. Ie, a worker heads to the oldest item of a type, picks up all the items he can in the area and then walks back **NOT** worker picks up the oldest, then heads to the next oldest of that type etc.

Opinions?