From 20ab618a929c5911b472781b5db47f39544a087b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 4 Jan 2016 23:26:17 +0100 Subject: PathBuilder: use getPaths() --- .../ch/asynk/rustanddust/engine/PathBuilder.java | 24 ++++++++++++---------- 1 file 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 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 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) -- cgit v1.1-2-g2b99