From 47d0af345b35660906523f9eefcf49930fe1c098 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 10 Apr 2016 12:03:54 +0200 Subject: Take current SubCell into account when searching for central --- src/ch/epfl/xblast/server/GameState.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 22fe233..702fa37 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -283,8 +283,7 @@ public final class GameState { * @return the truncated path */ private static Sq pathToNextCentralPosition(Sq p) { - return p.tail() - .takeWhile(dp -> dp.position().isCentral()); + return p.takeWhile(dp -> !dp.position().isCentral()); } /** @@ -294,9 +293,7 @@ public final class GameState { * @return the next central SubCell */ private static SubCell nextCentralPosition(Sq p) { - return p.tail() - .findFirst(dp -> dp.position().isCentral()) - .position(); + return p.findFirst(dp -> dp.position().isCentral()).position(); } /** -- cgit v1.2.3