summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-11 01:46:10 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-11 01:46:10 +0100
commit21af522854d1b10289e6c338be0663132afe5ba6 (patch)
treefdcb6cb729d2217c1d0c25eccff781a8c302526b /core/src/ch
parent9dee8da669ff216c7a8137c1e382c6b330fe411d (diff)
downloadRustAndDust-21af522854d1b10289e6c338be0663132afe5ba6.zip
RustAndDust-21af522854d1b10289e6c338be0663132afe5ba6.tar.gz
PathBuilder: tiles and paths use ArrayListIt
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java21
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map2Moves.java2
2 files changed, 10 insertions, 13 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index 127da12..aaaf399 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -1,9 +1,6 @@
package ch.asynk.rustanddust.engine;
import java.util.List;
-import java.util.LinkedList;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
import com.badlogic.gdx.utils.Disposable;
@@ -22,16 +19,16 @@ public class PathBuilder implements Disposable
private List<Tile> ctrlTiles;
private List<Path> paths;
private List<Path> filteredPaths;
- private HashSet<Tile> tiles;
+ private ArrayListIt<Tile> tiles;
- public PathBuilder(Board board, int tSize, int stSize, int ftSize, int vectSize)
+ public PathBuilder(Board board, int tSize, int stSize, int ftSize, int psSize)
{
this.board = board;
- this.tiles = new LinkedHashSet<Tile>(tSize);
+ this.tiles = new ArrayListIt<Tile>(tSize);
this.stack = new ArrayListIt<Tile>(stSize);
this.ctrlTiles = new ArrayListIt<Tile>(ftSize);
- this.paths = new LinkedList<Path>();
- this.filteredPaths = new LinkedList<Path>();
+ this.paths = new ArrayListIt<Path>(psSize);
+ this.filteredPaths = new ArrayListIt<Path>(psSize);
this.to = null;
this.pawn = null;
this.orientation = Orientation.KEEP;
@@ -197,7 +194,7 @@ public class PathBuilder implements Disposable
clearPaths();
paths.add(path);
for (Tile tile : path.tiles)
- tiles.add(tile);
+ tiles.addUnique(tile);
}
private void findAllPaths(Tile from, int mvtLeft, int fitness, boolean roadMarch)
@@ -220,7 +217,7 @@ public class PathBuilder implements Disposable
Path path = Path.get(stack.size() + 1);
for (Tile t: stack) {
path.tiles.add(t);
- tiles.add(t);
+ tiles.addUnique(t);
}
path.roadMarch = r;
path.fitness = f;
@@ -262,11 +259,11 @@ public class PathBuilder implements Disposable
filteredPaths.clear();
filteredPaths.add(path);
tiles.clear();
- for (Tile tile : path.tiles) tiles.add(tile);
+ for (Tile tile : path.tiles) tiles.addUnique(tile);
break;
} else {
filteredPaths.add(path);
- for (Tile tile : path.tiles) tiles.add(tile);
+ for (Tile tile : path.tiles) tiles.addUnique(tile);
}
}
}
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java b/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java
index 738de2b..5750320 100644
--- a/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java
+++ b/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java
@@ -21,7 +21,7 @@ public abstract class Map2Moves extends Map1Units
super(game, map, hex);
moves = new TileSet(this, 40);
- paths = new PathBuilder(this, 10, 20, 5, 10);
+ paths = new PathBuilder(this, 10, 20, 5, 20);
}
@Override