summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java23
1 files changed, 11 insertions, 12 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index 0017c43..f96c06f 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -129,12 +129,7 @@ public class PathBuilder implements Disposable
if ( (path.fitness > good.fitness) || ((path.fitness == good.fitness) && (path.cost < good.cost)))
good = path;
}
-
- ps.remove(good);
- clearPaths();
- paths.add(good);
- for (Tile tile : good.tiles)
- tiles.add(tile);
+ keepOnly(good);
}
return 1;
@@ -150,17 +145,21 @@ public class PathBuilder implements Disposable
if (path.tiles.size() < good.tiles.size())
good = path;
}
-
- ps.remove(good);
- clearPaths();
- paths.add(good);
- for (Tile tile : good.tiles)
- tiles.add(tile);
+ keepOnly(good);
}
return 1;
}
+ private void keepOnly(Path path)
+ {
+ getPaths().remove(path);
+ clearPaths();
+ paths.add(path);
+ for (Tile tile : path.tiles)
+ tiles.add(tile);
+ }
+
private void findAllPaths(Tile from, int mvtLeft, int fitness, boolean roadMarch)
{
Tile moves[] = new Tile[6];