From de2b08a713df18f01012694d2ecb65c1b62cd71d Mon Sep 17 00:00:00 2001 From: summerhenson Date: Tue, 25 Jun 2024 14:12:26 -0400 Subject: [PATCH 1/4] Added Too Few Stars contradiction rule test --- .../TooFewStarsContradictionRuleTest.java | 18 +++++++++ .../NotEnoughSpace | 40 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/NotEnoughSpace diff --git a/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java index 2e9f3ddef..8a5fcfb88 100644 --- a/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java +++ b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java @@ -136,4 +136,22 @@ public void TooFewStarsContradictionRule_FalseContradiction() } } + @Test + public void TooFewStarsContradictionRule_NotEnoughSpace() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooFewStarsContradictionRule/NotEnoughSpace", starBattle); + TreeNode rootNode = starBattle.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + StarBattleBoard board = (StarBattleBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); + for (int i = 0; i < board.getHeight(); ++i) { + for (int j = 0; j < board.getWidth(); ++j) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); + } + } + } + } diff --git a/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/NotEnoughSpace b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/NotEnoughSpace new file mode 100644 index 000000000..9280cefdd --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/NotEnoughSpace @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 24bd3841facbe4660ee37d3bb536522c30a7b7fd Mon Sep 17 00:00:00 2001 From: summerhenson Date: Fri, 28 Jun 2024 14:17:26 -0400 Subject: [PATCH 2/4] First test case boards for Columns w/in Regions direct rule --- .../ColumnsWithinRegionsDirectRuleTest.java | 32 +++++++++++++++ .../OneColumnOneSquare | 29 ++++++++++++++ .../OnePartialColumnOneSquare | 29 ++++++++++++++ .../OnePartialColumnTwoSquares | 29 ++++++++++++++ .../ColumnsWithinRegionsDirectRule/TwoColumns | 40 +++++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 src/test/java/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRuleTest.java create mode 100644 src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OneColumnOneSquare create mode 100644 src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnOneSquare create mode 100644 src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnTwoSquares create mode 100644 src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/TwoColumns diff --git a/src/test/java/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRuleTest.java b/src/test/java/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRuleTest.java new file mode 100644 index 000000000..790f993b9 --- /dev/null +++ b/src/test/java/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRuleTest.java @@ -0,0 +1,32 @@ +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.ColumnsWithinRegionsDirectRule; +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 ColumnsWithinRegionsDirectRuleTest { + + private static final ColumnsWithinRegionsDirectRule RULE = new ColumnsWithinRegionsDirectRule(); + private static StarBattle starbattle; + + @BeforeClass + public static void setUp() { + MockGameBoardFacade.getInstance(); + starbattle = new StarBattle(); + } + + //single column w/in single region one square outside + + +} diff --git a/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OneColumnOneSquare b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OneColumnOneSquare new file mode 100644 index 000000000..4d065b28f --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OneColumnOneSquare @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnOneSquare b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnOneSquare new file mode 100644 index 000000000..5c3fc22cc --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnOneSquare @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnTwoSquares b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnTwoSquares new file mode 100644 index 000000000..463f3a6d7 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/OnePartialColumnTwoSquares @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/TwoColumns b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/TwoColumns new file mode 100644 index 000000000..ad5e4d198 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/ColumnsWithinRegionsDirectRule/TwoColumns @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From cf78cacc4132615e0563cbfbcda7188d92931000 Mon Sep 17 00:00:00 2001 From: summerhenson Date: Fri, 28 Jun 2024 14:21:08 -0400 Subject: [PATCH 3/4] Added new Too Few Stars contradiction rule test case --- .../TooFewStarsContradictionRuleTest.java | 30 ++++++++++++++ .../TwoStarColumn | 40 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarColumn diff --git a/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java index 8a5fcfb88..e0aae994e 100644 --- a/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java +++ b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java @@ -154,4 +154,34 @@ public void TooFewStarsContradictionRule_NotEnoughSpace() } } + @Test + public void TooFewStarsContradictionRule_TwoStarColumn() + throws InvalidFileFormatException { + + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarColumn", 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))); + } + } + } + } + } diff --git a/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarColumn b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarColumn new file mode 100644 index 000000000..d781b3092 --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarColumn @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From dc7394769b4d0d117dbd1e1b354bc71367a69bb4 Mon Sep 17 00:00:00 2001 From: summerhenson Date: Fri, 28 Jun 2024 14:26:25 -0400 Subject: [PATCH 4/4] Added second new test case for Too Few Stars contradiction rule --- .../TooFewStarsContradictionRuleTest.java | 18 +++++++++ .../TwoStarFalseContradiction | 40 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarFalseContradiction diff --git a/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java index e0aae994e..2c90c6fb2 100644 --- a/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java +++ b/src/test/java/puzzles/starbattle/rules/TooFewStarsContradictionRuleTest.java @@ -184,4 +184,22 @@ public void TooFewStarsContradictionRule_TwoStarColumn() } } + @Test + public void TooFewStarsContradictionRule_TwoStarFalseContradiction() + throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarFalseContradiction", 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/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarFalseContradiction b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarFalseContradiction new file mode 100644 index 000000000..5f1d2753f --- /dev/null +++ b/src/test/resources/puzzles/starbattle/rules/TooFewStarsContradictionRule/TwoStarFalseContradiction @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file