From e427f2108cf06335e55425f159eb632a4d78177b Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 17 Mar 2023 14:34:33 -0400 Subject: [PATCH 01/42] set test points to make sure the STT files are loaded in correctly --- src/main/java/edu/rpi/legup/model/PuzzleImporter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index b72beac68..48c3c26a4 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -181,6 +181,9 @@ protected void createTree(Node node) throws InvalidFileFormatException { HashMap treeTransitions = new HashMap<>(); HashMap nodeChanges = new HashMap<>(); + System.out.println("test1"); + System.out.print(nodeList.getLength()); + System.out.println("test2"); for (int i = 0; i < nodeList.getLength(); i++) { org.w3c.dom.Element treeNodeElement = (org.w3c.dom.Element) nodeList.item(i); String nodeId = treeNodeElement.getAttribute("id"); From 3067af6cf00fb2f2afbe42079bde4d6b294b8d84 Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 17 Mar 2023 16:14:56 -0400 Subject: [PATCH 02/42] testing transitions --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 2 ++ src/main/java/edu/rpi/legup/model/PuzzleImporter.java | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index a8a0bce6d..bb00130f9 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -304,7 +304,9 @@ public void loadPuzzle(InputStream inputStream) throws InvalidFileFormatExceptio LOGGER.error("Puzzle importer is null"); throw new InvalidFileFormatException("Puzzle importer null"); } + importer.initializePuzzle(node); + // System.out.println("test1"); puzzle.initializeView(); puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); setPuzzle(puzzle); diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index 48c3c26a4..b1faa55b3 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -181,9 +181,6 @@ protected void createTree(Node node) throws InvalidFileFormatException { HashMap treeTransitions = new HashMap<>(); HashMap nodeChanges = new HashMap<>(); - System.out.println("test1"); - System.out.print(nodeList.getLength()); - System.out.println("test2"); for (int i = 0; i < nodeList.getLength(); i++) { org.w3c.dom.Element treeNodeElement = (org.w3c.dom.Element) nodeList.item(i); String nodeId = treeNodeElement.getAttribute("id"); @@ -213,6 +210,7 @@ protected void createTree(Node node) throws InvalidFileFormatException { NodeList transList = treeNodeElement.getElementsByTagName("transition"); for (int k = 0; k < transList.getLength(); k++) { + System.out.println("transition "+ k+ " for node "+ i+ "\n"); org.w3c.dom.Element trans = (org.w3c.dom.Element) transList.item(k); String transId = trans.getAttribute("id"); TreeTransition transition = treeTransitions.get(transId); From 712af0a71382394dea4aa292d7398b6514f51029 Mon Sep 17 00:00:00 2001 From: Jun Date: Sun, 19 Mar 2023 17:22:09 -0400 Subject: [PATCH 03/42] added a test case, BlockInVerticalPath for LightUp that tests there isn't a contradiction if there is a block between two bulbs. --- .../java/edu/rpi/legup/model/PuzzleImporter.java | 1 - .../rules/BulbsInPathContradictionRuleTest.java | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index b1faa55b3..b72beac68 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -210,7 +210,6 @@ protected void createTree(Node node) throws InvalidFileFormatException { NodeList transList = treeNodeElement.getElementsByTagName("transition"); for (int k = 0; k < transList.getLength(); k++) { - System.out.println("transition "+ k+ " for node "+ i+ "\n"); org.w3c.dom.Element trans = (org.w3c.dom.Element) transList.item(k); String transId = trans.getAttribute("id"); TreeTransition transition = treeTransitions.get(transId); diff --git a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java index 3b1748abb..94814868d 100644 --- a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java @@ -55,4 +55,19 @@ public void BulbsInPathContradictionRule_LightInVerticalPath() throws InvalidFil Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); } + + @Test + public void BulbsInPathContradictionRule_BlockInVerticalPath() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNotNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); + } } From 576f1f27a290814ffbadded8e723c94fee3e2997 Mon Sep 17 00:00:00 2001 From: Jun Date: Sun, 19 Mar 2023 18:11:51 -0400 Subject: [PATCH 04/42] added a test case, CannontFillMiddle for LightUp that tests CannotLightACell Contradiction Rule --- .../legup/puzzle/treetent/TreeTentCell.java | 2 +- ...CannotLightACellContradictionRuleTest.java | 28 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java index 290e0858d..7b938fabb 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java @@ -32,7 +32,7 @@ public void setType(Element e, MouseEvent m) { @Override public TreeTentCell copy() { - TreeTentCell copy = new TreeTentCell(data, (Point) location.clone()); + TreeTentCell copy = new TreeTentCell( data, (Point) location.clone()); copy.setIndex(index); copy.setModifiable(isModifiable); copy.setGiven(isGiven); diff --git a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java index 260a62c9c..d4f3e2d82 100644 --- a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java @@ -1,19 +1,43 @@ package puzzles.lightup.rules; +import edu.rpi.legup.puzzle.lightup.LightUpBoard; +import edu.rpi.legup.puzzle.lightup.rules.CannotLightACellContradictionRule; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import edu.rpi.legup.model.PuzzleImporter; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import org.junit.Assert; +import edu.rpi.legup.puzzle.lightup.LightUp; +import edu.rpi.legup.save.InvalidFileFormatException; + import org.junit.BeforeClass; import org.junit.Test; -import edu.rpi.legup.puzzle.lightup.LightUp; public class CannotLightACellContradictionRuleTest { + private static final CannotLightACellContradictionRule RULE = new CannotLightACellContradictionRule(); private static LightUp lightUp; + private static PuzzleImporter importer; @BeforeClass public static void setUp() { + MockGameBoardFacade.getInstance(); lightUp = new LightUp(); + importer = lightUp.getImporter(); } @Test - public void simpleCaseTest() { + public void CannotLightACellContradictionRule_CannotFillMiddle() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); } } From dc2289b075f1a090557f27865119982914603a79 Mon Sep 17 00:00:00 2001 From: Jun Date: Sun, 19 Mar 2023 18:14:00 -0400 Subject: [PATCH 05/42] removed unnecessary indent --- src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java index 7b938fabb..290e0858d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java @@ -32,7 +32,7 @@ public void setType(Element e, MouseEvent m) { @Override public TreeTentCell copy() { - TreeTentCell copy = new TreeTentCell( data, (Point) location.clone()); + TreeTentCell copy = new TreeTentCell(data, (Point) location.clone()); copy.setIndex(index); copy.setModifiable(isModifiable); copy.setGiven(isGiven); From 40438ce80ff723dfe278bf4cc4d3d72d6287f555 Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 24 Mar 2023 17:21:19 -0400 Subject: [PATCH 06/42] Added unit tests tor CannotLightACellContradictionRuleTest and TooFewBulbsContradictionRuleTest. --- ...CannotLightACellContradictionRuleTest.java | 16 ++++ .../TooFewBulbsContradictionRuleTest.java | 85 ++++++++++++++++++- 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java index d4f3e2d82..9a0b65fef 100644 --- a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java @@ -40,4 +40,20 @@ public void CannotLightACellContradictionRule_CannotFillMiddle() throws InvalidF Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); } + + @Test + public void CannotLightACellContradictionRule_CannotFillCorners() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); + } } diff --git a/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java index b3ff026ed..c131d09e0 100644 --- a/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java @@ -1,19 +1,100 @@ package puzzles.lightup.rules; +import edu.rpi.legup.puzzle.lightup.LightUpBoard; +import edu.rpi.legup.puzzle.lightup.rules.CannotLightACellContradictionRule; +import edu.rpi.legup.puzzle.lightup.rules.TooFewBulbsContradictionRule; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import edu.rpi.legup.model.PuzzleImporter; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import org.junit.Assert; +import edu.rpi.legup.puzzle.lightup.LightUp; +import edu.rpi.legup.save.InvalidFileFormatException; + import org.junit.BeforeClass; import org.junit.Test; -import edu.rpi.legup.puzzle.lightup.LightUp; + public class TooFewBulbsContradictionRuleTest { + private static final TooFewBulbsContradictionRule RULE = new TooFewBulbsContradictionRule(); private static LightUp lightUp; + private static PuzzleImporter importer; @BeforeClass public static void setUp() { + MockGameBoardFacade.getInstance(); lightUp = new LightUp(); + importer = lightUp.getImporter(); + } + + @Test + public void TooFewBulbsContradictionRule_BlockEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); + } + + @Test + public void TooFewBulbsContradictionRule_CornerBlockEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); } @Test - public void simpleCaseTest() { + public void TooFewBulbsContradictionRule_ManyBlocksEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 2))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); + } + + @Test + public void TooFewBulbsContradictionRule_CompleteBoardBlockEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); } } From b09d153258b9d07989076ee0663bca82383e3369 Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 24 Mar 2023 17:26:35 -0400 Subject: [PATCH 07/42] Added test LightUp files for testing --- .../BlockInVerticalPath | 11 +++++++++++ .../CannotFillMiddle | 0 .../LightInHorizontalPath | 10 ++++++++++ .../LightInVerticalPath | 10 ++++++++++ .../CannotFillCorners | 13 +++++++++++++ .../CannotFillMiddle | 11 +++++++++++ .../TooFewBulbsContradictionRule/BlockEnclosed | 13 +++++++++++++ .../CompleteBoardBlockEnclosed | 15 +++++++++++++++ .../CornerBlockEnclosed | 11 +++++++++++ .../ManyBlocksEnclosed | 17 +++++++++++++++++ 10 files changed, 111 insertions(+) create mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath create mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle create mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath create mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath create mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners create mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath new file mode 100644 index 000000000..5f27b3ec8 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInVerticalPath @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..e69de29bb diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath new file mode 100644 index 000000000..1b4926106 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInHorizontalPath @@ -0,0 +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 new file mode 100644 index 000000000..48aa7010c --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/LightInVerticalPath @@ -0,0 +1,10 @@ + + + + + + + + + + \ 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 new file mode 100644 index 000000000..38b52f04d --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..44086f145 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..a57a2473e --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..f48d240f0 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..1a9cd60d9 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..32200d831 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file From 08c59d1f050accdcd039109470ac32d51a0bafcd Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 24 Mar 2023 17:37:15 -0400 Subject: [PATCH 08/42] removed an unnecessary comment and spacing --- src/main/java/edu/rpi/legup/app/GameBoardFacade.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index bb00130f9..a8a0bce6d 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -304,9 +304,7 @@ public void loadPuzzle(InputStream inputStream) throws InvalidFileFormatExceptio LOGGER.error("Puzzle importer is null"); throw new InvalidFileFormatException("Puzzle importer null"); } - importer.initializePuzzle(node); - // System.out.println("test1"); puzzle.initializeView(); puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode()); setPuzzle(puzzle); From c7f4da3b53c6a98886df82580f719eb3ad7bb236 Mon Sep 17 00:00:00 2001 From: Jun Date: Tue, 28 Mar 2023 17:16:41 -0400 Subject: [PATCH 09/42] Added another set of tests for TooManyBulbsContradictionRule --- .../BlockEnclosed | 13 +++ .../CompleteBoardBlockEnclosed | 15 ++++ .../CornerBlockEnclosed | 11 +++ .../ManyBlocksEnclosed | 17 ++++ .../TooFewBulbsContradictionRuleTest.java | 1 - .../TooManyBulbsContradictionRuleTest.java | 82 ++++++++++++++++++- 6 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed diff --git a/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed new file mode 100644 index 000000000..c5760aede --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..88fb0a8f1 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..a9a8dc5a0 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..e743862eb --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java index c131d09e0..14b2a10bd 100644 --- a/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/TooFewBulbsContradictionRuleTest.java @@ -1,7 +1,6 @@ package puzzles.lightup.rules; import edu.rpi.legup.puzzle.lightup.LightUpBoard; -import edu.rpi.legup.puzzle.lightup.rules.CannotLightACellContradictionRule; import edu.rpi.legup.puzzle.lightup.rules.TooFewBulbsContradictionRule; import legup.MockGameBoardFacade; import legup.TestUtilities; diff --git a/src/test/java/puzzles/lightup/rules/TooManyBulbsContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/TooManyBulbsContradictionRuleTest.java index ac4c49520..bb7c31d6e 100644 --- a/src/test/java/puzzles/lightup/rules/TooManyBulbsContradictionRuleTest.java +++ b/src/test/java/puzzles/lightup/rules/TooManyBulbsContradictionRuleTest.java @@ -1,19 +1,97 @@ package puzzles.lightup.rules; +import edu.rpi.legup.puzzle.lightup.LightUpBoard; +import edu.rpi.legup.puzzle.lightup.rules.TooManyBulbsContradictionRule; +import legup.MockGameBoardFacade; +import legup.TestUtilities; +import edu.rpi.legup.model.PuzzleImporter; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import org.junit.Assert; +import edu.rpi.legup.puzzle.lightup.LightUp; +import edu.rpi.legup.save.InvalidFileFormatException; + import org.junit.BeforeClass; import org.junit.Test; -import edu.rpi.legup.puzzle.lightup.LightUp; public class TooManyBulbsContradictionRuleTest { + private static final TooManyBulbsContradictionRule RULE = new TooManyBulbsContradictionRule(); private static LightUp lightUp; + private static PuzzleImporter importer; @BeforeClass public static void setUp() { + MockGameBoardFacade.getInstance(); lightUp = new LightUp(); + importer = lightUp.getImporter(); + } + @Test + public void TooManyBulbsContradictionRule_BlockEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); } @Test - public void simpleCaseTest() { + public void TooManyBulbsContradictionRule_CornerBlockEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooManybulbsContradictionRule/CornerBlockEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + } +// + @Test + public void TooManyBulbsContradictionRule_ManyBlocksEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 2))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); + } + + @Test + public void TooManyBulbsContradictionRule_CompleteBoardBlockEnclosed() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed", lightUp); + TreeNode rootNode = lightUp.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + LightUpBoard board = (LightUpBoard) transition.getBoard(); + Assert.assertNull(RULE.checkContradiction(board)); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0))); + Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 1))); + Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2))); } } From 825786000e283fb5e793834290e9216c6a3ce143 Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 31 Mar 2023 16:50:40 -0400 Subject: [PATCH 10/42] Added Randomly Generated 7x7 lightup puzzles --- puzzles files/lightup/7x7 Random/puzzle1 | 26 ++++++++++++++++++++++++ puzzles files/lightup/7x7 Random/puzzle2 | 24 ++++++++++++++++++++++ puzzles files/lightup/7x7 Random/puzzle3 | 25 +++++++++++++++++++++++ puzzles files/lightup/7x7 Random/puzzle4 | 26 ++++++++++++++++++++++++ puzzles files/lightup/7x7 Random/puzzle5 | 24 ++++++++++++++++++++++ puzzles files/lightup/7x7 Random/puzzle6 | 22 ++++++++++++++++++++ puzzles files/lightup/7x7 Random/puzzle7 | 22 ++++++++++++++++++++ 7 files changed, 169 insertions(+) create mode 100644 puzzles files/lightup/7x7 Random/puzzle1 create mode 100644 puzzles files/lightup/7x7 Random/puzzle2 create mode 100644 puzzles files/lightup/7x7 Random/puzzle3 create mode 100644 puzzles files/lightup/7x7 Random/puzzle4 create mode 100644 puzzles files/lightup/7x7 Random/puzzle5 create mode 100644 puzzles files/lightup/7x7 Random/puzzle6 create mode 100644 puzzles files/lightup/7x7 Random/puzzle7 diff --git a/puzzles files/lightup/7x7 Random/puzzle1 b/puzzles files/lightup/7x7 Random/puzzle1 new file mode 100644 index 000000000..f4b51b504 --- /dev/null +++ b/puzzles files/lightup/7x7 Random/puzzle1 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/puzzles files/lightup/7x7 Random/puzzle2 b/puzzles files/lightup/7x7 Random/puzzle2 new file mode 100644 index 000000000..d8aa361fc --- /dev/null +++ b/puzzles files/lightup/7x7 Random/puzzle2 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/puzzles files/lightup/7x7 Random/puzzle3 b/puzzles files/lightup/7x7 Random/puzzle3 new file mode 100644 index 000000000..2bfc0eef6 --- /dev/null +++ b/puzzles files/lightup/7x7 Random/puzzle3 @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/puzzles files/lightup/7x7 Random/puzzle4 b/puzzles files/lightup/7x7 Random/puzzle4 new file mode 100644 index 000000000..dba59c00f --- /dev/null +++ b/puzzles files/lightup/7x7 Random/puzzle4 @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/puzzles files/lightup/7x7 Random/puzzle5 b/puzzles files/lightup/7x7 Random/puzzle5 new file mode 100644 index 000000000..86aecf364 --- /dev/null +++ b/puzzles files/lightup/7x7 Random/puzzle5 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/puzzles files/lightup/7x7 Random/puzzle6 b/puzzles files/lightup/7x7 Random/puzzle6 new file mode 100644 index 000000000..e8df41259 --- /dev/null +++ b/puzzles files/lightup/7x7 Random/puzzle6 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/puzzles files/lightup/7x7 Random/puzzle7 b/puzzles files/lightup/7x7 Random/puzzle7 new file mode 100644 index 000000000..2550033b4 --- /dev/null +++ b/puzzles files/lightup/7x7 Random/puzzle7 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 011a0c389ba0f019688afe5618a9aa8a41c052a1 Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 31 Mar 2023 17:53:24 -0400 Subject: [PATCH 11/42] prevented the same error message from being created numerous times when checking for direct rules. --- .../java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java index d812d0d93..d5b83d1e8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java @@ -15,6 +15,10 @@ public NurikabeBoard(int size) { @Override public NurikabeCell getCell(int x, int y) { + if (y * dimension.width + x >= puzzleElements.size() || x >= dimension.width || + y >= dimension.height || x < 0 || y < 0) { + return null; + } return (NurikabeCell) super.getCell(x, y); } From 20447e90170dbd7fe28602ff893788775578b437 Mon Sep 17 00:00:00 2001 From: Jason Pu Date: Mon, 3 Apr 2023 17:29:28 -0400 Subject: [PATCH 12/42] Failing test cases These tests were initially commented out. This commit uncomments the tests and fixed all errors --- .../rules/CornerBlackDirectRuleTest.java | 54 +++++++++++-------- .../rules/FillinWhiteDirectRuleTest.java | 33 ++++++++---- 2 files changed, 55 insertions(+), 32 deletions(-) diff --git a/src/test/java/puzzles/nurikabe/rules/CornerBlackDirectRuleTest.java b/src/test/java/puzzles/nurikabe/rules/CornerBlackDirectRuleTest.java index 2b23754f3..0ee3c247b 100644 --- a/src/test/java/puzzles/nurikabe/rules/CornerBlackDirectRuleTest.java +++ b/src/test/java/puzzles/nurikabe/rules/CornerBlackDirectRuleTest.java @@ -1,11 +1,21 @@ package puzzles.nurikabe.rules; +import edu.rpi.legup.puzzle.nurikabe.NurikabeType; import legup.MockGameBoardFacade; import org.junit.BeforeClass; import org.junit.Test; import edu.rpi.legup.puzzle.nurikabe.Nurikabe; import edu.rpi.legup.puzzle.nurikabe.rules.CornerBlackDirectRule; import edu.rpi.legup.save.InvalidFileFormatException; +import legup.TestUtilities; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import org.junit.Assert; +import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard; +import edu.rpi.legup.puzzle.nurikabe.NurikabeCell; + +import java.awt.*; + public class CornerBlackDirectRuleTest { @@ -20,26 +30,28 @@ public static void setUp() { @Test public void CornerBlackContradictionRule_SimpleCornerBlackTest() throws InvalidFileFormatException { -// TestUtilities.importTestBoard("puzzles/nurikabe/rules/TooFewSpacesContradictionRule/TwoSurroundBlack", nurikabe); -// TreeNode rootNode = nurikabe.getTree().getRootNode(); -// TreeTransition transition = rootNode.getChildren().get(0); -// transition.setRule(RULE); -// -// transition.getBoard().getModifiedData().clear(); -// -// Assert.assertNull(RULE.checkRule(transition)); -// -// NurikabeBoard board = (NurikabeBoard)transition.getBoard(); -// Point location = new Point(1, 1); -// for(int i = 0; i < board.getHeight(); i++) { -// for(int k = 0; k < board.getWidth(); k++) { -// Point point = new Point(k, i); -// if(point.equals(location)) { -// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } else { -// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } -// } -// } + TestUtilities.importTestBoard("puzzles/nurikabe/rules/TooFewSpacesContradictionRule/TwoSurroundBlack", nurikabe); + TreeNode rootNode = nurikabe.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + NurikabeBoard board = (NurikabeBoard) transition.getBoard(); + transition.setRule(RULE); + + NurikabeCell cell = board.getCell(2, 0); + cell.setData(NurikabeType.BLACK.toValue()); + board.addModifiedData(cell); + + Assert.assertNotNull(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(cell)) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } } } diff --git a/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java b/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java index dbc664a15..e78e1080f 100644 --- a/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java +++ b/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java @@ -6,6 +6,16 @@ import edu.rpi.legup.puzzle.nurikabe.Nurikabe; import edu.rpi.legup.puzzle.nurikabe.rules.FillinWhiteDirectRule; import edu.rpi.legup.save.InvalidFileFormatException; +import legup.TestUtilities; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import org.junit.Assert; +import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard; +import edu.rpi.legup.puzzle.nurikabe.NurikabeCell; +import edu.rpi.legup.puzzle.nurikabe.NurikabeType; + +import java.awt.*; + public class FillinWhiteDirectRuleTest { private static final FillinWhiteDirectRule RULE = new FillinWhiteDirectRule(); @@ -19,16 +29,16 @@ public static void setUp() { @Test public void FillinWhiteDirectRule_UnknownSurroundWhiteTest() throws InvalidFileFormatException { -// TestUtilities.importTestBoard("puzzles/nurikabe/rules/FillinWhiteDirectRule/UnknownSurroundWhite", nurikabe); -// TreeNode rootNode = nurikabe.getTree().getRootNode(); -// TreeTransition transition = rootNode.getChildren().get(0); -// transition.setRule(RULE); -// -// NurikabeBoard board = (NurikabeBoard) transition.getBoard(); -// NurikabeCell cell = board.getCell(1,1); -// cell.setData(NurikabeType.WHITE.toValue()); -// board.addModifiedData(cell); -// + TestUtilities.importTestBoard("puzzles/nurikabe/rules/FillinWhiteDirectRule/UnknownSurroundWhite", nurikabe); + TreeNode rootNode = nurikabe.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + NurikabeBoard board = (NurikabeBoard) transition.getBoard(); + NurikabeCell cell = board.getCell(1,1); + cell.setData(NurikabeType.WHITE.toValue()); + board.addModifiedData(cell); + // Assert.assertNull(RULE.checkRule(transition)); // // Point location = new Point(1, 1); @@ -37,7 +47,8 @@ public void FillinWhiteDirectRule_UnknownSurroundWhiteTest() throws InvalidFileF // Point point = new Point(k, i); // if(point.equals(location)) { // Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } else { +// } +// else { // Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); // } // } From 823a6688ce3419df9fac8b8a80bd37198558f763 Mon Sep 17 00:00:00 2001 From: Jason Pu Date: Mon, 3 Apr 2023 17:36:46 -0400 Subject: [PATCH 13/42] Fixes BlackBottleNeckRule test This test was failing because there was only one black cell on the test board. Another reachable cell was added so the rule can be successfully applied. --- .../rules/BlackBottleNeckDirectRuleTest.java | 56 +++++++++++-------- .../SimpleBlackBottleNeck | 1 + 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/test/java/puzzles/nurikabe/rules/BlackBottleNeckDirectRuleTest.java b/src/test/java/puzzles/nurikabe/rules/BlackBottleNeckDirectRuleTest.java index 45ed97030..91dcec802 100644 --- a/src/test/java/puzzles/nurikabe/rules/BlackBottleNeckDirectRuleTest.java +++ b/src/test/java/puzzles/nurikabe/rules/BlackBottleNeckDirectRuleTest.java @@ -3,9 +3,18 @@ import legup.MockGameBoardFacade; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.Assert; import edu.rpi.legup.puzzle.nurikabe.Nurikabe; +import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard; +import edu.rpi.legup.puzzle.nurikabe.NurikabeCell; +import edu.rpi.legup.puzzle.nurikabe.NurikabeType; import edu.rpi.legup.puzzle.nurikabe.rules.BlackBottleNeckDirectRule; import edu.rpi.legup.save.InvalidFileFormatException; +import legup.TestUtilities; +import edu.rpi.legup.model.tree.TreeNode; +import edu.rpi.legup.model.tree.TreeTransition; +import java.awt.*; + public class BlackBottleNeckDirectRuleTest { @@ -20,28 +29,29 @@ public static void setUp() { @Test public void BlackBottleNeckDirectRule_TwoSurroundBlackTest() throws InvalidFileFormatException { -// TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBottleNeckDirectRule/SimpleBlackBottleNeck", nurikabe); -// TreeNode rootNode = nurikabe.getTree().getRootNode(); -// TreeTransition transition = rootNode.getChildren().get(0); -// transition.setRule(RULE); -// -// NurikabeBoard board = (NurikabeBoard)transition.getBoard(); -// NurikabeCell cell = board.getCell(2,1); -// cell.setData(NurikabeType.BLACK.toValue()); -// -// board.addModifiedData(cell); -// -// 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(cell.getLocation())) { -// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } else { -// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } -// } -// } + TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBottleNeckDirectRule/SimpleBlackBottleNeck", nurikabe); + TreeNode rootNode = nurikabe.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + NurikabeBoard board = (NurikabeBoard)transition.getBoard(); + NurikabeCell cell = board.getCell(2,1); + cell.setData(NurikabeType.BLACK.toValue()); + + board.addModifiedData(cell); + + 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(cell.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } } } diff --git a/src/test/resources/puzzles/nurikabe/rules/BlackBottleNeckDirectRule/SimpleBlackBottleNeck b/src/test/resources/puzzles/nurikabe/rules/BlackBottleNeckDirectRule/SimpleBlackBottleNeck index 5501725fe..07f3cc9be 100644 --- a/src/test/resources/puzzles/nurikabe/rules/BlackBottleNeckDirectRule/SimpleBlackBottleNeck +++ b/src/test/resources/puzzles/nurikabe/rules/BlackBottleNeckDirectRule/SimpleBlackBottleNeck @@ -3,6 +3,7 @@ + From 02d4f1a00d5a33cf488aa8b8e9e80114ee045f39 Mon Sep 17 00:00:00 2001 From: ErinECohen <73081649+ErinECohen@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:44:53 -0400 Subject: [PATCH 14/42] Updated NurikabeCell.java if/else statements to switch case Cleaned up code to be faster/more readable by changing out nested if/elses to switch cases --- .../legup/puzzle/nurikabe/NurikabeCell.java | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java index 334831d84..373f7550c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java @@ -46,38 +46,30 @@ public NurikabeType getType() { */ @Override public void setType(Element e, MouseEvent m) { - if (e.getElementName().equals("Black Tile")) { - this.data = -1; - } - else { - if (e.getElementName().equals("White Tile")) { + switch (e.getElementName()){ + case "Black Tile": + this.data = -1; + case "White Tile": this.data = 0; - } - else { - if (e.getElementName().equals("Number Tile")) { - if (m.getButton() == MouseEvent.BUTTON1) { + case "Number Tile": + switch (m.getButton()){ + case MouseEvent.BUTTON1: if (this.data <= 0 || this.data > 8) { this.data = 1; } else { this.data = this.data + 1; } - } - else { - if (m.getButton() == MouseEvent.BUTTON3) { - if (this.data > 1) { - this.data = this.data - 1; - } - else { - this.data = 9; - } + case MouseEvent.BUTTON3: + if (this.data > 1) { + this.data = this.data - 1; + } + else { + this.data = 9; } - } - } - else { // unknown tile - this.data = -2; } - } + default: + this.data = -2; } } @@ -94,4 +86,4 @@ public NurikabeCell copy() { copy.setGiven(isGiven); return copy; } -} +} \ No newline at end of file From a73b387a26a08fb2669e482196bda241a9c0e8eb Mon Sep 17 00:00:00 2001 From: Jason Pu Date: Wed, 5 Apr 2023 15:32:29 -0400 Subject: [PATCH 15/42] Fixes TooManySpacesContradictionRuleTest bug The contradiction rule works for point (0, 1). This point was added to the "assertNull" list of points --- .../TooManySpacesContradictionRuleTest.java | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/test/java/puzzles/nurikabe/rules/TooManySpacesContradictionRuleTest.java b/src/test/java/puzzles/nurikabe/rules/TooManySpacesContradictionRuleTest.java index 2783b1565..48979d886 100644 --- a/src/test/java/puzzles/nurikabe/rules/TooManySpacesContradictionRuleTest.java +++ b/src/test/java/puzzles/nurikabe/rules/TooManySpacesContradictionRuleTest.java @@ -27,25 +27,26 @@ public static void setUp() { @Test public void TooManySpacesContradictionRule_TwoSurroundBlackTest() throws InvalidFileFormatException { -// TestUtilities.importTestBoard("puzzles/nurikabe/rules/TooManySpacesContradictionRule/TwoSurroundWhite", nurikabe); -// TreeNode rootNode = nurikabe.getTree().getRootNode(); -// TreeTransition transition = rootNode.getChildren().get(0); -// transition.setRule(RULE); -// -// Assert.assertNull(RULE.checkContradiction((NurikabeBoard)transition.getBoard())); -// -// NurikabeBoard board = (NurikabeBoard)transition.getBoard(); -// -// 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(new Point(1, 0)) || point.equals(new Point(1, 1)) || -// point.equals(new Point(2, 1)) || point.equals(new Point(1, 2))) { -// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } else { -// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } -// } -// } + TestUtilities.importTestBoard("puzzles/nurikabe/rules/TooManySpacesContradictionRule/TwoSurroundWhite", nurikabe); + TreeNode rootNode = nurikabe.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + Assert.assertNull(RULE.checkContradiction((NurikabeBoard)transition.getBoard())); + + NurikabeBoard board = (NurikabeBoard)transition.getBoard(); + + 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(new Point(1, 0)) || point.equals(new Point(1, 1)) || + point.equals(new Point(2, 1)) || point.equals(new Point(1, 2)) || point.equals(new Point(0, 1))) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } } } From 34b09355d337022b2d07d977b6f039c49474f783 Mon Sep 17 00:00:00 2001 From: Jun Date: Fri, 7 Apr 2023 05:03:10 -0400 Subject: [PATCH 16/42] reimplmented clear history so that it doesn't break Proof Editor --- src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index fb8c9fec6..bbc23306d 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -401,8 +401,10 @@ public void onRedo(boolean isBottom, boolean isTop) { @Override public void onClearHistory() { - //undo.setEnabled(false); - //redo.setEnabled(false); + // These buttons are never created and set to null if the user + // goes straight to the Proof Editor after running LEGUP + if (undo != null) undo.setEnabled(false); + if (redo != null) redo.setEnabled(false); } public BoardView getBoardView() { From 72390f93111d848bd843a59bcd867b1e2fd7abf9 Mon Sep 17 00:00:00 2001 From: Jason Pu Date: Fri, 7 Apr 2023 16:51:44 -0400 Subject: [PATCH 17/42] Fixes FillinWhiteDirectRuleTest The test failed on the original board because there is no black cells. The contradiction test it is checking against, isolatedBlackContradictionRule, requires at least one black cell. --- .../rules/FillinWhiteDirectRuleTest.java | 28 +++++++++---------- .../UnknownSurroundWhite | 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java b/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java index e78e1080f..4acc54f98 100644 --- a/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java +++ b/src/test/java/puzzles/nurikabe/rules/FillinWhiteDirectRuleTest.java @@ -39,19 +39,19 @@ public void FillinWhiteDirectRule_UnknownSurroundWhiteTest() throws InvalidFileF cell.setData(NurikabeType.WHITE.toValue()); board.addModifiedData(cell); -// Assert.assertNull(RULE.checkRule(transition)); -// -// Point location = new Point(1, 1); -// for(int i = 0; i < board.getHeight(); i++) { -// for(int k = 0; k < board.getWidth(); k++) { -// Point point = new Point(k, i); -// if(point.equals(location)) { -// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } -// else { -// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); -// } -// } -// } + Assert.assertNull(RULE.checkRule(transition)); + + Point location = new Point(1, 1); + for(int i = 0; i < board.getHeight(); i++) { + for(int k = 0; k < board.getWidth(); k++) { + Point point = new Point(k, i); + if(point.equals(location)) { + Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + } + } + } } } diff --git a/src/test/resources/puzzles/nurikabe/rules/FillinWhiteDirectRule/UnknownSurroundWhite b/src/test/resources/puzzles/nurikabe/rules/FillinWhiteDirectRule/UnknownSurroundWhite index 200f518cb..eb23eb55d 100644 --- a/src/test/resources/puzzles/nurikabe/rules/FillinWhiteDirectRule/UnknownSurroundWhite +++ b/src/test/resources/puzzles/nurikabe/rules/FillinWhiteDirectRule/UnknownSurroundWhite @@ -6,6 +6,7 @@ + From 24ee15d4d5b57f83c46a6aaa7eaad3291176ce9f Mon Sep 17 00:00:00 2001 From: Jun Date: Tue, 18 Apr 2023 16:44:58 -0400 Subject: [PATCH 18/42] allowed case rules to have only one option --- .../rpi/legup/puzzle/lightup/rules/SatisfyNumberCaseRule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/rules/SatisfyNumberCaseRule.java b/src/main/java/edu/rpi/legup/puzzle/lightup/rules/SatisfyNumberCaseRule.java index 2fbcf3826..1f166685b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/rules/SatisfyNumberCaseRule.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/rules/SatisfyNumberCaseRule.java @@ -181,8 +181,8 @@ public String checkRuleRaw(TreeTransition transition) { for (LightUpCell c : spots) { ArrayList cases = getCases(parent.getBoard(), c); - // We want to return false if cases.size() is equal to 1 because case rules aren't supposed to have only 1 option - if (cases.size() == childTransitions.size() && cases.size() > 1) { + // We will allow case rules to have only one option + if (cases.size() == childTransitions.size() && cases.size() >= 1) { boolean foundSpot = true; for (TreeTransition childTrans : childTransitions) { LightUpBoard actCase = (LightUpBoard) childTrans.getBoard(); From 7e7810a0d29770ce72c80ea3f2e979f7a63ba43f Mon Sep 17 00:00:00 2001 From: Jun Date: Tue, 18 Apr 2023 16:48:13 -0400 Subject: [PATCH 19/42] undo changes --- src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index bbc23306d..fb8c9fec6 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -401,10 +401,8 @@ public void onRedo(boolean isBottom, boolean isTop) { @Override public void onClearHistory() { - // These buttons are never created and set to null if the user - // goes straight to the Proof Editor after running LEGUP - if (undo != null) undo.setEnabled(false); - if (redo != null) redo.setEnabled(false); + //undo.setEnabled(false); + //redo.setEnabled(false); } public BoardView getBoardView() { From 212b73f0a034d11aaac5c70b0d145509f7dbcc48 Mon Sep 17 00:00:00 2001 From: Maitri Bijur <122646363+Mbijur@users.noreply.github.com> Date: Fri, 21 Apr 2023 16:23:21 -0400 Subject: [PATCH 20/42] Resolved errors and warnings in the Javadoc (#529) * Update Config.java * Update GameBoardFacade.java * Update ICommand.java * Update ICommand.java * Update ICommand.java * Update Puzzle.java * Update GameBoardFacade.java * Update Config.java * Update GameBoardFacade.java * Update Puzzle.java * Update Puzzle.java * Update Puzzle.java * Update SkyscrapersBoard.java * Update SkyscrapersBoard.java * Update SkyscrapersBoard.java * Update SkyscrapersBoard.java * Update SkyscrapersBoard.java * Update SkyscrapersBoard.java * Update SkyscrapersBoard.java * Update SkyscrapersCellFactory.java * Update PuzzleExporter.java * Update BattleshipCellFactory.java * Update PuzzleExporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update PuzzleImporter.java * Update BattleshipImporter.java * Created descriptions for param node and exception InvalidFileException * Update BattleshipType.java * Update BattleshipType.java * Update BoardView.java * Update GridBoardView.java * Update FillapixCellFactory.java * Update FillapixImporter.java * Update FillapixImporter.java * Update HeyawakeFactory.java * Update HeyawakeImporter.java * Update BattleshipImporter.java * Update HeyawakeImporter.java * Update AutoCaseRuleCommand.java * Update AutoCaseRuleCommand.java * Update ValidateCaseRuleCommand.java * Update LightUpCellFactory.java * Update LightUpImporter.java * Update MasyuCellFactory.java * Update MasyuImporter.java * Update NurikabeCellFactory.java * Update NurikabeImporter.java * Update RulePanel.java * Update RulePanel.java * Update RulePanel.java * Update RulePanel.java * Update RulePanel.java * Update ShortTruthTableCellFactory.java * Update ShortTruthTableCellType.java * Update ShortTruthTableCellType.java * Update ShortTruthTableCellType.java * Update SkyscrapersBoard.java * Update SkyscrapersImporter.java * Update SkyscrapersImporter.java * Update SudokuCell.java * Update SudokuCellFactory.java * Update SudokuImporter.java * Update SudokuImporter.java * Update Tree.java * Update TreeTentCellFactory.java * Update TreeTentImporter.java * Update TreeToolbarPanel.java * Update LegupUI.java * Update WrapLayout.java * Update LegupUtils.java * Update ValidateContradictionRuleCommand.java --------- Co-authored-by: Ivan Ho <41582274+Corppet@users.noreply.github.com> Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> --- src/main/java/edu/rpi/legup/app/Config.java | 2 +- .../edu/rpi/legup/app/GameBoardFacade.java | 3 ++- .../legup/history/AutoCaseRuleCommand.java | 3 +++ .../java/edu/rpi/legup/history/ICommand.java | 7 +++--- .../history/ValidateCaseRuleCommand.java | 1 + .../ValidateContradictionRuleCommand.java | 6 ++--- src/main/java/edu/rpi/legup/model/Puzzle.java | 8 +++--- .../edu/rpi/legup/model/PuzzleExporter.java | 3 ++- .../edu/rpi/legup/model/PuzzleImporter.java | 16 ++++++------ .../java/edu/rpi/legup/model/tree/Tree.java | 2 +- .../battleship/BattleshipCellFactory.java | 2 +- .../puzzle/battleship/BattleshipImporter.java | 4 +-- .../puzzle/battleship/BattleshipType.java | 2 +- .../puzzle/fillapix/FillapixCellFactory.java | 2 +- .../puzzle/fillapix/FillapixImporter.java | 4 +-- .../puzzle/heyawake/HeyawakeFactory.java | 2 +- .../puzzle/heyawake/HeyawakeImporter.java | 4 +-- .../puzzle/lightup/LightUpCellFactory.java | 2 +- .../legup/puzzle/lightup/LightUpImporter.java | 4 +-- .../legup/puzzle/masyu/MasyuCellFactory.java | 2 +- .../rpi/legup/puzzle/masyu/MasyuImporter.java | 4 +-- .../puzzle/nurikabe/NurikabeCellFactory.java | 2 +- .../puzzle/nurikabe/NurikabeImporter.java | 4 +-- .../ShortTruthTableCellFactory.java | 2 +- .../ShortTruthTableCellType.java | 4 ++- .../puzzle/skyscrapers/SkyscrapersBoard.java | 16 ++++++------ .../skyscrapers/SkyscrapersCellFactory.java | 2 +- .../skyscrapers/SkyscrapersImporter.java | 4 +-- .../rpi/legup/puzzle/sudoku/SudokuCell.java | 1 + .../puzzle/sudoku/SudokuCellFactory.java | 2 +- .../legup/puzzle/sudoku/SudokuImporter.java | 4 +-- .../puzzle/treetent/TreeTentCellFactory.java | 2 +- .../puzzle/treetent/TreeTentImporter.java | 4 +-- src/main/java/edu/rpi/legup/ui/LegupUI.java | 1 + .../edu/rpi/legup/ui/boardview/BoardView.java | 1 + .../rpi/legup/ui/boardview/GridBoardView.java | 3 ++- .../ui/proofeditorui/rulesview/RulePanel.java | 25 ++++++++++++------- .../treeview/TreeToolbarPanel.java | 1 + .../edu/rpi/legup/utility/LegupUtils.java | 4 +-- 39 files changed, 94 insertions(+), 71 deletions(-) diff --git a/src/main/java/edu/rpi/legup/app/Config.java b/src/main/java/edu/rpi/legup/app/Config.java index adae8459a..1847e14e4 100644 --- a/src/main/java/edu/rpi/legup/app/Config.java +++ b/src/main/java/edu/rpi/legup/app/Config.java @@ -25,7 +25,7 @@ public class Config { /** * Config Constructor for logic puzzles * - * @throws InvalidConfigException + * @throws InvalidConfigException if configuration is invalid */ public Config() throws InvalidConfigException { this.puzzles = new Hashtable<>(); diff --git a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java index 55e278c72..2686086a8 100644 --- a/src/main/java/edu/rpi/legup/app/GameBoardFacade.java +++ b/src/main/java/edu/rpi/legup/app/GameBoardFacade.java @@ -187,6 +187,7 @@ public void loadPuzzle(String game, int rows, int columns) throws RuntimeExcepti * Loads a puzzle file * * @param fileName file name of the board file + * @throws InvalidFileFormatException if input is invalid */ public void loadPuzzle(String fileName) throws InvalidFileFormatException { try { @@ -276,7 +277,7 @@ public void loadPuzzleEditor(InputStream inputStream) throws InvalidFileFormatEx /** * Loads a puzzle file from the input stream - * + * @throws InvalidFileFormatException if input is invalid * @param inputStream input stream for the puzzle file */ public void loadPuzzle(InputStream inputStream) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java index 8bc423334..b42f73c9a 100644 --- a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java @@ -29,6 +29,9 @@ public class AutoCaseRuleCommand extends PuzzleCommand { * * @param elementView currently selected puzzle puzzleElement view that is being edited * @param selection currently selected tree puzzleElement views that is being edited + * @param caseRule currently selected caseRule puzzleElement view that is being edited + * @param caseBoard currently selected caseBoard puzzleElement view that is being edited + * @param mouseEvent currently selected mouseEvent puzzleElement view that is being edited */ public AutoCaseRuleCommand(ElementView elementView, TreeViewSelection selection, CaseRule caseRule, CaseBoard caseBoard, MouseEvent mouseEvent) { this.elementView = elementView; diff --git a/src/main/java/edu/rpi/legup/history/ICommand.java b/src/main/java/edu/rpi/legup/history/ICommand.java index 188cee92e..bc82c4df5 100644 --- a/src/main/java/edu/rpi/legup/history/ICommand.java +++ b/src/main/java/edu/rpi/legup/history/ICommand.java @@ -2,12 +2,13 @@ public interface ICommand { /** - * Executes an command + * Executes a command */ void execute(); /** * Determines whether this command can be executed + * @return true if can execute, false otherwise */ boolean canExecute(); @@ -20,12 +21,12 @@ public interface ICommand { String getError(); /** - * Undoes an command + * Undoes a command */ void undo(); /** - * Redoes an command + * Redoes a command */ void redo(); } \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java index 923b17dda..398f17478 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateCaseRuleCommand.java @@ -25,6 +25,7 @@ public class ValidateCaseRuleCommand extends PuzzleCommand { * AutoCaseRuleCommand Constructor creates a command for verifying a case rule * * @param selection currently selected tree puzzleElement views that is being edited + * @param caseRule currently selected caseRule puzzleElement view that is being edited */ public ValidateCaseRuleCommand(TreeViewSelection selection, CaseRule caseRule) { this.selection = selection.copy(); diff --git a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java index c5e2de258..c5f8f0831 100644 --- a/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/ValidateContradictionRuleCommand.java @@ -22,7 +22,7 @@ public class ValidateContradictionRuleCommand extends PuzzleCommand { * ValidateContradictionRuleCommand Constructor creates a puzzle command for verifying a contradiction rule * * @param selection currently selected tree puzzleElement views - * @param rule contradiction rule to set to all of the tree elements + * @param rule contradiction rule to be set to all the tree elements */ public ValidateContradictionRuleCommand(TreeViewSelection selection, ContradictionRule rule) { this.selection = selection.copy(); @@ -32,7 +32,7 @@ public ValidateContradictionRuleCommand(TreeViewSelection selection, Contradicti } /** - * Executes an command + * Executes a command */ @Override public void executeCommand() { @@ -117,7 +117,7 @@ public String getErrorString() { } /** - * Undoes an command + * Undoes a command */ @Override public void undoCommand() { diff --git a/src/main/java/edu/rpi/legup/model/Puzzle.java b/src/main/java/edu/rpi/legup/model/Puzzle.java index 5139d7654..d25afa2cb 100644 --- a/src/main/java/edu/rpi/legup/model/Puzzle.java +++ b/src/main/java/edu/rpi/legup/model/Puzzle.java @@ -248,8 +248,8 @@ public boolean isPuzzleComplete() { /** * Imports the board using the file stream * - * @param fileName - * @throws InvalidFileFormatException + * @param fileName the file that is imported + * @throws InvalidFileFormatException if file is invalid */ public void importPuzzle(String fileName) throws InvalidFileFormatException { try { @@ -264,8 +264,8 @@ public void importPuzzle(String fileName) throws InvalidFileFormatException { /** * Imports the board using the file stream * - * @param inputStream - * @throws InvalidFileFormatException + * @param inputStream the file stream that is imported + * @throws InvalidFileFormatException if file stream is invalid */ public void importPuzzle(InputStream inputStream) throws InvalidFileFormatException { Document document; diff --git a/src/main/java/edu/rpi/legup/model/PuzzleExporter.java b/src/main/java/edu/rpi/legup/model/PuzzleExporter.java index 4b87b03c1..2fd77bd71 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleExporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleExporter.java @@ -26,6 +26,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) { this.puzzle = puzzle; @@ -35,7 +36,7 @@ public PuzzleExporter(Puzzle puzzle) { * Exports the puzzle to an xml formatted file * * @param fileName name of file to be exported - * @throws ExportFileException + * @throws ExportFileException if puzzle can not be exported */ public void exportPuzzle(String fileName) throws ExportFileException { try { diff --git a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java index b72beac68..c2b5b37fc 100644 --- a/src/main/java/edu/rpi/legup/model/PuzzleImporter.java +++ b/src/main/java/edu/rpi/legup/model/PuzzleImporter.java @@ -24,6 +24,7 @@ public abstract class PuzzleImporter { /** * PuzzleImporter Constructor creates the puzzle object + * @param puzzle puzzle that is imported */ public PuzzleImporter(Puzzle puzzle) { this.puzzle = puzzle; @@ -34,7 +35,7 @@ public PuzzleImporter(Puzzle puzzle) { * * @param rows number of rows on the puzzle * @param columns number of columns on the puzzle - * @throws RuntimeException + * @throws RuntimeException if puzzle can not be made */ public void initializePuzzle(int rows, int columns) throws RuntimeException { if (this.puzzle.isValidDimensions(rows, columns)) { @@ -49,7 +50,7 @@ public void initializePuzzle(int rows, int columns) throws RuntimeException { * Initializes the puzzle attributes * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ public void initializePuzzle(Node node) throws InvalidFileFormatException { if (node.getNodeName().equalsIgnoreCase("puzzle")) { @@ -103,7 +104,7 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { * * @param rows number of rows on the puzzle * @param columns number of columns on the puzzle - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ public abstract void initializeBoard(int rows, int columns); @@ -111,7 +112,7 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { * Creates an empty board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ public abstract void initializeBoard(Node node) throws InvalidFileFormatException; @@ -119,7 +120,7 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException { * Creates the proof for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ public void initializeProof(Node node) throws InvalidFileFormatException { if (node.getNodeName().equalsIgnoreCase("proof")) { @@ -153,6 +154,7 @@ public void initializeProof(Node node) throws InvalidFileFormatException { * Sets the puzzleElement from the xml document node * * @param node xml document node + * @throws InvalidFileFormatException if file is invalid */ protected void setCells(Node node) throws InvalidFileFormatException { NodeList dataList = ((org.w3c.dom.Element) node).getElementsByTagName("cell"); @@ -166,8 +168,8 @@ protected void setCells(Node node) throws InvalidFileFormatException { /** * Creates the tree for the edu.rpi.legup.puzzle * - * @param node - * @throws InvalidFileFormatException + * @param node xml document node + * @throws InvalidFileFormatException if file is invalid */ protected void createTree(Node node) throws InvalidFileFormatException { Element treeElement = (org.w3c.dom.Element) node; 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 cc222b809..31ef92359 100644 --- a/src/main/java/edu/rpi/legup/model/tree/Tree.java +++ b/src/main/java/edu/rpi/legup/model/tree/Tree.java @@ -101,7 +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 */ public Set getLeafTreeElements(TreeNode node) { diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellFactory.java index bc244856b..81629c360 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipCellFactory.java @@ -17,7 +17,7 @@ public class BattleshipCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormatException { 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 e63f915e1..aa7209f71 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipImporter.java @@ -18,7 +18,7 @@ public BattleshipImporter(Battleship battleShip) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -29,7 +29,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java index de643d1ca..6994222e3 100644 --- a/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java +++ b/src/main/java/edu/rpi/legup/puzzle/battleship/BattleshipType.java @@ -13,7 +13,7 @@ public enum BattleshipType { /** * Gets the enum of this BattleShipType - * + * @param value the integer value input * @return enum equivalent BattleShipType of integer value */ public static BattleshipType getType(int value) { diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixCellFactory.java index 65061bf2e..fcc48bccd 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixCellFactory.java @@ -17,7 +17,7 @@ public class FillapixCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public FillapixCell importCell(Node node, Board board) throws InvalidFileFormatException { 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 819e56fe7..45ad786e8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixImporter.java @@ -18,7 +18,7 @@ public FillapixImporter(Fillapix fillapix) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be made */ @Override public void initializeBoard(int rows, int columns) { @@ -29,7 +29,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeFactory.java b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeFactory.java index 2b1d329f0..96fc20e6f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeFactory.java @@ -17,7 +17,7 @@ public class HeyawakeFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public HeyawakeCell importCell(Node node, Board board) throws InvalidFileFormatException { 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 2ec326ee0..d09a15389 100644 --- a/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/heyawake/HeyawakeImporter.java @@ -19,7 +19,7 @@ public HeyawakeImporter(Heyawake heyawake) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -30,7 +30,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java index 5cb8353df..4914facfa 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCellFactory.java @@ -17,7 +17,7 @@ public class LightUpCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public LightUpCell importCell(Node node, Board board) throws InvalidFileFormatException { 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 fce5c53ed..fd9fd49e9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpImporter.java @@ -18,7 +18,7 @@ public LightUpImporter(LightUp lightUp) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -41,7 +41,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuCellFactory.java index 27120f097..5278e0036 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuCellFactory.java @@ -17,7 +17,7 @@ public class MasyuCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public MasyuCell importCell(Node node, Board board) throws InvalidFileFormatException { 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 0f439a780..50bf0c0c7 100644 --- a/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/masyu/MasyuImporter.java @@ -18,7 +18,7 @@ public MasyuImporter(Masyu masyu) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -29,7 +29,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCellFactory.java index 47113325b..b754f3e46 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCellFactory.java @@ -17,7 +17,7 @@ public class NurikabeCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public NurikabeCell importCell(Node node, Board board) throws InvalidFileFormatException { 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 0253291c5..7665a4865 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java @@ -18,7 +18,7 @@ public NurikabeImporter(Nurikabe nurikabe) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -39,7 +39,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java index 0e32eb7cf..99d626447 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableCellFactory.java @@ -17,7 +17,7 @@ public class ShortTruthTableCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public ShortTruthTableCell importCell(Node node, Board board) throws InvalidFileFormatException { 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 4e9b7b715..c01fe74d8 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,8 @@ 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 */ public static char toChar(ShortTruthTableCellType type) { if (type == TRUE) return 'T'; @@ -38,7 +40,7 @@ public static char toChar(ShortTruthTableCellType type) { /** * Returns true if this cell holds the value either TRUE or FALSE * - * @return + * @return true if this cell holds the value either TRUE or FALSE */ public boolean isTrueOrFalse() { return value == 0 || value == 1; diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersBoard.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersBoard.java index a8fc3170b..ca6bcbe02 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersBoard.java @@ -51,28 +51,28 @@ public ArrayList getLines() { } /** - * Returns a list of the eastern clues ordered from loc.y = 0 to max + * @return eastClues a list of the eastern clues ordered from loc.y = 0 to max */ public ArrayList getEastClues() { return eastClues; } /** - * Returns a list of the southern clues ordered from loc.x = 0 to max + * @return southClues a list of the southern clues ordered from loc.x = 0 to max */ public ArrayList getSouthClues() { return southClues; } /** - * Returns a list of the western clues ordered from loc.y = 0 to max + * @return westClues a list of the western clues ordered from loc.y = 0 to max */ public ArrayList getWestClues() { return westClues; } /** - * Returns a list of the northern clues ordered from loc.x = 0 to max + * @return northClues a list of the northern clues ordered from loc.x = 0 to max */ public ArrayList getNorthClues() { return northClues; @@ -164,7 +164,7 @@ public void notifyDeletion(PuzzleElement puzzleElement) { * Gets the cells of a certain type directly adjacent to a given cell * * @param cell at the center, - * type of cell to collect + * @param type of cell to collect * @return list of cells of the given type */ public List getAdjacent(SkyscrapersCell cell, SkyscrapersType type) { @@ -193,7 +193,7 @@ public List getAdjacent(SkyscrapersCell cell, SkyscrapersType t * Gets the cells of a certain type directly diagonal to a given cell * * @param cell at the center, - * type of cell to collect + * @param type of cell to collect * @return list of cells of the given type */ public List getDiagonals(SkyscrapersCell cell, SkyscrapersType type) { @@ -222,8 +222,8 @@ public List getDiagonals(SkyscrapersCell cell, SkyscrapersType * Gets the cells of a certain type in a given row/column * * @param index: y pos of row or x pos of col, - * type of cell to collect, - * boolean true if row, false if col + * @param type of cell to collect, + * @param isRow true if row, false if col * @return list of cells of the given type, ordered west to east or north to south */ public List getRowCol(int index, SkyscrapersType type, boolean isRow) { 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 6f0c6edfd..bb4b49b6c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java @@ -17,7 +17,7 @@ public class SkyscrapersCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if input is invalid */ @Override public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java index ff815fcf0..0b2dcbab4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersImporter.java @@ -18,7 +18,7 @@ public SkyscrapersImporter(Skyscrapers skyscrapers) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -29,7 +29,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java index 6e13d70dc..0e1595d03 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java @@ -17,6 +17,7 @@ public class SudokuCell extends GridCell { * @param value value of the sudoku cell * @param location location of the cell on the board * @param groupIndex index of the group the cell is in on the board + * @param size size of the sudoku cell */ public SudokuCell(int value, Point location, int groupIndex, int size) { super(value, location); diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCellFactory.java index e9bafa43a..90f84d519 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCellFactory.java @@ -17,7 +17,7 @@ public class SudokuCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public SudokuCell importCell(Node node, Board board) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java index dcce56946..f77a68d7a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuImporter.java @@ -18,7 +18,7 @@ public SudokuImporter(Sudoku sudoku) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -45,7 +45,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java index e5e7603a6..969ffdf0f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java @@ -17,7 +17,7 @@ public class TreeTentCellFactory extends ElementFactory { * @param node node that represents the puzzleElement * @param board board to add the newly created cell * @return newly created cell from the xml document Node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java index acd094a1b..e48122a7a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentImporter.java @@ -18,7 +18,7 @@ public TreeTentImporter(TreeTent treeTent) { * * @param rows the number of rows on the board * @param columns the number of columns on the board - * @throws RuntimeException + * @throws RuntimeException if board can not be created */ @Override public void initializeBoard(int rows, int columns) { @@ -50,7 +50,7 @@ public void initializeBoard(int rows, int columns) { * Creates the board for building * * @param node xml document node - * @throws InvalidFileFormatException + * @throws InvalidFileFormatException if file is invalid */ @Override public void initializeBoard(Node node) throws InvalidFileFormatException { diff --git a/src/main/java/edu/rpi/legup/ui/LegupUI.java b/src/main/java/edu/rpi/legup/ui/LegupUI.java index 9eb1977aa..82ef7dc44 100644 --- a/src/main/java/edu/rpi/legup/ui/LegupUI.java +++ b/src/main/java/edu/rpi/legup/ui/LegupUI.java @@ -27,6 +27,7 @@ public class LegupUI extends JFrame implements WindowListener { /** * Identifies operating system + * @return operating system, either mac or win */ public static String getOS() { String os = System.getProperty("os.name").toLowerCase(); diff --git a/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java b/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java index 77e6449e4..602672a9e 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/BoardView.java @@ -24,6 +24,7 @@ public abstract class BoardView extends ScrollView implements IBoardListener { * BoardView Constructor creates a view for the board object using the controller handle the ui events * * @param boardController controller that handles the ui events + * @param elementController controller that handles the ui events */ public BoardView(BoardController boardController, ElementController elementController) { super(boardController); diff --git a/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java b/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java index e851d14d7..5fdacc6b0 100644 --- a/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java +++ b/src/main/java/edu/rpi/legup/ui/boardview/GridBoardView.java @@ -14,7 +14,8 @@ public class GridBoardView extends BoardView { * GridBoardView Constructor creates a GridBoardView object using the controller handle the ui events * * @param boardController controller that handles the ui events - * @param gridSize dimension of the grid + * @param gridSize dimension of the grid + * @param elementController controller that handles the ui events */ public GridBoardView(BoardController boardController, ElementController elementController, Dimension gridSize) { this(boardController, elementController); diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java index 411b7bc4c..f11fee5b4 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/rulesview/RulePanel.java @@ -80,13 +80,14 @@ public void updateRules() { /** * Search a certain rule in all the puzzles and set it for the searchBarPanel * - * @param puzzle, ruleName - *

- * This function is the searching algorithm for "public void setSearchBar(Puzzle allPuzzle)" (below) - *

- * It takes two param Puzzle puzzle and String ruleName - * puzzle contains rules, this function will compare each rule of puzzle with ruleName, - * to find exact same, similar rules, or all the rules with same start letter (if input is a signal letter) + * @param puzzle puzzle where the rule is being searched for + * @param ruleName rule that is being compared to each puzzle + * + * This function is the searching algorithm for "public void setSearchBar(Puzzle allPuzzle)" (below) + * + * It takes two param Puzzle puzzle and String ruleName + * puzzle contains rules, this function will compare each rule of puzzle with ruleName, + * to find exact same, similar rules, or all the rules with same start letter (if input is a signal letter) */ public void searchForRule(Puzzle puzzle, String ruleName) { @@ -160,9 +161,11 @@ public void searchForRule(Puzzle puzzle, String ruleName) { /** * Calculates the similarity (a number within 0 and 1) between two strings. - * This funtion will take two para String s1 and String s2, which s1 is the user's input + * This function will take two para String s1 and String s2, which s1 is the user's input * and s2 is the compared really rule name - *

+ * @param s1 user's input + * @param s2 the compared really rule name + * @return a similarity degree between 0 and 1 * similarityCheck will use a helper function to calculate a similarity degree(from 0 to 1). * closer to 0 means less similar, and closer to 1 means more similar. */ @@ -181,6 +184,9 @@ public static double similarityCheck(String s1, String s2) { /** * Help function for similarityCheck(); + * @param s1 user's input + * @param s2 the compared really rule name + * @return a similarity degree between 0 and 1 */ public static int editDistance(String s1, String s2) { s1 = s1.toLowerCase(); @@ -216,6 +222,7 @@ public static int editDistance(String s1, String s2) { * search bar allows user to input a name to get relative rules * once a name is entered and click ok will load (a/several) rule icon, * which has all the functions just as other rule icons. + * @param allPuzzle name of rule input */ public void setSearchBar(Puzzle allPuzzle) { diff --git a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java index d0b25257a..332fd64a0 100644 --- a/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java +++ b/src/main/java/edu/rpi/legup/ui/proofeditorui/treeview/TreeToolbarPanel.java @@ -9,6 +9,7 @@ public class TreeToolbarPanel extends JPanel { /** * TreeToolbarPanel Constructor - creates the tree tool mBar panel + * @param treePanel treePanel input */ public TreeToolbarPanel(TreePanel treePanel) { this.treePanel = treePanel; diff --git a/src/main/java/edu/rpi/legup/utility/LegupUtils.java b/src/main/java/edu/rpi/legup/utility/LegupUtils.java index 8c09cfd1e..dbdd24e7f 100644 --- a/src/main/java/edu/rpi/legup/utility/LegupUtils.java +++ b/src/main/java/edu/rpi/legup/utility/LegupUtils.java @@ -21,8 +21,8 @@ public class LegupUtils { * * @param packageName The base package * @return The classes - * @throws ClassNotFoundException - * @throws IOException + * @throws ClassNotFoundException if class is not in package + * @throws IOException if file is not found */ public static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException { From 0d4f5bb157541e9d9f0936cc660ad9c714ca84f3 Mon Sep 17 00:00:00 2001 From: 25tallurich <93100501+25tallurich@users.noreply.github.com> Date: Fri, 21 Apr 2023 16:31:44 -0400 Subject: [PATCH 21/42] Reset puzzle (#527) * Reset button attempt 1 * Reset button attempt works * checkstyle fix * checkstyle fix * checkstyle fix --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Ivan Ho <41582274+Corppet@users.noreply.github.com> --- src/main/java/edu/rpi/legup/model/tree/TreeNode.java | 5 +++++ src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/edu/rpi/legup/model/tree/TreeNode.java b/src/main/java/edu/rpi/legup/model/tree/TreeNode.java index dc4e2a587..59f6e736e 100644 --- a/src/main/java/edu/rpi/legup/model/tree/TreeNode.java +++ b/src/main/java/edu/rpi/legup/model/tree/TreeNode.java @@ -328,4 +328,9 @@ public boolean isRoot() { public void setRoot(boolean isRoot) { this.isRoot = isRoot; } + + public void clearChildren() { + this.children.clear(); + } + } \ No newline at end of file diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index b27c4bb05..86a0ca2c1 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -220,10 +220,14 @@ public JMenuBar getMenuBar() { if (rootNode != null) { int confirmReset = JOptionPane.showConfirmDialog(this, "Reset Puzzle to Root Node?", "Confirm Reset", JOptionPane.YES_NO_OPTION); if (confirmReset == JOptionPane.YES_OPTION) { + List children = rootNode.getChildren(); children.forEach(t -> puzzle.notifyTreeListeners(l -> l.onTreeElementRemoved(t))); + children.forEach(t -> puzzle.notifyBoardListeners(l -> l.onTreeElementChanged(t))); + rootNode.clearChildren(); final TreeViewSelection selection = new TreeViewSelection(treePanel.getTreeView().getElementView(rootNode)); puzzle.notifyTreeListeners(l -> l.onTreeSelectionChanged(selection)); + puzzle.notifyBoardListeners(listener -> listener.onTreeElementChanged(selection.getFirstSelection().getTreeElement())); GameBoardFacade.getInstance().getHistory().clear(); } } From ee7b4f37d31fc3a43c398815a6032738d84e95ae Mon Sep 17 00:00:00 2001 From: ErinECohen <73081649+ErinECohen@users.noreply.github.com> Date: Fri, 21 Apr 2023 16:46:04 -0400 Subject: [PATCH 22/42] Update NurikabeCell.java to use .getElementID instead of .getElementName Update NurikabeCell.java to use .getElementID instead of .getElementName --- .../java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java index 373f7550c..554899d34 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java @@ -46,12 +46,12 @@ public NurikabeType getType() { */ @Override public void setType(Element e, MouseEvent m) { - switch (e.getElementName()){ - case "Black Tile": + switch (e.getElementID()){ + case "NURI-PLAC-0001": this.data = -1; - case "White Tile": + case "NURI-PLAC-0002": this.data = 0; - case "Number Tile": + case "NURI-UNPL-0001": switch (m.getButton()){ case MouseEvent.BUTTON1: if (this.data <= 0 || this.data > 8) { From 8f58caefb31a49dd3581c67842ef070c5be2a797 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 25 Apr 2023 10:40:10 -0400 Subject: [PATCH 23/42] Added break statements to switch statements --- .../java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java index 554899d34..f84a3c9f1 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeCell.java @@ -49,8 +49,10 @@ public void setType(Element e, MouseEvent m) { switch (e.getElementID()){ case "NURI-PLAC-0001": this.data = -1; + break; case "NURI-PLAC-0002": this.data = 0; + break; case "NURI-UNPL-0001": switch (m.getButton()){ case MouseEvent.BUTTON1: @@ -60,6 +62,7 @@ public void setType(Element e, MouseEvent m) { else { this.data = this.data + 1; } + break; case MouseEvent.BUTTON3: if (this.data > 1) { this.data = this.data - 1; @@ -67,9 +70,12 @@ public void setType(Element e, MouseEvent m) { else { this.data = 9; } + break; } + break; default: this.data = -2; + break; } } From 9c874d0f64e93e61ea6343e5d489d657df20689e Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 25 Apr 2023 10:58:27 -0400 Subject: [PATCH 24/42] Attempting to fix Javadocs issue --- .github/workflows/publish-javadoc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-javadoc.yml b/.github/workflows/publish-javadoc.yml index 2e02596fb..2430dabbb 100644 --- a/.github/workflows/publish-javadoc.yml +++ b/.github/workflows/publish-javadoc.yml @@ -6,6 +6,8 @@ on: push: branches: - dev + permissions: + contents: write jobs: publish: From 1834daa35593839553a6100a7f0c01e7dfb6c4ff Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Tue, 25 Apr 2023 11:03:56 -0400 Subject: [PATCH 25/42] Retrying Javadocs changes --- .github/workflows/publish-javadoc.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-javadoc.yml b/.github/workflows/publish-javadoc.yml index 2430dabbb..37eac9482 100644 --- a/.github/workflows/publish-javadoc.yml +++ b/.github/workflows/publish-javadoc.yml @@ -6,8 +6,8 @@ on: push: branches: - dev - permissions: - contents: write +permissions: + contents: write jobs: publish: From 8dfa6ef278a2ba5ab50ac3d07ead238c0eb4437d Mon Sep 17 00:00:00 2001 From: Matthew Mosley Date: Fri, 28 Apr 2023 01:04:19 -0400 Subject: [PATCH 26/42] Finding initial issue and starting fix --- .../CannotFillMiddle | 0 .../CannotFillCorners | 13 ---------- .../CannotFillMiddle | 11 --------- .../BlockEnclosed | 13 ---------- .../CompleteBoardBlockEnclosed | 15 ------------ .../CornerBlockEnclosed | 11 --------- .../ManyBlocksEnclosed | 17 ------------- .../BlockEnclosed | 13 ---------- .../CompleteBoardBlockEnclosed | 15 ------------ .../CornerBlockEnclosed | 11 --------- .../ManyBlocksEnclosed | 17 ------------- .../shorttruthtable/ShortTruthTableBoard.java | 24 +++++++++++++++++++ .../ShortTruthTableExporter.java | 3 ++- 13 files changed, 26 insertions(+), 137 deletions(-) delete mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle 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/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/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/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index d084cd2ff..8a0b6de64 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -1,5 +1,6 @@ package edu.rpi.legup.puzzle.shorttruthtable; +import edu.rpi.legup.model.elements.Element; import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; @@ -7,6 +8,7 @@ import edu.rpi.legup.puzzle.shorttruthtable.*; import java.awt.*; +import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -24,6 +26,28 @@ public ShortTruthTableBoard(int width, int height, ShortTruthTableStatement[] st } + @Override + public void setCell(int x, int y, Element e, MouseEvent m) { + System.out.println("Setting Cell"); + if (e != null && y * dimension.width + x >= puzzleElements.size() || x >= dimension.width || + y >= dimension.height || x < 0 || y < 0) { + return; + } + else { + if (e != null) { + puzzleElements.get(y * dimension.width + x).setType(e, m); + for (ShortTruthTableStatement s : statements) { + for (int i = 0; i < s.getLength(); i++) { + if (s.getCell(i).getX() == x && s.getCell(i).getY() == y) { + System.out.println("Setting Statement"); + s.getCell(i).setType(e, m); + //s.getStringRep(). + } + } + } + } + } + } public Set getCellsWithSymbol(char symbol) { Set cells = new HashSet(); 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..4a3f3c269 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java @@ -13,7 +13,7 @@ public ShortTruthTableExporter(ShortTruthTable stt) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { ShortTruthTableBoard board = (ShortTruthTableBoard) puzzle.getTree().getRootNode().getBoard(); - + System.out.println(board.toString()); org.w3c.dom.Element boardElement = newDocument.createElement("board"); org.w3c.dom.Element dataElement = newDocument.createElement("data"); @@ -21,6 +21,7 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { ShortTruthTableStatement[] statements = board.getStatements(); for (int i = 0; i < statements.length; i++) { org.w3c.dom.Element statementElement = newDocument.createElement("statement"); + System.out.println(statements[i].toString()); statementElement.setAttribute("representation", statements[i].getStringRep()); statementElement.setAttribute("row_index", String.valueOf(i)); dataElement.appendChild(statementElement); From 12ee63b0b7c6be90c2889554099fc2f3c169615b Mon Sep 17 00:00:00 2001 From: Matthew Mosley Date: Fri, 28 Apr 2023 02:30:12 -0400 Subject: [PATCH 27/42] Issue is statement copying and modifying --- .../shorttruthtable/ShortTruthTableBoard.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index 8a0b6de64..8693f087e 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -36,13 +36,38 @@ public void setCell(int x, int y, Element e, MouseEvent m) { else { if (e != null) { puzzleElements.get(y * dimension.width + x).setType(e, m); + int count = 0; for (ShortTruthTableStatement s : statements) { for (int i = 0; i < s.getLength(); i++) { if (s.getCell(i).getX() == x && s.getCell(i).getY() == y) { System.out.println("Setting Statement"); - s.getCell(i).setType(e, m); + + List cells = new ArrayList(); + for (int c = 0; c < s.getLength(); c++) { + System.out.println(c); + if (i == c) { + ShortTruthTableCell newC = new ShortTruthTableCell(s.getCell(i).getSymbol(), s.getCell(i).getType(), s.getCell(i).getLocation()); + newC.setType(e,m); + cells.add(newC); + } else { + cells.add(s.getCell(c)); + } + } + + + System.out.println(s.getStringRep()); + String newS = s.getStringRep().substring(0, i) + cells.get(i).getSymbol() + s.getStringRep().substring(i + 1); + System.out.println(newS); + //ShortTruthTableStatement parent = s.getParentStatement(); + + ShortTruthTableStatement temp = new ShortTruthTableStatement(newS, cells); + System.out.println(temp.getStringRep()); + statements[count] = temp; + System.out.println(statements[count]); + //s.getCell(i).setType(e, m); //s.getStringRep(). } + count++; } } } From 8d444863c7ea2be933e2b875f1269edf9ceae404 Mon Sep 17 00:00:00 2001 From: Matthew Mosley Date: Fri, 28 Apr 2023 15:12:06 -0400 Subject: [PATCH 28/42] STT exporter now working. Overrode setCell for STTBoard. --- .../shorttruthtable/ShortTruthTableBoard.java | 14 +------------- .../shorttruthtable/ShortTruthTableExporter.java | 1 - 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index 8693f087e..51e134f1b 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -40,35 +40,23 @@ public void setCell(int x, int y, Element e, MouseEvent m) { for (ShortTruthTableStatement s : statements) { for (int i = 0; i < s.getLength(); i++) { if (s.getCell(i).getX() == x && s.getCell(i).getY() == y) { - System.out.println("Setting Statement"); List cells = new ArrayList(); for (int c = 0; c < s.getLength(); c++) { - System.out.println(c); if (i == c) { ShortTruthTableCell newC = new ShortTruthTableCell(s.getCell(i).getSymbol(), s.getCell(i).getType(), s.getCell(i).getLocation()); - newC.setType(e,m); cells.add(newC); } else { cells.add(s.getCell(c)); } } - - System.out.println(s.getStringRep()); String newS = s.getStringRep().substring(0, i) + cells.get(i).getSymbol() + s.getStringRep().substring(i + 1); - System.out.println(newS); - //ShortTruthTableStatement parent = s.getParentStatement(); - ShortTruthTableStatement temp = new ShortTruthTableStatement(newS, cells); - System.out.println(temp.getStringRep()); statements[count] = temp; - System.out.println(statements[count]); - //s.getCell(i).setType(e, m); - //s.getStringRep(). } - count++; } + count++; } } } 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 4a3f3c269..b37a7214c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java @@ -13,7 +13,6 @@ public ShortTruthTableExporter(ShortTruthTable stt) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { ShortTruthTableBoard board = (ShortTruthTableBoard) puzzle.getTree().getRootNode().getBoard(); - System.out.println(board.toString()); org.w3c.dom.Element boardElement = newDocument.createElement("board"); org.w3c.dom.Element dataElement = newDocument.createElement("data"); From 25d2585fc14286cdc0b840e38dacb6cb3b99b393 Mon Sep 17 00:00:00 2001 From: Matthew Mosley Date: Fri, 28 Apr 2023 16:12:15 -0400 Subject: [PATCH 29/42] Added code documentation --- .../puzzle/shorttruthtable/ShortTruthTableBoard.java | 11 ++++++++++- .../shorttruthtable/ShortTruthTableExporter.java | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index 51e134f1b..59066b2b5 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -26,6 +26,12 @@ public ShortTruthTableBoard(int width, int height, ShortTruthTableStatement[] st } + /** + * Sets ShortTruthTable cell at position (x,y) + * @param x position on the x axis + * @param y position on the y axis + * @param e element to set the type of this ShortTruthTable cell to + */ @Override public void setCell(int x, int y, Element e, MouseEvent m) { System.out.println("Setting Cell"); @@ -37,11 +43,12 @@ public void setCell(int x, int y, Element e, MouseEvent m) { if (e != null) { puzzleElements.get(y * dimension.width + x).setType(e, m); int count = 0; + // remakes statement that included original cell to include new cell for (ShortTruthTableStatement s : statements) { for (int i = 0; i < s.getLength(); i++) { if (s.getCell(i).getX() == x && s.getCell(i).getY() == y) { - List cells = new ArrayList(); + // adds new cell to cell list for (int c = 0; c < s.getLength(); c++) { if (i == c) { ShortTruthTableCell newC = new ShortTruthTableCell(s.getCell(i).getSymbol(), s.getCell(i).getType(), s.getCell(i).getLocation()); @@ -51,7 +58,9 @@ public void setCell(int x, int y, Element e, MouseEvent m) { } } + // modifies StringRep String newS = s.getStringRep().substring(0, i) + cells.get(i).getSymbol() + s.getStringRep().substring(i + 1); + // makes modified statement ShortTruthTableStatement temp = new ShortTruthTableStatement(newS, cells); statements[count] = temp; } 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 b37a7214c..a8d98f513 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java @@ -20,7 +20,6 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { ShortTruthTableStatement[] statements = board.getStatements(); for (int i = 0; i < statements.length; i++) { org.w3c.dom.Element statementElement = newDocument.createElement("statement"); - System.out.println(statements[i].toString()); statementElement.setAttribute("representation", statements[i].getStringRep()); statementElement.setAttribute("row_index", String.valueOf(i)); dataElement.appendChild(statementElement); From 52344ea7e284be02d3a4c074c303e3d863886901 Mon Sep 17 00:00:00 2001 From: Matthew Mosley Date: Fri, 28 Apr 2023 16:26:14 -0400 Subject: [PATCH 30/42] removed testing println() --- .../rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index 59066b2b5..6eb5dd2c4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -34,7 +34,6 @@ public ShortTruthTableBoard(int width, int height, ShortTruthTableStatement[] st */ @Override public void setCell(int x, int y, Element e, MouseEvent m) { - System.out.println("Setting Cell"); if (e != null && y * dimension.width + x >= puzzleElements.size() || x >= dimension.width || y >= dimension.height || x < 0 || y < 0) { return; From 1d1a562949d04165594b5e00f5e17500560d56bc Mon Sep 17 00:00:00 2001 From: Matthew Mosley Date: Fri, 28 Apr 2023 16:40:41 -0400 Subject: [PATCH 31/42] Gradle fixes --- .../legup/puzzle/shorttruthtable/ShortTruthTable.java | 10 ++++++---- .../puzzle/shorttruthtable/ShortTruthTableBoard.java | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) 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 4849baf40..65a9eac97 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java @@ -64,13 +64,15 @@ public boolean isValidDimensions(int rows, int columns) { * @return true if the statements are valid for Short Truth Table, false otherwise */ public boolean isValidTextInput(String[] statements) { - if (statements.length == 0) + if (statements.length == 0) { return false; - + } ShortTruthTableImporter importer = (ShortTruthTableImporter) this.getImporter(); - for (String s : statements) - if (!importer.validGrammar(s)) + for (String s : statements) { + if (!importer.validGrammar(s)) { return false; + } + } return true; } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index 6eb5dd2c4..77f1534d1 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -52,7 +52,8 @@ public void setCell(int x, int y, Element e, MouseEvent m) { if (i == c) { ShortTruthTableCell newC = new ShortTruthTableCell(s.getCell(i).getSymbol(), s.getCell(i).getType(), s.getCell(i).getLocation()); cells.add(newC); - } else { + } + else { cells.add(s.getCell(c)); } } From 0285505319b56cf361e603054b84dcd40153f5e0 Mon Sep 17 00:00:00 2001 From: charlestian23 Date: Fri, 28 Apr 2023 17:21:41 -0400 Subject: [PATCH 32/42] Revert "Merge pull request #545 from MMosley502/puzzle_editor-short_truth_table-file_saving" This reverts commit 2e82547896a7fb3e52ec27634cd8938ef299732f, reversing changes made to beb60a2ab67c8317d404f54e52471739f698bf22. --- .../CannotFillMiddle | 0 .../CannotFillCorners | 13 ++++++ .../CannotFillMiddle | 11 +++++ .../BlockEnclosed | 13 ++++++ .../CompleteBoardBlockEnclosed | 15 ++++++ .../CornerBlockEnclosed | 11 +++++ .../ManyBlocksEnclosed | 17 +++++++ .../BlockEnclosed | 13 ++++++ .../CompleteBoardBlockEnclosed | 15 ++++++ .../CornerBlockEnclosed | 11 +++++ .../ManyBlocksEnclosed | 17 +++++++ .../shorttruthtable/ShortTruthTable.java | 10 ++-- .../shorttruthtable/ShortTruthTableBoard.java | 46 ------------------- .../ShortTruthTableExporter.java | 1 + 14 files changed, 141 insertions(+), 52 deletions(-) create mode 100644 build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle create mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners create mode 100644 build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed create mode 100644 build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed diff --git a/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle b/build/resources/test/puzzles/lightup/rules/BulbsInPathContradictionRule/CannotFillMiddle new file mode 100644 index 000000000..e69de29bb diff --git a/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners new file mode 100644 index 000000000..38b52f04d --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillCorners @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..44086f145 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/CannotLightACellContradictionRule/CannotFillMiddle @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..a57a2473e --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/BlockEnclosed @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..f48d240f0 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CompleteBoardBlockEnclosed @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..1a9cd60d9 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/CornerBlockEnclosed @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..32200d831 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooFewBulbsContradictionRule/ManyBlocksEnclosed @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..c5760aede --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/BlockEnclosed @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..88fb0a8f1 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CompleteBoardBlockEnclosed @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..a9a8dc5a0 --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/CornerBlockEnclosed @@ -0,0 +1,11 @@ + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..e743862eb --- /dev/null +++ b/build/resources/test/puzzles/lightup/rules/TooManyBulbsContradictionRule/ManyBlocksEnclosed @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file 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 65a9eac97..4849baf40 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTable.java @@ -64,15 +64,13 @@ public boolean isValidDimensions(int rows, int columns) { * @return true if the statements are valid for Short Truth Table, false otherwise */ public boolean isValidTextInput(String[] statements) { - if (statements.length == 0) { + if (statements.length == 0) return false; - } + ShortTruthTableImporter importer = (ShortTruthTableImporter) this.getImporter(); - for (String s : statements) { - if (!importer.validGrammar(s)) { + for (String s : statements) + if (!importer.validGrammar(s)) return false; - } - } return true; } diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index 77f1534d1..d084cd2ff 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -1,6 +1,5 @@ package edu.rpi.legup.puzzle.shorttruthtable; -import edu.rpi.legup.model.elements.Element; import edu.rpi.legup.model.gameboard.Board; import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; @@ -8,7 +7,6 @@ import edu.rpi.legup.puzzle.shorttruthtable.*; import java.awt.*; -import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -26,50 +24,6 @@ public ShortTruthTableBoard(int width, int height, ShortTruthTableStatement[] st } - /** - * Sets ShortTruthTable cell at position (x,y) - * @param x position on the x axis - * @param y position on the y axis - * @param e element to set the type of this ShortTruthTable cell to - */ - @Override - public void setCell(int x, int y, Element e, MouseEvent m) { - if (e != null && y * dimension.width + x >= puzzleElements.size() || x >= dimension.width || - y >= dimension.height || x < 0 || y < 0) { - return; - } - else { - if (e != null) { - puzzleElements.get(y * dimension.width + x).setType(e, m); - int count = 0; - // remakes statement that included original cell to include new cell - for (ShortTruthTableStatement s : statements) { - for (int i = 0; i < s.getLength(); i++) { - if (s.getCell(i).getX() == x && s.getCell(i).getY() == y) { - List cells = new ArrayList(); - // adds new cell to cell list - for (int c = 0; c < s.getLength(); c++) { - if (i == c) { - ShortTruthTableCell newC = new ShortTruthTableCell(s.getCell(i).getSymbol(), s.getCell(i).getType(), s.getCell(i).getLocation()); - cells.add(newC); - } - else { - cells.add(s.getCell(c)); - } - } - - // modifies StringRep - String newS = s.getStringRep().substring(0, i) + cells.get(i).getSymbol() + s.getStringRep().substring(i + 1); - // makes modified statement - ShortTruthTableStatement temp = new ShortTruthTableStatement(newS, cells); - statements[count] = temp; - } - } - count++; - } - } - } - } public Set getCellsWithSymbol(char symbol) { Set cells = new HashSet(); 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 a8d98f513..bcb744789 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableExporter.java @@ -13,6 +13,7 @@ public ShortTruthTableExporter(ShortTruthTable stt) { @Override protected org.w3c.dom.Element createBoardElement(Document newDocument) { ShortTruthTableBoard board = (ShortTruthTableBoard) puzzle.getTree().getRootNode().getBoard(); + org.w3c.dom.Element boardElement = newDocument.createElement("board"); org.w3c.dom.Element dataElement = newDocument.createElement("data"); From 9d9484dffcece147e9009c07d30459685a3527cd Mon Sep 17 00:00:00 2001 From: 19690ao Date: Sat, 6 May 2023 21:37:29 -0400 Subject: [PATCH 33/42] Typo --- .../edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md | 2 +- .../shorttruthtable/ShortTruthTableImporter.java | 10 +++++----- .../edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/main/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md b/bin/main/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md index 94ef1e214..4695f25f2 100644 --- a/bin/main/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md +++ b/bin/main/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md @@ -11,7 +11,7 @@ spreadsheet : https://docs.google.com/spreadsheets/d/1l7aUZtavtysM8dtGnaEIXhBKMR 4. Refactoring: - document utility functions in the reference sheet, COMMENTS! - review and identify dead code - - remove all these damn print statments (commented ones too if they aren't useful) + - remove all these damn print statements (commented ones too if they aren't useful) - Edit to allow blank clues - Display flags somewhere 5. Flags 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 347175867..cccdbca19 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableImporter.java @@ -22,7 +22,7 @@ public ShortTruthTableImporter(ShortTruthTable stt) { /** - * Parse a string into all te cells, the y position of the statement is passed so the y position can be set + * Parse a string into all the cells, the y position of the statement is passed so the y position can be set * * @param statement * @param y @@ -54,7 +54,7 @@ private List getCells(String statement, int y) { * @param statements returns all the statements * @return the length, in chars, of the longest statement */ - private int parseAllStatmentsAndCells(final NodeList statementData, + private int parseAllStatementsAndCells(final NodeList statementData, List> allCells, List statements) throws InvalidFileFormatException { @@ -167,7 +167,7 @@ private ShortTruthTableBoard generateBoard(List> allCe //get the cell at this location; or create a not_in_play one if necessary ShortTruthTableCell cell = null; - //for a cell to exist at (x, y), it must be a valid row and within the statment length + //for a cell to exist at (x, y), it must be a valid row and within the statement length if (y % 2 == 0 && x < statements.get(statementIndex).getLength()) { cell = allCells.get(statementIndex).get(x); System.out.println("Importer: check cell statement ref: " + cell.getStatementReference()); @@ -195,7 +195,7 @@ private void setGivenCells(ShortTruthTableBoard sttBoard, List statements) throws InvalidFileFormatException { - //if it is normal, set all predicats to true and the conclusion to false + //if it is normal, set all predicates to true and the conclusion to false if (dataElement.getAttribute("normal").equalsIgnoreCase("true")) { //set all predicates to true (all but the last one) for (int i = 0; i < statements.size() - 1; i++) { @@ -264,7 +264,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException { //Parse the data - int maxStatementLength = parseAllStatmentsAndCells(statementData, allCells, statements); + int maxStatementLength = parseAllStatementsAndCells(statementData, allCells, statements); //generate the board ShortTruthTableBoard sttBoard = generateBoard(allCells, statements, maxStatementLength); diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md index d0be95913..60a8bd19d 100644 --- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md +++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/TODO.md @@ -11,7 +11,7 @@ spreadsheet : https://docs.google.com/spreadsheets/d/1l7aUZtavtysM8dtGnaEIXhBKMR 4. Refactoring: - document utility functions in the reference sheet, COMMENTS! - review and identify dead code - - remove all these damn print statments (commented ones too if they aren't useful) + - remove all these damn print statements (commented ones too if they aren't useful) - Edit to allow blank clues - Display flags somewhere 5. Flags From f3e47f63af66bbf4fb2a540fc92bd1d4a45e868c Mon Sep 17 00:00:00 2001 From: 19690ao Date: Thu, 1 Jun 2023 20:19:37 -0400 Subject: [PATCH 34/42] Typecast getCell --- .../legup/puzzle/shorttruthtable/ShortTruthTableBoard.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index d084cd2ff..4e122b47f 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -4,6 +4,7 @@ import edu.rpi.legup.model.gameboard.GridBoard; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.lightup.LightUpCell; import edu.rpi.legup.puzzle.shorttruthtable.*; import java.awt.*; @@ -42,6 +43,11 @@ public ShortTruthTableCell getCellFromElement(PuzzleElement element) { return (ShortTruthTableCell) getPuzzleElement(element); } + @Override + public ShortTruthTableCell getCell(int x, int y) { + return (ShortTruthTableCell) super.getCell(x, y); + } + @Override public ShortTruthTableBoard copy() { From d195c2ba75f8be7b6e7bdffd9e602e5c413b9cf4 Mon Sep 17 00:00:00 2001 From: 19690ao Date: Fri, 2 Jun 2023 04:23:55 -0400 Subject: [PATCH 35/42] Override notifyChange --- .../shorttruthtable/ShortTruthTableBoard.java | 11 +++++++++++ .../shorttruthtable/ShortTruthTableStatement.java | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java index 4e122b47f..e5011182a 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableBoard.java @@ -99,6 +99,17 @@ public static List copyStatementList(List cellsCopy = new ArrayList<>(); + for (ShortTruthTableCell c : cells) { + if (c.getX() == column) { + cellsCopy.add(cell); + } else { + cellsCopy.add(c.copy()); + } + } + //make a copy of the statement with all the copied cells + //return the new statement + return new ShortTruthTableStatement(stringRep, cellsCopy); + } + } \ No newline at end of file From e6c781b323a17e1153fb170949769df90a9854dd Mon Sep 17 00:00:00 2001 From: 19690ao Date: Fri, 2 Jun 2023 04:37:00 -0400 Subject: [PATCH 36/42] Checkstyle --- .../legup/puzzle/shorttruthtable/ShortTruthTableStatement.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java index 58c20c0fe..e5f35fa67 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java @@ -301,7 +301,8 @@ public ShortTruthTableStatement replace(int column, ShortTruthTableCell cell) { for (ShortTruthTableCell c : cells) { if (c.getX() == column) { cellsCopy.add(cell); - } else { + } + else { cellsCopy.add(c.copy()); } } From e87de2c688c84397d6d0f6a4e7666e5ba0284db8 Mon Sep 17 00:00:00 2001 From: 19690ao Date: Fri, 2 Jun 2023 13:46:58 -0400 Subject: [PATCH 37/42] Reduce Warnings --- .../shorttruthtable/ShortTruthTableStatement.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java index e5f35fa67..ca217575c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java @@ -95,7 +95,7 @@ static String removeParens(String statement) { if (c == ')') openParenCount--; } - //if the first paren has been closed and it is not the end of the string, + //if the first paren has been closed, and it is not the end of the string, //then there is no whole statement parens to remove if (openParenCount == 0 && i != statement.length() - 1) { return statement; @@ -164,7 +164,7 @@ static void removeParens(List cells) { if (c == ')') openParenCount--; } - //if the first paren has been closed and it is not the end of the string, + //if the first paren has been closed, and it is not the end of the string, //then there is no whole statement parens to remove if (openParenCount == 0 && i != cells.size() - 1) { return; @@ -241,7 +241,7 @@ public Set getCellsWithSymbol(char symbol) { * Returns an array of three elements where [0] is the left * statement type, [1] is this statement type, and [2] is the * right statement type. null means either the statement doesn't - * exist or is is an unknown value. + * exist or is an unknown value. * * @return the assigned values to this statement and its sub-statements */ @@ -285,14 +285,13 @@ public void setCellLocations(int rowIndex) { public ShortTruthTableStatement copy() { //copy all the cells - List cellsCopy = new ArrayList(); + List cellsCopy = new ArrayList<>(); for (ShortTruthTableCell c : cells) { cellsCopy.add(c.copy()); } //make a copy of the statement with all the copied cells - ShortTruthTableStatement statementCopy = new ShortTruthTableStatement(stringRep, cellsCopy); //return the new statement - return statementCopy; + return new ShortTruthTableStatement(stringRep, cellsCopy); } public ShortTruthTableStatement replace(int column, ShortTruthTableCell cell) { From 14561ed19ecc62d1f7370c07d5fed915aedd2122 Mon Sep 17 00:00:00 2001 From: 19690ao Date: Fri, 2 Jun 2023 14:37:21 -0400 Subject: [PATCH 38/42] Don't Copy Cells (replace) --- .../legup/puzzle/shorttruthtable/ShortTruthTableStatement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java index ca217575c..e40a10cf0 100644 --- a/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java +++ b/src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableStatement.java @@ -302,7 +302,7 @@ public ShortTruthTableStatement replace(int column, ShortTruthTableCell cell) { cellsCopy.add(cell); } else { - cellsCopy.add(c.copy()); + cellsCopy.add(c); } } //make a copy of the statement with all the copied cells From ef12e8fccb538072c6508272945422a229035f86 Mon Sep 17 00:00:00 2001 From: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Date: Thu, 15 Jun 2023 04:24:17 -0700 Subject: [PATCH 39/42] Get Tests to be called Revert "Create first cypress test template" This reverts commit 3e50909b93b5aa9634cf0d296e9aeff756b0a909. First commit Finish Lightup tests --- src/test/java/legup/TestUtilities.java | 9 ++++ .../puzzles/battleship/rules/TestRunner.java | 53 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/test/java/puzzles/battleship/rules/TestRunner.java diff --git a/src/test/java/legup/TestUtilities.java b/src/test/java/legup/TestUtilities.java index 9f203b223..d49529921 100644 --- a/src/test/java/legup/TestUtilities.java +++ b/src/test/java/legup/TestUtilities.java @@ -6,6 +6,11 @@ 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 { @@ -16,4 +21,8 @@ public static void importTestBoard(String fileName, Puzzle puzzle) throws Invali TreeTransition transition = new TreeTransition(rootNode, board); rootNode.getChildren().add(transition); } + + } + + diff --git a/src/test/java/puzzles/battleship/rules/TestRunner.java b/src/test/java/puzzles/battleship/rules/TestRunner.java new file mode 100644 index 000000000..077f3a5d8 --- /dev/null +++ b/src/test/java/puzzles/battleship/rules/TestRunner.java @@ -0,0 +1,53 @@ +package puzzles.battleship.rules; + + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import puzzles.lightup.rules.*; + +public class TestRunner { + public static void main(String[] args) { + // Battleship Tests + Result result1 = JUnitCore.runClasses(AdjacentShipsContradictionRuleTest.class); + printTestResults(result1); + Result result2 = JUnitCore.runClasses(FinishWithShipsDirectRuleTests.class); + printTestResults(result2); + + // Lightup Tests + Result result3 = JUnitCore.runClasses(BulbsInPathContradictionRuleTest.class); + printTestResults(result3); + Result result4 = JUnitCore.runClasses(CannotLightACellContradictionRuleTest.class); + printTestResults(result4); + Result result5 = JUnitCore.runClasses(EmptyCellinLightDirectRuleTest.class); + printTestResults(result5); + Result result6 = JUnitCore.runClasses(EmptyCornersDirectRuleTest.class); + printTestResults(result6); + Result result7 = JUnitCore.runClasses(FinishWithBulbsDirectRuleTest.class); + printTestResults(result7); + Result result8 = JUnitCore.runClasses(LightOrEmptyCaseRuleTest.class); + printTestResults(result8); + Result result9 = JUnitCore.runClasses(MustLightDirectRuleTest.class); + printTestResults(result9); + Result result10 = JUnitCore.runClasses(SatisfyNumberCaseRuleTest.class); + printTestResults(result10); + Result result11 = JUnitCore.runClasses(TooFewBulbsContradictionRuleTest.class); + printTestResults(result11); + Result result12 = JUnitCore.runClasses(TooManyBulbsContradictionRuleTest.class); + printTestResults(result12); + + } + + private static void printTestResults(Result result) { + for (Failure failure : result.getFailures()) { + System.out.println(failure.toString()); + } + + System.out.println("Tests run: " + result.getRunCount()); + System.out.println("Tests failed: " + result.getFailureCount()); + System.out.println("All tests passed: " + result.wasSuccessful()); + System.out.println(); + } + + +} \ No newline at end of file From 5673e0220add7da6ef88fd08e0f778ae6b97a345 Mon Sep 17 00:00:00 2001 From: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Date: Thu, 15 Jun 2023 13:13:13 -0700 Subject: [PATCH 40/42] Add more tests Update TestRunner.java --- .../puzzles/battleship/rules/TestRunner.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/test/java/puzzles/battleship/rules/TestRunner.java b/src/test/java/puzzles/battleship/rules/TestRunner.java index 077f3a5d8..407c1e00c 100644 --- a/src/test/java/puzzles/battleship/rules/TestRunner.java +++ b/src/test/java/puzzles/battleship/rules/TestRunner.java @@ -5,6 +5,8 @@ import org.junit.runner.Result; import org.junit.runner.notification.Failure; import puzzles.lightup.rules.*; +import puzzles.nurikabe.rules.*; +import puzzles.treetent.rules.*; public class TestRunner { public static void main(String[] args) { @@ -36,6 +38,58 @@ public static void main(String[] args) { Result result12 = JUnitCore.runClasses(TooManyBulbsContradictionRuleTest.class); printTestResults(result12); + + + //nurikabe tests + Result result13 = JUnitCore.runClasses(BlackBetweenRegionsDirectRuleTest.class); + printTestResults(result13); + Result result14 = JUnitCore.runClasses(BlackBottleNeckDirectRuleTest.class); + printTestResults(result14); + Result result15 = JUnitCore.runClasses(BlackOrWhiteCaseRuleTest.class); + printTestResults(result15); + Result result16 = JUnitCore.runClasses(BlackSquareContradictionRuleTest.class); + printTestResults(result16); + Result result17 = JUnitCore.runClasses(CornerBlackDirectRuleTest.class); + printTestResults(result17); + Result result18 = JUnitCore.runClasses(FillinBlackDirectRuleTest.class); + printTestResults(result18); + Result result19 = JUnitCore.runClasses(FillinWhiteDirectRuleTest.class); + printTestResults(result19); + Result result20 = JUnitCore.runClasses(IsolateBlackContradictionRuleTest.class); + printTestResults(result20); + Result result21 = JUnitCore.runClasses(MultipleNumbersContradictionRuleTest.class); + printTestResults(result21); + Result result22 = JUnitCore.runClasses(NoNumbersContradictionRuleTest.class); + printTestResults(result22); + Result result23 = JUnitCore.runClasses(PreventBlackSquareDirectRuleTest.class); + printTestResults(result23); + Result result24 = JUnitCore.runClasses(SurroundRegionDirectRuleTest.class); + printTestResults(result24); + Result result25 = JUnitCore.runClasses(TooFewSpacesContradictionRuleTest.class); + printTestResults(result25); + Result result26 = JUnitCore.runClasses(TooManySpacesContradictionRuleTest.class); + printTestResults(result26); + Result result27 = JUnitCore.runClasses(WhiteBottleNeckDirectRuleTest.class); + printTestResults(result27); + + + // Treetent + Result result28 = JUnitCore.runClasses(EmptyFieldDirectRuleTest.class); + printTestResults(result28); + Result result29 = JUnitCore.runClasses(FinishWithGrassDirectRuleTest.class); + printTestResults(result29); + Result result30 = JUnitCore.runClasses(FinishWithTentsDirectRuleTest.class); + printTestResults(result30); + Result result31 = JUnitCore.runClasses(LastCampingSpotDirectRuleTest.class); + printTestResults(result31); + Result result32 = JUnitCore.runClasses(NoTentForTreeContradictionRuleTest.class); + printTestResults(result32); + Result result33 = JUnitCore.runClasses(NoTreeForTentContradictionRuleTest.class); + printTestResults(result33); + Result result34 = JUnitCore.runClasses(SurroundTentWithGrassDirectRuleTest.class); + printTestResults(result34); + Result result35 = JUnitCore.runClasses(TreeForTentDirectRuleTest.class); + printTestResults(result35); } private static void printTestResults(Result result) { From 3445e364afc563048c0f3e9b4a3078401b5295ba Mon Sep 17 00:00:00 2001 From: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Date: Thu, 15 Jun 2023 13:17:01 -0700 Subject: [PATCH 41/42] Somehow ended up in the wrong spot Fix Import --- .../java/{puzzles/battleship/rules => legup}/TestRunner.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename src/test/java/{puzzles/battleship/rules => legup}/TestRunner.java (99%) diff --git a/src/test/java/puzzles/battleship/rules/TestRunner.java b/src/test/java/legup/TestRunner.java similarity index 99% rename from src/test/java/puzzles/battleship/rules/TestRunner.java rename to src/test/java/legup/TestRunner.java index 407c1e00c..7e2dbe737 100644 --- a/src/test/java/puzzles/battleship/rules/TestRunner.java +++ b/src/test/java/legup/TestRunner.java @@ -1,9 +1,10 @@ -package puzzles.battleship.rules; +package legup; import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; +import puzzles.battleship.rules.*; import puzzles.lightup.rules.*; import puzzles.nurikabe.rules.*; import puzzles.treetent.rules.*; From 886ea3dd6e3a4b03c26857ec6cfa4d9648f832bf Mon Sep 17 00:00:00 2001 From: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:58:49 -0700 Subject: [PATCH 42/42] Update ProofEditorPanel.java hi Update ProofEditorPanel.java --- src/main/java/edu/rpi/legup/app/LegupPreferences.java | 11 +++++++++++ src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/app/LegupPreferences.java b/src/main/java/edu/rpi/legup/app/LegupPreferences.java index f9c3791f6..578cefc5b 100644 --- a/src/main/java/edu/rpi/legup/app/LegupPreferences.java +++ b/src/main/java/edu/rpi/legup/app/LegupPreferences.java @@ -8,6 +8,8 @@ public class LegupPreferences { private static LegupPreferences instance; + private static String SAVED_PATH = ""; + private static final Preferences preferences = Preferences.userNodeForPackage(LegupPreferences.class); private static final Map preferencesMap = new HashMap<>(); @@ -104,4 +106,13 @@ public boolean getUserPrefAsBool(String key) { } } } + + + public String getSavedPath() { + return SAVED_PATH; + } + + public void setSavedPath(String path) { + SAVED_PATH = path; + } } diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 86a0ca2c1..aac040bdb 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -380,6 +380,9 @@ public Object[] promptPuzzle() { LegupPreferences preferences = LegupPreferences.getInstance(); String preferredDirectory = preferences.getUserPref(LegupPreferences.WORK_DIRECTORY); + if (preferences.getSavedPath() != "") { + preferredDirectory = preferences.getSavedPath(); + } File preferredDirectoryFile = new File(preferredDirectory); JFileChooser fileBrowser = new JFileChooser(preferredDirectoryFile); @@ -388,7 +391,7 @@ public Object[] promptPuzzle() { fileBrowser.showOpenDialog(this); fileBrowser.setVisible(true); - fileBrowser.setCurrentDirectory(new File(LegupPreferences.WORK_DIRECTORY)); + fileBrowser.setCurrentDirectory(new File(preferredDirectory)); fileBrowser.setDialogTitle("Select Proof File"); fileBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileBrowser.setAcceptAllFileFilterUsed(false); @@ -398,6 +401,8 @@ public Object[] promptPuzzle() { if (puzzlePath != null) { fileName = puzzlePath.getAbsolutePath(); + String lastDirectoryPath = fileName.substring(0, fileName.lastIndexOf(File.separator)); + preferences.setSavedPath(lastDirectoryPath); puzzleFile = puzzlePath; } else {