diff --git a/src/comp1110/ass2/State.java b/src/comp1110/ass2/State.java index bc7eeed..fe25652 100644 --- a/src/comp1110/ass2/State.java +++ b/src/comp1110/ass2/State.java @@ -563,9 +563,7 @@ public class State { public int scoreLinks(int playerID) { Coord[] playerCoords = players[playerID].getPieces(); Set playerCoordsSet = new HashSet<>(Arrays.asList(playerCoords)); - int maxScore = findLongestLinkScore(playerCoordsSet, islands); - return maxScore; } @@ -574,7 +572,6 @@ public class State { Set current = new HashSet<>(); Coord now; - int max = scoreForLink(longest,islands); for(Island islandIter : islands) { @@ -608,19 +605,16 @@ public class State { } public static int scoreForLink(Set longestLink, Island[] islands) { - int numOfIslands = 0; - - outerLoop: - for (Island i : islands) { - for ( Coord c : longestLink ) { + Set connectedIslands = new HashSet<>(); + for (Coord c : longestLink) { + for (Island i : islands) { if (i.containsCoord(c)) { - numOfIslands++; - continue outerLoop; + connectedIslands.add(i); + break; } } } - - return numOfIslands * 5; + return connectedIslands.size() * 5; } /**