diff --git a/src/main/java/com/jatkin/splixkoth/ppcg/SplixSettings.java b/src/main/java/com/jatkin/splixkoth/ppcg/SplixSettings.java index a6f6dd9..af7e806 100644 --- a/src/main/java/com/jatkin/splixkoth/ppcg/SplixSettings.java +++ b/src/main/java/com/jatkin/splixkoth/ppcg/SplixSettings.java @@ -15,7 +15,7 @@ public class SplixSettings { public static final int gameIterationsCount = 2000; public static final int pointsForKill = 300; - public static final int boardDims = 200; + public static final int boardDims = 100; // must be square for the ui to work correctly public static final Point2D viewingAreaSize = new Point2D(20, 20); diff --git a/src/main/java/com/jatkin/splixkoth/ppcg/game/SplixBoard.java b/src/main/java/com/jatkin/splixkoth/ppcg/game/SplixBoard.java index ab305dd..f851fb0 100644 --- a/src/main/java/com/jatkin/splixkoth/ppcg/game/SplixBoard.java +++ b/src/main/java/com/jatkin/splixkoth/ppcg/game/SplixBoard.java @@ -167,7 +167,18 @@ public void fillPlayerCapturedArea(SplixPlayer whoToCheck, Set areaChan for (Point2D pt : checkSpace) { Set points = floodSearchHelperFillPlayerCapturedArea(pt, whoToCheck, previouslyVisitedLocations); - if (points != null) {// valid fill that didn't hit wall + MutableList border = getAdjacent(points); + + // Interesting edge case: A player can completely surround another, and when the 2nd player + // exits his area to make a trail and claim more area, the first player would originally + // capture all of the 2nd player's land. This code removes that edge case. + // ref: https://chat.stackexchange.com/transcript/message/38228281#38228281 + boolean canFillIn = border.toSet().select(p2d -> { + SplixPlayer claimer = get(p2d).getClaimer(); + return claimer != null && claimer != whoToCheck; + }).isEmpty(); + + if (points != null && canFillIn) {// valid fill that didn't hit wall points.forEach(x -> get(x).setOwner(whoToCheck)); } }