summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-05-04 10:58:31 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-05-04 10:58:31 +0200
commit0b5038c41de682d3c1bb68c706290178426f82d7 (patch)
tree3c3f85b9bf381c5e7b1d60cc9fc15548a0b25b05 /core/src/ch
parent1287a6e7bad4a3846eaab20a9b407919ae456147 (diff)
downloadRustAndDust-0b5038c41de682d3c1bb68c706290178426f82d7.zip
RustAndDust-0b5038c41de682d3c1bb68c706290178426f82d7.tar.gz
PathBuilder: best() priority : fitness > cost > roadMarch > size
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java16
1 files 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;
}