cheapestPathTo method
Computes the shortest path to other hex. The path is a list of connected hexes, including 'this' and to. If there is no path,
method returns null. The path is computed using the given costFunction, which is a function that returns the cost of
transition from one hex to another. See MoveCost. Default costFunction assigns value 1 to any transition.
The searched area is limited by a circle with radius maximumDistanceFromTo and
center in to. Default value of maximumDistanceFromTo is arbitrary value of max(distanceTo(to) * 2, 10).
Implementation
HexPath? cheapestPathTo(Hex to,
{MoveCost? costFunction, int? maximumDistanceFromTo}) {
maximumDistanceFromTo ??= max(distanceTo(to) * 2, 10);
costFunction ??= (from, to) => 1;
return findCheapestPath(this, to, costFunction, maximumDistanceFromTo);
}