diff --git a/puzzles files/starbattle/10x10 Star Battle 2 star Normal/10x10 Star Battle 2star Normal1.xml b/puzzles files/starbattle/10x10 Star Battle 2 star Normal/10x10 Star Battle 2star Normal1.xml new file mode 100644 index 000000000..aac7dd8f9 --- /dev/null +++ b/puzzles files/starbattle/10x10 Star Battle 2 star Normal/10x10 Star Battle 2star Normal1.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/puzzles files/starbattle/5x5 Star Battle 1 star Normal/5x5 Star Battle Normal visualized (DO NOT OPEN AS A PUZZLE).png b/puzzles files/starbattle/5x5 Star Battle 1 star Normal/5x5 Star Battle Normal visualized (DO NOT OPEN AS A PUZZLE).png new file mode 100644 index 000000000..5e42c2033 Binary files /dev/null and b/puzzles files/starbattle/5x5 Star Battle 1 star Normal/5x5 Star Battle Normal visualized (DO NOT OPEN AS A PUZZLE).png differ diff --git a/puzzles files/starbattle/6x6 Star Battle 1 star Normal/6x6 Star Battle Normal1 visualized (DO NOT OPEN AS A PUZZLE).png b/puzzles files/starbattle/6x6 Star Battle 1 star Normal/6x6 Star Battle Normal1 visualized (DO NOT OPEN AS A PUZZLE).png new file mode 100644 index 000000000..584d08153 Binary files /dev/null and b/puzzles files/starbattle/6x6 Star Battle 1 star Normal/6x6 Star Battle Normal1 visualized (DO NOT OPEN AS A PUZZLE).png differ diff --git a/src/main/java/edu/rpi/legup/puzzle/starbattle/StarBattleBoard.java b/src/main/java/edu/rpi/legup/puzzle/starbattle/StarBattleBoard.java index 5132f33e4..3b91aee35 100644 --- a/src/main/java/edu/rpi/legup/puzzle/starbattle/StarBattleBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/starbattle/StarBattleBoard.java @@ -97,14 +97,25 @@ public int rowStars(int rowIndex) { public StarBattleBoard copy() { StarBattleBoard copy = new StarBattleBoard(size, puzzleNum); + for (int r = 0; r < this.regions.size(); ++r) { + StarBattleRegion regionCopy = this.regions.get(r).copy(); + for (StarBattleCell cell: regionCopy.getCells()) { + copy.setCell(cell.getLocation().x, cell.getLocation().y, cell); + } + copy.setRegion(r, regionCopy); + } + /* for (int x = 0; x < this.dimension.width; x++) { for (int y = 0; y < this.dimension.height; y++) { copy.setCell(x, y, getCell(x, y).copy()); } + if (x < this.regions.size()) { copy.regions.add(this.getRegion(x).copy()); } + } + */ for (PuzzleElement e : modifiedData) { copy.getPuzzleElement(e).setModifiable(false); } diff --git a/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/EmptyAdjacentDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/EmptyAdjacentDirectRule.java new file mode 100644 index 000000000..17909e233 --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/EmptyAdjacentDirectRule.java @@ -0,0 +1,95 @@ +package edu.rpi.legup.puzzle.starbattle.rules; + +import edu.rpi.legup.model.gameboard.Board; +import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.model.rules.ContradictionRule; +import edu.rpi.legup.model.rules.DirectRule; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.nurikabe.NurikabeCell; +import edu.rpi.legup.puzzle.nurikabe.NurikabeType; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; + +public class EmptyAdjacentDirectRule extends DirectRule { + + public EmptyAdjacentDirectRule() { + super( + "STBL-BASC-0010", + "Empty Adjacent", + "Tiles next to other tiles that need to contain a star to reach the puzzle number for their region/row/column need to be blacked out.", + "edu/rpi/legup/images/starbattle/rules/EmptyAdjacentDirectRule.png"); + } + + /** + * Checks whether the child node logically follows from the parent node at the specific + * puzzleElement index using this rule + * + * @param transition transition to check + * @param puzzleElement equivalent puzzleElement + * @return null if the child node logically follow from the parent node at the specified + * puzzleElement, otherwise error message + */ + @Override + public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) { + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleBoard origBoard = (StarBattleBoard) transition.getParents().get(0).getBoard(); + ContradictionRule contraRule = new TooFewStarsContradictionRule(); + + StarBattleCell cell = (StarBattleCell) board.getPuzzleElement(puzzleElement); + + if (cell.getType() != StarBattleCellType.BLACK) { + return super.getInvalidUseOfRuleMessage() + + ": Only black cells are allowed for this rule!"; + } + + int x = cell.getLocation().x; + int y = cell.getLocation().y; + + StarBattleCell northWest = board.getCell(x - 1, y - 1); + StarBattleCell north = board.getCell(x, y - 1); + StarBattleCell northEast = board.getCell(x + 1, y - 1); + StarBattleCell west = board.getCell(x - 1, y); + StarBattleCell east = board.getCell(x + 1, y); + StarBattleCell southWest = board.getCell(x - 1, y + 1); + StarBattleCell south = board.getCell(x, y + 1); + StarBattleCell southEast = board.getCell(x + 1, y + 1); + + StarBattleCell[] adjacent = {northWest, north, northEast, west, east, southWest, south, southEast}; + + StarBattleBoard modified = (StarBattleBoard) origBoard.copy(); + modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.STAR.value); + for(int i = 0; i < 8; i++){ //sets each spot to a black square if not filled + StarBattleCell temp = adjacent[i]; + + if (temp != null && temp.getType() == StarBattleCellType.UNKNOWN) { + temp.setData(StarBattleCellType.BLACK.value); + int X = temp.getLocation().x; + int Y = temp.getLocation().y; + modified.getCell(X,Y).setData(StarBattleCellType.BLACK.value); + System.out.println("covering square " + X + " " + Y + " type " + modified.getCell(X,Y).getType() + " i = " + i + "\n"); + if(contraRule.checkContradictionAt(modified, temp) == null){ + System.out.println("Good job!"); + return null; //used correctly if even one space causes a toofewstars issue + } + } + } + System.out.println("Wait why did this exit?\n"); + + return "Black cells must be placed adjacent to a tile(s) where a star is needed!"; + } + + /** + * Creates a transition {@link Board} that has this rule applied to it using the {@link + * TreeNode}. + * + * @param node tree node used to create default transition board + * @return default board or null if this rule cannot be applied to this tree node + */ + @Override + public Board getDefaultBoard(TreeNode node) { + + return null; + } +} diff --git a/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/TooFewStarsContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/TooFewStarsContradictionRule.java index e88b7c6b9..358e5b9bd 100644 --- a/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/TooFewStarsContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/TooFewStarsContradictionRule.java @@ -38,14 +38,16 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { int rowCount = 0; int columnCount = 0; for (int i = 0; i < sbBoard.getSize(); ++i) { - if (sbBoard.getCell(row, i).getType() != StarBattleCellType.BLACK) { + if (sbBoard.getCell(i, row).getType() != StarBattleCellType.BLACK) { ++rowCount; } - if (sbBoard.getCell(i, column).getType() != StarBattleCellType.BLACK) { + if (sbBoard.getCell(column, i).getType() != StarBattleCellType.BLACK) { ++columnCount; } } + System.out.println("rowCount = " + rowCount + " columnCount = " + columnCount + " at " + column + "," + row + "\n"); if (rowCount < sbBoard.getPuzzleNumber() || columnCount < sbBoard.getPuzzleNumber()) { + System.out.println("Returning Null\n"); return null; } StarBattleRegion region = sbBoard.getRegion(cell); diff --git a/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/starbattle_reference_sheet.txt b/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/starbattle_reference_sheet.txt index f18965fd6..c332fcee0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/starbattle_reference_sheet.txt +++ b/src/main/java/edu/rpi/legup/puzzle/starbattle/rules/starbattle_reference_sheet.txt @@ -12,6 +12,7 @@ Regions Within Rows: STBL-BASC-0006 Rows Within Columns: STBL-BASC-0007 Rows Within Regions: STBL-BASC-0008 Surround Star: STBL-BASC-0009 +Empty Adjacent: STBL-BASC-0010 Contradiction Rules: Too Many Stars: STBL-CONT-0001 diff --git a/src/main/resources/edu/rpi/legup/images/starbattle/rules/EmptyAdjacentDirectRule.png b/src/main/resources/edu/rpi/legup/images/starbattle/rules/EmptyAdjacentDirectRule.png new file mode 100644 index 000000000..db3c0d9d5 Binary files /dev/null and b/src/main/resources/edu/rpi/legup/images/starbattle/rules/EmptyAdjacentDirectRule.png differ diff --git a/src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.java b/src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.java index 59d5b37af..76367ace5 100644 --- a/src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.java +++ b/src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.java @@ -1,76 +1,216 @@ -// This test is for a puzzle that is not fully implemented yet and is causing issues. -// Commenting this out for now, but once Star Battle is fully implemented this should -// be uncommented and finished. - -// package puzzles.starbattle.rules; -// -// import edu.rpi.legup.puzzle.nurikabe.Nurikabe; -// import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard; -// import edu.rpi.legup.puzzle.nurikabe.NurikabeCell; -// import edu.rpi.legup.puzzle.nurikabe.NurikabeType; -// import legup.MockGameBoardFacade; -// import legup.TestUtilities; -// import edu.rpi.legup.model.tree.TreeNode; -// import edu.rpi.legup.model.tree.TreeTransition; -// import org.junit.Assert; -// import org.junit.BeforeClass; -// import org.junit.Test; -// -// import edu.rpi.legup.puzzle.starbattle.StarBattle; -// import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; -// import edu.rpi.legup.puzzle.starbattle.StarBattleCell; -// import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; -// import edu.rpi.legup.puzzle.starbattle.rules.BlackoutDirectRule; -// import edu.rpi.legup.save.InvalidFileFormatException; -// -// import java.awt.*; -// -// public class BlackoutDirectRuleTest { -// -// private static final BlackoutDirectRule RULE = new BlackoutDirectRule(); -// private static StarBattle starbattle; -// -// @BeforeClass -// public static void setUp() { -// MockGameBoardFacade.getInstance(); -// starbattle = new StarBattle(); -// } -// -// @Test -// public void BlackoutDirectRuleTest_ColumnBlackout() throws InvalidFileFormatException { -// -// TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/ColumnBlackout", -// starbattle); -// TreeNode rootNode = starbattle.getTree().getRootNode(); -// TreeTransition transition = rootNode.getChildren().get(0); -// transition.setRule(RULE); -// -// StarBattleBoard board = (StarBattleBoard) transition.getBoard(); -// -// StarBattleCell cell1 = board.getCell(1, 1); -// cell1.setData(StarBattleCellType.BLACK.value); -// StarBattleCell cell2 = board.getCell(1, 2); -// cell2.setData(StarBattleCellType.BLACK.value); -// StarBattleCell cell3 = board.getCell(1, 3); -// cell3.setData(StarBattleCellType.BLACK.value); -// -// board.addModifiedData(cell1); -// board.addModifiedData(cell2); -// board.addModifiedData(cell3); -// -// Assert.assertNull(RULE.checkRule(transition)); -// -// for (int i = 0; i < board.getHeight(); i++) { -// for (int k = 0; k < board.getWidth(); k++) { -// Point point = new Point(k, i); -// if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || -// point.equals(cell3.getLocation())) { -// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } -// else { -// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } -// } -// } -// } -// } +package puzzles.starbattle.rules; + +import edu.rpi.legup.puzzle.starbattle.rules.BlackoutDirectRule; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class BlackoutDirectRuleTest { + private static final BlackoutDirectRule RULE = new BlackoutDirectRule(); + private static StarBattle starBattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starBattle = new StarBattle(); + } + + /* Blackout Direct Rule where star is in the corner */ + @Test + public void BlackoutDirectRuleTestCorner() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/Corner", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,0); + cell1.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell2 = board.getCell(2,0); + cell2.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell3 = board.getCell(3,0); + cell3.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell4 = board.getCell(0,1); + cell4.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell5 = board.getCell(1,1); + cell5.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell6 = board.getCell(0,2); + cell6.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell7 = board.getCell(0,3); + cell7.setData(StarBattleCellType.BLACK.value); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + board.addModifiedData(cell5); + board.addModifiedData(cell6); + board.addModifiedData(cell7); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || + point.equals(cell3.getLocation()) || point.equals(cell4.getLocation()) || + point.equals(cell5.getLocation()) || point.equals(cell6.getLocation()) || + point.equals(cell7.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + /* Blackout Direct Rule where star is on the edge */ + @Test + public void BlackoutDirectRuleTestEdge() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/Edge", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + cell1.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell2 = board.getCell(2,0); + cell2.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell3 = board.getCell(3,0); + cell3.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell4 = board.getCell(0,1); + cell4.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell5 = board.getCell(1,1); + cell5.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell6 = board.getCell(1,2); + cell6.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell7 = board.getCell(1,3); + cell7.setData(StarBattleCellType.BLACK.value); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + board.addModifiedData(cell5); + board.addModifiedData(cell6); + board.addModifiedData(cell7); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || + point.equals(cell3.getLocation()) || point.equals(cell4.getLocation()) || + point.equals(cell5.getLocation()) || point.equals(cell6.getLocation()) || + point.equals(cell7.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /* Blackout Direct Rule where star is on the edge */ + @Test + public void BlackoutDirectRuleTestMiddle() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/Middle", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + cell1.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell2 = board.getCell(1,0); + cell2.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell3 = board.getCell(0,1); + cell3.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell4 = board.getCell(2,1); + cell4.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell5 = board.getCell(3,1); + cell5.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell6 = board.getCell(1,2); + cell6.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell7 = board.getCell(1,3); + cell7.setData(StarBattleCellType.BLACK.value); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + board.addModifiedData(cell5); + board.addModifiedData(cell6); + board.addModifiedData(cell7); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || + point.equals(cell3.getLocation()) || point.equals(cell4.getLocation()) || + point.equals(cell5.getLocation()) || point.equals(cell6.getLocation()) || + point.equals(cell7.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + /* Blackout Direct Rule where rule is called incorrectly */ + @Test + public void BlackoutDirectRuleTestFalse() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/Middle", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(2,2); + cell1.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell2 = board.getCell(2,3); + cell2.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell3 = board.getCell(3,2); + cell3.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell4 = board.getCell(3,3); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + + Assert.assertNotNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + + +} diff --git a/src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java b/src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java new file mode 100644 index 000000000..ae8aaa08e --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java @@ -0,0 +1,137 @@ +package puzzles.starbattle.rules; + +import edu.rpi.legup.puzzle.starbattle.rules.ClashingOrbitContradictionRule; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ClashingOrbitContradictionRuleTest { + + private static final ClashingOrbitContradictionRule RULE = new ClashingOrbitContradictionRule(); + private static StarBattle starBattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starBattle = new StarBattle(); + } + + /*Tests the Clashing Orbit contradiction rule for directly adjacent stars not at the + edge of the board */ + @Test + public void ClashingOrbitContradictionRule_DirectlyAdjacentCenter() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + StarBattleCell cell2 = board.getCell(2,1); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /* Tests the Clashing Orbit contradiction rule for diagonally adjacent stars */ + @Test + public void ClashingOrbitContradictionRule_DiagonallyAdjacent() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DiagonallyAdjacent", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + StarBattleCell cell2 = board.getCell(2,2); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /*Tests the Clashing Orbit contradiction rule for stars at the edge of the board */ + @Test + public void ClashingOrbitContradictionRule_DirectlyAdjacentEdge() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentEdge", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + StarBattleCell cell2 = board.getCell(1,0); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /*Tests the Clashing Orbit contradiction rule for a false contradiction. */ + @Test + public void ClashingOrbitContradictionRule_FalseContradiction() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/FalseContradiction", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + + Assert.assertNotNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } +} diff --git a/src/test/java/puzzles/starbattle/rules/EmptyAdjacentDirectRuleTest.java b/src/test/java/puzzles/starbattle/rules/EmptyAdjacentDirectRuleTest.java new file mode 100644 index 000000000..c81c74657 --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/EmptyAdjacentDirectRuleTest.java @@ -0,0 +1,177 @@ +package puzzles.starbattle.rules; + +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.puzzle.starbattle.rules.EmptyAdjacentDirectRule; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class EmptyAdjacentDirectRuleTest { + + private static final EmptyAdjacentDirectRule RULE = new EmptyAdjacentDirectRule(); + private static StarBattle starbattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starbattle = new StarBattle(); + } + + @Test + public void EmptyAdjacentDirectRule_OneLeft() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + cell1.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell2 = board.getCell(2,1); + cell2.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell3 = board.getCell(3,1); + cell3.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell4 = board.getCell(1,3); + cell4.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell5 = board.getCell(2,3); + cell5.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell6 = board.getCell(3,3); + cell6.setData(StarBattleCellType.BLACK.value); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + board.addModifiedData(cell5); + board.addModifiedData(cell6); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || + point.equals(cell3.getLocation()) || point.equals(cell4.getLocation()) || + point.equals(cell5.getLocation()) || point.equals(cell6.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + @Test + public void EmptyAdjacentDirectRule_TwoLeft() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + cell1.setData(StarBattleCellType.BLACK.value); + /* + StarBattleCell cell2 = board.getCell(2,1); + cell2.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell3 = board.getCell(1,3); + cell3.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell4 = board.getCell(2,3); + cell4.setData(StarBattleCellType.BLACK.value); + */ + + board.addModifiedData(cell1); + /* + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + */ + + Assert.assertNull(RULE.checkRule(transition)); + System.out.println("General Case is done\n"); + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } /* + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } */ + } + } + } + + @Test + public void EmptyAdjacentDirectRule_ThreeLeft() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + cell1.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell2 = board.getCell(2,1); + cell2.setData(StarBattleCellType.BLACK.value); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + @Test + public void EmptyAdjacentDirectRule_ImproperUseFourLeft() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + cell1.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell2 = board.getCell(2,1); + cell2.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell3 = board.getCell(1,3); + cell3.setData(StarBattleCellType.BLACK.value); + StarBattleCell cell4 = board.getCell(2,3); + cell4.setData(StarBattleCellType.BLACK.value); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + + Assert.assertNotNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } +} diff --git a/src/test/java/puzzles/starbattle/rules/FinishWithStarsDirectRuleTest.java b/src/test/java/puzzles/starbattle/rules/FinishWithStarsDirectRuleTest.java new file mode 100644 index 000000000..552e3703e --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/FinishWithStarsDirectRuleTest.java @@ -0,0 +1,209 @@ +package puzzles.starbattle.rules; + +import edu.rpi.legup.puzzle.starbattle.rules.FinishWithStarsDirectRule; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class FinishWithStarsDirectRuleTest { + private static final FinishWithStarsDirectRule RULE = new FinishWithStarsDirectRule(); + private static StarBattle starBattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starBattle = new StarBattle(); + } + + /* Finish With Stars Direct Rule where star is in the corner and only the row is blacked out */ + @Test + public void FinishWithStarsDirectRuleTestCornerRow() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRow", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + cell1.setData(StarBattleCellType.STAR.value); + + board.addModifiedData(cell1); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /* Finish With Stars Direct Rule where star is in the corner and only the column is blacked out */ + @Test + public void FinishWithStarsDirectRuleTestCornerColumn() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerColumn", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + cell1.setData(StarBattleCellType.STAR.value); + + board.addModifiedData(cell1); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /* Finish With Stars Direct Rule where star is in the corner and only the column is blacked out */ + @Test + public void FinishWithStarsDirectRuleTestCornerRowColumn() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRowColumn", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + cell1.setData(StarBattleCellType.STAR.value); + + board.addModifiedData(cell1); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + /* Finish With Stars Direct Rule where star is in the corner and only the column is blacked out */ + @Test + public void FinishWithStarsDirectRuleTestRegion() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/FinishWithStarsDirectRule/Region", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + cell1.setData(StarBattleCellType.STAR.value); + + board.addModifiedData(cell1); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + /* Finish With Stars Direct Rule where there are two stars in two different mostly blacked out regions */ + @Test + public void FinishWithStarsDirectRuleTestDoubleRegion() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/FinishWithStarsDirectRule/DoubleRegion", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(1,1); + cell1.setData(StarBattleCellType.STAR.value); + StarBattleCell cell2 = board.getCell(2,3); + cell2.setData(StarBattleCellType.STAR.value); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + + Assert.assertNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /* Finish With Stars Direct Rule where there are two stars in two different mostly blacked out regions */ + @Test + public void FinishWithStarsDirectRuleTestFalse() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/FinishWithStarsDirectRule/False", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(2,0); + cell1.setData(StarBattleCellType.STAR.value); + + board.addModifiedData(cell1); + + Assert.assertNotNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + +} diff --git a/src/test/java/puzzles/starbattle/rules/SurroundStarDirectRuleTest.java b/src/test/java/puzzles/starbattle/rules/SurroundStarDirectRuleTest.java new file mode 100644 index 000000000..db55d0f65 --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/SurroundStarDirectRuleTest.java @@ -0,0 +1,173 @@ +package puzzles.starbattle.rules; + +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.puzzle.starbattle.rules.SurroundStarDirectRule; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class SurroundStarDirectRuleTest { + + private static final SurroundStarDirectRule RULE = new SurroundStarDirectRule(); + private static StarBattle starbattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starbattle = new StarBattle(); + } + + @Test + public void SurroundStarDirectRule_CenterStarOneTile() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/SurroundStarDirectRule/CenterStar", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell = board.getCell(0,1); + cell.setData(StarBattleCellType.BLACK.value); + board.addModifiedData(cell); + + Assert.assertNull(RULE.checkRule(transition)); + + Point location = new Point(0, 1); + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + Point point = new Point(k, i); + if (point.equals(location)) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } + } + + @Test + public void SurroundStarDirectRule_CenterStarOneTileDiagonal() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/SurroundStarDirectRule/CenterStar", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell = board.getCell(0,0); + cell.setData(StarBattleCellType.BLACK.value); + board.addModifiedData(cell); + + Assert.assertNull(RULE.checkRule(transition)); + + Point location = new Point(0, 0); + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + Point point = new Point(k, i); + if (point.equals(location)) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } + } + + @Test + public void SurroundStarDirectRule_CenterStarAllTiles() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/SurroundStarDirectRule/CenterStar", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + for (int i = 0; i < board.getWidth(); i++) { + for (int j = 0; j < board.getHeight(); j++) { + if (i != 1 || j != 1) { + StarBattleCell cell = board.getCell(i,j); + cell.setData(StarBattleCellType.BLACK.value); + board.addModifiedData(cell); + } + } + } + + Assert.assertNull(RULE.checkRule(transition)); + + Point location = new Point(1, 1); + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + Point point = new Point(k, i); + if (point.equals(location)) { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } else { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } + } + + @Test + public void SurroundStarDirectRule_CornerStar() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/SurroundStarDirectRule/CornerStar", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,1); + cell1.setData(StarBattleCellType.BLACK.value); + board.addModifiedData(cell1); + StarBattleCell cell2 = board.getCell(1,0); + cell2.setData(StarBattleCellType.BLACK.value); + board.addModifiedData(cell2); + StarBattleCell cell3 = board.getCell(1,1); + cell3.setData(StarBattleCellType.BLACK.value); + board.addModifiedData(cell3); + + Assert.assertNull(RULE.checkRule(transition)); + + Point location1 = new Point(0, 1); + Point location2 = new Point(1,0); + Point location3 = new Point(1,1); + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + Point point = new Point(k, i); + if (point.equals(location1) || point.equals(location2) || point.equals(location3)) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } + } + + @Test + public void SurroundStarDirectRule_FalseSurroundStar() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/SurroundStarDirectRule/CornerStar", starbattle); + TreeNode rootNode = starbattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell = board.getCell(2,0); + cell.setData(StarBattleCellType.BLACK.value); + board.addModifiedData(cell); + + Assert.assertNotNull(RULE.checkRule(transition)); + + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } +} diff --git a/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java new file mode 100644 index 000000000..2e9f3ddef --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java @@ -0,0 +1,139 @@ +package puzzles.starbattle.rules; + +import edu.rpi.legup.puzzle.starbattle.rules.ClashingOrbitContradictionRule; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.puzzle.starbattle.rules.TooFewStarsContradictionRule; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class TooFewStarsContradictionRuleTest { + private static final TooFewStarsContradictionRule RULE = new TooFewStarsContradictionRule(); + private static StarBattle starBattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starBattle = new StarBattle(); + } + + /*Too few stars in column */ + @Test + public void TooFewStarsContradictionRule_Column() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooFewStarsContradictionRule/Column", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + StarBattleCell cell2 = board.getCell(0,1); + StarBattleCell cell3 = board.getCell(0,2); + StarBattleCell cell4 = board.getCell(0,3); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || + point.equals(cell3.getLocation()) || point.equals(cell4.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + + } + + /*Too few stars in row*/ + @Test + public void TooFewStarsContradictionRule_Row() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooFewStarsContradictionRule/Row", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + StarBattleCell cell2 = board.getCell(1,0); + StarBattleCell cell3 = board.getCell(2,0); + StarBattleCell cell4 = board.getCell(3,0); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || + point.equals(cell3.getLocation()) || point.equals(cell4.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /*Too few stars in region*/ + @Test + public void TooFewStarsContradictionRule_Region() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooFewStarsContradictionRule/Region", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + StarBattleCell cell2 = board.getCell(0,1); + StarBattleCell cell3 = board.getCell(1,0); + StarBattleCell cell4 = board.getCell(1,1); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || + point.equals(cell3.getLocation()) || point.equals(cell4.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /*False contradiction*/ + @Test + public void TooFewStarsContradictionRule_FalseContradiction() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooFewStarsContradictionRule/FalseContradiction", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + + Assert.assertNotNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + +} diff --git a/src/test/java/puzzles/starbattle/rules/TooManyStarsContradictionRuleTests.java b/src/test/java/puzzles/starbattle/rules/TooManyStarsContradictionRuleTests.java new file mode 100644 index 000000000..3424bbaac --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/TooManyStarsContradictionRuleTests.java @@ -0,0 +1,137 @@ +package puzzles.starbattle.rules; + +import edu.rpi.legup.puzzle.starbattle.rules.TooManyStarsContradictionRule; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.starbattle.StarBattle; +import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; +import edu.rpi.legup.puzzle.starbattle.StarBattleCell; +import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; +import edu.rpi.legup.save.InvalidFileFormatException; +import java.awt.*; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class TooManyStarsContradictionRuleTests { + private static final TooManyStarsContradictionRule RULE = new TooManyStarsContradictionRule(); + private static StarBattle starBattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starBattle = new StarBattle(); + } + + /* Tests the Too Many Stars contradiction rule where a region has + more stars than the puzzle number */ + @Test + public void TooManyStarsContradictionRule_RegionOverloaded() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooManyStarsContradictionRule/RegionOverloaded", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(2,1); + StarBattleCell cell2 = board.getCell(0,2); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + + /* Tests the Too Many Stars contradiction rule where a column has + more stars than the puzzle number */ + @Test + public void TooManyStarsContradictionRule_ColumnOverloaded() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooManyStarsContradictionRule/ColumnOverloaded", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + StarBattleCell cell2 = board.getCell(0,3); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + /* Tests the Too Many Stars contradiction rule where a row has + more stars than the puzzle number */ + @Test + public void TooManyStarsContradictionRule_RowOverloaded() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooManyStarsContradictionRule/RowOverloaded", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + StarBattleCell cell1 = board.getCell(0,0); + StarBattleCell cell2 = board.getCell(3,0); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } + /*Tests the Too Many Stars contradiction rule for a false contradiction. */ + @Test + public void TooManyStarsContradictionRule_FalseContradiction() + throws InvalidFileFormatException + { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooManyStarsContradictionRule/Correct", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + + Assert.assertNotNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Point point = new Point(j,i); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } +} diff --git a/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/ColumnBlackout b/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/ColumnBlackout deleted file mode 100644 index ddcc4dc9a..000000000 --- a/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/ColumnBlackout +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RegionBlackout b/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RegionBlackout deleted file mode 100644 index f2a5b42d9..000000000 --- a/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RegionBlackout +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RowBlackout b/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RowBlackout deleted file mode 100644 index f2a5b42d9..000000000 --- a/src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RowBlackout +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Blackout visualized.png b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Blackout visualized.png new file mode 100644 index 000000000..e8670e07e Binary files /dev/null and b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Blackout visualized.png differ diff --git a/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Corner b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Corner new file mode 100644 index 000000000..d1c6722e4 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Corner @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Edge b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Edge new file mode 100644 index 000000000..7995657c9 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Edge @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Middle b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Middle new file mode 100644 index 000000000..b6f483244 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/BlackoutDirectRule/Middle @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DiagonallyAdjacent b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DiagonallyAdjacent new file mode 100644 index 000000000..f63daad23 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DiagonallyAdjacent @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter new file mode 100644 index 000000000..b57a5989e --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentEdge b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentEdge new file mode 100644 index 000000000..f5a23b081 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentEdge @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/FalseContradiction b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/FalseContradiction new file mode 100644 index 000000000..04a4a6f6c --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ClashingOrbitContradictionRule/FalseContradiction @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft new file mode 100644 index 000000000..782c1d37d --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ImproperUseFourLeft @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft new file mode 100644 index 000000000..29005798d --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/OneLeft @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ThreeLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ThreeLeft new file mode 100644 index 000000000..ab6f4b178 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/ThreeLeft @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft new file mode 100644 index 000000000..5e8d71fbb --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/EmptyAdjacentDirectRule/TwoLeft @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerColumn b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerColumn new file mode 100644 index 000000000..ac0e35380 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerColumn @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRow b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRow new file mode 100644 index 000000000..3fb595a65 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRow @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRowColumn b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRowColumn new file mode 100644 index 000000000..44fe2b9ba --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/CornerRowColumn @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/DoubleRegion b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/DoubleRegion new file mode 100644 index 000000000..16171cd01 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/DoubleRegion @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/False b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/False new file mode 100644 index 000000000..16ab2cc7c --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/False @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/Region b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/Region new file mode 100644 index 000000000..d3c74607f --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/FinishWithStarsDirectRule/Region @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/SurroundStarDirectRule/CenterStar b/src/test/resources/puzzles/starbattle/rules/SurroundStarDirectRule/CenterStar new file mode 100644 index 000000000..a22f988df --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/SurroundStarDirectRule/CenterStar @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/SurroundStarDirectRule/CornerStar b/src/test/resources/puzzles/starbattle/rules/SurroundStarDirectRule/CornerStar new file mode 100644 index 000000000..50558d4c4 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/SurroundStarDirectRule/CornerStar @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Column b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Column new file mode 100644 index 000000000..1d1004b8b --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Column @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/FalseContradiction b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/FalseContradiction new file mode 100644 index 000000000..0c377a58b --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/FalseContradiction @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Region b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Region new file mode 100644 index 000000000..2594f46e5 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Region @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Row b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Row new file mode 100644 index 000000000..67c36c5e8 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/Row @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/ColumnOverloaded b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/ColumnOverloaded new file mode 100644 index 000000000..4e7170b3e --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/ColumnOverloaded @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/Correct b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/Correct new file mode 100644 index 000000000..15921e601 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/Correct @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/Region Overloaded Visualized-01.png b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/Region Overloaded Visualized-01.png new file mode 100644 index 000000000..bfe24d1a4 Binary files /dev/null and b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/Region Overloaded Visualized-01.png differ diff --git a/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/RegionOverloaded b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/RegionOverloaded new file mode 100644 index 000000000..bcf4a679a --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/RegionOverloaded @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/RowOverloaded b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/RowOverloaded new file mode 100644 index 000000000..fdf1adc11 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooManyStarsContradictionRule/RowOverloaded @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +