summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-04 23:26:17 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-04 23:26:17 +0100
commit20ab618a929c5911b472781b5db47f39544a087b (patch)
treed9c1ef776f0fd676972af2b7431924c125941fab /core
parent6145c7004e2a6da0958be3068fc193f5dda7423e (diff)
downloadRustAndDust-20ab618a929c5911b472781b5db47f39544a087b.zip
RustAndDust-20ab618a929c5911b472781b5db47f39544a087b.tar.gz
PathBuilder: use getPaths()
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index 524e353..0017c43 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -85,9 +85,7 @@ public class PathBuilder implements Disposable
public int size()
{
- if (ctrlTiles.size() == 0)
- return paths.size();
- return filteredPaths.size();
+ return getPaths().size();
}
public boolean contains(Tile tile)
@@ -123,14 +121,16 @@ public class PathBuilder implements Disposable
public int chooseBest()
{
- if (paths.size() > 1) {
- Path good = paths.get(0);
- for (Path path : paths) {
+ List<Path> ps = getPaths();
+
+ if (ps.size() > 1) {
+ Path good = ps.get(0);
+ for (Path path : ps) {
if ( (path.fitness > good.fitness) || ((path.fitness == good.fitness) && (path.cost < good.cost)))
good = path;
}
- paths.remove(good);
+ ps.remove(good);
clearPaths();
paths.add(good);
for (Tile tile : good.tiles)
@@ -142,14 +142,16 @@ public class PathBuilder implements Disposable
public int chooseShortest()
{
- if (paths.size() > 1) {
- Path good = paths.get(0);
- for (Path path : paths) {
+ List<Path> ps = getPaths();
+
+ if (ps.size() > 1) {
+ Path good = ps.get(0);
+ for (Path path : ps) {
if (path.tiles.size() < good.tiles.size())
good = path;
}
- paths.remove(good);
+ ps.remove(good);
clearPaths();
paths.add(good);
for (Tile tile : good.tiles)