From 44ea007be20126cb47e289fd74155d2f5b88c71e Mon Sep 17 00:00:00 2001 From: Rorymar <36866664+Rorymar@users.noreply.github.com> Date: Fri, 29 Sep 2023 17:16:00 -0400 Subject: [PATCH 01/11] Improvement of TouchingTents Tests Improved the Diagonal and Adjacency Tests to verify different orientations all work. --- .../LightInHorizontalPath | 18 +++--- .../LightInVerticalPath | 18 +++--- .../TouchingTentsContradictionRuleTest.java | 58 +++++++++++++++++-- .../TouchingTentsAdjacentAlt | 19 ++++++ .../TouchingTentsDiagonalAlt | 19 ++++++ .../TouchingTentsFull2By2 | 21 +++++++ 6 files changed, 129 insertions(+), 24 deletions(-) create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsAdjacentAlt create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsDiagonalAlt create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsFull2By2 diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath index 633ccc80b..1b4926106 100644 --- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath +++ b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath index 70419c40c..48aa7010c 100644 --- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath +++ b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java index 79fc70118..1f66b863b 100644 --- a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java @@ -10,13 +10,9 @@ import edu.rpi.legup.puzzle.treetent.TreeTent; import edu.rpi.legup.puzzle.treetent.TreeTentBoard; -import edu.rpi.legup.puzzle.treetent.TreeTentCell; -import edu.rpi.legup.puzzle.treetent.TreeTentType; import edu.rpi.legup.puzzle.treetent.rules.TouchingTentsContradictionRule; import edu.rpi.legup.save.InvalidFileFormatException; -import java.awt.*; - public class TouchingTentsContradictionRuleTest { private static final TouchingTentsContradictionRule RULE = new TouchingTentsContradictionRule(); @@ -28,8 +24,13 @@ public static void setUp() { treetent = new TreeTent(); } + //DIAGONAL TESTS + /** + * Tests a tent diagonal of orientation T + * T + **/ @Test - public void TouchingTentsContradictionRule_Diagonal() throws InvalidFileFormatException { + public void TouchingTentsContradictionRule_DiagonalUpLeftToDownRight() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsDiagonal", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); @@ -44,8 +45,33 @@ public void TouchingTentsContradictionRule_Diagonal() throws InvalidFileFormatEx Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); } + /** + * Tests a tent diagonal of orientation T + * T + **/ @Test - public void TouchingTentsContradictionRule_Adjacent() throws InvalidFileFormatException { + public void TouchingTentsContradictionRule_DiagonalDownLeftToUpRight() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsDiagonalAlt",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition,board.getCell(1,0))); + Assert.assertNull(RULE.checkRuleAt(transition,board.getCell(0,1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + + //ADJACENT TESTS + /** + * Tests a tent adjacent of orientation T + * T + **/ + @Test + public void TouchingTentsContradictionRule_AdjacentVertical() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsAdjacent", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); @@ -59,6 +85,26 @@ public void TouchingTentsContradictionRule_Adjacent() throws InvalidFileFormatEx Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } + + /** + * Tests a tent adjacent of orientation TT + * + **/ + @Test + public void TouchingTentsContradictionRule_AdjacentHorizontal() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsAdjacentAlt", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } } diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsAdjacentAlt b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsAdjacentAlt new file mode 100644 index 000000000..902fb3ee7 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsAdjacentAlt @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsDiagonalAlt b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsDiagonalAlt new file mode 100644 index 000000000..9b35fb998 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsDiagonalAlt @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsFull2By2 b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsFull2By2 new file mode 100644 index 000000000..59805ca35 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsFull2By2 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8503f38ea86563bb9095bcb58d9c9ed6166619c4 Mon Sep 17 00:00:00 2001 From: Rorymar <36866664+Rorymar@users.noreply.github.com> Date: Fri, 29 Sep 2023 17:37:52 -0400 Subject: [PATCH 02/11] Added Mixed Tests Added tests for a combination of diagonals and adjacents. --- .../TouchingTentsContradictionRuleTest.java | 102 ++++++++++++++++++ .../TouchingTentsMixedDownLeft | 20 ++++ .../TouchingTentsMixedDownRight | 20 ++++ .../TouchingTentsMixedUpLeft | 20 ++++ .../TouchingTentsMixedUpRight | 20 ++++ 5 files changed, 182 insertions(+) create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownLeft create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownRight create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpLeft create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpRight diff --git a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java index 1f66b863b..aece8eaba 100644 --- a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java @@ -105,6 +105,108 @@ public void TouchingTentsContradictionRule_AdjacentHorizontal() throws InvalidFi Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } + //MIXED TESTS + /** + * Tests a tent of orientation TT + * TT + * + **/ + @Test + public void TouchingTentsContradictionRule_2By2Square() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsFull2By2",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + /** + * Tests a tent of orientation TT + * T + * + **/ + @Test + public void TouchingTentsContradictionRule_UpLeft() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpLeft",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + /** + * Tests a tent of orientation TT + * T + * + **/ + @Test + public void TouchingTentsContradictionRule_UpRight() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpRight",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + } + /** + * Tests a tent of orientation T + * TT + * + **/ + @Test + public void TouchingTentsContradictionRule_DownLeft() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownLeft",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + } + /** + * Tests a tent of orientation T + * TT + * + **/ + @Test + public void TouchingTentsContradictionRule_DownRight() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownRight",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + } + } diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownLeft b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownLeft new file mode 100644 index 000000000..af4ca0831 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownLeft @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownRight b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownRight new file mode 100644 index 000000000..05b7a7667 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedDownRight @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpLeft b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpLeft new file mode 100644 index 000000000..b8b81c7b4 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpLeft @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpRight b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpRight new file mode 100644 index 000000000..af7fb5df2 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsMixedUpRight @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 964cf7b165d15bfab55764beb75143140cf75c6c Mon Sep 17 00:00:00 2001 From: Rorymar <36866664+Rorymar@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:14:14 -0400 Subject: [PATCH 03/11] Added Tree-Including Tests Added tests to the TouchingTents tests that made sure trees do not trigger this contradiction. --- .../TouchingTentsContradictionRuleTest.java | 32 +++++++++++++++++++ .../TouchingTentsTreeAdjacent | 19 +++++++++++ .../TouchingTentsTreeDiagonal | 19 +++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeAdjacent create mode 100644 src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeDiagonal diff --git a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java index aece8eaba..764021caf 100644 --- a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java @@ -206,6 +206,38 @@ public void TouchingTentsContradictionRule_DownRight() throws InvalidFileFormatE Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); } + /** + * Tests if tree adjacent triggers a null + */ + @Test + public void TouchingTentsContradictionRule_TreeAdjacent() throws InvalidFileFormatException{ + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeAdjacent",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNotNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + } + /** + * Tests if tree diagonal triggers a null + */ + @Test + public void TouchingTentsContradictionRule_TreeDiagonal() throws InvalidFileFormatException{ + TestUtilities.importTestBoard("puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeDiagonal",treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNotNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + } } diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeAdjacent b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeAdjacent new file mode 100644 index 000000000..4c63558c2 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeAdjacent @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeDiagonal b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeDiagonal new file mode 100644 index 000000000..b2f54aef3 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/TouchingTentsContradictionRule/TouchingTentsTreeDiagonal @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4e1c003159234872858945aa060f2989ce1bac26 Mon Sep 17 00:00:00 2001 From: Rorymar <36866664+Rorymar@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:41:05 -0400 Subject: [PATCH 04/11] 2x2 NoTreeForTent Basic Tests Added Files for NoTreeForTent Tests, and test cases for the basic 2x2 Tests. Also fixed some spacing in the TouchingTents Test File. --- .../NoTreeForTentContradictionRuleTest.java | 76 +++++++++++++++++-- .../TouchingTentsContradictionRuleTest.java | 17 +++-- .../NoTreeForTent3x3 | 0 .../NoTreeForTentDiagonals | 0 .../NoTreeForTentJustTent | 0 .../NoTreeForTentNE | 21 +++++ .../{NoTreeForTent => NoTreeForTentNW} | 0 .../NoTreeForTentSE | 21 +++++ .../NoTreeForTentSW | 21 +++++ .../NoTreeForTentYesTree | 0 10 files changed, 144 insertions(+), 12 deletions(-) create mode 100644 src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3 create mode 100644 src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals create mode 100644 src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent create mode 100644 src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNE rename src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/{NoTreeForTent => NoTreeForTentNW} (100%) create mode 100644 src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSE create mode 100644 src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSW create mode 100644 src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree diff --git a/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java index c3003cef1..4e83c8778 100644 --- a/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java @@ -10,13 +10,9 @@ import edu.rpi.legup.puzzle.treetent.TreeTent; import edu.rpi.legup.puzzle.treetent.TreeTentBoard; -import edu.rpi.legup.puzzle.treetent.TreeTentCell; -import edu.rpi.legup.puzzle.treetent.TreeTentType; import edu.rpi.legup.puzzle.treetent.rules.NoTreeForTentContradictionRule; import edu.rpi.legup.save.InvalidFileFormatException; -import java.awt.*; - public class NoTreeForTentContradictionRuleTest { private static final NoTreeForTentContradictionRule RULE = new NoTreeForTentContradictionRule(); @@ -28,9 +24,13 @@ public static void setUp() { treetent = new TreeTent(); } + /** + * @throws InvalidFileFormatException + * Tests if, in a 2x2 Grid, a Tent in the NW corner has no adjacent trees + */ @Test - public void NoTreeForTentContradictionRule_() throws InvalidFileFormatException { - TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent", treetent); + public void NoTreeForTentContradictionRule_NW() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNW", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); @@ -43,5 +43,69 @@ public void NoTreeForTentContradictionRule_() throws InvalidFileFormatException Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } + + /** + * @throws InvalidFileFormatException + * Tests if, in a 2x2 Grid, a Tent in the NE corner has no adjacent trees + */ + @Test + public void NoTreeForTentContradictionRule_NE() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNE", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + + /** + * @throws InvalidFileFormatException + * Tests if, in a 2x2 Grid, a Tent in the NW corner has no adjacent trees + */ + @Test + public void NoTreeForTentContradictionRule_SW() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSW", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + + /** + * @throws InvalidFileFormatException + * Tests if, in a 2x2 Grid, a Tent in the SE corner has no adjacent trees + */ + @Test + public void NoTreeForTentContradictionRule_SE() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSE", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + //Center of 3x3 Board + //Test with a board with Trees all diagonal + //Test with a board with Trees all adjacent (should assertNotNull) + //Test with a board with Tents all adjacent } diff --git a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java index 764021caf..f48afe5d7 100644 --- a/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/TouchingTentsContradictionRuleTest.java @@ -26,6 +26,7 @@ public static void setUp() { //DIAGONAL TESTS /** + * @throws InvalidFileFormatException * Tests a tent diagonal of orientation T * T **/ @@ -46,6 +47,7 @@ public void TouchingTentsContradictionRule_DiagonalUpLeftToDownRight() throws In } /** + * @throws InvalidFileFormatException * Tests a tent diagonal of orientation T * T **/ @@ -67,6 +69,7 @@ public void TouchingTentsContradictionRule_DiagonalDownLeftToUpRight() throws In //ADJACENT TESTS /** + * @throws InvalidFileFormatException * Tests a tent adjacent of orientation T * T **/ @@ -87,8 +90,8 @@ public void TouchingTentsContradictionRule_AdjacentVertical() throws InvalidFile } /** + * @throws InvalidFileFormatException * Tests a tent adjacent of orientation TT - * **/ @Test public void TouchingTentsContradictionRule_AdjacentHorizontal() throws InvalidFileFormatException { @@ -107,9 +110,9 @@ public void TouchingTentsContradictionRule_AdjacentHorizontal() throws InvalidFi } //MIXED TESTS /** + * @throws InvalidFileFormatException * Tests a tent of orientation TT * TT - * **/ @Test public void TouchingTentsContradictionRule_2By2Square() throws InvalidFileFormatException { @@ -127,9 +130,9 @@ public void TouchingTentsContradictionRule_2By2Square() throws InvalidFileFormat Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } /** + * @throws InvalidFileFormatException * Tests a tent of orientation TT * T - * **/ @Test public void TouchingTentsContradictionRule_UpLeft() throws InvalidFileFormatException { @@ -147,9 +150,9 @@ public void TouchingTentsContradictionRule_UpLeft() throws InvalidFileFormatExce Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } /** + * @throws InvalidFileFormatException * Tests a tent of orientation TT * T - * **/ @Test public void TouchingTentsContradictionRule_UpRight() throws InvalidFileFormatException { @@ -167,9 +170,9 @@ public void TouchingTentsContradictionRule_UpRight() throws InvalidFileFormatExc Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); } /** + * @throws InvalidFileFormatException * Tests a tent of orientation T * TT - * **/ @Test public void TouchingTentsContradictionRule_DownLeft() throws InvalidFileFormatException { @@ -187,9 +190,9 @@ public void TouchingTentsContradictionRule_DownLeft() throws InvalidFileFormatEx Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); } /** + * @throws InvalidFileFormatException * Tests a tent of orientation T * TT - * **/ @Test public void TouchingTentsContradictionRule_DownRight() throws InvalidFileFormatException { @@ -207,6 +210,7 @@ public void TouchingTentsContradictionRule_DownRight() throws InvalidFileFormatE Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); } /** + * @throws InvalidFileFormatException * Tests if tree adjacent triggers a null */ @Test @@ -223,6 +227,7 @@ public void TouchingTentsContradictionRule_TreeAdjacent() throws InvalidFileForm Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); } /** + * @throws InvalidFileFormatException * Tests if tree diagonal triggers a null */ @Test diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3 b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3 new file mode 100644 index 000000000..e69de29bb diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals new file mode 100644 index 000000000..e69de29bb diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent new file mode 100644 index 000000000..e69de29bb diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNE b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNE new file mode 100644 index 000000000..80ffb9525 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNE @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNW similarity index 100% rename from src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent rename to src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentNW diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSE b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSE new file mode 100644 index 000000000..c2fc5206d --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSE @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSW b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSW new file mode 100644 index 000000000..8e8249b27 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentSW @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree new file mode 100644 index 000000000..e69de29bb From 0f5e1a60b6f581883ccacb96f4fa3ad8a47c46e4 Mon Sep 17 00:00:00 2001 From: Rorymar <36866664+Rorymar@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:43:40 -0400 Subject: [PATCH 05/11] Improved NoTreeForTent Tests Added more complex 3x3 tests to the NoTreeForTents. Fixed an error with the 2x2 Tests --- .../NoTreeForTentContradictionRuleTest.java | 112 ++++++++++++++++-- .../NoTreeForTent3x3 | 28 +++++ .../NoTreeForTentDiagonals | 28 +++++ .../NoTreeForTentJustTent | 28 +++++ .../NoTreeForTentYesTree | 28 +++++ 5 files changed, 216 insertions(+), 8 deletions(-) diff --git a/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java index 4e83c8778..2ad2ac90e 100644 --- a/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/NoTreeForTentContradictionRuleTest.java @@ -59,8 +59,8 @@ public void NoTreeForTentContradictionRule_NE() throws InvalidFileFormatExceptio Assert.assertNull(RULE.checkContradiction(board)); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); - Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); - Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } @@ -79,8 +79,8 @@ public void NoTreeForTentContradictionRule_SW() throws InvalidFileFormatExceptio Assert.assertNull(RULE.checkContradiction(board)); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); - Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); - Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } @@ -103,9 +103,105 @@ public void NoTreeForTentContradictionRule_SE() throws InvalidFileFormatExceptio Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } - //Center of 3x3 Board - //Test with a board with Trees all diagonal - //Test with a board with Trees all adjacent (should assertNotNull) - //Test with a board with Tents all adjacent + + /** + * @throws InvalidFileFormatException + * Tests if, in a 3x3 Grid with no trees, a Tent in the center cell has no adjacent trees + */ + @Test + public void NoTreeForTentContradictionRule_3x3() throws InvalidFileFormatException{ + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 2))); + } + + /** + * @throws InvalidFileFormatException + * Tests if, in a 3x3 Grid with diagonal trees, a Tent in the center cell has no adjacent trees + */ + @Test + public void NoTreeForTentContradictionRule_3x3WithDiagonalTrees() throws InvalidFileFormatException{ + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 2))); + } + + /** + * @throws InvalidFileFormatException + * Tests if, in a 3x3 Grid with an adjacent tree, test does not assert null. + */ + @Test + public void NoTreeForTentContradictionRule_YesTree() throws InvalidFileFormatException{ + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNotNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 2))); + } + + /** + * @throws InvalidFileFormatException + * Tests if, in a 3x3 Grid with touching tents, a Tent in the center cell has no adjacent trees + */ + @Test + public void NoTreeForTentContradictionRule_JustTent() throws InvalidFileFormatException{ + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 0))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 2))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(2, 2))); + } } diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3 b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3 index e69de29bb..9c5e81936 100644 --- a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3 +++ b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTent3x3 @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals index e69de29bb..ad086bbc1 100644 --- a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals +++ b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentDiagonals @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent index e69de29bb..93aaf451f 100644 --- a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent +++ b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentJustTent @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree index e69de29bb..f46e4b5a5 100644 --- a/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree +++ b/src/test/resources/puzzles/treetent/rules/NoTreeForTentContradictionRule/NoTreeForTentYesTree @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 7aba3f34bbc77ad84fe7954166a953dea60c84e5 Mon Sep 17 00:00:00 2001 From: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:38:46 -0400 Subject: [PATCH 06/11] October Merge (#636) * Region Based Changes (#559) Co-authored-by: Hanson Gu <123511202+hansongu123@users.noreply.github.com> * Short Truth Table Puzzle Editor (#451) * Created files for STT elements * Renamed Tiles classes to Elements to match package name Also added an elements reference sheet and renamed rules reference sheet accordingly * More progress made This won't compile, just saving progress made * More progress being made * Fixed file name typo and added placeholder tiles * Added image paths * Created element classes and added placeholder tile images (#452) * Renamed Tiles classes to Elements to match package name Also added an elements reference sheet and renamed rules reference sheet accordingly * More progress made This won't compile, just saving progress made * More progress being made * Fixed file name typo and added placeholder tiles * Added image paths * Set the current board on boardView * Fixed typo and turned on STT puzzle editor for testing * Added preliminary valid dimensions checker This will most definitely change in the future, hopefully can change to accept a number of statements * Fixed image file paths * Added ActionListener Allows us to determine what puzzle is selected by the user * Hide rows and columns input for Short Truth Table * Added text area for Short Truth Table * Added scrollbars to show up as needed * Reformatted code * More code reformatting * Even more reformatting * Separate the data from the TextArea into different lines * Did some researching/testing Tested certain variable values with a STT file with no true/false values * Made more progress Added new methods to handle creating Short Truth Table boards from an array of strings * Added a bunch of TODOs - Implemented a couple functions to be used later - Added a bunch of TODO comments for future work * Made some more progress * Implemented abstract methods from PuzzleImporter * Added abstract methods to Fillapix and added other exception reporting * CheckStyle formatting * Removed a TODO comment * Statements show up in puzzle editor Fixed a bug where the importer was not properly being initialized. Statements now show up in the puzzle editor. * Removed empty statements * Changed InvalidFormatException to IllegalArgumentException * Remove argument that has already been caught * Removed elements that will not be used * Added puzzle editor cell clicking functionality * Added ability to toggle certain logical elements * New icons and more functionality implemented * Fixed a bug where spacer rows could be modified * Added statement error checking * Fixed formatting * Only one logic symbol element needed * Changed InputMismatchException to UnsupportedOperationException * Renamed variables to not be STT specific * Finding initial issue and starting fix * Issue is statement copying and modifying * STT exporter now working. Overrode setCell for STTBoard. * Added code documentation * removed testing println() * Gradle fixes * Revert "Merge pull request #545 from MMosley502/puzzle_editor-short_truth_table-file_saving" This reverts commit 2e82547896a7fb3e52ec27634cd8938ef299732f, reversing changes made to beb60a2ab67c8317d404f54e52471739f698bf22. * Saving files now works * Fixed the blank element to be categorized as a placeable element * Fixed a bug where file wouldn't save due to batch grader updates * Reformatted code in STT * Reformatted code again * MORE REFORMATTING Pls like my code CheckStyle --------- Co-authored-by: Matthew Mosley Co-authored-by: MMosley502 <74743867+MMosley502@users.noreply.github.com> * Have null changes be valid and fix IsolatedBlackContradicitonRule error message (#561) * Get Tests to be called Revert "Create first cypress test template" This reverts commit 3e50909b93b5aa9634cf0d296e9aeff756b0a909. First commit Finish Lightup tests * Add more tests Update TestRunner.java * Somehow ended up in the wrong spot Fix Import * Please let this be the fix Update TreeTransition.java Update TreeTransition.java Update DirectRule.java Check to see which is not correct Update ElementController.java Revert "maybe the null is making it think that it's not valid" This reverts commit 7bf1de0d66ced6749ee37fbb9c252636b2fcdc79. Just trying to change color Revert "Just trying to change color" This reverts commit ec44695ee578d664055d135a668927a0fd900f5d. Revert "maybe the null is making it think that it's not valid" This reverts commit 3f162fbdc32e6fbd23da321a14a6af96f0ff520d. Check to see which is not correct Revert "Check to see which is not correct" This reverts commit 136b0a41b9d103e6f3e9a7f8cd5d970bf76b050b. Update TreeTransition.java Update TreeTransition.java Revert "Update TreeTransition.java" This reverts commit cde45bb9001cfbfa4f6e2a49b4e9990d2fa7ad33. * Fix error with isolated Black Fix error message with isolated black * Removed excess whitespace and imports. Added short JavaDoc for `TestRunner.java` --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Bram van Heuveln Co-authored-by: Corppet * Fixed a bug * Update BlackTile.java Black tile should not be placeable * Added unknown tile stuff * ID error * Some Fixes to Recently Discussed UX Bugs (#563) * frame and panels default sizes, default pos on screen * hardcoded version number * homepanel default size * set panels' own sizes * some changes * Removed unused import --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Corppet * Oops pushed the wrong file Yeah some tiles work now but this is the ID error * Number Tile working * Update Exporter (#627) * Update Exporter * Delete Test_Save --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> * Create run-tests.yml * Update run-tests.yml * Update run-tests.yml * Update run-tests.yml * Update run-tests.yml * Windows things * Added print messages * More Windows things * Debugging * Update run-tests.yml * Update run-tests.yml * Maybe this will work now? * Didn't work * Update run-tests.yml * Update run-tests.yml * Create DummyTest.java For debugging purposes * Added another dummy test * Update run-tests.yml * Update run-tests.yml Get rid of all this info * Deleted the dummy tests --------- Co-authored-by: Antonio Orta <60408336+19690ao@users.noreply.github.com> Co-authored-by: Hanson Gu <123511202+hansongu123@users.noreply.github.com> Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Matthew Mosley Co-authored-by: MMosley502 <74743867+MMosley502@users.noreply.github.com> Co-authored-by: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Co-authored-by: Bram van Heuveln Co-authored-by: Corppet Co-authored-by: charlestian23 Co-authored-by: ThisMatt <98851950+ThisMatt@users.noreply.github.com> --- .github/workflows/run-tests.yml | 73 +++++++++++++ bin/main/edu/rpi/legup/legup/config | 2 +- puzzles files/shorttruthtable/empty_test.xml | 14 +++ .../edu/rpi/legup/app/GameBoardFacade.java | 84 ++++++++++++-- .../ValidateContradictionRuleCommand.java | 12 +- src/main/java/edu/rpi/legup/model/Puzzle.java | 14 +++ .../edu/rpi/legup/model/PuzzleExporter.java | 1 + .../edu/rpi/legup/model/PuzzleImporter.java | 19 +++- .../edu/rpi/legup/model/rules/DirectRule.java | 14 +-- .../java/edu/rpi/legup/model/tree/Tree.java | 1 + .../puzzle/battleship/BattleshipExporter.java | 9 +- .../puzzle/battleship/BattleshipImporter.java | 15 +++ .../puzzle/fillapix/FillapixExporter.java | 9 +- .../puzzle/fillapix/FillapixImporter.java | 15 +++ .../puzzle/heyawake/HeyawakeExporter.java | 9 +- .../puzzle/heyawake/HeyawakeImporter.java | 15 +++ .../rpi/legup/puzzle/lightup/LightUpCell.java | 37 +++++++ .../legup/puzzle/lightup/LightUpExporter.java | 9 +- .../legup/puzzle/lightup/LightUpImporter.java | 15 +++ .../puzzle/lightup/elements/BlackTile.java | 6 +- .../puzzle/lightup/elements/UnknownTile.java | 9 ++ .../rpi/legup/puzzle/masyu/MasyuExporter.java | 9 +- .../rpi/legup/puzzle/masyu/MasyuImporter.java | 15 +++ .../puzzle/nurikabe/NurikabeImporter.java | 15 +++ .../puzzle/nurikabe/NurikabeUtilities.java | 63 +++++++++++ .../rules/NoNumberContradictionRule.java | 22 ++-- .../shorttruthtable/ShortTruthTable.java | 29 ++++- .../shorttruthtable/ShortTruthTableCell.java | 103 +++++++++++++++++- .../ShortTruthTableCellType.java | 1 + .../ShortTruthTableController.java | 2 +- .../ShortTruthTableExporter.java | 9 +- .../ShortTruthTableImporter.java | 80 ++++++++++++-- .../elements/ArgumentElement.java | 9 ++ .../elements/GreenElement.java | 9 ++ .../elements/LogicSymbolElement.java | 9 ++ .../shorttruthtable/elements/RedElement.java | 9 ++ .../elements/UnknownElement.java | 9 ++ .../shorttruthtable_elements_reference_sheet | 6 + ...shorttruthtable_rules_reference_sheet.txt} | 0 .../skyscrapers/SkyscrapersCellFactory.java | 2 +- .../skyscrapers/SkyscrapersExporter.java | 24 ++-- .../skyscrapers/SkyscrapersImporter.java | 15 +++ .../legup/puzzle/sudoku/SudokuExporter.java | 9 +- .../legup/puzzle/sudoku/SudokuImporter.java | 15 +++ .../puzzle/treetent/TreeTentImporter.java | 15 +++ .../edu/rpi/legup/ui/CreatePuzzleDialog.java | 79 ++++++++++++-- src/main/java/edu/rpi/legup/ui/HomePanel.java | 29 ++++- src/main/java/edu/rpi/legup/ui/LegupUI.java | 7 +- .../edu/rpi/legup/ui/ProofEditorPanel.java | 3 +- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 17 ++- .../ui/proofeditorui/rulesview/RuleFrame.java | 2 +- .../rpi/legup/images/lightup/UnknownTile.png | Bin 0 -> 9733 bytes .../shorttruthtable/tiles/AndOrTile.png | Bin 0 -> 442 bytes .../tiles/ConditionalBiconditionalTile.png | Bin 0 -> 326 bytes .../shorttruthtable/tiles/GreenTile.png | Bin 0 -> 190 bytes .../shorttruthtable/tiles/LetterTile.png | Bin 0 -> 579 bytes .../images/shorttruthtable/tiles/RedTile.png | Bin 0 -> 152 bytes .../shorttruthtable/tiles/UnknownTile.png | Bin 0 -> 9733 bytes src/main/resources/edu/rpi/legup/legup/config | 2 +- src/test/java/legup/TestRunner.java | 7 +- src/test/java/legup/TestUtilities.java | 9 -- 61 files changed, 915 insertions(+), 101 deletions(-) create mode 100644 .github/workflows/run-tests.yml create mode 100644 puzzles files/shorttruthtable/empty_test.xml create mode 100644 src/main/java/edu/rpi/legup/puzzle/lightup/elements/UnknownTile.java create mode 100644 src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/ArgumentElement.java create mode 100644 src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/GreenElement.java create mode 100644 src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/LogicSymbolElement.java create mode 100644 src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/RedElement.java create mode 100644 src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/UnknownElement.java create mode 100644 src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/shorttruthtable_elements_reference_sheet rename src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/{shorttruthtable_reference_sheet.txt => shorttruthtable_rules_reference_sheet.txt} (100%) create mode 100644 src/main/resources/edu/rpi/legup/images/lightup/UnknownTile.png create mode 100644 src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/AndOrTile.png create mode 100644 src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/ConditionalBiconditionalTile.png create mode 100644 src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/GreenTile.png create mode 100644 src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/LetterTile.png create mode 100644 src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/RedTile.png create mode 100644 src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/UnknownTile.png diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 000000000..bed9d7ad2 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,73 @@ +name: Run JUnit Tests + +on: + push: + branches: + - master + - dev + pull_request: + branches: + - master + - dev + +jobs: + ubuntu-test: + runs-on: ubuntu-latest + + steps: + - name: Check Out Code + uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Run JUnit Tests on Linux + run: | + ./gradlew test + + test-macos: + runs-on: macos-latest + + steps: + - name: Check Out Code + uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Run JUnit Tests on macOS + run: | + ./gradlew test + + test-windows: + runs-on: windows-latest + + steps: + - name: Check Out Code + uses: actions/checkout@v2 + + - name: Set up JDK and Gradle on Windows + uses: actions/setup-java@v2 + with: + java-version: 11 + distribution: 'adopt' + + - name: Run JUnit Tests on Windows + run: | + .\gradlew.bat test \ No newline at end of file diff --git a/bin/main/edu/rpi/legup/legup/config b/bin/main/edu/rpi/legup/legup/config index bb7da871a..24fdcf365 100644 --- a/bin/main/edu/rpi/legup/legup/config +++ b/bin/main/edu/rpi/legup/legup/config @@ -27,7 +27,7 @@ + fileCreationDisabled="false"/> diff --git a/puzzles files/shorttruthtable/empty_test.xml b/puzzles files/shorttruthtable/empty_test.xml new file mode 100644 index 000000000..2d8e4b6c8 --- /dev/null +++ b/puzzles files/shorttruthtable/empty_test.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 2686086a8..55273ab4f 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -1,23 +1,22 @@ package edu.rpi.legup.app; +import edu.rpi.legup.history.History; import edu.rpi.legup.history.IHistoryListener; import edu.rpi.legup.history.IHistorySubject; +import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.PuzzleImporter; import edu.rpi.legup.model.gameboard.Board; -import edu.rpi.legup.model.Puzzle; import edu.rpi.legup.model.tree.Tree; +import edu.rpi.legup.save.InvalidFileFormatException; +import edu.rpi.legup.ui.LegupUI; import edu.rpi.legup.ui.ProofEditorPanel; import edu.rpi.legup.ui.PuzzleEditorPanel; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.xml.sax.SAXException; -import edu.rpi.legup.save.InvalidFileFormatException; -import edu.rpi.legup.ui.LegupUI; -import edu.rpi.legup.history.History; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -144,6 +143,30 @@ public boolean validateDimensions(String game, int rows, int columns) throws Run } } + /** + * Validates the given text input for the given puzzle + * + * @param game the name of the puzzle + * @param statements an array of statements + * @return true if it is possible to create a board for the given game with the given statements, + * false otherwise + * @throws RuntimeException if any of the input is invalid + */ + public boolean validateTextInput(String game, String[] statements) throws RuntimeException { + String qualifiedClassName = config.getPuzzleClassForName(game); + try { + Class c = Class.forName(qualifiedClassName); + Constructor constructor = c.getConstructor(); + Puzzle puzzle = (Puzzle) constructor.newInstance(); + return puzzle.isValidTextInput(statements); + } + catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | + InstantiationException e) { + LOGGER.error(e); + throw new RuntimeException("Error validating puzzle text input"); + } + } + /** * Loads an empty puzzle * @@ -159,7 +182,6 @@ public void loadPuzzle(String game, int rows, int columns) throws RuntimeExcepti Class c = Class.forName(qualifiedClassName); Constructor cons = c.getConstructor(); Puzzle puzzle = (Puzzle) cons.newInstance(); - setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); PuzzleImporter importer = puzzle.getImporter(); if (importer == null) { @@ -167,6 +189,13 @@ public void loadPuzzle(String game, int rows, int columns) throws RuntimeExcepti throw new RuntimeException("Puzzle importer null"); } + // Theoretically, this exception should never be thrown, since LEGUP should not be + // allowing the user to give row/column input for a puzzle that doesn't support it + if (!importer.acceptsRowsAndColumnsInput()) { + throw new IllegalArgumentException(puzzle.getName() + " does not accept rows and columns input"); + } + + setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); importer.initializePuzzle(rows, columns); puzzle.initializeView(); @@ -183,6 +212,45 @@ public void loadPuzzle(String game, int rows, int columns) throws RuntimeExcepti } } + public void loadPuzzle(String game, String[] statements) { + String qualifiedClassName = config.getPuzzleClassForName(game); + LOGGER.debug("Loading " + qualifiedClassName); + + try { + Class c = Class.forName(qualifiedClassName); + Constructor cons = c.getConstructor(); + Puzzle puzzle = (Puzzle) cons.newInstance(); + + PuzzleImporter importer = puzzle.getImporter(); + if (importer == null) { + LOGGER.error("Puzzle importer is null"); + throw new RuntimeException("Puzzle importer null"); + } + + // Theoretically, this exception should never be thrown, since LEGUP should not be + // allowing the user to give text input for a puzzle that doesn't support it + if (!importer.acceptsTextInput()) { + throw new IllegalArgumentException(puzzle.getName() + " does not accept text input"); + } + + setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle"); + importer.initializePuzzle(statements); + + puzzle.initializeView(); +// puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); + setPuzzleEditor(puzzle); + } + catch (IllegalArgumentException exception) { + throw new IllegalArgumentException(exception.getMessage()); + } + catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | + IllegalAccessException | InstantiationException e) { + LOGGER.error(e); + throw new RuntimeException("Puzzle creation error"); + } + + } + /** * Loads a puzzle file * diff --git a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java index c5f8f0831..a0f58a571 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java @@ -86,9 +86,17 @@ public void executeCommand() { } else { TreeTransitionView transitionView = (TreeTransitionView) firstSelectedView; - finalTreeElement = transitionView.getChildView().getTreeElement(); + if (transitionView.getChildView() != null) { + finalTreeElement = transitionView.getChildView().getTreeElement(); + } + else { + finalTreeElement = null; + } + } + + if (finalTreeElement != null) { + puzzle.notifyBoardListeners(listener -> listener.onTreeElementChanged(finalTreeElement)); } - puzzle.notifyBoardListeners(listener -> listener.onTreeElementChanged(finalTreeElement)); puzzle.notifyTreeListeners(listener -> listener.onTreeSelectionChanged(newSelection)); } diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index d25afa2cb..18614131b 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -204,12 +204,26 @@ public boolean isValidDimensions(int rows, int columns) { return rows > 0 && columns > 0; } + /** + * Checks if the given array of statements is valid text input for the given puzzle + * + * @param statements + * @return + */ + public boolean isValidTextInput(String[] statements) { + return statements.length > 0; + } + /** * Determines if the edu.rpi.legup.puzzle was solves correctly * * @return true if the board was solved correctly, false otherwise */ public boolean isPuzzleComplete() { + if (tree == null) { + return false; + } + boolean isComplete = tree.isValid(); if (isComplete) { for (TreeElement leaf : tree.getLeafTreeElements()) { diff --git a/src/main/java/edu/rpi/legup/model/PuzzleExporter.java b/src/main/java/edu/rpi/legup/model/PuzzleExporter.java index a2f662772..613d2ed1c 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleExporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleExporter.java @@ -29,6 +29,7 @@ public abstract class PuzzleExporter { /** * PuzzleExporter Constructor exports the puzzle object to a file + * * @param puzzle puzzle that is to be exported */ public PuzzleExporter(Puzzle puzzle) { diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index c2b5b37fc..327a92773 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -12,10 +12,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public abstract class PuzzleImporter { private static final Logger LOGGER = LogManager.getLogger(PuzzleImporter.class.getName()); @@ -24,12 +21,17 @@ public abstract class PuzzleImporter { /** * PuzzleImporter Constructor creates the puzzle object + * * @param puzzle puzzle that is imported */ public PuzzleImporter(Puzzle puzzle) { this.puzzle = puzzle; } + public abstract boolean acceptsRowsAndColumnsInput(); + + public abstract boolean acceptsTextInput(); + /** * Initializes an empty puzzle * @@ -46,6 +48,13 @@ public void initializePuzzle(int rows, int columns) throws RuntimeException { } } + public void initializePuzzle(String[] statements) throws InputMismatchException, IllegalArgumentException { + // Note: Error checking for the statements will be left up to the puzzles that support + // text input. For example, some puzzles may be okay with "blank" statements (Strings with + // length = 0) while others may not. + initializeBoard(statements); + } + /** * Initializes the puzzle attributes * @@ -116,6 +125,8 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { */ public abstract void initializeBoard(Node node) throws InvalidFileFormatException; + public abstract void initializeBoard(String[] statements) throws UnsupportedOperationException, IllegalArgumentException; + /** * Creates the proof for building * diff --git a/src/main/java/edu/rpi/legup/model/rules/DirectRule.java b/src/main/java/edu/rpi/legup/model/rules/DirectRule.java index 940bbe32f..4acc7573e 100644 --- a/src/main/java/edu/rpi/legup/model/rules/DirectRule.java +++ b/src/main/java/edu/rpi/legup/model/rules/DirectRule.java @@ -29,18 +29,12 @@ public DirectRule(String ruleID, String ruleName, String description, String ima */ public String checkRule(TreeTransition transition) { Board finalBoard = transition.getBoard(); - - if (!finalBoard.isModified()) { - return "State must be modified"; + if (transition.getParents().size() != 1 || + transition.getParents().get(0).getChildren().size() != 1) { + return "State must have only 1 parent and 1 child"; } else { - if (transition.getParents().size() != 1 || - transition.getParents().get(0).getChildren().size() != 1) { - return "State must have only 1 parent and 1 child"; - } - else { - return checkRuleRaw(transition); - } + return checkRuleRaw(transition); } } diff --git a/src/main/java/edu/rpi/legup/model/tree/Tree.java b/src/main/java/edu/rpi/legup/model/tree/Tree.java index 31ef92359..79c0bcece 100644 --- a/src/main/java/edu/rpi/legup/model/tree/Tree.java +++ b/src/main/java/edu/rpi/legup/model/tree/Tree.java @@ -101,6 +101,7 @@ public Set getLeafTreeElements() { /** * Gets a Set of TreeNodes that are leaf nodes from the sub tree rooted at the specified node + * * @param node node that is input * @return Set of TreeNodes that are leaf nodes from the sub tree */ diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipExporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipExporter.java index b954a1065..4205d0125 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class BattleshipExporter extends PuzzleExporter { @@ -18,7 +19,13 @@ public BattleshipExporter(Battleship battleShip) { */ @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - BattleshipBoard board = (BattleshipBoard) puzzle.getTree().getRootNode().getBoard(); + BattleshipBoard board; + if (puzzle.getTree() != null) { + board = (BattleshipBoard) puzzle.getTree().getRootNode().getBoard(); + } + else { + board = (BattleshipBoard) puzzle.getBoardView().getBoard(); + } org.w3c.dom.Element boardElement = newDocument.createElement("board"); boardElement.setAttribute("width", String.valueOf(board.getWidth())); diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java index aa7209f71..749ceaaa9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java @@ -13,6 +13,16 @@ public BattleshipImporter(Battleship battleShip) { super(battleShip); } + @Override + public boolean acceptsRowsAndColumnsInput() { + return true; + } + + @Override + public boolean acceptsTextInput() { + return false; + } + /** * Creates an empty board for building * @@ -177,4 +187,9 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { "unknown value where integer expected"); } } + + @Override + public void initializeBoard(String[] statements) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Battleship cannot accept text input"); + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java index f7dc9d375..757d14cd8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class FillapixExporter extends PuzzleExporter { @@ -12,7 +13,13 @@ public FillapixExporter(Fillapix fillapix) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - FillapixBoard board = (FillapixBoard) puzzle.getTree().getRootNode().getBoard(); + FillapixBoard board; + if (puzzle.getTree() != null) { + board = (FillapixBoard) puzzle.getTree().getRootNode().getBoard(); + } + else { + board = (FillapixBoard) puzzle.getBoardView().getBoard(); + } org.w3c.dom.Element boardElement = newDocument.createElement("board"); boardElement.setAttribute("width", String.valueOf(board.getWidth())); diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java index 45ad786e8..6c30b2272 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java @@ -13,6 +13,16 @@ public FillapixImporter(Fillapix fillapix) { super(fillapix); } + @Override + public boolean acceptsRowsAndColumnsInput() { + return true; + } + + @Override + public boolean acceptsTextInput() { + return false; + } + /** * Creates an empty board for building * @@ -88,4 +98,9 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { throw new InvalidFileFormatException("Fillapix Importer: unknown value where integer expected"); } } + + @Override + public void initializeBoard(String[] statements) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Fillapix cannot accept text input"); + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeExporter.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeExporter.java index a23273ab4..344a0be92 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class HeyawakeExporter extends PuzzleExporter { @@ -12,7 +13,13 @@ public HeyawakeExporter(Heyawake heyawake) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - HeyawakeBoard board = (HeyawakeBoard) puzzle.getTree().getRootNode().getBoard(); + HeyawakeBoard board; + if (puzzle.getTree() != null) { + board = (HeyawakeBoard) puzzle.getTree().getRootNode().getBoard(); + } + else { + board = (HeyawakeBoard) puzzle.getBoardView().getBoard(); + } org.w3c.dom.Element boardElement = newDocument.createElement("board"); boardElement.setAttribute("width", String.valueOf(board.getWidth())); diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java index d09a15389..7527c717f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java @@ -14,6 +14,16 @@ public HeyawakeImporter(Heyawake heyawake) { super(heyawake); } + @Override + public boolean acceptsRowsAndColumnsInput() { + return true; + } + + @Override + public boolean acceptsTextInput() { + return false; + } + /** * Creates an empty board for building * @@ -91,4 +101,9 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { throw new InvalidFileFormatException("Heyawake Importer: unknown value where integer expected"); } } + + @Override + public void initializeBoard(String[] statements) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Hey Awake cannot accept text input"); + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java index 3189eff7a..36e5a5088 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java @@ -1,8 +1,10 @@ package edu.rpi.legup.puzzle.lightup; +import edu.rpi.legup.model.elements.Element; import edu.rpi.legup.model.gameboard.GridCell; import java.awt.*; +import java.awt.event.MouseEvent; public class LightUpCell extends GridCell { private boolean isLite; @@ -12,6 +14,41 @@ public LightUpCell(int valueInt, Point location) { this.isLite = false; } + @Override + public void setType(Element e, MouseEvent m) { + switch (e.getElementID()) { + case "LTUP-PLAC-0001": + this.data = -4; + break; + case "LTUP-UNPL-0002": + this.data = -1; + break; + case "LTUP-UNPL-0003": + this.data = -2; + break; + case "LTUP-UNPL-0001": + switch (m.getButton()){ + case MouseEvent.BUTTON1: + if (this.data < 0 || this.data > 3) { + this.data = 0; + } + else { + this.data = this.data + 1; + } + break; + case MouseEvent.BUTTON3: + if (this.data > 0) { + this.data = this.data - 1; + } + else { + this.data = 4; + } + break; + } + break; + } + } + public LightUpCellType getType() { switch (data) { case -4: diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java index 78270e112..89024ad6c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class LightUpExporter extends PuzzleExporter { @@ -12,7 +13,13 @@ public LightUpExporter(LightUp lightUp) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - LightUpBoard board = (LightUpBoard) puzzle.getTree().getRootNode().getBoard(); + LightUpBoard board; + if (puzzle.getTree() != null) { + board = (LightUpBoard) puzzle.getTree().getRootNode().getBoard(); + } + else { + board = (LightUpBoard) puzzle.getBoardView().getBoard(); + } org.w3c.dom.Element boardElement = newDocument.createElement("board"); boardElement.setAttribute("width", String.valueOf(board.getWidth())); diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java index fd9fd49e9..7ef24ca69 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java @@ -13,6 +13,16 @@ public LightUpImporter(LightUp lightUp) { super(lightUp); } + @Override + public boolean acceptsRowsAndColumnsInput() { + return true; + } + + @Override + public boolean acceptsTextInput() { + return false; + } + /** * Creates an empty board for building * @@ -102,4 +112,9 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { throw new InvalidFileFormatException("lightup Importer: unknown value where integer expected"); } } + + @Override + public void initializeBoard(String[] statements) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Light Up cannot accept text input"); + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/elements/BlackTile.java b/src/main/java/edu/rpi/legup/puzzle/lightup/elements/BlackTile.java index b72ae1fab..d3e8cf506 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/elements/BlackTile.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/elements/BlackTile.java @@ -1,9 +1,9 @@ package edu.rpi.legup.puzzle.lightup.elements; -import edu.rpi.legup.model.elements.PlaceableElement; +import edu.rpi.legup.model.elements.NonPlaceableElement; -public class BlackTile extends PlaceableElement { +public class BlackTile extends NonPlaceableElement { public BlackTile() { - super("LTUP-PLAC-0002", "Black Tile", "The black tile", "edu/rpi/legup/images/lightup/black.gif"); + super("LTUP-UNPL-0002", "Black Tile", "The black tile", "edu/rpi/legup/images/lightup/black.gif"); } } diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/elements/UnknownTile.java b/src/main/java/edu/rpi/legup/puzzle/lightup/elements/UnknownTile.java new file mode 100644 index 000000000..6839e70de --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/elements/UnknownTile.java @@ -0,0 +1,9 @@ +package edu.rpi.legup.puzzle.lightup.elements; + +import edu.rpi.legup.model.elements.NonPlaceableElement; + +public class UnknownTile extends NonPlaceableElement { + public UnknownTile() { + super("LTUP-UNPL-0003", "Unknown Tile", "A blank tile", "edu/rpi/legup/images/lightup/UnknownTile.png"); + } +} diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuExporter.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuExporter.java index 471be22f1..e5fb071b4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class MasyuExporter extends PuzzleExporter { @@ -12,7 +13,13 @@ public MasyuExporter(Masyu masyu) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - MasyuBoard board = (MasyuBoard) puzzle.getTree().getRootNode().getBoard(); + MasyuBoard board; + if (puzzle.getTree() != null) { + board = (MasyuBoard) puzzle.getTree().getRootNode().getBoard(); + } + else { + board = (MasyuBoard) puzzle.getBoardView().getBoard(); + } org.w3c.dom.Element boardElement = newDocument.createElement("board"); boardElement.setAttribute("width", String.valueOf(board.getWidth())); diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java index 50bf0c0c7..3e0d328c4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java @@ -13,6 +13,16 @@ public MasyuImporter(Masyu masyu) { super(masyu); } + @Override + public boolean acceptsRowsAndColumnsInput() { + return true; + } + + @Override + public boolean acceptsTextInput() { + return false; + } + /** * Creates an empty board for building * @@ -90,4 +100,9 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { throw new InvalidFileFormatException("Masyu Importer: unknown value where integer expected"); } } + + @Override + public void initializeBoard(String[] statements) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Masyu cannot accept text input"); + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java index 7665a4865..2cbcc9ad0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java @@ -13,6 +13,16 @@ public NurikabeImporter(Nurikabe nurikabe) { super(nurikabe); } + @Override + public boolean acceptsRowsAndColumnsInput() { + return true; + } + + @Override + public boolean acceptsTextInput() { + return false; + } + /** * Creates an empty board for building * @@ -100,4 +110,9 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { throw new InvalidFileFormatException("nurikabe Importer: unknown value where integer expected"); } } + + @Override + public void initializeBoard(String[] statements) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Nurikabe cannot accept text input"); + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeUtilities.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeUtilities.java index 34278ff9f..024cf6bb2 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeUtilities.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeUtilities.java @@ -241,4 +241,67 @@ public static HashMap getWhiteRegionMap(NurikabeBoard boa } return whiteRegionMap; } + + /** + * Gets all the non-black cells connected to the given cell + * + * @param board nurikabe board + * @param center nurikabe cell + * @return a set of all white/numbered cells in the region + */ + public static Set getSurroundedRegionOf(NurikabeBoard board, NurikabeCell center) { + int width = board.getWidth(); + int height = board.getHeight(); + + // Mark all the vertices as not visited(By default + // set as false) + Set visited = new HashSet<>(); + + // Create a queue for BFS + LinkedList queue = new LinkedList<>(); + + // Mark the current node as visited and enqueue it + visited.add(center); + queue.add(center); + + // Set of cells in the current region + Set connected = new HashSet<>(); + + while (queue.size() != 0) { + // Dequeue a vertex from queue and print it + // s is the source node in the graph + NurikabeCell s = queue.poll(); + System.out.print(s + " "); + + // Make a set of all adjacent squares + Set adj = new HashSet<>(); + + Point loc = s.getLocation(); + // First check if the side is on the board + if (loc.x >= 1) { + adj.add(board.getCell(loc.x - 1, loc.y)); + } + if (loc.x < width - 1) { + adj.add(board.getCell(loc.x + 1, loc.y)); + } + if (loc.y >= 1) { + adj.add(board.getCell(loc.x, loc.y - 1)); + } + if (loc.y < height - 1) { + adj.add(board.getCell(loc.x, loc.y + 1)); + } + // Get all adjacent vertices of the dequeued vertex s + // If a adjacent has not been visited, then mark it + // visited and enqueue it + for (NurikabeCell n : adj) { + if (!visited.contains(n) && n.getType() != NurikabeType.BLACK) { + connected.add(n); + visited.add(n); + queue.add(n); + } + } + } + + return connected; + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/NoNumberContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/NoNumberContradictionRule.java index 06eb9d2eb..c2752da7a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/NoNumberContradictionRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/NoNumberContradictionRule.java @@ -42,20 +42,18 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { return super.getInvalidUseOfRuleMessage() + ": " + this.INVALID_USE_MESSAGE; } -// If the transition creates a room of white cells with no number, a contradiction occurs. - DisjointSets anotherRegion = NurikabeUtilities.getPossibleWhiteRegions(nurikabeBoard); - List> allsets = anotherRegion.getAllSets(); - for (Set s : allsets) { - boolean numberExists = false; - for (NurikabeCell c : s) { - if (c.getType() == NurikabeType.NUMBER) { - numberExists = true; - } - } - if (!numberExists) { - return null; + Set region = NurikabeUtilities.getSurroundedRegionOf(nurikabeBoard, cell); + + boolean numberExists = false; + for (NurikabeCell c : region) { + if (c.getType() == NurikabeType.NUMBER) { + numberExists = true; + break; } } + if (!numberExists) { + return null; + } return super.getNoContradictionMessage() + ": " + this.NO_CONTRADICTION_MESSAGE; } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java index 3ce185b6c..e8f9ffc0d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java @@ -25,6 +25,7 @@ public ShortTruthTable() { public void initializeView() { ShortTruthTableBoard sttBoard = (ShortTruthTableBoard) currentBoard; boardView = new ShortTruthTableView(sttBoard); + boardView.setBoard(currentBoard); addBoardListener(boardView); } @@ -48,8 +49,32 @@ public Board generatePuzzle(int difficulty) { * @return true if the given dimensions are valid for Short Truth Table, false otherwise */ public boolean isValidDimensions(int rows, int columns) { - // This is a placeholder, this method needs to be implemented - throw new UnsupportedOperationException(); + // Number of rows must be odd to allow for proper spacing between the statements + if (rows % 2 != 1) { + return false; + } + + return true; + } + + /** + * Determines if the given statements are valid for Short Truth Table + * + * @param statements + * @return true if the statements are valid for Short Truth Table, false otherwise + */ + public boolean isValidTextInput(String[] statements) { + if (statements.length == 0) { + return false; + } + + ShortTruthTableImporter importer = (ShortTruthTableImporter) this.getImporter(); + for (String s : statements) { + if (!importer.validGrammar(s)) { + return false; + } + } + return true; } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java index 768b4ed2a..59b5f4272 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCell.java @@ -1,15 +1,17 @@ package edu.rpi.legup.puzzle.shorttruthtable; +import edu.rpi.legup.model.elements.Element; import edu.rpi.legup.model.gameboard.GridCell; import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableStatement; import java.awt.Point; +import java.awt.event.MouseEvent; public class ShortTruthTableCell extends GridCell { //The symbol on the cell - private final char symbol; + private char symbol; //This is a reference to the statement that contains this cell private ShortTruthTableStatement statement; @@ -127,5 +129,104 @@ public ShortTruthTableCell copy() { return copy; } + /** + * Sets the type of this ShortTruthTableCell + * + * @param e element to set the type of this Short Truth Table cell to + */ + @Override + public void setType(Element e, MouseEvent m) { + // Do not allow odd rows to be modified since they are spacer rows + if (this.getLocation().getY() % 2 == 1) { + return; + } + // Red Element + if (e.getElementID().equals("STTT-PLAC-0002")) { + this.data = ShortTruthTableCellType.FALSE; + } + // Green Element + else { + if (e.getElementID().equals("STTT-PLAC-0001")) { + this.data = ShortTruthTableCellType.TRUE; + } + // Unknown Element + else { + if (e.getElementID().equals("STTT-PLAC-0003")) { + this.data = ShortTruthTableCellType.UNKNOWN; + } + // Argument Element + else { + if (e.getElementID().equals("STTT-UNPL-0001")) { + // Prevents non-argument symbols from being changed + if (!(this.symbol >= 'A' && this.symbol <= 'Z')) { + return; + } + + if (m.getButton() == MouseEvent.BUTTON1) { + this.symbol += 1; + if (this.symbol > 'Z') { + this.symbol = 'A'; + } + } + else { + if (m.getButton() == MouseEvent.BUTTON3) { + this.symbol -= 1; + if (this.symbol < 'A') { + this.symbol = 'Z'; + } + } + } + } + // And/Or Element + else { + if (e.getElementID().equals("STTT-UNPL-0002")) { + if (m.getButton() == MouseEvent.BUTTON1) { + if (this.symbol == '^') { + this.symbol = '|'; + } + else { + if (this.symbol == '|') { + this.symbol = '>'; + } + else { + if (this.symbol == '>') { + this.symbol = '-'; + } + else { + if (this.symbol == '-') { + this.symbol = '^'; + } + } + } + } + } + else { + if (m.getButton() == MouseEvent.BUTTON3) { + if (this.symbol == '^') { + this.symbol = '-'; + } + else { + if (this.symbol == '|') { + this.symbol = '^'; + } + else { + if (this.symbol == '>') { + this.symbol = '|'; + } + else { + if (this.symbol == '-') { + this.symbol = '>'; + } + } + } + } + } + } + } + } + } + } + } + } } \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java index c01fe74d8..c997faf5f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellType.java @@ -26,6 +26,7 @@ public static ShortTruthTableCellType valueOf(int cellType) { /** * Gets the char value of a cell, Used for debugging + * * @param type cell type input * @return true if value is 1, false if value is 0, ? if value is -1, or blank otherwise */ diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java index ccf4e9274..bddde44a5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableController.java @@ -12,7 +12,7 @@ public void changeCell(MouseEvent e, PuzzleElement data) { System.out.println("STTController: Cell change"); - //cast the data to a short truth table cell + // cast the data to a short truth table cell ShortTruthTableCell cell = (ShortTruthTableCell) data; if (e.getButton() == MouseEvent.BUTTON1) { diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java index bcb744789..9d6553c7c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard; import org.w3c.dom.Document; public class ShortTruthTableExporter extends PuzzleExporter { @@ -12,7 +13,13 @@ public ShortTruthTableExporter(ShortTruthTable stt) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - ShortTruthTableBoard board = (ShortTruthTableBoard) puzzle.getTree().getRootNode().getBoard(); + ShortTruthTableBoard board; + if (puzzle.getTree() != null) { + board = (ShortTruthTableBoard) puzzle.getTree().getRootNode().getBoard(); + } + else { + board = (ShortTruthTableBoard) puzzle.getBoardView().getBoard(); + } org.w3c.dom.Element boardElement = newDocument.createElement("board"); diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java index cccdbca19..84d04fb45 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java @@ -3,16 +3,15 @@ import edu.rpi.legup.model.PuzzleImporter; import edu.rpi.legup.save.InvalidFileFormatException; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.w3c.dom.NamedNodeMap; +import javax.swing.*; import java.awt.*; - -import java.util.List; import java.util.ArrayList; - -import javax.swing.*; +import java.util.LinkedList; +import java.util.List; class ShortTruthTableImporter extends PuzzleImporter { @@ -55,8 +54,8 @@ private List getCells(String statement, int y) { * @return the length, in chars, of the longest statement */ private int parseAllStatementsAndCells(final NodeList statementData, - List> allCells, - List statements) throws InvalidFileFormatException { + List> allCells, + List statements) throws InvalidFileFormatException { int maxStatementLength = 0; @@ -65,7 +64,10 @@ private int parseAllStatementsAndCells(final NodeList statementData, //Get the atributes from the statement i in the file NamedNodeMap attributeList = statementData.item(i).getAttributes(); + String statementRep = attributeList.getNamedItem("representation").getNodeValue(); + System.out.println("STATEMENT REP: " + statementRep); + System.out.println("ROW INDEX: " + attributeList.getNamedItem("row_index").getNodeValue()); //parser time (on statementRep) //if (!validGrammar(statementRep)) throw some error if (!validGrammar(statementRep)) { @@ -85,10 +87,32 @@ private int parseAllStatementsAndCells(final NodeList statementData, } return maxStatementLength; + } + + private int parseAllStatementsAndCells(String[] statementData, + List> allCells, + List statements) throws IllegalArgumentException { + int maxStatementLength = 0; + + for (int i = 0; i < statementData.length; i++) { + if (!validGrammar(statementData[i])) { + JOptionPane.showMessageDialog(null, "ERROR: Invalid file syntax"); + throw new IllegalArgumentException("shorttruthtable importer: invalid sentence syntax"); + } + + //get the cells for the statement + List rowOfCells = getCells(statementData[i], i * 2); + allCells.add(rowOfCells); + statements.add(new ShortTruthTableStatement(statementData[i], rowOfCells)); + + //keep track of the length of the longest statement + maxStatementLength = Math.max(maxStatementLength, statementData[i].length()); + } + return maxStatementLength; } - private boolean validGrammar(String sentence) { + protected boolean validGrammar(String sentence) { int open = 0; int close = 0; char[] valid_characters = new char[]{'^', 'v', '!', '>', '-', '&', '|', '~', '$', '%'}; @@ -217,6 +241,16 @@ private void setGivenCells(ShortTruthTableBoard sttBoard, } + @Override + public boolean acceptsRowsAndColumnsInput() { + return false; + } + + @Override + public boolean acceptsTextInput() { + return true; + } + /** * Creates an empty board for building * @@ -278,9 +312,37 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { catch (NumberFormatException e) { throw new InvalidFileFormatException("short truth table Importer: unknown value where integer expected"); } + } + /** + * Creates the board for building using statements + * + * @param statementInput + * @throws UnsupportedOperationException + * @throws IllegalArgumentException + */ + public void initializeBoard(String[] statementInput) throws UnsupportedOperationException, IllegalArgumentException { + List statementsList = new LinkedList<>(); + for (String s : statementInput) { + if (s.strip().length() > 0) { + statementsList.add(s); + } + } + String[] statementData = statementsList.toArray(new String[statementsList.size()]); - } + if (statementData.length == 0) { + throw new IllegalArgumentException("short truth table Importer: no statements found for board"); + } + // Store all cells and statements + List> allCells = new ArrayList<>(); + List statements = new ArrayList<>(); + // Parse the data + int maxStatementLength = parseAllStatementsAndCells(statementData, allCells, statements); + + // Generate and set the board - don't set given cell values since none are given + ShortTruthTableBoard sttBoard = generateBoard(allCells, statements, maxStatementLength); + puzzle.setCurrentBoard(sttBoard); + } } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/ArgumentElement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/ArgumentElement.java new file mode 100644 index 000000000..9f238a9bf --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/ArgumentElement.java @@ -0,0 +1,9 @@ +package edu.rpi.legup.puzzle.shorttruthtable.elements; + +import edu.rpi.legup.model.elements.NonPlaceableElement; + +public class ArgumentElement extends NonPlaceableElement { + public ArgumentElement() { + super("STTT-UNPL-0001", "Argument Element", "Argument of logic statement element", "edu/rpi/legup/images/shorttruthtable/tiles/LetterTile.png"); + } +} diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/GreenElement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/GreenElement.java new file mode 100644 index 000000000..605f6a207 --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/GreenElement.java @@ -0,0 +1,9 @@ +package edu.rpi.legup.puzzle.shorttruthtable.elements; + +import edu.rpi.legup.model.elements.PlaceableElement; + +public class GreenElement extends PlaceableElement { + public GreenElement() { + super("STTT-PLAC-0001", "Green Element", "A green tile to set certain tiles to true", "edu/rpi/legup/images/shorttruthtable/tiles/GreenTile.png"); + } +} diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/LogicSymbolElement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/LogicSymbolElement.java new file mode 100644 index 000000000..b2adfddef --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/LogicSymbolElement.java @@ -0,0 +1,9 @@ +package edu.rpi.legup.puzzle.shorttruthtable.elements; + +import edu.rpi.legup.model.elements.NonPlaceableElement; + +public class LogicSymbolElement extends NonPlaceableElement { + public LogicSymbolElement() { + super("STTT-UNPL-0002", "Logic Symbol Element", "Logic symbol element", "edu/rpi/legup/images/shorttruthtable/tiles/ConditionalBiconditionalTile.png"); + } +} diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/RedElement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/RedElement.java new file mode 100644 index 000000000..ecc7d5a02 --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/RedElement.java @@ -0,0 +1,9 @@ +package edu.rpi.legup.puzzle.shorttruthtable.elements; + +import edu.rpi.legup.model.elements.PlaceableElement; + +public class RedElement extends PlaceableElement { + public RedElement() { + super("STTT-PLAC-0002", "Red Element", "A red tile to set certain tiles to false", "edu/rpi/legup/images/shorttruthtable/tiles/RedTile.png"); + } +} diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/UnknownElement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/UnknownElement.java new file mode 100644 index 000000000..9a9ab8b84 --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/UnknownElement.java @@ -0,0 +1,9 @@ +package edu.rpi.legup.puzzle.shorttruthtable.elements; + +import edu.rpi.legup.model.elements.PlaceableElement; + +public class UnknownElement extends PlaceableElement { + public UnknownElement() { + super("STTT-PLAC-0003", "Unknown Element", "A blank tile", "edu/rpi/legup/images/shorttruthtable/tiles/UnknownTile.png"); + } +} diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/shorttruthtable_elements_reference_sheet b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/shorttruthtable_elements_reference_sheet new file mode 100644 index 000000000..471631553 --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/elements/shorttruthtable_elements_reference_sheet @@ -0,0 +1,6 @@ +STTT-UNPL-0001 : ArgumentElement +STTT-UNPL-0002 : ConditionalBiconditionalElement + +STTT-PLAC-0001 : GreenElement +STTT-PLAC-0002 : RedElement +STTT-PLAC-0003 : UnknownElement \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/shorttruthtable_reference_sheet.txt b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/shorttruthtable_rules_reference_sheet.txt similarity index 100% rename from src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/shorttruthtable_reference_sheet.txt rename to src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/shorttruthtable_rules_reference_sheet.txt diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java index d276c8bff..da6899f75 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java @@ -35,7 +35,7 @@ public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormat if (x >= width || y >= height) { throw new InvalidFileFormatException("TreeTent Factory: cell location out of bounds"); } - if (value < 0 || value > 3) { + if (value < 0 || value > width) { throw new InvalidFileFormatException("TreeTent Factory: cell unknown value"); } diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersExporter.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersExporter.java index dac09bd16..155a1466c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class SkyscrapersExporter extends PuzzleExporter { @@ -12,11 +13,16 @@ public SkyscrapersExporter(Skyscrapers skyscrapers) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { - SkyscrapersBoard board = (SkyscrapersBoard) puzzle.getTree().getRootNode().getBoard(); + SkyscrapersBoard board; + if (puzzle.getTree() != null) { + board = (SkyscrapersBoard) puzzle.getTree().getRootNode().getBoard(); + } + else { + board = (SkyscrapersBoard) puzzle.getBoardView().getBoard(); + } org.w3c.dom.Element boardElement = newDocument.createElement("board"); - boardElement.setAttribute("width", String.valueOf(board.getWidth())); - boardElement.setAttribute("height", String.valueOf(board.getHeight())); + boardElement.setAttribute("size", String.valueOf(board.getWidth())); org.w3c.dom.Element cellsElement = newDocument.createElement("cells"); for (PuzzleElement puzzleElement : board.getPuzzleElements()) { @@ -30,20 +36,20 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { org.w3c.dom.Element axisEast = newDocument.createElement("axis"); axisEast.setAttribute("side", "east"); - for (SkyscrapersClue clue : board.getEastClues()) { + for (int i=0; i { - JOptionPane.showMessageDialog(null, "Version: 2.0.0"); + JOptionPane.showMessageDialog(null, "Version: 5.1.0"); }); about.add(helpLegup); diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index cce4feec5..2c4f37c85 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -64,6 +64,7 @@ public PuzzleEditorPanel(FileDialog fileDialog, JFrame frame, LegupUI legupUI) { this.frame = frame; this.legupUI = legupUI; setLayout(new BorderLayout()); + setPreferredSize(new Dimension(800, 700)); } protected void setupContent() { @@ -202,7 +203,7 @@ public void actionPerformed(ActionEvent e) { }); menus[2].add(aboutLegup); aboutLegup.addActionListener(l -> { - JOptionPane.showMessageDialog(null, "Version: 2.0.0"); + JOptionPane.showMessageDialog(null, "Version: 5.1.0"); }); // add menus to menubar for (JMenu menu : menus) { @@ -327,6 +328,20 @@ public void loadPuzzleFromHome(String game, int rows, int columns) throws Illega } } + public void loadPuzzleFromHome(String game, String[] statements) { + GameBoardFacade facade = GameBoardFacade.getInstance(); + try { + facade.loadPuzzle(game, statements); + } + catch (IllegalArgumentException exception) { + throw new IllegalArgumentException(exception.getMessage()); + } + catch (RuntimeException e) { + e.printStackTrace(); + LOGGER.error(e.getMessage()); + } + } + // File opener public Object[] promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java index a2d37e800..0fe03d476 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RuleFrame.java @@ -70,7 +70,7 @@ protected boolean shouldRotateTabRuns(int i) { setLayout(new BorderLayout()); setMinimumSize(new Dimension(250, 256)); - setPreferredSize(new Dimension(330, 256)); + setPreferredSize(new Dimension(355, 256)); add(tabbedPane); add(status, BorderLayout.SOUTH); diff --git a/src/main/resources/edu/rpi/legup/images/lightup/UnknownTile.png b/src/main/resources/edu/rpi/legup/images/lightup/UnknownTile.png new file mode 100644 index 0000000000000000000000000000000000000000..850fbf127f04020fe83c6a4f6db75078967916ea GIT bin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#LJ%6Te;mi-oLC3cPB$mf+ysKbFOm!UQw|S9AVn*4vW&e?0vt0$|4gaBt8YOuawub>;H`|p?{7$BpUDwhz%TOP=6Tg{XaVG zrZMZC_VrHtdZ&H8)4twmU+=W9ciPuG?dzTP^-lY5opvR*bO6v!=kwTSf&;CrzOyT@ zBmxpaKT}602qe6D_2L4hWyk_TewLY~5&tm1w1f(eU_#WU)keG-ZjYTq?PM2R90U`o zHORBK8rF|IC|nzhtEmnOH7OP@Do>u?vF)j#7}y{b#Kp}c@Z;u1)ri6_TVDOep)ugE QTOg2`(SBUvUiYy70dQO53jhEB literal 0 HcmV?d00001 diff --git a/src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/AndOrTile.png b/src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/AndOrTile.png new file mode 100644 index 0000000000000000000000000000000000000000..9ea93250297e9bc46769cc2b1df83fa1fdfdf6a6 GIT binary patch literal 442 zcmV;r0Y(0aP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc0Z&OpK~z{r?UFyL zgFq0*CD_J*h2#J^frXyIM#L_cNMRQc3ojrZKu8@@`L9U8KUH$8d9Gxa>^dfS%@ZCQ z_`%Hg&CYyal;H;pqrl_wSOghB29N<{fd3hwC<;`kbX~{luLAhK57+Az^)Pf@hcFCL z&ooU4f`Ij31$Yjj-W+rDqW;`HzdT72ux%Sws}<@~qA23}&1M7V^O@5QhXZ(?$7vq} zP%qDO*lxEIpJEsW*SBrU-cqnTL>s^ZkfWNWv3_ojKn{wUs;Y3m-^V)3GT7~QlbN>x zL_LmUuq=zy2*=}bq7llng!Oto*6(hh0dBV&`Uum=KU>r&Wd3rwpzo+ZfFB~CK-3+_ zf&G5ZX-(5`{VS)_Y24NKJ?g&=AZnCXFHKX!lvI6;>1s;*b3=G^tAk28_ZrvZC;B8MA$B+p3w|yHqTMa~9buXnba%+p9;P6XK zpRK1Hv2=REV-~#!Oie3T?r8m&Hu%%-sLFNdIV<0jd(*}JzSurXRobj`T6+Nl7ZClK z?ht$Z-oK9HENzJ&zNOo!2^`HpV$-uM2lEXSG8IlI&#iZ{%*^CduID~M-Ia|#lP#+3s{dyoCpnV z+%rk#zopr0F1hR+W-In literal 0 HcmV?d00001 diff --git a/src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/GreenTile.png b/src/main/resources/edu/rpi/legup/images/shorttruthtable/tiles/GreenTile.png new file mode 100644 index 0000000000000000000000000000000000000000..a438e30375f0598657b2a7e3873d3d03655a5b31 GIT binary patch literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=G^tAk28_ZrvZCV6dl)V@QPi(G!M@K;u{zuFosdJy64^lau~k lJFPP^Y1#}`(x|jD`L~l9qAz|@;AI@Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc0oX}IK~z{r?Ug;R z0YMaoNk|Bh=twmD0+lETg-S%JRZ?itXb_cxMARw;AsUIoM|_5Vb?!YUcQ?zPowd97 z#w}LzL^9`{vrl$*W*px?_%IH5JRTpx7O(|=MPRjBvE%RXD+1AI6o$hgThqg`z+f<- zCh2sVt?OY~ARdoX6Q9oqhr@x*h_EEE-|rz941(9|rAFm)nazo?Bv2?6pi-$oE|;T5 zkw}Eii7+j2yWJoV2*7+khtX(6jhs#=Y&IJ-Y@ zxL&W|_xoWonaE?cT8)~y-EP?Jc29W`rUa(bDY#rNIG@k**mAj)nnAnWe#(n5C6LeO zq0wll##5=3EOEJ9RCNx+0(k7=Ywq{^DsV?g0?OqPVOXHqY|{E?G8q<0pj0Zc^ItI} zfL}X4Ty*(Vt5s@>Z|R*aX-J^c>Cn;3)g-8GK;V^|4iv^rcCpL>5k4LE2 z>#_h|R!lvI6;>1s;*b3=G_YAk0{w5C;92(%$B$j*UfgJ*;N7<4klmjq@7`jNmS4uuQ?ae8jr zQ%Yu)MZVp#9TY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zHORBK8rF|IC|nzhtEmnOH7OP@Do>u?vF)j#7}y{b#Kp}c@Z;u1)ri6_TVDOep)ugE QTOg2`(SBUvUiYy70dQO53jhEB literal 0 HcmV?d00001 diff --git a/src/main/resources/edu/rpi/legup/legup/config b/src/main/resources/edu/rpi/legup/legup/config index bb7da871a..24fdcf365 100644 --- a/src/main/resources/edu/rpi/legup/legup/config +++ b/src/main/resources/edu/rpi/legup/legup/config @@ -27,7 +27,7 @@ + fileCreationDisabled="false"/> diff --git a/src/test/java/legup/TestRunner.java b/src/test/java/legup/TestRunner.java index 7e2dbe737..9d79c590e 100644 --- a/src/test/java/legup/TestRunner.java +++ b/src/test/java/legup/TestRunner.java @@ -9,6 +9,9 @@ import puzzles.nurikabe.rules.*; import puzzles.treetent.rules.*; +/** + * This class runs all of the tests for the project without needing to run build scripts. + */ public class TestRunner { public static void main(String[] args) { // Battleship Tests @@ -103,6 +106,4 @@ private static void printTestResults(Result result) { System.out.println("All tests passed: " + result.wasSuccessful()); System.out.println(); } - - -} \ No newline at end of file +} diff --git a/src/test/java/legup/TestUtilities.java b/src/test/java/legup/TestUtilities.java index d49529921..9f203b223 100644 --- a/src/test/java/legup/TestUtilities.java +++ b/src/test/java/legup/TestUtilities.java @@ -6,11 +6,6 @@ import edu.rpi.legup.model.tree.TreeNode; import edu.rpi.legup.model.tree.TreeTransition; import edu.rpi.legup.save.InvalidFileFormatException; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; -import puzzles.battleship.rules.AdjacentShipsContradictionRuleTest; -import puzzles.battleship.rules.FinishWithShipsDirectRuleTests; public final class TestUtilities { public static void importTestBoard(String fileName, Puzzle puzzle) throws InvalidFileFormatException { @@ -21,8 +16,4 @@ public static void importTestBoard(String fileName, Puzzle puzzle) throws Invali TreeTransition transition = new TreeTransition(rootNode, board); rootNode.getChildren().add(transition); } - - } - - From c8bd17e9871405ff986063856393c10be5993766 Mon Sep 17 00:00:00 2001 From: Rorymar <36866664+Rorymar@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:33:50 -0400 Subject: [PATCH 07/11] Added NoTentForTree Tests Added NoTentForTree Tests involving more complex instances for the contradiction to consider. --- .../NoTentForTreeContradictionRuleTest.java | 66 ++++++++++++++++++- .../NoTentForTreeDiagonal | 21 ++++++ .../NoTentForTreeTwoTrees | 21 ++++++ .../NoTentForTreeTwoTreesDiagonal | 21 ++++++ 4 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeDiagonal create mode 100644 src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTrees create mode 100644 src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTreesDiagonal diff --git a/src/test/java/puzzles/treetent/rules/NoTentForTreeContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/NoTentForTreeContradictionRuleTest.java index b2d47e222..52aea28c0 100644 --- a/src/test/java/puzzles/treetent/rules/NoTentForTreeContradictionRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/NoTentForTreeContradictionRuleTest.java @@ -28,8 +28,12 @@ public static void setUp() { treetent = new TreeTent(); } + /** + * @throws InvalidFileFormatException + * Tests if a tree is next to only grass in a 2x2 grid triggers the contradiction + */ @Test - public void NoTentForTreeContradictionRule_() throws InvalidFileFormatException { + public void NoTentForTreeContradictionRule_Basic() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTree", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); @@ -43,5 +47,65 @@ public void NoTentForTreeContradictionRule_() throws InvalidFileFormatException Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); } + + /** + * @throws InvalidFileFormatException + * Tests similarly to above, but now with a tent diagonally next to the tree, which should still contradict + */ + @Test + public void NoTentForTreeContradictionRule_Diagonal() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeDiagonal", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + + /** + * @throws InvalidFileFormatException + * Tests that adjacent trees do not allow a pass + */ + @Test + public void NoTentForTreeContradictionRule_TwoTrees() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTrees", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } + + /** + * @throws InvalidFileFormatException + * Tests similarly to above, but now with a tent diagonally next to two trees, which should still contradict on one. + */ + @Test + public void NoTentForTreeContradictionRule_TwoTreesDiagonal() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTreesDiagonal", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(1, 1))); + } } diff --git a/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeDiagonal b/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeDiagonal new file mode 100644 index 000000000..af0b49e31 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeDiagonal @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTrees b/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTrees new file mode 100644 index 000000000..5111e0585 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTrees @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTreesDiagonal b/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTreesDiagonal new file mode 100644 index 000000000..10391b85c --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/NoTentForTreeContradictionRule/NoTentForTreeTwoTreesDiagonal @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 7eddb36d60b65cff9ed0ff93bb6392060c9c4c5f Mon Sep 17 00:00:00 2001 From: Rorymar <36866664+Rorymar@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:09:13 -0400 Subject: [PATCH 08/11] Added SurroundTent Tests Added tests for the SurroundTestWithGrass direct rule --- .../SurroundTentWithGrassDirectRuleTest.java | 88 +++++++++++++++++++ .../SurroundTentWithGrassBad | 20 +++++ .../SurroundTentWithGrassTrees | 28 ++++++ 3 files changed, 136 insertions(+) create mode 100644 src/test/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassBad create mode 100644 src/test/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassTrees diff --git a/src/test/java/puzzles/treetent/rules/SurroundTentWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/SurroundTentWithGrassDirectRuleTest.java index 14afb4dc0..999405747 100644 --- a/src/test/java/puzzles/treetent/rules/SurroundTentWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/SurroundTentWithGrassDirectRuleTest.java @@ -27,6 +27,10 @@ public static void setUp() { treetent = new TreeTent(); } + /** + * @throws InvalidFileFormatException + * Test to check if all adjacent and diagonals not filled with a tree are filled with grass + */ @Test public void SurroundTentWithGrassBasicRuleTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrass", treetent); @@ -58,6 +62,90 @@ public void SurroundTentWithGrassBasicRuleTest() throws InvalidFileFormatExcepti } } } + + /** + * @throws InvalidFileFormatException + * + * Test with a 3x3 board with an absolutely empty area aside from a tent in the middle + * While such a situation is an illegal treetent setup, this direct rule doesn't consider that aspect, so its ok in this context + */ + @Test + public void SurroundTentWithGrassBasicRuleTest_BadBoard() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassBad", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + TreeTentCell cell1 = board.getCell(0, 0); + cell1.setData(TreeTentType.GRASS); + TreeTentCell cell2 = board.getCell(1, 0); + cell2.setData(TreeTentType.GRASS); + TreeTentCell cell3 = board.getCell(2, 0); + cell3.setData(TreeTentType.GRASS); + TreeTentCell cell4 = board.getCell(0, 1); + cell4.setData(TreeTentType.GRASS); + //Skip (1,1) due to being the Tent + TreeTentCell cell5 = board.getCell(2, 1); + cell5.setData(TreeTentType.GRASS); + TreeTentCell cell6 = board.getCell(0, 2); + cell6.setData(TreeTentType.GRASS); + TreeTentCell cell7 = board.getCell(1, 2); + cell7.setData(TreeTentType.GRASS); + TreeTentCell cell8 = board.getCell(2, 2); + cell8.setData(TreeTentType.GRASS); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + //board.addModifiedData(cell4); + board.addModifiedData(cell5); + board.addModifiedData(cell6); + board.addModifiedData(cell7); + board.addModifiedData(cell8); + + 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()) || //point.equals(cell4.getLocation()) || + point.equals(cell5.getLocation()) || point.equals(cell6.getLocation()) || + point.equals(cell7.getLocation()) || point.equals(cell8.getLocation()) + ) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } + } + + /** + * @throws InvalidFileFormatException + * + * Test to see if the rule passes even if no grass was able to be placed due to the presence of trees. + */ + @Test + public void SurroundTentWithGrassBasicRuleTest_FullBoard() throws InvalidFileFormatException{ + TestUtilities.importTestBoard("puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassTrees", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + Assert.assertNull(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/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassBad b/src/test/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassBad new file mode 100644 index 000000000..6065d42cd --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassBad @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassTrees b/src/test/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassTrees new file mode 100644 index 000000000..e8fef64dc --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/SurroundTentWithGrassDirectRule/SurroundTentWithGrassTrees @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 6986a3d8379055f04a118cc688ae63de68882ab8 Mon Sep 17 00:00:00 2001 From: Charles Tian <46334090+charlestian23@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:35:32 -0400 Subject: [PATCH 09/11] Atomic Direct Rule Test (#651) * Initial setup * Working initial test * Added another test * Added more tests * Added another test * Added comments, removed useless imports, added 1 more test * Reformatting * Removed useless import --------- Co-authored-by: Ivan Ho <41582274+Corppet@users.noreply.github.com> --- .../rules/AtomicDirectRuleTest.java | 188 ++++++++++++++++++ .../rules/DirectRuleAtomicTest.java | 6 - .../rules/AtomicDirectRule/Empty | 13 ++ .../rules/AtomicDirectRule/FalseA | 14 ++ .../rules/AtomicDirectRule/TrueB | 14 ++ 5 files changed, 229 insertions(+), 6 deletions(-) create mode 100644 src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java delete mode 100644 src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA create mode 100644 src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB diff --git a/src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java b/src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java new file mode 100644 index 000000000..51aa213c6 --- /dev/null +++ b/src/test/java/puzzles/shorttruthtable/rules/AtomicDirectRuleTest.java @@ -0,0 +1,188 @@ +package puzzles.shorttruthtable.rules; + +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTable; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCell; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType; +import edu.rpi.legup.puzzle.shorttruthtable.rules.basic.DirectRuleAtomic; +import edu.rpi.legup.save.InvalidFileFormatException; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class AtomicDirectRuleTest { + private static final DirectRuleAtomic RULE = new DirectRuleAtomic(); + private static ShortTruthTable stt; + + @BeforeClass + public static void setup() { + MockGameBoardFacade.getInstance(); + stt = new ShortTruthTable(); + } + + /** + * Given two statements: + * A + * A + * where the first A is set to false. + * + * This test sets the second A to false and then asserts that this + * is a valid application of the rule. + * + * @throws InvalidFileFormatException + */ + @Test + public void MatchingFalseTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA", stt); + TreeNode rootNode = stt.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard(); + + ShortTruthTableCell cell = board.getCell(0, 2); + cell.setData(ShortTruthTableCellType.FALSE); + board.addModifiedData(cell); + + Assert.assertNull(RULE.checkRule(transition)); + } + + /** + * Given two statements: + * A + * A + * where the first A is set to false. + * + * This test sets the second A to true and then asserts that this + * is not a valid application of the rule. + * + * @throws InvalidFileFormatException + */ + @Test + public void MismatchingFalseTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA", stt); + TreeNode rootNode = stt.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard(); + + ShortTruthTableCell cell = board.getCell(0, 2); + cell.setData(ShortTruthTableCellType.TRUE); + board.addModifiedData(cell); + + Assert.assertNotNull(RULE.checkRule(transition)); + } + + /** + * Given two statements: + * B + * B + * where the first B is set to true. + * + * This test sets the second B to true and then asserts that this + * is a valid application of the rule. + * + * @throws InvalidFileFormatException + */ + @Test + public void MatchingTrueTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB", stt); + TreeNode rootNode = stt.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard(); + + ShortTruthTableCell cell = board.getCell(0, 2); + cell.setData(ShortTruthTableCellType.TRUE); + board.addModifiedData(cell); + + Assert.assertNull(RULE.checkRule(transition)); + } + + /** + * Given two statements: + * B + * B + * where the first B is set to true. + * + * This test sets the second B to false and then asserts that this + * is not a valid application of the rule. + * + * @throws InvalidFileFormatException + */ + @Test + public void MismatchingTrueTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB", stt); + TreeNode rootNode = stt.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard(); + + ShortTruthTableCell cell = board.getCell(0, 2); + cell.setData(ShortTruthTableCellType.FALSE); + board.addModifiedData(cell); + + Assert.assertNotNull(RULE.checkRule(transition)); + } + + /** + * Given two statements: + * C + * C + * where neither statement is set to anything. + * + * This test sets the second C to false and then asserts that this + * is not a valid application of the rule. + * + * @throws InvalidFileFormatException + */ + @Test + public void NothingPreviouslyMarkedTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/Empty", stt); + TreeNode rootNode = stt.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard(); + + ShortTruthTableCell cell = board.getCell(0, 2); + cell.setData(ShortTruthTableCellType.FALSE); + board.addModifiedData(cell); + + Assert.assertNotNull(RULE.checkRule(transition)); + } + + /** + * Given two statements: + * C + * C + * where neither statement is set to anything. + * + * This test sets the second C to true and then asserts that this + * is not a valid application of the rule. + * + * @throws InvalidFileFormatException + */ + @Test + public void NothingPreviouslyMarkedTest2() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/shorttruthtable/rules/AtomicDirectRule/Empty", stt); + TreeNode rootNode = stt.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + ShortTruthTableBoard board = (ShortTruthTableBoard) transition.getBoard(); + + ShortTruthTableCell cell = board.getCell(0, 2); + cell.setData(ShortTruthTableCellType.TRUE); + board.addModifiedData(cell); + + Assert.assertNotNull(RULE.checkRule(transition)); + } +} \ No newline at end of file diff --git a/src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java b/src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java deleted file mode 100644 index 81991fa46..000000000 --- a/src/test/java/puzzles/shorttruthtable/rules/DirectRuleAtomicTest.java +++ /dev/null @@ -1,6 +0,0 @@ -package puzzles.shorttruthtable.rules; - -class DirectRuleAtomicTest { - - -} \ No newline at end of file diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty new file mode 100644 index 000000000..6a6effadf --- /dev/null +++ b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/Empty @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA new file mode 100644 index 000000000..8c5ddc7b9 --- /dev/null +++ b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/FalseA @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB new file mode 100644 index 000000000..46a1beb2d --- /dev/null +++ b/src/test/resources/puzzles/shorttruthtable/rules/AtomicDirectRule/TrueB @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + From 535a825f6968464c98d1a9b8d1dce73cd919db5a Mon Sep 17 00:00:00 2001 From: Charles Tian <46334090+charlestian23@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:49:30 -0400 Subject: [PATCH 10/11] Gradle fixes + removed build files (#648) * Removed build files These shouldn't be here * Removed legup-update and legup Gradle projects --------- Co-authored-by: Ivan Ho <41582274+Corppet@users.noreply.github.com> --- build.gradle | 1 - .../BlockInVerticalPath | 11 ----------- .../CannotFillMiddle | 0 .../LightInHorizontalPath | 10 ---------- .../LightInVerticalPath | 10 ---------- .../CannotFillCorners | 13 ------------- .../CannotFillMiddle | 11 ----------- .../TooFewBulbsContradictionRule/BlockEnclosed | 13 ------------- .../CompleteBoardBlockEnclosed | 15 --------------- .../CornerBlockEnclosed | 11 ----------- .../ManyBlocksEnclosed | 17 ----------------- .../TooManyBulbsContradictionRule/BlockEnclosed | 13 ------------- .../CompleteBoardBlockEnclosed | 15 --------------- .../CornerBlockEnclosed | 11 ----------- .../ManyBlocksEnclosed | 17 ----------------- settings.gradle | 2 -- 16 files changed, 170 deletions(-) delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath delete mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners delete mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed delete mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed delete mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed diff --git a/build.gradle b/build.gradle index fafa54cac..1ba7ea006 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,6 @@ dependencies { implementation 'org.jetbrains:annotations:20.1.0' implementation 'org.jetbrains:annotations:20.1.0' implementation 'com.formdev:flatlaf:3.0' - implementation project(':legup-update') implementation 'com.google.firebase:firebase-admin:6.3.0' implementation 'org.apache.httpcomponents:httpclient:4.5.1' implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath deleted file mode 100644 index 5f27b3ec8..000000000 --- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle deleted file mode 100644 index e69de29bb..000000000 diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath deleted file mode 100644 index 633ccc80b..000000000 --- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath deleted file mode 100644 index 70419c40c..000000000 --- a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners deleted file mode 100644 index 38b52f04d..000000000 --- a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle deleted file mode 100644 index 44086f145..000000000 --- a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed deleted file mode 100644 index a57a2473e..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed deleted file mode 100644 index f48d240f0..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed deleted file mode 100644 index 1a9cd60d9..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed deleted file mode 100644 index 32200d831..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed deleted file mode 100644 index c5760aede..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed deleted file mode 100644 index 88fb0a8f1..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed deleted file mode 100644 index a9a8dc5a0..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed deleted file mode 100644 index e743862eb..000000000 --- a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 936e82b6f..f9f593d2b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,2 @@ rootProject.name = 'Legup' -include ':legup' -include ':legup-update' From f69fbe328216fda52db8da1eed2d748c0cda67f4 Mon Sep 17 00:00:00 2001 From: Jacob Long Date: Tue, 17 Oct 2023 19:14:16 -0400 Subject: [PATCH 11/11] fix typo that was causing javadoc to fail --- .../java/edu/rpi/legup/puzzle/fillapix/FillapixUtilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixUtilities.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixUtilities.java index 0df99b820..a7feac91d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixUtilities.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixUtilities.java @@ -154,7 +154,7 @@ public static ArrayList getCellsAtDistance(FillapixBoard board, Fi * * @return an ArrayList of Boolean arrays. Each index in the ArrayList represents * a distinct combination. Each Boolean array will be totalNumItems - * long and each index will be true<\code> if the corresponding item is + * long and each index will be true if the corresponding item is * included in that combination, and false otherwise. */ public static ArrayList getCombinations(int chosenNumItems, int totalNumItems) {