Transfer priority patch
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Hi!
I have prepared another patch for transfer priority system, as discussed in http://
Now patch does not change anything in inner workings of widelands, excluding, of course the transportation.
It makes only several small additions to already defined classes and its wighting algorithm is very clear.
It works in following way:
1) By default all wares, which were dropped at the flag for delivery, have minimal priority 0.
2) Priority set in destination building is determined. It is given as 2/4/8 integer depending on low/normal/high priority. Priorities respected as well for production sites as for construction sites.
3) If destination is a construction site, it is modified +2 (obviously, higher priority)
4) If destination is a warehouse, it is modified -2 (ware being delivered to warehouse have small importance for player in short term, in fact, it is useless now if going to be stored at warehouse)
5) if this is a last transportation step, then modify +2 (preference given for items almost at their destination point)
6) if item needs just two steps to destination, then +1.
So, depending on the actual conditions, ware may have priorities from 0 till 12 (last step to construction site), but usually are expected to be about 4-6.
After that, when carrier tries to pick up some item at the flag, it looks for the highest priority item (and takes the first in the queue, if there are several with the same priority). All items, that now missed the chance for delivery, increase their priorities +1. The maximal priority that may be achieved this way is clamped to 16. Even for the worst possible case - if the flag is very busy with constant flow of highest priority items, the lowest initial priority item will wait no more than 15 attempts, because, by that time it will be picked up as a highest priority in FIFO fashion.
The patch was checked in the game. Obviously, I am biased, but I should note that the game became more pleasant and smooth, especially, there is virtually no extra wait time for constructions if resources are available.
If the item has no request attached (are there any actually such cases? are these items really important if they were not requested?) - then it is treated as priority 0.
I hope it would be successfully reviewed.
PS: unfortunately, Transfer class is not very useful here. Economical priority determination code went to the Request