From 5e2c58f780555e2faf619d4896b2bea64352624d Mon Sep 17 00:00:00 2001
From: Rorymar <36866664+Rorymar@users.noreply.github.com>
Date: Wed, 18 Oct 2023 13:45:58 -0400
Subject: [PATCH 1/7] TooManyTents Test Overhaul
Overhauled the TooManyTents Tests to better account for possible situations, and improved commenting.
---
.../TooManyTentsContradictionRuleTest.java | 228 +++++++++++++++++-
.../TooManyTentsBottomAccount | 22 ++
...nRuleColumn_Row => TooManyTentsBottomDown} | 2 +-
.../TooManyTentsBottomMissDown | 22 ++
.../TooManyTentsBottomMissRight | 22 ++
.../TooManyTentsBottomRight | 22 ++
.../TooManyTentsTopAccount | 22 ++
.../TooManyTentsTopDown | 22 ++
.../TooManyTentsTopRight | 22 ++
.../TooManyTentsTotalFail | 22 ++
10 files changed, 398 insertions(+), 8 deletions(-)
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomAccount
rename src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/{TooManyTentsContradictionRuleColumn_Row => TooManyTentsBottomDown} (93%)
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissDown
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissRight
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomRight
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopAccount
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopDown
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopRight
create mode 100644 src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTotalFail
diff --git a/src/test/java/puzzles/treetent/rules/TooManyTentsContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/TooManyTentsContradictionRuleTest.java
index 2845c7b25..2a351556b 100644
--- a/src/test/java/puzzles/treetent/rules/TooManyTentsContradictionRuleTest.java
+++ b/src/test/java/puzzles/treetent/rules/TooManyTentsContradictionRuleTest.java
@@ -28,17 +28,162 @@ public static void setUp() {
treetent = new TreeTent();
}
+ /*
+ TESTING BASIS:
+ All test in this Rule use a 3x3 table.
+ There is a Tree at (1,1)
+ There are tents at (0,1) and (2,2)
+ All Tent Counts are listed left to right or top to bottom
+ */
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests for TooManyTents if:
+ * Row Tent Counts: 0,0,0
+ * Column Tent Counts: 0,0,0
+ */
+ @Test
+ public void TooManyTentsContradictionRule_TotalFail() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTotalFail",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);
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ 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())) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests for TooManyTents if:
+ * Row Tent Counts: 1,0,0
+ * Column Tent Counts: 0,0,0
+ */
+ @Test
+ public void TooManyTentsContradictionRule_TopRight() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopRight",treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ TreeTentCell cell1 = board.getCell(0,0);
+ TreeTentCell cell2 = board.getCell(0,1);
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ 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.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests for TooManyTests if:
+ * Row Tent Counts: 0,0,1
+ * Column Tent Counts: 0,0,0
+ */
+ @Test
+ public void TooManyTentsContradictionRule_BottomRight() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomRight",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);
+ TreeTentCell cell2 = board.getCell(0,2);
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ 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.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests for TooManyTents if:
+ * Row Tent Counts: 0,0,0
+ * Column Tent Counts: 0,1,0
+ */
+ @Test
+ public void TooManyTentsContradictionRule_TopDown() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopDown",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);
+ TreeTentCell cell2 = board.getCell(1,1);
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ 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.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests for TooManyTents if:
+ * Row Tent Counts: 0,0,0
+ * Column Tent Counts: 0,0,1
+ */
@Test
- public void TooManyTentsContradictionRule_Column_Row() throws InvalidFileFormatException {
- TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsContradictionRuleColumn_Row", treetent);
+ public void TooManyTentsContradictionRule_BottomDown() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomDown",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);
- TreeTentCell cell2 = board.getCell(2, 1);
+ TreeTentCell cell1 = board.getCell(0,1);
+ TreeTentCell cell2 = board.getCell(2,1);
Assert.assertNull(RULE.checkContradiction(board));
@@ -49,9 +194,78 @@ public void TooManyTentsContradictionRule_Column_Row() throws InvalidFileFormatE
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
}
else {
- // The TooManyTentsContradictionRule checks the col and row the cell is in
- // Therefore, even if a cell(0, 0) is empty, it follows the contradiction rule because
- // the row it is in follows the contradiciton rule. (And because cell(1, 0) has tent row tent total is 0)
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests for TooManyTents if the Top Tent is completely accounted for, but not the bottom
+ * Row Tent Counts: 1,0,0
+ * Column Tent Counts: 0,1,0
+ */
+ @Test
+ public void TooManyTentsContradictionRule_TopAccount() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopAccount",treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ TreeTentCell cell1 = board.getCell(0,0);
+ TreeTentCell cell2 = board.getCell(1,0);
+ TreeTentCell cell3 = board.getCell(0,1);
+ TreeTentCell cell4 = board.getCell(1,1);
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) ||
+ point.equals(cell3.getLocation()) || point.equals(cell4.getLocation())) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests for TooManyTents if the Bottom Tent is completely accounted for, but not the Top
+ * Row Tent Counts: 0,0,1
+ * Column Tent Counts: 0,0,1
+ */
+ @Test
+ public void TooManyTentsContradictionRule_BottomAccount() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomAccount",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);
+ TreeTentCell cell2 = board.getCell(2,1);
+ TreeTentCell cell3 = board.getCell(0,2);
+ TreeTentCell cell4 = board.getCell(2,2);
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) ||
+ point.equals(cell3.getLocation()) || point.equals(cell4.getLocation())) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
}
}
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomAccount b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomAccount
new file mode 100644
index 000000000..8474e916a
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomAccount
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsContradictionRuleColumn_Row b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomDown
similarity index 93%
rename from src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsContradictionRuleColumn_Row
rename to src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomDown
index 78e956c35..8051a5501 100644
--- a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsContradictionRuleColumn_Row
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomDown
@@ -8,7 +8,7 @@
-
+
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissDown b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissDown
new file mode 100644
index 000000000..3cbb1cdb4
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissDown
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissRight b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissRight
new file mode 100644
index 000000000..d22778c4e
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomMissRight
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomRight b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomRight
new file mode 100644
index 000000000..aeb4cd148
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsBottomRight
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopAccount b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopAccount
new file mode 100644
index 000000000..258e32d47
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopAccount
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopDown b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopDown
new file mode 100644
index 000000000..58d4bbddf
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopDown
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopRight b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopRight
new file mode 100644
index 000000000..dd5b7b935
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTopRight
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTotalFail b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTotalFail
new file mode 100644
index 000000000..9fbb8b82f
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooManyTentsContradictionRule/TooManyTentsTotalFail
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 16a8f0f1ba347037e11a2a7981adbc24a310bc9e Mon Sep 17 00:00:00 2001
From: Rorymar <36866664+Rorymar@users.noreply.github.com>
Date: Tue, 24 Oct 2023 16:51:13 -0400
Subject: [PATCH 2/7] TooFewTents Tests
Added more expansive tests for the TooFewTents rule
---
.../TooFewTentsContradictionRuleTest.java | 45 ++++++++++++++++---
.../TooFewTentsDoubleBad | 16 +++++++
.../{TooFewTents => TooFewTentsJustY} | 0
.../TooFewTentsWithTent | 16 +++++++
4 files changed, 71 insertions(+), 6 deletions(-)
create mode 100644 src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsDoubleBad
rename src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/{TooFewTents => TooFewTentsJustY} (100%)
create mode 100644 src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsWithTent
diff --git a/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java
index bfcb80a23..465b86b0a 100644
--- a/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java
+++ b/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java
@@ -10,13 +10,9 @@
import edu.rpi.legup.puzzle.treetent.TreeTent;
import edu.rpi.legup.puzzle.treetent.TreeTentBoard;
-import edu.rpi.legup.puzzle.treetent.TreeTentCell;
-import edu.rpi.legup.puzzle.treetent.TreeTentType;
import edu.rpi.legup.puzzle.treetent.rules.TooFewTentsContradictionRule;
import edu.rpi.legup.save.InvalidFileFormatException;
-import java.awt.*;
-
public class TooFewTentsContradictionRuleTest {
private static final TooFewTentsContradictionRule RULE = new TooFewTentsContradictionRule();
@@ -28,9 +24,46 @@ public static void setUp() {
treetent = new TreeTent();
}
+ /**
+ * @throws InvalidFileFormatException
+ * Using a 1x1 Puzzle Grid, which is just grass, checks if the fact it expects a tent on the y-axis is caught.
+ */
+ @Test
+ public void TooFewTentsContradictionRule_JustY() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsJustY", treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+ Assert.assertNull(RULE.checkContradiction(board));
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0)));
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Using a 1x1 Puzzle Grid, which is just a tent, checks if the fact it expects 2 tents on the y-axis is caught.
+ * (This is an impossible situation given the constraints, but for the purposes of the test it is fine)
+ */
+ @Test
+ public void TooFewTentsContradictionRule_WithTent() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsWithTent", treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+ Assert.assertNull(RULE.checkContradiction(board));
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0)));
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Using a 1x1 Puzzle Grid, which is just grass, checks if the fact it expects a tent on both x and y is caught.
+ */
@Test
- public void TooFewTentsContradictionRule_() throws InvalidFileFormatException {
- TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents", treetent);
+ public void TooFewTentsContradictionRule_DoubleBad() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsDoubleBad", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsDoubleBad b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsDoubleBad
new file mode 100644
index 000000000..ecc8988c6
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsDoubleBad
@@ -0,0 +1,16 @@
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsJustY
similarity index 100%
rename from src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents
rename to src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsJustY
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsWithTent b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsWithTent
new file mode 100644
index 000000000..8ae51f0a3
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsWithTent
@@ -0,0 +1,16 @@
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 9730b908777463f10c82ecc02dfaaec307bebc5d Mon Sep 17 00:00:00 2001
From: Rorymar <36866664+Rorymar@users.noreply.github.com>
Date: Fri, 27 Oct 2023 17:31:22 -0400
Subject: [PATCH 3/7] Fill With Tests
Completed the Fill With Test Overhaul
---
.../rules/FinishWithGrassDirectRuleTest.java | 83 ++++++++++++++++++-
.../rules/FinishWithTentsDirectRuleTest.java | 8 +-
...FinishWithGrass => FinishWithGrassJustRow} | 0
.../FinishWithGrassJustTent | 16 ++++
.../FinishWithTentsDirectRule/FinishWithTents | 2 +-
.../FinishWithTentsBothWays | 20 +++++
6 files changed, 124 insertions(+), 5 deletions(-)
rename src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/{FinishWithGrass => FinishWithGrassJustRow} (100%)
create mode 100644 src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustTent
create mode 100644 src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTentsBothWays
diff --git a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java
index 8dbec657a..5489236dd 100644
--- a/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java
+++ b/src/test/java/puzzles/treetent/rules/FinishWithGrassDirectRuleTest.java
@@ -27,9 +27,13 @@ public static void setUp() {
treetent = new TreeTent();
}
+ /**
+ * @throws InvalidFileFormatException
+ * Tests if you can fill in a row that has its number matched up.
+ */
@Test
- public void EmptyFieldTest() throws InvalidFileFormatException {
- TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass", treetent);
+ public void FinishWithGrass_JustRow() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustRow", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
@@ -58,6 +62,81 @@ public void EmptyFieldTest() throws InvalidFileFormatException {
}
}
}
+
+ /**
+ * @throws InvalidFileFormatException
+ * Tests if you pass by filling the previous board completely.
+ */
+ @Test
+ public void FinishWithGrass_FullFill() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustRow", 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);
+ TreeTentCell cell3 = board.getCell(0, 1);
+ cell3.setData(TreeTentType.GRASS);
+ TreeTentCell cell4 = board.getCell(1, 1);
+ cell4.setData(TreeTentType.GRASS);
+ TreeTentCell cell5 = board.getCell(2, 1);
+ cell5.setData(TreeTentType.GRASS);
+ TreeTentCell cell6 = board.getCell(0, 2);
+ cell6.setData(TreeTentType.GRASS);
+ TreeTentCell cell7 = board.getCell(1, 2);
+ cell7.setData(TreeTentType.GRASS);
+ TreeTentCell cell8 = board.getCell(2, 2);
+ cell8.setData(TreeTentType.GRASS);
+
+ board.addModifiedData(cell1);
+ board.addModifiedData(cell2);
+ board.addModifiedData(cell3);
+ board.addModifiedData(cell4);
+ board.addModifiedData(cell5);
+ board.addModifiedData(cell6);
+ board.addModifiedData(cell7);
+ board.addModifiedData(cell8);
+
+ Assert.assertNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) ||
+ point.equals(cell3.getLocation()) || point.equals(cell4.getLocation()) ||
+ point.equals(cell5.getLocation()) || point.equals(cell6.getLocation()) ||
+ point.equals(cell7.getLocation()) || point.equals(cell8.getLocation())
+ ) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * A super simple test that verifies that you can't pass this test with a 1x1 board of just a Tent.
+ */
+ @Test
+ public void FinishWithGrass_JustTent() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustTent", treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ Assert.assertNull(RULE.checkRule(transition));
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(0, 0)));
+ }
}
diff --git a/src/test/java/puzzles/treetent/rules/FinishWithTentsDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/FinishWithTentsDirectRuleTest.java
index 6c1468c50..259ac6fd7 100644
--- a/src/test/java/puzzles/treetent/rules/FinishWithTentsDirectRuleTest.java
+++ b/src/test/java/puzzles/treetent/rules/FinishWithTentsDirectRuleTest.java
@@ -27,8 +27,12 @@ public static void setUp() {
treetent = new TreeTent();
}
+ /**
+ * @throws InvalidFileFormatException
+ * Tests if tent successfully returns null if tents can be added
+ */
@Test
- public void EmptyFieldTest() throws InvalidFileFormatException {
+ public void FinishWithTents_Normal() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTents", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
@@ -36,7 +40,7 @@ public void EmptyFieldTest() throws InvalidFileFormatException {
TreeTentBoard board = (TreeTentBoard) transition.getBoard();
- TreeTentCell cell1 = board.getCell(1, 0);
+ TreeTentCell cell1 = board.getCell(0, 0);
cell1.setData(TreeTentType.TENT);
TreeTentCell cell2 = board.getCell(2, 0);
cell2.setData(TreeTentType.TENT);
diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustRow
similarity index 100%
rename from src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrass
rename to src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustRow
diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustTent b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustTent
new file mode 100644
index 000000000..cbd3662e6
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/FinishWithGrassDirectRule/FinishWithGrassJustTent
@@ -0,0 +1,16 @@
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTents b/src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTents
index a10c04124..4ddc202ef 100644
--- a/src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTents
+++ b/src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTents
@@ -2,7 +2,7 @@
- |
+ |
diff --git a/src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTentsBothWays b/src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTentsBothWays
new file mode 100644
index 000000000..c4d58ef60
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/FinishWithTentsDirectRule/FinishWithTentsBothWays
@@ -0,0 +1,20 @@
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 2e3c5f3e45885d76a240af9217ca6d79898e6ce5 Mon Sep 17 00:00:00 2001
From: Rorymar <36866664+Rorymar@users.noreply.github.com>
Date: Tue, 31 Oct 2023 17:28:16 -0400
Subject: [PATCH 4/7] Last Camping Spot Test
Updated the Last Camping Spot Test to be commented and more comprehensive.
---
.../rules/LastCampingSpotDirectRuleTest.java | 111 +++++++++++++++++-
.../LastCampingSpotDown | 23 ++++
.../LastCampingSpotLeft | 23 ++++
.../LastCampingSpotRight | 23 ++++
.../{LastCampingSpot => LastCampingSpotUp} | 0
5 files changed, 178 insertions(+), 2 deletions(-)
create mode 100644 src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotDown
create mode 100644 src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotLeft
create mode 100644 src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotRight
rename src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/{LastCampingSpot => LastCampingSpotUp} (100%)
diff --git a/src/test/java/puzzles/treetent/rules/LastCampingSpotDirectRuleTest.java b/src/test/java/puzzles/treetent/rules/LastCampingSpotDirectRuleTest.java
index 415b4f4b9..3e1b390fb 100644
--- a/src/test/java/puzzles/treetent/rules/LastCampingSpotDirectRuleTest.java
+++ b/src/test/java/puzzles/treetent/rules/LastCampingSpotDirectRuleTest.java
@@ -27,9 +27,14 @@ public static void setUp() {
treetent = new TreeTent();
}
+ /**
+ * @throws InvalidFileFormatException
+ *
+ * Checks if a test works for an empty square above a tree which is surrounded on all other sides.
+ */
@Test
- public void EmptyFieldTest() throws InvalidFileFormatException {
- TestUtilities.importTestBoard("puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpot", treetent);
+ public void EmptyFieldTest_Up() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotUp", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);
@@ -55,6 +60,108 @@ public void EmptyFieldTest() throws InvalidFileFormatException {
}
}
}
+
+ /**
+ * @throws InvalidFileFormatException
+ *
+ * Checks if a test works for an empty square below a tree which is surrounded on all other sides.
+ */
+ @Test
+ public void EmptyFieldTest_Down() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotDown", 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, 2);
+ cell1.setData(TreeTentType.TENT);
+
+ board.addModifiedData(cell1);
+
+ Assert.assertNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ *
+ * Checks if a test works for an empty square to the left of a tree which is surrounded on all other sides.
+ */
+ @Test
+ public void EmptyFieldTest_Left() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotLeft", 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.TENT);
+
+ board.addModifiedData(cell1);
+
+ Assert.assertNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ *
+ * Checks if a test works for an empty square to the right of a tree which is surrounded on all other sides.
+ */
+ @Test
+ public void EmptyFieldTest_Right() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotRight", treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ TreeTentCell cell1 = board.getCell(2, 1);
+ cell1.setData(TreeTentType.TENT);
+
+ board.addModifiedData(cell1);
+
+ Assert.assertNull(RULE.checkRule(transition));
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation())) {
+ 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/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotDown b/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotDown
new file mode 100644
index 000000000..cb19ab33f
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotDown
@@ -0,0 +1,23 @@
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotLeft b/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotLeft
new file mode 100644
index 000000000..e70dc4be5
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotLeft
@@ -0,0 +1,23 @@
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotRight b/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotRight
new file mode 100644
index 000000000..64ddf29db
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotRight
@@ -0,0 +1,23 @@
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpot b/src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotUp
similarity index 100%
rename from src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpot
rename to src/test/resources/puzzles/treetent/rules/LastCampingSpotDirectRule/LastCampingSpotUp
From 6afa15c57fca05a9b8da4b4f27b88dd55d69bfb8 Mon Sep 17 00:00:00 2001
From: pitbull51067 <103721450+pitbull51067@users.noreply.github.com>
Date: Thu, 9 Nov 2023 11:15:56 -0500
Subject: [PATCH 5/7] Test suite branch -- BulbsInPathContradictionRuleTest
(#674)
* 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
* BulbsInPathContradictionRuleTest looks good. I added one more function to check for the BlockInHorizontalPath test case.
* I think I might have run into a problem on the testing function. I will confirm this problem next time and will write another test case.
* I made another puzzle and test case to check what would happen if the cells could actually be lit, meaning there would be no contradiction. The test case passed and so I think CannotLightACellContradictionRule works correctly for all cases.
* I made another puzzle and test case to check what would happen if the cells could actually be lit, meaning there would be no contradiction. The test case passed and so I think CannotLightACellContradictionRule works correctly for all cases.
---------
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: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com>
Co-authored-by: ThisMatt <98851950+ThisMatt@users.noreply.github.com>
---
.../BulbsInPathContradictionRuleTest.java | 16 ++++++++++
...CannotLightACellContradictionRuleTest.java | 30 +++++++++++++++----
.../BlockInHorizontalPath | 11 +++++++
.../CanLightTest | 18 +++++++++++
4 files changed, 70 insertions(+), 5 deletions(-)
create mode 100644 src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath
create mode 100644 src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest
diff --git a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java
index b595fec15..0e7930751 100644
--- a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java
+++ b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java
@@ -34,6 +34,7 @@ public void BulbsInPathContradictionRule_LightInHorizontalPath() throws InvalidF
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 0)));
+
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1)));
}
@@ -67,4 +68,19 @@ public void BulbsInPathContradictionRule_BlockInVerticalPath() throws InvalidFil
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
}
+
+ @Test
+ public void BulbsInPathContradictionRule_BlockInHorizontalPath() throws InvalidFileFormatException{
+ TestUtilities.importTestBoard("puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath", 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(2,0)));
+ Assert.assertNotNull(RULE.checkContradictionAt(board,board.getCell(1,1)));
+
+ }
}
diff --git a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java
index 447476dbb..7b3ffd2b9 100644
--- a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java
+++ b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java
@@ -21,13 +21,13 @@ public static void setUp() {
lightUp = new LightUp();
}
- @Test
+ @Test
//extensive full testing of null and non-null in a 5x5 board
public void FullLightTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/FullLightTest", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
- transition.setRule(RULE);
+ transition.setRule(RULE);
LightUpBoard board = (LightUpBoard) transition.getBoard();
//confirm there is a contradiction somewhere on the board
@@ -36,7 +36,7 @@ public void FullLightTest() throws InvalidFileFormatException {
//confirm it is impossible to light up these squares
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 3)));
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(3, 3)));
-
+
//confirm these are not required to be lit because they are already lit or unable to be
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
@@ -44,13 +44,13 @@ public void FullLightTest() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 2)));
}
- @Test
+ @Test
//simple contradiction testing for null and non-null in a 3x3 board
public void CannotLightMiddleTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CannotLight", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
- transition.setRule(RULE);
+ transition.setRule(RULE);
LightUpBoard board = (LightUpBoard) transition.getBoard();
//confirm there is a contradiction somewhere on the board
@@ -68,4 +68,24 @@ public void CannotLightMiddleTest() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
}
+
+ @Test
+ public void CanLightTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest", lightUp);
+ TreeNode rootNode = lightUp.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ LightUpBoard board = (LightUpBoard) transition.getBoard();
+ //confirm there is not a contradiction somewhere on the board
+ Assert.assertNotNull(RULE.checkContradiction(board));
+
+ //confirm that these cells can be lit, are already lit, or that they are just black blocks
+ Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 3)));
+ Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 3)));
+ Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
+ Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
+ Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0)));
+ Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 2)));
+ }
}
diff --git a/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath b/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath
new file mode 100644
index 000000000..3c8786e54
--- /dev/null
+++ b/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath
@@ -0,0 +1,11 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest b/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest
new file mode 100644
index 000000000..4169bf382
--- /dev/null
+++ b/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest
@@ -0,0 +1,18 @@
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
\ No newline at end of file
From 9eb50758e8751a755d6630bffbf932b0c53607d9 Mon Sep 17 00:00:00 2001
From: Charles Tian <46334090+charlestian23@users.noreply.github.com>
Date: Thu, 9 Nov 2023 11:17:29 -0500
Subject: [PATCH 6/7] Revert "Test suite branch --
BulbsInPathContradictionRuleTest (#674)" (#687)
This reverts commit 6afa15c57fca05a9b8da4b4f27b88dd55d69bfb8.
---
.../BulbsInPathContradictionRuleTest.java | 16 ----------
...CannotLightACellContradictionRuleTest.java | 30 ++++---------------
.../BlockInHorizontalPath | 11 -------
.../CanLightTest | 18 -----------
4 files changed, 5 insertions(+), 70 deletions(-)
delete mode 100644 src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath
delete mode 100644 src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest
diff --git a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java
index 0e7930751..b595fec15 100644
--- a/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java
+++ b/src/test/java/puzzles/lightup/rules/BulbsInPathContradictionRuleTest.java
@@ -34,7 +34,6 @@ public void BulbsInPathContradictionRule_LightInHorizontalPath() throws InvalidF
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(2, 0)));
-
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1)));
}
@@ -68,19 +67,4 @@ public void BulbsInPathContradictionRule_BlockInVerticalPath() throws InvalidFil
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
}
-
- @Test
- public void BulbsInPathContradictionRule_BlockInHorizontalPath() throws InvalidFileFormatException{
- TestUtilities.importTestBoard("puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath", 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(2,0)));
- Assert.assertNotNull(RULE.checkContradictionAt(board,board.getCell(1,1)));
-
- }
}
diff --git a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java
index 7b3ffd2b9..447476dbb 100644
--- a/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java
+++ b/src/test/java/puzzles/lightup/rules/CannotLightACellContradictionRuleTest.java
@@ -21,13 +21,13 @@ public static void setUp() {
lightUp = new LightUp();
}
- @Test
+ @Test
//extensive full testing of null and non-null in a 5x5 board
public void FullLightTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/FullLightTest", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
- transition.setRule(RULE);
+ transition.setRule(RULE);
LightUpBoard board = (LightUpBoard) transition.getBoard();
//confirm there is a contradiction somewhere on the board
@@ -36,7 +36,7 @@ public void FullLightTest() throws InvalidFileFormatException {
//confirm it is impossible to light up these squares
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(1, 3)));
Assert.assertNull(RULE.checkContradictionAt(board, board.getCell(3, 3)));
-
+
//confirm these are not required to be lit because they are already lit or unable to be
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
@@ -44,13 +44,13 @@ public void FullLightTest() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 2)));
}
- @Test
+ @Test
//simple contradiction testing for null and non-null in a 3x3 board
public void CannotLightMiddleTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CannotLight", lightUp);
TreeNode rootNode = lightUp.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
- transition.setRule(RULE);
+ transition.setRule(RULE);
LightUpBoard board = (LightUpBoard) transition.getBoard();
//confirm there is a contradiction somewhere on the board
@@ -68,24 +68,4 @@ public void CannotLightMiddleTest() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
}
-
- @Test
- public void CanLightTest() throws InvalidFileFormatException {
- TestUtilities.importTestBoard("puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest", lightUp);
- TreeNode rootNode = lightUp.getTree().getRootNode();
- TreeTransition transition = rootNode.getChildren().get(0);
- transition.setRule(RULE);
-
- LightUpBoard board = (LightUpBoard) transition.getBoard();
- //confirm there is not a contradiction somewhere on the board
- Assert.assertNotNull(RULE.checkContradiction(board));
-
- //confirm that these cells can be lit, are already lit, or that they are just black blocks
- Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 3)));
- Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 3)));
- Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 0)));
- Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 1)));
- Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0)));
- Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(3, 2)));
- }
}
diff --git a/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath b/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath
deleted file mode 100644
index 3c8786e54..000000000
--- a/src/test/resources/puzzles/lightup/rules/BulbsInPathContradictionRule/BlockInHorizontalPath
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- |
- |
- |
-
-
-
-
\ No newline at end of file
diff --git a/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest b/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest
deleted file mode 100644
index 4169bf382..000000000
--- a/src/test/resources/puzzles/lightup/rules/CannotLightACellContradictionRule/CanLightTest
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
-
-
-
-
\ No newline at end of file
From 51e20dbdae93fc5312d3151b235348d8cef32519 Mon Sep 17 00:00:00 2001
From: Rorymar <36866664+Rorymar@users.noreply.github.com>
Date: Fri, 1 Dec 2023 17:24:30 -0500
Subject: [PATCH 7/7] TooFewTents Overhaul
---
.../rules/TentOrGrassCaseRuleTest.java | 54 ++++++
.../TooFewTentsContradictionRuleTest.java | 175 ++++++++++++++++++
.../rules/TentOrGrassCaseRule/TentOrGrassTest | 20 ++
.../TooFewTents2x2Column | 19 ++
.../TooFewTents2x2Row | 19 ++
.../TooFewTents3x3Column | 22 +++
.../TooFewTents3x3DoubleColumn | 27 +++
.../TooFewTentsNoContradiction | 19 ++
8 files changed, 355 insertions(+)
create mode 100644 src/test/java/puzzles/treetent/rules/TentOrGrassCaseRuleTest.java
create mode 100644 src/test/resources/puzzles/treetent/rules/TentOrGrassCaseRule/TentOrGrassTest
create mode 100644 src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Column
create mode 100644 src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Row
create mode 100644 src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3Column
create mode 100644 src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3DoubleColumn
create mode 100644 src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsNoContradiction
diff --git a/src/test/java/puzzles/treetent/rules/TentOrGrassCaseRuleTest.java b/src/test/java/puzzles/treetent/rules/TentOrGrassCaseRuleTest.java
new file mode 100644
index 000000000..c7159ccad
--- /dev/null
+++ b/src/test/java/puzzles/treetent/rules/TentOrGrassCaseRuleTest.java
@@ -0,0 +1,54 @@
+package puzzles.treetent.rules;
+
+import edu.rpi.legup.model.gameboard.Board;
+import edu.rpi.legup.model.tree.Tree;
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.treetent.TreeTent;
+import edu.rpi.legup.puzzle.treetent.TreeTentBoard;
+import edu.rpi.legup.puzzle.treetent.TreeTentCell;
+import edu.rpi.legup.puzzle.treetent.TreeTentType;
+import edu.rpi.legup.puzzle.treetent.rules.FillinRowCaseRule;
+import edu.rpi.legup.puzzle.treetent.rules.TentOrGrassCaseRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.awt.*;
+import java.util.ArrayList;
+
+public class TentOrGrassCaseRuleTest {
+ private static final TentOrGrassCaseRule RULE = new TentOrGrassCaseRule();
+ private static TreeTent treetent;
+
+ @BeforeClass
+ public static void setUp(){
+ MockGameBoardFacade.getInstance();
+ treetent = new TreeTent();
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * A temporary test
+ */
+ @Test
+ public void TentOrGrassCaseRule_Test() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TentOrGrassCaseRule/TentOrGrassTest", treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+ TreeTentCell testing_cell = board.getCell(1, 0);
+ ArrayList cases = RULE.getCases(board, testing_cell);
+ // assert correct number of cases created
+ Assert.assertEquals(2, cases.size());
+ //Store the 0,1 cells from each case
+ //Assert that the Array of their states match to a an array of the expected.
+
+ }
+
+}
diff --git a/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java b/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java
index 465b86b0a..a5999dc6e 100644
--- a/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java
+++ b/src/test/java/puzzles/treetent/rules/TooFewTentsContradictionRuleTest.java
@@ -1,5 +1,6 @@
package puzzles.treetent.rules;
+import edu.rpi.legup.puzzle.treetent.TreeTentCell;
import legup.MockGameBoardFacade;
import legup.TestUtilities;
import edu.rpi.legup.model.tree.TreeNode;
@@ -13,6 +14,8 @@
import edu.rpi.legup.puzzle.treetent.rules.TooFewTentsContradictionRule;
import edu.rpi.legup.save.InvalidFileFormatException;
+import java.awt.*;
+
public class TooFewTentsContradictionRuleTest {
private static final TooFewTentsContradictionRule RULE = new TooFewTentsContradictionRule();
@@ -72,5 +75,177 @@ public void TooFewTentsContradictionRule_DoubleBad() throws InvalidFileFormatExc
Assert.assertNull(RULE.checkContradiction(board));
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(0, 0)));
}
+
+ /**
+ * @throws InvalidFileFormatException
+ * Looks at a 2x2 Board in the format:
+ * [] Tr
+ * [] Gr
+ * Column 2 is checked to have 1 Tent (which is not present, thus producing a contradiction)
+ */
+ @Test
+ public void TooFewTentsContradictionRule_2x2ColumnOnly() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Column",treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ TreeTentCell cell1 = board.getCell(1,0);
+ TreeTentCell cell2 = board.getCell(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(cell1.getLocation()) || point.equals(cell2.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Looks at a 2x2 Board in the format:
+ * Tr Gr
+ * [] []
+ * Row 1 is checked to have 1 Tent (which is not present, thus producing a contradiction)
+ */
+ @Test
+ public void TooFewTentsContradictionRule_2x2RowOnly() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Row",treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ TreeTentCell cell1 = board.getCell(0,0);
+ TreeTentCell cell2 = board.getCell(1,0);
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Looks at a 3x3 Board in the format:
+ * [] Tr []
+ * [] Gr []
+ * [] Gr []
+ * Column 2 is checked to have 1 Tent (which is not present, thus producing a contradiction)
+ */
+ @Test
+ public void TooFewTentsContradictionRule_3x3OneColumn() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3Column",treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ TreeTentCell cell1 = board.getCell(1,0);
+ TreeTentCell cell2 = board.getCell(1,1);
+ TreeTentCell cell3 = board.getCell(1,2);
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || point.equals(cell3.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Looks at a 3x3 Board in the format:
+ * Gr Tr Gr
+ * Gr [] Gr
+ * Gr Tr Gr
+ * Column 1 and 3 are checked to have 1 Tent (which is not present, thus producing a contradiction)
+ */
+ @Test
+ public void TooFewTentsContradictionRule_3x3TwoColumn() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3DoubleColumn",treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ Assert.assertNull(RULE.checkContradiction(board));
+
+ TreeTentCell cell1 = board.getCell(0,0);
+ TreeTentCell cell2 = board.getCell(0,1);
+ TreeTentCell cell3 = board.getCell(0,2);
+ TreeTentCell cell4 = board.getCell(2,0);
+ TreeTentCell cell5 = board.getCell(2,1);
+ TreeTentCell cell6 = board.getCell(2,2);
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Point point = new Point(k, i);
+ if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || point.equals(cell3.getLocation()) ||
+ point.equals(cell4.getLocation()) || point.equals(cell5.getLocation()) || point.equals(cell6.getLocation())) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws InvalidFileFormatException
+ * Looks at a 2x2 Board in the format:
+ * Tn []
+ * Tr []
+ * This should fail the contradiction as it is a legal board.
+ */
+ @Test
+ public void TooFewTentsContradictionRule_NoContradiction() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsNoContradiction",treetent);
+ TreeNode rootNode = treetent.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ TreeTentBoard board = (TreeTentBoard) transition.getBoard();
+
+ Assert.assertNotNull(RULE.checkContradiction(board));
+
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+
+
+
}
diff --git a/src/test/resources/puzzles/treetent/rules/TentOrGrassCaseRule/TentOrGrassTest b/src/test/resources/puzzles/treetent/rules/TentOrGrassCaseRule/TentOrGrassTest
new file mode 100644
index 000000000..9ae8455e1
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TentOrGrassCaseRule/TentOrGrassTest
@@ -0,0 +1,20 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Column b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Column
new file mode 100644
index 000000000..0f78702c4
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Column
@@ -0,0 +1,19 @@
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Row b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Row
new file mode 100644
index 000000000..c423b179b
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents2x2Row
@@ -0,0 +1,19 @@
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3Column b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3Column
new file mode 100644
index 000000000..d1e79a76e
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3Column
@@ -0,0 +1,22 @@
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3DoubleColumn b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3DoubleColumn
new file mode 100644
index 000000000..e71832f08
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTents3x3DoubleColumn
@@ -0,0 +1,27 @@
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsNoContradiction b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsNoContradiction
new file mode 100644
index 000000000..2f609e161
--- /dev/null
+++ b/src/test/resources/puzzles/treetent/rules/TooFewTentsContradictionRule/TooFewTentsNoContradiction
@@ -0,0 +1,19 @@
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file