From 204c035ab23cbadf022c8e63b6a0bcd5a0b047b8 Mon Sep 17 00:00:00 2001 From: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:38:46 -0400 Subject: [PATCH 01/14] October Merge (#636) * Region Based Changes (#559) Co-authored-by: Hanson Gu <123511202+hansongu123@users.noreply.github.com> * Short Truth Table Puzzle Editor (#451) * Created files for STT elements * Renamed Tiles classes to Elements to match package name Also added an elements reference sheet and renamed rules reference sheet accordingly * More progress made This won't compile, just saving progress made * More progress being made * Fixed file name typo and added placeholder tiles * Added image paths * Created element classes and added placeholder tile images (#452) * Renamed Tiles classes to Elements to match package name Also added an elements reference sheet and renamed rules reference sheet accordingly * More progress made This won't compile, just saving progress made * More progress being made * Fixed file name typo and added placeholder tiles * Added image paths * Set the current board on boardView * Fixed typo and turned on STT puzzle editor for testing * Added preliminary valid dimensions checker This will most definitely change in the future, hopefully can change to accept a number of statements * Fixed image file paths * Added ActionListener Allows us to determine what puzzle is selected by the user * Hide rows and columns input for Short Truth Table * Added text area for Short Truth Table * Added scrollbars to show up as needed * Reformatted code * More code reformatting * Even more reformatting * Separate the data from the TextArea into different lines * Did some researching/testing Tested certain variable values with a STT file with no true/false values * Made more progress Added new methods to handle creating Short Truth Table boards from an array of strings * Added a bunch of TODOs - Implemented a couple functions to be used later - Added a bunch of TODO comments for future work * Made some more progress * Implemented abstract methods from PuzzleImporter * Added abstract methods to Fillapix and added other exception reporting * CheckStyle formatting * Removed a TODO comment * Statements show up in puzzle editor Fixed a bug where the importer was not properly being initialized. Statements now show up in the puzzle editor. * Removed empty statements * Changed InvalidFormatException to IllegalArgumentException * Remove argument that has already been caught * Removed elements that will not be used * Added puzzle editor cell clicking functionality * Added ability to toggle certain logical elements * New icons and more functionality implemented * Fixed a bug where spacer rows could be modified * Added statement error checking * Fixed formatting * Only one logic symbol element needed * Changed InputMismatchException to UnsupportedOperationException * Renamed variables to not be STT specific * Finding initial issue and starting fix * Issue is statement copying and modifying * STT exporter now working. Overrode setCell for STTBoard. * Added code documentation * removed testing println() * Gradle fixes * Revert "Merge pull request #545 from MMosley502/puzzle_editor-short_truth_table-file_saving" This reverts commit 2e82547896a7fb3e52ec27634cd8938ef299732f, reversing changes made to beb60a2ab67c8317d404f54e52471739f698bf22. * Saving files now works * Fixed the blank element to be categorized as a placeable element * Fixed a bug where file wouldn't save due to batch grader updates * Reformatted code in STT * Reformatted code again * MORE REFORMATTING Pls like my code CheckStyle --------- Co-authored-by: Matthew Mosley Co-authored-by: MMosley502 <74743867+MMosley502@users.noreply.github.com> * Have null changes be valid and fix IsolatedBlackContradicitonRule error message (#561) * Get Tests to be called Revert "Create first cypress test template" This reverts commit 3e50909b93b5aa9634cf0d296e9aeff756b0a909. First commit Finish Lightup tests * Add more tests Update TestRunner.java * Somehow ended up in the wrong spot Fix Import * Please let this be the fix Update TreeTransition.java Update TreeTransition.java Update DirectRule.java Check to see which is not correct Update ElementController.java Revert "maybe the null is making it think that it's not valid" This reverts commit 7bf1de0d66ced6749ee37fbb9c252636b2fcdc79. Just trying to change color Revert "Just trying to change color" This reverts commit ec44695ee578d664055d135a668927a0fd900f5d. Revert "maybe the null is making it think that it's not valid" This reverts commit 3f162fbdc32e6fbd23da321a14a6af96f0ff520d. Check to see which is not correct Revert "Check to see which is not correct" This reverts commit 136b0a41b9d103e6f3e9a7f8cd5d970bf76b050b. Update TreeTransition.java Update TreeTransition.java Revert "Update TreeTransition.java" This reverts commit cde45bb9001cfbfa4f6e2a49b4e9990d2fa7ad33. * Fix error with isolated Black Fix error message with isolated black * Removed excess whitespace and imports. Added short JavaDoc for `TestRunner.java` --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Bram van Heuveln Co-authored-by: Corppet * Fixed a bug * Update BlackTile.java Black tile should not be placeable * Added unknown tile stuff * ID error * Some Fixes to Recently Discussed UX Bugs (#563) * frame and panels default sizes, default pos on screen * hardcoded version number * homepanel default size * set panels' own sizes * some changes * Removed unused import --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Corppet * Oops pushed the wrong file Yeah some tiles work now but this is the ID error * Number Tile working * Update Exporter (#627) * Update Exporter * Delete Test_Save --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> * Create run-tests.yml * Update run-tests.yml * Update run-tests.yml * Update run-tests.yml * Update run-tests.yml * Windows things * Added print messages * More Windows things * Debugging * Update run-tests.yml * Update run-tests.yml * Maybe this will work now? * Didn't work * Update run-tests.yml * Update run-tests.yml * Create DummyTest.java For debugging purposes * Added another dummy test * Update run-tests.yml * Update run-tests.yml Get rid of all this info * Deleted the dummy tests --------- Co-authored-by: Antonio Orta <60408336+19690ao@users.noreply.github.com> Co-authored-by: Hanson Gu <123511202+hansongu123@users.noreply.github.com> Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Matthew Mosley Co-authored-by: MMosley502 <74743867+MMosley502@users.noreply.github.com> Co-authored-by: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Co-authored-by: Bram van Heuveln Co-authored-by: Corppet Co-authored-by: charlestian23 Co-authored-by: ThisMatt <98851950+ThisMatt@users.noreply.github.com> --- .../java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java index 2fa8fb64c..757d14cd8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java @@ -2,6 +2,7 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class FillapixExporter extends PuzzleExporter { @@ -15,7 +16,7 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { FillapixBoard board; if (puzzle.getTree() != null) { board = (FillapixBoard) puzzle.getTree().getRootNode().getBoard(); - } + } else { board = (FillapixBoard) puzzle.getBoardView().getBoard(); } From 6b9023f1d957ad1a1fb993f6757aa337a5af6b93 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:10:16 -0400 Subject: [PATCH 02/14] fixed error on puzzle --- .../treetent/rules/FinishWithGrassDirectRule/FinishWithGrass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass index 3e293d22f..daba3648e 100644 --- a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass +++ b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass @@ -10,7 +10,7 @@ - + From f6183ac5015a408501c79d3db38528a2e1a8be3a Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:25:55 -0400 Subject: [PATCH 03/14] added some tests --- .../rules/FinishWithGrassDirectRuleTest.java | 86 +++++++++++++++++-- 1 file changed, 81 insertions(+), 5 deletions(-) diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java index 8dbec657a..37a340547 100644 --- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java @@ -28,7 +28,7 @@ public static void setUp() { } @Test - public void EmptyFieldTest() throws InvalidFileFormatException { + public void FinishWithGrassTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); @@ -40,20 +40,96 @@ public void EmptyFieldTest() throws InvalidFileFormatException { cell1.setData(TreeTentType.GRASS); TreeTentCell cell2 = board.getCell(2, 0); cell2.setData(TreeTentType.GRASS); + TreeTentCell cell3 = board.getCell(0, 1); + cell3.setData(TreeTentType.GRASS); + TreeTentCell cell4 = board.getCell(0, 2); + cell4.setData(TreeTentType.GRASS); board.addModifiedData(cell1); board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); Assert.assertNull(RULE.checkRule(transition)); + TreeTentCell c; for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { - Point point = new Point(k, i); - if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { - Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + c = board.getCell(k, i); + if (c.getLocation().equals(cell1.getLocation()) || + c.getLocation().equals(cell2.getLocation()) || + c.getLocation().equals(cell3.getLocation()) || + c.getLocation().equals(cell4.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { - Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); + Assert.assertNotNull(RULE.checkRuleAt(transition, c)); + } + } + } + } + + @Test + public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + TreeTentCell cell1 = board.getCell(1, 0); + cell1.setData(TreeTentType.GRASS); + TreeTentCell cell2 = board.getCell(2, 0); + cell2.setData(TreeTentType.GRASS); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + + Assert.assertNull(RULE.checkRule(transition)); + + TreeTentCell c; + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + c = board.getCell(k, i); + if (c.getLocation().equals(cell1.getLocation()) || c.getLocation().equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, c)); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, c)); + } + } + } + } + + @Test + public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + TreeTentCell cell1 = board.getCell(0, 1); + cell1.setData(TreeTentType.GRASS); + TreeTentCell cell2 = board.getCell(0, 2); + cell2.setData(TreeTentType.GRASS); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + + Assert.assertNull(RULE.checkRule(transition)); + + TreeTentCell c; + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + c = board.getCell(k, i); + if (c.getLocation().equals(cell1.getLocation()) || c.getLocation().equals(cell2.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, c)); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } } From 49c83c109d80bad3573613a3fef163c5396b2bf5 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:59:52 -0400 Subject: [PATCH 04/14] added test on empty puzzle --- .../rules/FinishWithGrassDirectRuleTest.java | 37 +++++++++++++++++-- .../{FinishWithGrass => CornerTent} | 0 .../FinishWithGrassDirectRule/MiddleTent | 20 ++++++++++ .../rules/FinishWithGrassDirectRule/NoTent | 19 ++++++++++ 4 files changed, 73 insertions(+), 3 deletions(-) rename src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/{FinishWithGrass => CornerTent} (100%) create mode 100644 src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent create mode 100644 src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/NoTent diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java index 37a340547..fd9289802 100644 --- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java @@ -15,6 +15,8 @@ import org.junit.Test; import java.awt.*; +import java.util.List; +import java.util.ArrayList; public class FinishWithGrassDirectRuleTest { @@ -29,7 +31,7 @@ public static void setUp() { @Test public void FinishWithGrassTest() throws InvalidFileFormatException { - TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass", treetent); + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); @@ -71,7 +73,7 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { @Test public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { - TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass", treetent); + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); @@ -104,7 +106,7 @@ public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { @Test public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { - TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass", treetent); + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); @@ -134,6 +136,35 @@ public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { } } } + + @Test + public void NoTentTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/NoTent", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + List cells = new ArrayList(); + for (int i = 0; i < board.getWidth(); i++) { + for (int k = 0; k < board.getHeight(); k++) { + TreeTentCell c = board.getCell(i, k); + c.setData(TreeTentType.GRASS); + cells.add(c); + } + } + + for (TreeTentCell c : cells) { + board.addModifiedData(c); + } + + Assert.assertNull(RULE.checkRule(transition)); + + for (TreeTentCell c : cells) { + Assert.assertNull(RULE.checkRuleAt(transition, c)); + } + } } diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent similarity index 100% rename from src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass rename to src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent new file mode 100644 index 000000000..6f7e6e80e --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/NoTent b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/NoTent new file mode 100644 index 000000000..a13c7cc55 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/NoTent @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 37d4534bc4de72be4fd9dc83df671c23015685dc Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:02:14 -0400 Subject: [PATCH 05/14] fixed error on puzzle --- .../treetent/rules/FinishWithGrassDirectRule/MiddleTent | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent index 6f7e6e80e..8f71a57f9 100644 --- a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent +++ b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent @@ -5,13 +5,13 @@ - - + + - - + + From 3b8513c3b13c46438e2a951e23e2010fe7efacc5 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:19:17 -0400 Subject: [PATCH 06/14] added test with tent in the middle --- .../rules/FinishWithGrassDirectRuleTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java index fd9289802..b4ccbb2eb 100644 --- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java @@ -165,6 +165,49 @@ public void NoTentTest() throws InvalidFileFormatException { Assert.assertNull(RULE.checkRuleAt(transition, c)); } } + + @Test + public void MiddleTentTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + TreeTentCell cell1 = board.getCell(1, 0); + TreeTentCell cell2 = board.getCell(0, 1); + TreeTentCell cell3 = board.getCell(2, 1); + TreeTentCell cell4 = board.getCell(1, 2); + + cell1.setData(TreeTentType.GRASS); + cell2.setData(TreeTentType.GRASS); + cell3.setData(TreeTentType.GRASS); + cell4.setData(TreeTentType.GRASS); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + + Assert.assertNull(RULE.checkRule(transition)); + + TreeTentCell c; + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + c = board.getCell(k, i); + if (c.getLocation().equals(cell1.getLocation()) || + c.getLocation().equals(cell2.getLocation()) || + c.getLocation().equals(cell3.getLocation()) || + c.getLocation().equals(cell4.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, c)); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, c)); + } + } + } + } } From 8ab6eb58b1c862e83becf282dc023f4da5da035b Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:28:29 -0400 Subject: [PATCH 07/14] added test where rule should not work --- .../rules/FinishWithGrassDirectRuleTest.java | 29 +++++++++++++++++++ .../rules/FinishWithGrassDirectRule/FailTent | 19 ++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FailTent diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java index b4ccbb2eb..f3d9d985d 100644 --- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java @@ -208,6 +208,35 @@ public void MiddleTentTest() throws InvalidFileFormatException { } } } + + @Test + public void FailTentTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FailTent", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + List cells = new ArrayList(); + for (int i = 0; i < board.getWidth(); i++) { + for (int k = 0; k < board.getHeight(); k++) { + TreeTentCell c = board.getCell(i, k); + c.setData(TreeTentType.GRASS); + cells.add(c); + } + } + + for (TreeTentCell c : cells) { + board.addModifiedData(c); + } + + Assert.assertNotNull(RULE.checkRule(transition)); + + for (TreeTentCell c : cells) { + Assert.assertNotNull(RULE.checkRuleAt(transition, c)); + } + } } diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FailTent b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FailTent new file mode 100644 index 000000000..9fa14ebe4 --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FailTent @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 694b08fbe5444c8b5d9864f742a165faf79449f7 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:31:00 -0400 Subject: [PATCH 08/14] added space behind bracket --- .../java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java index 757d14cd8..ee40107a9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java @@ -16,7 +16,7 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { FillapixBoard board; if (puzzle.getTree() != null) { board = (FillapixBoard) puzzle.getTree().getRootNode().getBoard(); - } + } else { board = (FillapixBoard) puzzle.getBoardView().getBoard(); } From 7e34a71ef73dc9aa3d7d3abecc2f69427140ec18 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:31:52 -0400 Subject: [PATCH 09/14] updated to be inline with dev --- .../java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java index ee40107a9..2fa8fb64c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/fillapix/FillapixExporter.java @@ -2,7 +2,6 @@ import edu.rpi.legup.model.PuzzleExporter; import edu.rpi.legup.model.gameboard.PuzzleElement; -import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableBoard; import org.w3c.dom.Document; public class FillapixExporter extends PuzzleExporter { From d100798e8822c6e901a1f1f6a9688ca34204e77b Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:07:22 -0400 Subject: [PATCH 10/14] added SpacedOutTentTest added a test with the tents spread out --- .../rules/FinishWithGrassDirectRuleTest.java | 66 ++++++++++++++++++- .../FinishWithGrassDirectRule/SpacedOutTent | 30 +++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/SpacedOutTent diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java index f3d9d985d..8d76cebcd 100644 --- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java @@ -29,6 +29,10 @@ public static void setUp() { treetent = new TreeTent(); } + /** + * + * @throws InvalidFileFormatException + */ @Test public void FinishWithGrassTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); @@ -71,6 +75,10 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { } } + /** + * + * @throws InvalidFileFormatException + */ @Test public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); @@ -104,6 +112,10 @@ public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { } } + /** + * + * @throws InvalidFileFormatException + */ @Test public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); @@ -137,6 +149,10 @@ public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { } } + /** + * + * @throws InvalidFileFormatException + */ @Test public void NoTentTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/NoTent", treetent); @@ -165,7 +181,10 @@ public void NoTentTest() throws InvalidFileFormatException { Assert.assertNull(RULE.checkRuleAt(transition, c)); } } - + /** + * + * @throws InvalidFileFormatException + */ @Test public void MiddleTentTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/MiddleTent", treetent); @@ -209,6 +228,10 @@ public void MiddleTentTest() throws InvalidFileFormatException { } } + /** + * + * @throws InvalidFileFormatException + */ @Test public void FailTentTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FailTent", treetent); @@ -237,7 +260,46 @@ public void FailTentTest() throws InvalidFileFormatException { Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } -} + @Test + public void SpacedOutTentTest() throws InvalidFileFormatException { + TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/SpacedOutTent", treetent); + TreeNode rootNode = treetent.getTree().getRootNode(); + TreeTransition transition = rootNode.getChildren().get(0); + transition.setRule(RULE); + + TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + TreeTentCell cell1 = board.getCell(0, 3); + TreeTentCell cell2 = board.getCell(2, 3); + TreeTentCell cell3 = board.getCell(4, 3); + TreeTentCell cell4 = board.getCell(6, 3); + + cell1.setData(TreeTentType.GRASS); + cell2.setData(TreeTentType.GRASS); + cell3.setData(TreeTentType.GRASS); + cell4.setData(TreeTentType.GRASS); + + board.addModifiedData(cell1); + board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); + Assert.assertNull(RULE.checkRule(transition)); + TreeTentCell c; + for (int i = 0; i < board.getHeight(); i++) { + for (int k = 0; k < board.getWidth(); k++) { + c = board.getCell(k, i); + if (c.getLocation().equals(cell1.getLocation()) || + c.getLocation().equals(cell2.getLocation()) || + c.getLocation().equals(cell3.getLocation()) || + c.getLocation().equals(cell4.getLocation())) { + Assert.assertNull(RULE.checkRuleAt(transition, c)); + } + else { + Assert.assertNotNull(RULE.checkRuleAt(transition, c)); + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/SpacedOutTent b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/SpacedOutTent new file mode 100644 index 000000000..f7b523b0a --- /dev/null +++ b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/SpacedOutTent @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 3f6dd518f23505c2e649ad59bc8d6edce490bdff Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:42:24 -0400 Subject: [PATCH 11/14] added some comments to tests --- .../rules/FinishWithGrassDirectRuleTest.java | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java index 8d76cebcd..9320aeefd 100644 --- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java @@ -30,11 +30,14 @@ public static void setUp() { } /** + * 3x3 TreeTent puzzle with a tent at (0,0) + * Tests FinishWithGrassDirectRule on GRASS tiles horizontal of the tent + * at (1,0) and (2,0) * * @throws InvalidFileFormatException */ @Test - public void FinishWithGrassTest() throws InvalidFileFormatException { + public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); @@ -46,15 +49,9 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { cell1.setData(TreeTentType.GRASS); TreeTentCell cell2 = board.getCell(2, 0); cell2.setData(TreeTentType.GRASS); - TreeTentCell cell3 = board.getCell(0, 1); - cell3.setData(TreeTentType.GRASS); - TreeTentCell cell4 = board.getCell(0, 2); - cell4.setData(TreeTentType.GRASS); board.addModifiedData(cell1); board.addModifiedData(cell2); - board.addModifiedData(cell3); - board.addModifiedData(cell4); Assert.assertNull(RULE.checkRule(transition)); @@ -62,10 +59,7 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { c = board.getCell(k, i); - if (c.getLocation().equals(cell1.getLocation()) || - c.getLocation().equals(cell2.getLocation()) || - c.getLocation().equals(cell3.getLocation()) || - c.getLocation().equals(cell4.getLocation())) { + if (c.getLocation().equals(cell1.getLocation()) || c.getLocation().equals(cell2.getLocation())) { Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { @@ -76,11 +70,14 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { } /** + * 3x3 TreeTent puzzle with a tent at (0,0) + * Tests FinishWithGrassDirectRule on GRASS tiles vertical of the tent + * at (0,1) and (0,2) * * @throws InvalidFileFormatException */ @Test - public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { + public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); @@ -88,9 +85,9 @@ public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { TreeTentBoard board = (TreeTentBoard) transition.getBoard(); - TreeTentCell cell1 = board.getCell(1, 0); + TreeTentCell cell1 = board.getCell(0, 1); cell1.setData(TreeTentType.GRASS); - TreeTentCell cell2 = board.getCell(2, 0); + TreeTentCell cell2 = board.getCell(0, 2); cell2.setData(TreeTentType.GRASS); board.addModifiedData(cell1); @@ -113,11 +110,14 @@ public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { } /** + * 3x3 TreeTent puzzle with a tent at (0,0) + * Tests FinishWithGrassDirectRule on GRASS tiles + * at (1,0), (2,0), (0,1), and (0,2) * * @throws InvalidFileFormatException */ @Test - public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { + public void FinishWithGrassTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/CornerTent", treetent); TreeNode rootNode = treetent.getTree().getRootNode(); TreeTransition transition = rootNode.getChildren().get(0); @@ -125,13 +125,19 @@ public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { TreeTentBoard board = (TreeTentBoard) transition.getBoard(); - TreeTentCell cell1 = board.getCell(0, 1); + TreeTentCell cell1 = board.getCell(1, 0); cell1.setData(TreeTentType.GRASS); - TreeTentCell cell2 = board.getCell(0, 2); + TreeTentCell cell2 = board.getCell(2, 0); cell2.setData(TreeTentType.GRASS); + TreeTentCell cell3 = board.getCell(0, 1); + cell3.setData(TreeTentType.GRASS); + TreeTentCell cell4 = board.getCell(0, 2); + cell4.setData(TreeTentType.GRASS); board.addModifiedData(cell1); board.addModifiedData(cell2); + board.addModifiedData(cell3); + board.addModifiedData(cell4); Assert.assertNull(RULE.checkRule(transition)); @@ -139,7 +145,10 @@ public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { c = board.getCell(k, i); - if (c.getLocation().equals(cell1.getLocation()) || c.getLocation().equals(cell2.getLocation())) { + if (c.getLocation().equals(cell1.getLocation()) || + c.getLocation().equals(cell2.getLocation()) || + c.getLocation().equals(cell3.getLocation()) || + c.getLocation().equals(cell4.getLocation())) { Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { @@ -150,6 +159,9 @@ public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { } /** + * 3x3 TreeTent puzzle with no tents + * Tests FinishWithGrassDirectRule on GRASS tiles + * GRASS tiles fill entire board * * @throws InvalidFileFormatException */ @@ -182,6 +194,9 @@ public void NoTentTest() throws InvalidFileFormatException { } } /** + * 3x3 TreeTent puzzle with a tent at (1,1) + * Tests FinishWithGrassDirectRule on GRASS tiles surrounding the tent + * at (1,0), (0,1), (2,1), and (1,2) * * @throws InvalidFileFormatException */ @@ -229,6 +244,9 @@ public void MiddleTentTest() throws InvalidFileFormatException { } /** + * 3x3 TreeTent puzzle with missing tents + * Tests FinishWithGrassDirectRule on GRASS tiles filling the puzzle + * all GRASS tiles should fail the FinishWithGrassDirectRule * * @throws InvalidFileFormatException */ @@ -260,7 +278,13 @@ public void FailTentTest() throws InvalidFileFormatException { Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } - + /** + * 7x7 TreeTent puzzle with multiple tents spaced out + * Tests FinishWithGrassDirectRule on GRASS tiles between the tents + * at (0,3), (2,3), (4,3), and (6,3) + * + * @throws InvalidFileFormatException + */ @Test public void SpacedOutTentTest() throws InvalidFileFormatException { TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/SpacedOutTent", treetent); From 95c13d561834194b31f49292caabda46f1868347 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 20 Oct 2023 18:19:10 -0400 Subject: [PATCH 12/14] added comments to tests --- src/test/java/legup/TestRunner.java | 7 ++-- .../rules/FinishWithGrassDirectRuleTest.java | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/test/java/legup/TestRunner.java b/src/test/java/legup/TestRunner.java index 9d79c590e..c9036beee 100644 --- a/src/test/java/legup/TestRunner.java +++ b/src/test/java/legup/TestRunner.java @@ -13,7 +13,8 @@ * This class runs all of the tests for the project without needing to run build scripts. */ public class TestRunner { - public static void main(String[] args) { + public static void main(String[] args) { + /* // Battleship Tests Result result1 = JUnitCore.runClasses(AdjacentShipsContradictionRuleTest.class); printTestResults(result1); @@ -75,8 +76,8 @@ public static void main(String[] args) { printTestResults(result26); Result result27 = JUnitCore.runClasses(WhiteBottleNeckDirectRuleTest.class); printTestResults(result27); - - + */ + // Treetent Result result28 = JUnitCore.runClasses(EmptyFieldDirectRuleTest.class); printTestResults(result28); diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java index 9320aeefd..2517df563 100644 --- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java +++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java @@ -43,8 +43,10 @@ public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); + // get board state TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + // change the board's cells considering the FinishWithGrass rule TreeTentCell cell1 = board.getCell(1, 0); cell1.setData(TreeTentType.GRASS); TreeTentCell cell2 = board.getCell(2, 0); @@ -53,16 +55,20 @@ public void FinishWithGrassHorizontalTest() throws InvalidFileFormatException { board.addModifiedData(cell1); board.addModifiedData(cell2); + // confirm there is a logical following of the EmptyField rule Assert.assertNull(RULE.checkRule(transition)); + // only the cell above should change following the rule TreeTentCell c; for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { c = board.getCell(k, i); if (c.getLocation().equals(cell1.getLocation()) || c.getLocation().equals(cell2.getLocation())) { + // logically follows Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { + // does not use the rule to logically follow Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } @@ -83,8 +89,10 @@ public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); + // get board state TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + // change the board's cells considering the FinishWithGrass rule TreeTentCell cell1 = board.getCell(0, 1); cell1.setData(TreeTentType.GRASS); TreeTentCell cell2 = board.getCell(0, 2); @@ -93,16 +101,20 @@ public void FinishWithGrassVerticalTest() throws InvalidFileFormatException { board.addModifiedData(cell1); board.addModifiedData(cell2); + // confirm there is a logical following of the EmptyField rule Assert.assertNull(RULE.checkRule(transition)); + // only the cell above should change following the rule TreeTentCell c; for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { c = board.getCell(k, i); if (c.getLocation().equals(cell1.getLocation()) || c.getLocation().equals(cell2.getLocation())) { + // logically follows Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { + // does not use the rule to logically follow Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } @@ -123,8 +135,10 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); + // get board state TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + // change the board's cells considering the FinishWithGrass rule TreeTentCell cell1 = board.getCell(1, 0); cell1.setData(TreeTentType.GRASS); TreeTentCell cell2 = board.getCell(2, 0); @@ -139,8 +153,10 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { board.addModifiedData(cell3); board.addModifiedData(cell4); + // confirm there is a logical following of the EmptyField rule Assert.assertNull(RULE.checkRule(transition)); + // only the cell above should change following the rule TreeTentCell c; for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { @@ -149,9 +165,11 @@ public void FinishWithGrassTest() throws InvalidFileFormatException { c.getLocation().equals(cell2.getLocation()) || c.getLocation().equals(cell3.getLocation()) || c.getLocation().equals(cell4.getLocation())) { + // logically follows Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { + // does not use the rule to logically follow Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } @@ -172,8 +190,10 @@ public void NoTentTest() throws InvalidFileFormatException { TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); + // get board state TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + // change the board's cells considering the FinishWithGrass rule List cells = new ArrayList(); for (int i = 0; i < board.getWidth(); i++) { for (int k = 0; k < board.getHeight(); k++) { @@ -187,9 +207,12 @@ public void NoTentTest() throws InvalidFileFormatException { board.addModifiedData(c); } + // confirm there is a logical following of the EmptyField rule Assert.assertNull(RULE.checkRule(transition)); + // all cells should change following the rule for (TreeTentCell c : cells) { + // logically follows Assert.assertNull(RULE.checkRuleAt(transition, c)); } } @@ -207,8 +230,10 @@ public void MiddleTentTest() throws InvalidFileFormatException { TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); + // get board state TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + // change the board's cells considering the FinishWithGrass rule TreeTentCell cell1 = board.getCell(1, 0); TreeTentCell cell2 = board.getCell(0, 1); TreeTentCell cell3 = board.getCell(2, 1); @@ -224,8 +249,10 @@ public void MiddleTentTest() throws InvalidFileFormatException { board.addModifiedData(cell3); board.addModifiedData(cell4); + // confirm there is a logical following of the EmptyField rule Assert.assertNull(RULE.checkRule(transition)); + // only the cell above should change following the rule TreeTentCell c; for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { @@ -234,9 +261,11 @@ public void MiddleTentTest() throws InvalidFileFormatException { c.getLocation().equals(cell2.getLocation()) || c.getLocation().equals(cell3.getLocation()) || c.getLocation().equals(cell4.getLocation())) { + // logically follows Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { + // does not use the rule to logically follow Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } @@ -257,8 +286,10 @@ public void FailTentTest() throws InvalidFileFormatException { TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); + // get board state TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + // change the board's cells not following the FinishWithGrass rule List cells = new ArrayList(); for (int i = 0; i < board.getWidth(); i++) { for (int k = 0; k < board.getHeight(); k++) { @@ -272,9 +303,12 @@ public void FailTentTest() throws InvalidFileFormatException { board.addModifiedData(c); } + // confirm there is a logical following of the EmptyField rule Assert.assertNotNull(RULE.checkRule(transition)); + // all cells should fail the rule test for (TreeTentCell c : cells) { + // does not use the rule to logically follow Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } @@ -292,7 +326,10 @@ public void SpacedOutTentTest() throws InvalidFileFormatException { TreeTransition transition = rootNode.getChildren().get(0); transition.setRule(RULE); + // get board state TreeTentBoard board = (TreeTentBoard) transition.getBoard(); + + // change the board's cells considering the FinishWithGrass rule TreeTentCell cell1 = board.getCell(0, 3); TreeTentCell cell2 = board.getCell(2, 3); TreeTentCell cell3 = board.getCell(4, 3); @@ -308,8 +345,10 @@ public void SpacedOutTentTest() throws InvalidFileFormatException { board.addModifiedData(cell3); board.addModifiedData(cell4); + // confirm there is a logical following of the EmptyField rule Assert.assertNull(RULE.checkRule(transition)); + // only the cell above should change following the rule TreeTentCell c; for (int i = 0; i < board.getHeight(); i++) { for (int k = 0; k < board.getWidth(); k++) { @@ -318,9 +357,11 @@ public void SpacedOutTentTest() throws InvalidFileFormatException { c.getLocation().equals(cell2.getLocation()) || c.getLocation().equals(cell3.getLocation()) || c.getLocation().equals(cell4.getLocation())) { + // logically follows Assert.assertNull(RULE.checkRuleAt(transition, c)); } else { + // does not use the rule to logically follow Assert.assertNotNull(RULE.checkRuleAt(transition, c)); } } From 0613fb6567ef463f3d56477878309b868a929ee6 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 20 Oct 2023 18:21:53 -0400 Subject: [PATCH 13/14] removed isolationg code --- src/test/java/legup/TestRunner.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/legup/TestRunner.java b/src/test/java/legup/TestRunner.java index c9036beee..65837d0d5 100644 --- a/src/test/java/legup/TestRunner.java +++ b/src/test/java/legup/TestRunner.java @@ -14,7 +14,6 @@ */ public class TestRunner { public static void main(String[] args) { - /* // Battleship Tests Result result1 = JUnitCore.runClasses(AdjacentShipsContradictionRuleTest.class); printTestResults(result1); @@ -76,7 +75,6 @@ public static void main(String[] args) { printTestResults(result26); Result result27 = JUnitCore.runClasses(WhiteBottleNeckDirectRuleTest.class); printTestResults(result27); - */ // Treetent Result result28 = JUnitCore.runClasses(EmptyFieldDirectRuleTest.class); From 049226e6eed6b2ec646b833932091947a3efe69b Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Fri, 20 Oct 2023 18:23:06 -0400 Subject: [PATCH 14/14] reverted TestRunner.java --- src/test/java/legup/TestRunner.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/legup/TestRunner.java b/src/test/java/legup/TestRunner.java index 65837d0d5..9d79c590e 100644 --- a/src/test/java/legup/TestRunner.java +++ b/src/test/java/legup/TestRunner.java @@ -13,7 +13,7 @@ * This class runs all of the tests for the project without needing to run build scripts. */ public class TestRunner { - public static void main(String[] args) { + public static void main(String[] args) { // Battleship Tests Result result1 = JUnitCore.runClasses(AdjacentShipsContradictionRuleTest.class); printTestResults(result1); @@ -75,7 +75,8 @@ public static void main(String[] args) { printTestResults(result26); Result result27 = JUnitCore.runClasses(WhiteBottleNeckDirectRuleTest.class); printTestResults(result27); - + + // Treetent Result result28 = JUnitCore.runClasses(EmptyFieldDirectRuleTest.class); printTestResults(result28);