Expose a setting for Weighted A*
Replace Constants.CellCost and Constants.DiagonalCellCost with a dynamically calculated value based on the lowest cost terrain to traverse. Using a fixed value meant the pathfinder heuristics would be incorrect. In the four default mods, the minimum cost is in fact 100, not 125. This increase would essentially allow the pathfinder to return suboptimal paths up to 25% longer in the worst case, but it would be quicker to do so. This is exactly what Weighted A* does - overestimate the heuristic by some factor in order to speed up the search by checking fewer routes. This makes the heuristic inadmissible and it may now return suboptimal paths, but their worst case length is bounded by the weight. A weight of 125% will never produce paths more than 25% longer than the shortest, optimal, path. We set the default weight to 25% to effectively maintain the existing, suboptimal, behaviour due to the choice of the old constant - in future it may prove a useful tuning knob for performance.
This commit is contained in:
@@ -194,7 +194,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Too many harvesters clogs up the refinery's delivery location:
|
||||
if (occupancy >= Info.MaxUnloadQueue)
|
||||
return Constants.InvalidNode;
|
||||
return PathGraph.CostForInvalidCell;
|
||||
|
||||
// Prefer refineries with less occupancy (multiplier is to offset distance cost):
|
||||
return occupancy * Info.UnloadQueueCostModifier;
|
||||
|
||||
Reference in New Issue
Block a user