Topic: wishlist: preferrably split selcted ware among warehouses
einstein13![]() |
Posted at:
2015-12-01, 23:59 UTC+1.0
If you really don't want to spot this situation, we can just add randomness to the engine:
of course this algorithm is simple from math side, not from programmistic side Adding one to Xn (to make xn values) is only to avoid infinity problem when dividing. EDIT: This algorithm will not solve completely the problem, but it will avoid the situation when all wares will go to the warehouse with 0 wares inside, while second warehouse will have only 1 ware. With situation avbove (1 & 0 warehouses, 10 wares to split), the solution will be 4 & 7 wares instead of 1 & 10. Better? Or not?
Edited:
2015-12-02, 00:09 UTC+1.0
einstein13 ![]() ![]() |
Tibor |
Posted at:
2015-12-02, 21:54 UTC+1.0
So I just pushed branch request_supply_opt with couple of changes in economy.cc file.
![]() ![]() |
GunChleoc![]() |
Posted at:
2015-12-02, 22:02 UTC+1.0
I am against a checkbox - this would mean that the user would have to do our (the programmers') job. Is there a way to find a good cutoff, so the algorithm can decide itself? Map dimensions can be read from the map, or you could go by number of flags in the economy. Busy indexing nil values ![]() ![]() |
Tibor |
Posted at:
2015-12-02, 22:23 UTC+1.0
Well, for a single request a number of available wares varies from 0 to 20 (rarely more). The smaller map the lesser average. So for smaller maps it will be 5 from 'smaller number' and for bigger maps 5 from 'bigger number'. Usually there is good correlation between direct distance and walking distance, but mainly seafaring makes thinks complicated (not proportional). Anyway, we can manipulate the treshold 5. I picked 5 because it seems a good tradeoff. If we set it to 10, CPU savings will be much smaller. This is why I thought of check box - let everybody think what he prefers - speed or accuracy..... EDIT: Game uses world Supply - a warehouse is a single supply even if it contains many pieces of ware...
Edited:
2015-12-02, 22:40 UTC+1.0
![]() ![]() |
GunChleoc![]() |
Posted at:
2015-12-02, 22:46 UTC+1.0
Well, I expect that most players won't understand the checkbox and never change the value. Even for people who are good at computers, they won't know why it's there and what to base their decision on. I don't really know that part of the code - would it be feasible to make the threshold dynamic, or maybe do a fuller check every few cycles, to make sure that edge cases eventually do get a ware assigned? Busy indexing nil values ![]() ![]() |
Tibor |
Posted at:
2015-12-02, 22:58 UTC+1.0
Well - a ware will be ALWAYS assigned - providing there is at least one available in economy at all. This all is only about cause that supply 100 fields away ('as crow flies') can be closer (walking on a roads) then 5 supplies in distances 20,30,50,70,90. Probability of this is low, but can happen.... On small map you might have 3 warehouses and handful of wares just on road. Let say 7 supplies. Pick 5 closest ones, changes are close to 100% that you will pick just the exact piece of ware as if you tested all wares...
Yes, probably.... ![]() ![]() |
king_of_nowhere![]() Topic Opener |
Posted at:
2015-12-02, 23:28 UTC+1.0
i don't understad this thing aboout available resources. when a building requires a new resource, it get it if it is available in the economy, i.e. if it is available in a warehouse. if there is no such ware in a wharehouse, then all such wares are already "booked" for a destination and the building must wait. So this modification would take effect only if one has more than 5 warehouses. except you are talking like it referred to wares on the road. does it mean that wares on the road can now be rerouted if they were being sent to a warehouse and another building requires them? Regardless of whether I understood it right, I think there would be a better way to save cpu, although it would likely require a bit more coding. Basically, you'd have to confront the distance as the crow flies with that along a road, and if a ware is closer by road than any other is as the crow flies, then it can skip further calculation. So the logic would be like
EDIT: also, your cutting at 5 wares may or may not work. it would work if the 5 closer wares have largely different distances. but if the 6 closer are at 50, 55, 57, 60, 61, 63, then likelyhood that the closer oneis actually the 6th are rather high. i think a better way to cutoff would be to use difference of distances. if you cutoff as crow-distances that are longer than the shorter road distance calculated so far, then you are safe. or, you could cut off when distance(crow) is twice the diistance(crow) of the closer ware
Edited:
2015-12-02, 23:47 UTC+1.0
![]() ![]() |
Tibor |
Posted at:
2015-12-02, 23:47 UTC+1.0
yes, the algorithm you proposed is actual there. And this is another reason I reorders wares by distance. If distance (as crow flies) is 100,50,10 - all three routes will be calculated. But now I reorder them to 10,50,100 and chances are that only first one will be calculated... But if distances are like 40,45,50,55,60,65,75 - changes are that all of them will be calculated..... Or an algorithm will go to the middle of expected road and decide to not go on. Astar compares actual_distance + remaining_distance_as_crow_flies to distance_of_best_route_up_to_now and may decide anytime to drop calculation of a route... But this could be after spending a lot of time on calculating a route... So reordering wares itself brings some benefits.
In fact I dont understand that logic fully - but yes, also unassigned wares on roads can be under some circumstances used as a supply ![]() ![]() |
einstein13![]() |
Posted at:
2015-12-04, 10:04 UTC+1.0
I am against checkbox too. As I understad now: You want to add a window with some values that will differ a bit the results of algorithms inside the core of Widelands? It will not work properly with multiplayer. Or you will spot more problems then. einstein13 ![]() ![]() |
Tibor |
Posted at:
2015-12-04, 20:55 UTC+1.0
Or do you suggest new type of preferred policy that would include even distribution? You should discuss it now not two weeks after merging into trunk! EDIT: Oops, what I was reacting to???
Edited:
2015-12-04, 21:48 UTC+1.0
![]() ![]() |