diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-01 20:52:25 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-01 20:52:25 +0200 |
commit | f693542375b099c662c05cc7a5d5fb8b97bf9dd2 (patch) | |
tree | dc6e8b32d3dec3bf19b91bbaa3e96e7acade206e | |
parent | 33f543ab0cfdd39d8e3bbd659c701ab88a89872b (diff) | |
download | RustAndDust-f693542375b099c662c05cc7a5d5fb8b97bf9dd2.zip RustAndDust-f693542375b099c662c05cc7a5d5fb8b97bf9dd2.tar.gz |
Board/SearchBoard: possiblePathsFilterAdd -> possiblePathsFilterToggle
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/SearchBoard.java | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 36df6bd..7099326 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -373,9 +373,9 @@ public abstract class Board implements Disposable return nodesToSet(paths, points); } - public int possiblePathsFilterAdd(int col, int row, Set<GridPoint2> points) + public int possiblePathsFilterToggle(int col, int row, Set<GridPoint2> points) { - List<Vector<SearchBoard.Node>> paths = searchBoard.possiblePathsFilterAdd(col, row); + List<Vector<SearchBoard.Node>> paths = searchBoard.possiblePathsFilterToggle(col, row); return nodesToSet(paths, points); } diff --git a/core/src/ch/asynk/tankontank/engine/SearchBoard.java b/core/src/ch/asynk/tankontank/engine/SearchBoard.java index 9a11835..68a2f51 100644 --- a/core/src/ch/asynk/tankontank/engine/SearchBoard.java +++ b/core/src/ch/asynk/tankontank/engine/SearchBoard.java @@ -497,10 +497,15 @@ public class SearchBoard possiblePathsFilters.clear(); } - public List<Vector<Node>> possiblePathsFilterAdd(int col, int row) + public List<Vector<Node>> possiblePathsFilterToggle(int col, int row) { - possiblePathsFilters.add(getNode(col, row)); - int n = possiblePathsFilters.size(); + Node n = getNode(col, row); + if (possiblePathsFilters.contains(n)) + possiblePathsFilters.remove(n); + else + possiblePathsFilters.add(n); + + int s = possiblePathsFilters.size(); List<Vector<Node>> paths = new LinkedList<Vector<Node>>(); for (Vector<Node> path : possiblePaths) { @@ -509,7 +514,7 @@ public class SearchBoard if (path.contains(filter)) ok += 1; } - if (ok == n) + if (ok == s) paths.add(path); } |