From f693542375b099c662c05cc7a5d5fb8b97bf9dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 1 Oct 2014 20:52:25 +0200 Subject: Board/SearchBoard: possiblePathsFilterAdd -> possiblePathsFilterToggle --- core/src/ch/asynk/tankontank/engine/Board.java | 4 ++-- 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 points) + public int possiblePathsFilterToggle(int col, int row, Set points) { - List> paths = searchBoard.possiblePathsFilterAdd(col, row); + List> 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> possiblePathsFilterAdd(int col, int row) + public List> 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> paths = new LinkedList>(); for (Vector path : possiblePaths) { @@ -509,7 +514,7 @@ public class SearchBoard if (path.contains(filter)) ok += 1; } - if (ok == n) + if (ok == s) paths.add(path); } -- cgit v1.1-2-g2b99