From 1670f5afbf1fa49a5d7e56829149bb58a379cfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 7 Oct 2014 11:38:24 +0200 Subject: Board: possiblePaths(p, from, to, points) remove 'from' and 'to' from point Set 'points' --- core/src/ch/asynk/tankontank/engine/Board.java | 3 ++- core/test/ch/asynk/tankontank/BoardUtils.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 9d3ae65..b906348 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -298,7 +298,8 @@ public abstract class Board implements Disposable points.clear(); for (ArrayList path : nodes) { - for (SearchBoard.Node node : path) { + for (int i = 1, n = (path.size() - 1); i < n; i++) { + SearchBoard.Node node = path.get(i); GridPoint2 point = gridPoint2Pool.obtain(); point.set(node.col, node.row); if (!points.add(point)) diff --git a/core/test/ch/asynk/tankontank/BoardUtils.java b/core/test/ch/asynk/tankontank/BoardUtils.java index f691cbf..757e315 100644 --- a/core/test/ch/asynk/tankontank/BoardUtils.java +++ b/core/test/ch/asynk/tankontank/BoardUtils.java @@ -102,19 +102,19 @@ public class BoardUtils int n = b.possiblePaths(p, from, to, points); assertTrue(n == 1); - assertTrue(points.size() == 2); + assertTrue(points.size() == 0); to.set(4, 3); n = b.possiblePaths(p, from, to, points); assertTrue(n == 8); - assertTrue(points.size() == 8); + assertTrue(points.size() == 6); GridPoint2 p0 = new GridPoint2(3, 3); n = b.possiblePathsFilterToggle(p0, points); assertTrue(n == 1); - assertTrue(points.size() == 3); + assertTrue(points.size() == 1); to.set(5, 3); -- cgit v1.1-2-g2b99