From 0b5038c41de682d3c1bb68c706290178426f82d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 4 May 2016 10:58:31 +0200 Subject: PathBuilder: best() priority : fitness > cost > roadMarch > size --- core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index cae1d94..994f07d 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -190,11 +190,17 @@ public class PathBuilder implements Disposable { if (a == null) return b; - if ( (b.fitness > a.fitness) || ( - (b.fitness == a.fitness) && ( - (b.cost < a.cost) || ((b.cost == a.cost) && b.roadMarch && !a.roadMarch) - ) - )) + // better fitness or equal and ... + if ((b.fitness > a.fitness) || ((b.fitness == a.fitness) && + // smaller cost or equal and ... + ((b.cost < a.cost) || ((b.cost == a.cost) && + // roadmarch or same roadmarch and ... + ((b.roadMarch && !a.roadMarch) || ((b.roadMarch == a.roadMarch) && + // smaller + (b.tiles.size() < a.tiles.size()) + )) + )) + )) return b; return a; } -- cgit v1.1-2-g2b99