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/tankontank/engine/Board.java4
-rw-r--r--core/src/ch/asynk/tankontank/engine/SearchBoard.java13
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);
}