summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/engine
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/rustanddust/engine')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index 2846928..ca25535 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -140,6 +140,25 @@ public class PathBuilder implements Disposable
return 1;
}
+ public int chooseShortest()
+ {
+ if (paths.size() > 1) {
+ Path good = paths.get(0);
+ for (Path path : paths) {
+ if (path.tiles.size() < good.tiles.size())
+ good = path;
+ }
+
+ paths.remove(good);
+ clearPaths();
+ paths.add(good);
+ for (Tile tile : good.tiles)
+ tiles.add(tile);
+ }
+
+ return 1;
+ }
+
private void findAllPaths(Tile from, int mvtLeft, int fitness, boolean roadMarch)
{
Tile moves[] = new Tile[6];