From: "Enrico Weigelt, metux IT consult" <enrico.weig...@gr13.net>
--- src/net/sf/freecol/common/model/Unit.java | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/net/sf/freecol/common/model/Unit.java b/src/net/sf/freecol/common/model/Unit.java index b8e5ffa53e5..737c629ea18 100644 --- a/src/net/sf/freecol/common/model/Unit.java +++ b/src/net/sf/freecol/common/model/Unit.java @@ -2796,14 +2796,23 @@ public class Unit extends GoodsLocation public PathNode findPathToNeighbour(Location start, Tile end, Unit carrier, CostDecider costDecider) { final Player owner = getOwner(); - final Predicate<Tile> endPred = t -> - (isTileAccessible(t) - && (t.getFirstUnit() == null || owner.owns(t.getFirstUnit()))); - - Tile best = minimize(end.getSurroundingTiles(1, 1), endPred, - getPathComparator(start, carrier, costDecider)); - return (best == null) ? null - : this.findPath(start, best, carrier, costDecider); + + PathNode best_path = null; + int best_turns = 0; + for (Tile t : end.getSurroundingTiles(1, 1)) { + if (isTileAccessible(t) + && (t.getFirstUnit() == null || owner.owns(t.getFirstUnit()))) { + PathNode p = this.findPath(start, t, carrier, costDecider); + if (p == null) continue; + int turns = p.getTotalTurns(); + if (best_path == null || turns < best_turns) { + best_path = p; + best_turns = turns; + } + } + } + + return best_path; } /** -- 2.11.0.rc0.7.gbe5a750 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Freecol-developers mailing list Freecol-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freecol-developers