diff --git a/puzzles files/skyscrapers/1646651 b/puzzles files/skyscrapers/1646651
deleted file mode 100644
index 847d8639c..000000000
--- a/puzzles files/skyscrapers/1646651
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/puzzles files/skyscrapers/easy1.xml b/puzzles files/skyscrapers/easy1.xml
deleted file mode 100644
index 9d3135bff..000000000
--- a/puzzles files/skyscrapers/easy1.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java
index d276c8bff..d218e1165 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/SkyscrapersCellFactory.java
@@ -35,7 +35,7 @@ public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormat
if (x >= width || y >= height) {
throw new InvalidFileFormatException("TreeTent Factory: cell location out of bounds");
}
- if (value < 0 || value > 3) {
+ if (value < 0) {
throw new InvalidFileFormatException("TreeTent Factory: cell unknown value");
}
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/DuplicateNumberContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/DuplicateNumberContradictionRule.java
index db5357fbe..620a87f68 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/DuplicateNumberContradictionRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/DuplicateNumberContradictionRule.java
@@ -29,7 +29,6 @@ public DuplicateNumberContradictionRule() {
*/
@Override
public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
- //TODO:? Refactor to count each row/col once rather than per cell (override checkContradiction)
SkyscrapersCell cell = (SkyscrapersCell) puzzleElement;
SkyscrapersBoard skyscrapersboard = (SkyscrapersBoard) board;
Point loc = cell.getLocation();
@@ -40,8 +39,8 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
for (int i = 0; i < skyscrapersboard.getWidth(); i++) {
SkyscrapersCell c = skyscrapersboard.getCell(i, loc.y);
if (i != loc.x && cell.getType() == SkyscrapersType.Number && c.getType() == SkyscrapersType.Number && c.getData() == cell.getData()) {
- System.out.print(c.getData());
- System.out.println(cell.getData());
+ //System.out.print(c.getData());
+ //System.out.println(cell.getData());
return null;
}
}
@@ -50,8 +49,8 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
for (int i = 0; i < skyscrapersboard.getHeight(); i++) {
SkyscrapersCell c = skyscrapersboard.getCell(loc.x, i);
if (i != loc.y && cell.getType() == SkyscrapersType.Number && c.getType() == SkyscrapersType.Number && c.getData() == cell.getData()) {
- System.out.print(c.getData());
- System.out.println(cell.getData());
+ //System.out.print(c.getData());
+ //System.out.println(cell.getData());
return null;
}
}
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/ExceedingVisibilityContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/ExceedingVisibilityContradictionRule.java
index efa905ea2..e38018745 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/ExceedingVisibilityContradictionRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/ExceedingVisibilityContradictionRule.java
@@ -65,7 +65,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
Collections.reverse(row);
for (SkyscrapersCell c : row) {
if (c.getData() > max) {
- System.out.print(c.getData());
+ //System.out.print(c.getData());
//System.out.println(cell.getData());
max = c.getData();
count++;
@@ -83,7 +83,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
max = 0;
count = 0;
for (SkyscrapersCell c : col) {
- System.out.println(c.getData());
+ //System.out.println(c.getData());
if (c.getData() > max) {
//System.out.println(cell.getData());
@@ -100,7 +100,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
count = 0;
Collections.reverse(col);
for (SkyscrapersCell c : col) {
- System.out.println(c.getData());
+ //System.out.println(c.getData());
if (c.getData() > max) {
//System.out.println(cell.getData());
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/InsufficientVisibilityContradictionRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/InsufficientVisibilityContradictionRule.java
index afc1b1341..7d405f122 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/InsufficientVisibilityContradictionRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/InsufficientVisibilityContradictionRule.java
@@ -49,7 +49,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
//from west border
for (SkyscrapersCell c : row) {
if (c.getData() > max) {
- System.out.print(c.getData());
+ //System.out.print(c.getData());
//System.out.println(cell.getData());
max = c.getData();
count++;
@@ -65,7 +65,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
Collections.reverse(row);
for (SkyscrapersCell c : row) {
if (c.getData() > max) {
- System.out.print(c.getData());
+ //System.out.print(c.getData());
//System.out.println(cell.getData());
max = c.getData();
count++;
@@ -83,7 +83,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
max = 0;
count = 0;
for (SkyscrapersCell c : col) {
- System.out.println(c.getData());
+ //System.out.println(c.getData());
if (c.getData() > max) {
//System.out.println(cell.getData());
@@ -100,7 +100,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
count = 0;
Collections.reverse(col);
for (SkyscrapersCell c : col) {
- System.out.println(c.getData());
+ //System.out.println(c.getData());
if (c.getData() > max) {
//System.out.println(cell.getData());
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularCellDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularCellDirectRule.java
index 541075167..2cede4117 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularCellDirectRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularCellDirectRule.java
@@ -14,7 +14,7 @@
public class LastSingularCellDirectRule extends DirectRule {
public LastSingularCellDirectRule() {
- super("SKYS-BASC-0002", "Last Non-Duplicate Cell",
+ super("SKYS-BASC-0002", "Last Cell for Number",
"There is only one cell on this row/col for this number that does not create a duplicate contradiction",
"edu/rpi/legup/images/skyscrapers/rules/LastCell.png");
}
@@ -49,8 +49,8 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
initialBoard.setDupeFlag(dupeTemp);
initialBoard.setViewFlag(viewTemp);
- System.out.println(XCandidates.size());
- System.out.println(YCandidates.size());
+ //System.out.println(XCandidates.size());
+ //System.out.println(YCandidates.size());
//return null if either pass, both messages otherwise
String xCheck = candidateCheck(XCandidates, puzzleElement, finalCell);
@@ -96,9 +96,8 @@ private boolean isForced(SkyscrapersBoard board, SkyscrapersCell cell) {
public Board getDefaultBoard(TreeNode node) {
SkyscrapersBoard initialBoard = (SkyscrapersBoard) node.getBoard();
SkyscrapersBoard lightUpBoard = (SkyscrapersBoard) node.getBoard().copy();
- System.out.println(lightUpBoard.getPuzzleElements().size());
+ //System.out.println(lightUpBoard.getPuzzleElements().size());
for (PuzzleElement element : lightUpBoard.getPuzzleElements()) {
- System.out.println("123");
SkyscrapersCell cell = (SkyscrapersCell) element;
if (cell.getType() == SkyscrapersType.UNKNOWN && isForced(initialBoard, cell)) {
//cell.setData(SkyscrapersType.BULB.value);
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularNumberDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularNumberDirectRule.java
index 934496827..280325190 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularNumberDirectRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastSingularNumberDirectRule.java
@@ -14,7 +14,7 @@
public class LastSingularNumberDirectRule extends DirectRule {
public LastSingularNumberDirectRule() {
- super("SKYS-BASC-0003", "Last Non-Duplicate Number",
+ super("SKYS-BASC-0003", "Last Number for Cell",
"There is only one number for this cell that does not create a duplicate contradiction",
"edu/rpi/legup/images/skyscrapers/rules/LastNumber.png");
}
@@ -79,9 +79,8 @@ private boolean isForced(SkyscrapersBoard board, SkyscrapersCell cell) {
public Board getDefaultBoard(TreeNode node) {
SkyscrapersBoard initialBoard = (SkyscrapersBoard) node.getBoard();
SkyscrapersBoard lightUpBoard = (SkyscrapersBoard) node.getBoard().copy();
- System.out.println(lightUpBoard.getPuzzleElements().size());
+ //System.out.println(lightUpBoard.getPuzzleElements().size());
for (PuzzleElement element : lightUpBoard.getPuzzleElements()) {
- System.out.println("123");
SkyscrapersCell cell = (SkyscrapersCell) element;
if (cell.getType() == SkyscrapersType.UNKNOWN && isForced(initialBoard, cell)) {
//cell.setData(SkyscrapersType.BULB.value);
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleCellDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleCellDirectRule.java
index 49dc33677..3aa28bab8 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleCellDirectRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleCellDirectRule.java
@@ -50,8 +50,8 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
initialBoard.setDupeFlag(dupeTemp);
initialBoard.setViewFlag(viewTemp);
- System.out.println(XCandidates.size());
- System.out.println(YCandidates.size());
+ //System.out.println(XCandidates.size());
+ //System.out.println(YCandidates.size());
//return null if either pass, both messages otherwise
String xCheck = candidateCheck(XCandidates, puzzleElement, finalCell);
@@ -97,16 +97,15 @@ private boolean isForced(SkyscrapersBoard board, SkyscrapersCell cell) {
public Board getDefaultBoard(TreeNode node) {
SkyscrapersBoard initialBoard = (SkyscrapersBoard) node.getBoard();
SkyscrapersBoard modBoard = (SkyscrapersBoard) node.getBoard().copy();
- System.out.println(modBoard.getPuzzleElements().size());
+ //System.out.println(modBoard.getPuzzleElements().size());
for (PuzzleElement element : modBoard.getPuzzleElements()) {
- System.out.println("123");
SkyscrapersCell cell = (SkyscrapersCell) element;
if (cell.getType() == SkyscrapersType.UNKNOWN && isForced(initialBoard, cell)) {
//cell.setData(SkyscrapersType.BULB.value);
modBoard.addModifiedData(cell);
}
}
- System.out.println(modBoard.getModifiedData().isEmpty());
+ //System.out.println(modBoard.getModifiedData().isEmpty());
if (modBoard.getModifiedData().isEmpty()) {
return null;
}
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleNumberDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleNumberDirectRule.java
index d3d4ff2ab..e5524418d 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleNumberDirectRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/LastVisibleNumberDirectRule.java
@@ -80,9 +80,8 @@ private boolean isForced(SkyscrapersBoard board, SkyscrapersCell cell) {
public Board getDefaultBoard(TreeNode node) {
SkyscrapersBoard initialBoard = (SkyscrapersBoard) node.getBoard();
SkyscrapersBoard lightUpBoard = (SkyscrapersBoard) node.getBoard().copy();
- System.out.println(lightUpBoard.getPuzzleElements().size());
+ //System.out.println(lightUpBoard.getPuzzleElements().size());
for (PuzzleElement element : lightUpBoard.getPuzzleElements()) {
- System.out.println("123");
SkyscrapersCell cell = (SkyscrapersCell) element;
if (cell.getType() == SkyscrapersType.UNKNOWN && isForced(initialBoard, cell)) {
//cell.setData(SkyscrapersType.BULB.value);
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NEdgeDirectRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NEdgeDirectRule.java
index 9ba726ae4..78533a819 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NEdgeDirectRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NEdgeDirectRule.java
@@ -81,9 +81,8 @@ private boolean isForced(SkyscrapersBoard board, SkyscrapersCell cell) {
public Board getDefaultBoard(TreeNode node) {
SkyscrapersBoard initialBoard = (SkyscrapersBoard) node.getBoard();
SkyscrapersBoard lightUpBoard = (SkyscrapersBoard) node.getBoard().copy();
- System.out.println(lightUpBoard.getPuzzleElements().size());
+ //System.out.println(lightUpBoard.getPuzzleElements().size());
for (PuzzleElement element : lightUpBoard.getPuzzleElements()) {
- System.out.println("123");
SkyscrapersCell cell = (SkyscrapersCell) element;
if (cell.getType() == SkyscrapersType.UNKNOWN && isForced(initialBoard, cell)) {
//cell.setData(SkyscrapersType.BULB.value);
diff --git a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NumberForCellCaseRule.java b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NumberForCellCaseRule.java
index a061c62a3..1bc059116 100644
--- a/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NumberForCellCaseRule.java
+++ b/src/main/java/edu/rpi/legup/puzzle/skyscrapers/rules/NumberForCellCaseRule.java
@@ -87,7 +87,6 @@ public ArrayList getCases(Board board, PuzzleElement puzzleElement) {
public String checkRuleRaw(TreeTransition transition) {
List childTransitions = transition.getParents().get(0).getChildren();
if (childTransitions.size() == 0) {
- //System.out.println("0");
return "This case rule must have at least one child.";
}
else {
@@ -104,16 +103,13 @@ public String checkRuleRaw(TreeTransition transition) {
for (int i = 0; i < childTransitions.size(); i++) {
TreeTransition case2 = childTransitions.get(i);
if (case2.getBoard().getModifiedData().size() != 1) {
- //System.out.println("1");
return super.getInvalidUseOfRuleMessage() + ": This case rule must have 1 modified cell for each case.";
}
SkyscrapersCell mod2 = (SkyscrapersCell) case2.getBoard().getModifiedData().iterator().next();
if (!mod1.getLocation().equals(mod2.getLocation())) {
- //System.out.println("2");
return super.getInvalidUseOfRuleMessage() + ": This case rule must modify the same cell for each case.";
}
if (!(mod2.getType() == SkyscrapersType.Number)) {
- //System.out.println("3");
return super.getInvalidUseOfRuleMessage() + ": This case rule must assign a number.";
}
}
diff --git a/src/test/java/legup/TestRunner.java b/src/test/java/legup/TestRunner.java
index 9d79c590e..0f24e2249 100644
--- a/src/test/java/legup/TestRunner.java
+++ b/src/test/java/legup/TestRunner.java
@@ -7,6 +7,7 @@
import puzzles.battleship.rules.*;
import puzzles.lightup.rules.*;
import puzzles.nurikabe.rules.*;
+import puzzles.skyscrapers.rules.*;
import puzzles.treetent.rules.*;
/**
@@ -94,6 +95,21 @@ public static void main(String[] args) {
printTestResults(result34);
Result result35 = JUnitCore.runClasses(TreeForTentDirectRuleTest.class);
printTestResults(result35);
+
+ // Skyscrapers Tests
+ Result result36 = JUnitCore.runClasses(DuplicateNumberContradictionTest.class);
+ printTestResults(result36);
+ Result result37 = JUnitCore.runClasses(ExceedingVisibilityContradictionTest.class);
+ printTestResults(result37);
+ Result result38 = JUnitCore.runClasses(InsufficientVisibilityContradictionTest.class);
+ printTestResults(result38);
+ Result result39 = JUnitCore.runClasses(PreemptiveVisibilityContradictionTest.class);
+ printTestResults(result39);
+ Result result40 = JUnitCore.runClasses(UnresolvedCellContradictionTest.class);
+ printTestResults(result40);
+ Result result41 = JUnitCore.runClasses(UnresolvedNumberContradictionTest.class);
+ printTestResults(result41);
+
}
private static void printTestResults(Result result) {
diff --git a/src/test/java/puzzles/skyscrapers/rules/DuplicateNumberContradictionTest.java b/src/test/java/puzzles/skyscrapers/rules/DuplicateNumberContradictionTest.java
new file mode 100644
index 000000000..00cce1b91
--- /dev/null
+++ b/src/test/java/puzzles/skyscrapers/rules/DuplicateNumberContradictionTest.java
@@ -0,0 +1,150 @@
+package puzzles.skyscrapers.rules;
+
+
+import edu.rpi.legup.puzzle.skyscrapers.Skyscrapers;
+import edu.rpi.legup.puzzle.skyscrapers.SkyscrapersBoard;
+import edu.rpi.legup.puzzle.skyscrapers.rules.DuplicateNumberContradictionRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class DuplicateNumberContradictionTest {
+
+ private static final DuplicateNumberContradictionRule RULE = new DuplicateNumberContradictionRule();
+ private static Skyscrapers skyscrapers;
+
+ @BeforeClass
+ public static void setUp() {
+ MockGameBoardFacade.getInstance();
+ skyscrapers = new Skyscrapers();
+ }
+
+ //empty
+ @Test
+ public void DuplicateNumberContradictionRule_EmptyBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/empty", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ 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)));
+ }
+ }
+ }
+
+ //correct board, no cont
+ @Test
+ public void DuplicateNumberContradictionRule_SolvedBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/Solved", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ 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)));
+ }
+ }
+ }
+
+ //invalid board, no cont
+ @Test
+ public void DuplicateNumberContradictionRule_OtherContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/FullRowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ 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)));
+ }
+ }
+ }
+
+ //on row
+ @Test
+ public void DuplicateNumberContradictionRule_RowContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/RowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ if((k==0 || k==1) && i==0){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ //on col
+ @Test
+ public void DuplicateNumberContradictionRule_ColContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/ColContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ if(k==0 && (i==0 || i==1)){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ //multitudes
+ @Test
+ public void DuplicateNumberContradictionRule_AllContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/AllContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/skyscrapers/rules/ExceedingVisibilityContradictionTest.java b/src/test/java/puzzles/skyscrapers/rules/ExceedingVisibilityContradictionTest.java
new file mode 100644
index 000000000..c7f73c998
--- /dev/null
+++ b/src/test/java/puzzles/skyscrapers/rules/ExceedingVisibilityContradictionTest.java
@@ -0,0 +1,138 @@
+package puzzles.skyscrapers.rules;
+
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.skyscrapers.Skyscrapers;
+import edu.rpi.legup.puzzle.skyscrapers.SkyscrapersBoard;
+import edu.rpi.legup.puzzle.skyscrapers.rules.ExceedingVisibilityContradictionRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ExceedingVisibilityContradictionTest {
+
+ private static final ExceedingVisibilityContradictionRule RULE = new ExceedingVisibilityContradictionRule();
+ private static Skyscrapers skyscrapers;
+
+ @BeforeClass
+ public static void setUp() {
+ MockGameBoardFacade.getInstance();
+ skyscrapers = new Skyscrapers();
+ }
+
+ //empty
+ @Test
+ public void ExceedingVisibilityContradictionRule_EmptyBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/empty", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //correct board, no cont
+ @Test
+ public void ExceedingVisibilityContradictionRule_SolvedBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/Solved", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //invalid board, no cont
+ @Test
+ public void ExceedingVisibilityContradictionRule_OtherContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/RowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //on row
+ @Test
+ public void ExceedingVisibilityContradictionRule_RowContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/FullRowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if(i==1 || i==3){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //on col
+ @Test
+ public void ExceedingVisibilityContradictionRule_ColContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/FullColContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if(i==2 || i==3){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //multitudes
+ @Test
+ public void ExceedingVisibilityContradictionRule_AllContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/AllContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/skyscrapers/rules/InsufficientVisibilityContradictionTest.java b/src/test/java/puzzles/skyscrapers/rules/InsufficientVisibilityContradictionTest.java
new file mode 100644
index 000000000..4e90861fc
--- /dev/null
+++ b/src/test/java/puzzles/skyscrapers/rules/InsufficientVisibilityContradictionTest.java
@@ -0,0 +1,138 @@
+package puzzles.skyscrapers.rules;
+
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.skyscrapers.Skyscrapers;
+import edu.rpi.legup.puzzle.skyscrapers.SkyscrapersBoard;
+import edu.rpi.legup.puzzle.skyscrapers.rules.InsufficientVisibilityContradictionRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class InsufficientVisibilityContradictionTest {
+
+ private static final InsufficientVisibilityContradictionRule RULE = new InsufficientVisibilityContradictionRule();
+ private static Skyscrapers skyscrapers;
+
+ @BeforeClass
+ public static void setUp() {
+ MockGameBoardFacade.getInstance();
+ skyscrapers = new Skyscrapers();
+ }
+
+ //empty
+ @Test
+ public void InsufficientVisibilityContradictionRule_EmptyBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/empty", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //correct board, no cont
+ @Test
+ public void InsufficientVisibilityContradictionRule_SolvedBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/Solved", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //invalid board, no cont
+ @Test
+ public void InsufficientVisibilityContradictionRule_OtherContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/RowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //on row
+ @Test
+ public void InsufficientVisibilityContradictionRule_RowContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/FullRowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if(i==1 || i==3){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //on col
+ @Test
+ public void InsufficientVisibilityContradictionRule_ColContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/FullColContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if(i==2 || i==3){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //multitudes
+ @Test
+ public void InsufficientVisibilityContradictionRule_AllContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/AllContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/skyscrapers/rules/PreemptiveVisibilityContradictionTest.java b/src/test/java/puzzles/skyscrapers/rules/PreemptiveVisibilityContradictionTest.java
new file mode 100644
index 000000000..69f4e593a
--- /dev/null
+++ b/src/test/java/puzzles/skyscrapers/rules/PreemptiveVisibilityContradictionTest.java
@@ -0,0 +1,155 @@
+package puzzles.skyscrapers.rules;
+
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.skyscrapers.Skyscrapers;
+import edu.rpi.legup.puzzle.skyscrapers.SkyscrapersBoard;
+import edu.rpi.legup.puzzle.skyscrapers.rules.PreemptiveVisibilityContradictionRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class PreemptiveVisibilityContradictionTest {
+
+ private static final PreemptiveVisibilityContradictionRule RULE = new PreemptiveVisibilityContradictionRule();
+ private static Skyscrapers skyscrapers;
+
+ @BeforeClass
+ public static void setUp() {
+ MockGameBoardFacade.getInstance();
+ skyscrapers = new Skyscrapers();
+ }
+
+ //empty
+ @Test
+ public void PreemptiveVisibilityContradictionRule_EmptyBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/empty", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //correct board, no cont
+ @Test
+ public void PreemptiveVisibilityContradictionRule_SolvedBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/Solved", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //invalid board, no cont
+ @Test
+ public void PreemptiveVisibilityContradictionRule_OtherContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2CellContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //on row
+ @Test
+ public void PreemptiveVisibilityContradictionRule_RowContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedRowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if(i==1){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //on col
+ @Test
+ public void PreemptiveVisibilityContradictionRule_ColContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedColContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if(i==2){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //multitudes
+ @Test
+ public void PreemptiveVisibilityContradictionRule_AllContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/AllContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //multitudes - preemptive
+ @Test
+ public void PreemptiveVisibilityContradictionRule_ImpliedAllContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedAllContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/skyscrapers/rules/UnresolvedCellContradictionTest.java b/src/test/java/puzzles/skyscrapers/rules/UnresolvedCellContradictionTest.java
new file mode 100644
index 000000000..d5f21a8d7
--- /dev/null
+++ b/src/test/java/puzzles/skyscrapers/rules/UnresolvedCellContradictionTest.java
@@ -0,0 +1,155 @@
+package puzzles.skyscrapers.rules;
+
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.skyscrapers.Skyscrapers;
+import edu.rpi.legup.puzzle.skyscrapers.SkyscrapersBoard;
+import edu.rpi.legup.puzzle.skyscrapers.rules.UnresolvedCellContradictionRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class UnresolvedCellContradictionTest {
+
+ private static final UnresolvedCellContradictionRule RULE = new UnresolvedCellContradictionRule();
+ private static Skyscrapers skyscrapers;
+
+ @BeforeClass
+ public static void setUp() {
+ MockGameBoardFacade.getInstance();
+ skyscrapers = new Skyscrapers();
+ }
+
+ //empty
+ @Test
+ public void UnresolvedCellContradictionRule_EmptyBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/empty", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ 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)));
+ }
+ }
+ }
+
+ //correct board, no cont
+ @Test
+ public void UnresolvedCellContradictionRule_SolvedBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/Solved", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ 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)));
+ }
+ }
+ }
+
+ //invalid board, no cont
+ @Test
+ public void UnresolvedCellContradictionRule_OtherContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedAllContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ 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)));
+ }
+ }
+ }
+
+ //3 in a row, 1 in col creates contradiction
+ @Test
+ public void UnresolvedCellContradictionRule_RowContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1RowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ if(k==2 && i==3){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ //3 in a col, 1 in row creates contradiction
+ @Test
+ public void UnresolvedCellContradictionRule_ColContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1ColContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ if(k==1 && i==0){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+
+ //2 in a col, 2 in row creates cell contradiction
+ @Test
+ public void UnresolvedCellContradictionRule_MixedContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2CellContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ for (int k = 0; k < board.getWidth(); k++) {
+ if(k==2 && i==3){
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ else{
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/puzzles/skyscrapers/rules/UnresolvedNumberContradictionTest.java b/src/test/java/puzzles/skyscrapers/rules/UnresolvedNumberContradictionTest.java
new file mode 100644
index 000000000..fe4a4865a
--- /dev/null
+++ b/src/test/java/puzzles/skyscrapers/rules/UnresolvedNumberContradictionTest.java
@@ -0,0 +1,165 @@
+package puzzles.skyscrapers.rules;
+
+
+import edu.rpi.legup.model.tree.TreeNode;
+import edu.rpi.legup.model.tree.TreeTransition;
+import edu.rpi.legup.puzzle.skyscrapers.Skyscrapers;
+import edu.rpi.legup.puzzle.skyscrapers.SkyscrapersBoard;
+import edu.rpi.legup.puzzle.skyscrapers.rules.UnresolvedNumberContradictionRule;
+import edu.rpi.legup.save.InvalidFileFormatException;
+import legup.MockGameBoardFacade;
+import legup.TestUtilities;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class UnresolvedNumberContradictionTest {
+
+ private static final UnresolvedNumberContradictionRule RULE = new UnresolvedNumberContradictionRule();
+ private static Skyscrapers skyscrapers;
+
+ @BeforeClass
+ public static void setUp() {
+ MockGameBoardFacade.getInstance();
+ skyscrapers = new Skyscrapers();
+ }
+
+ //empty
+ @Test
+ public void UnresolvedNumberContradictionRule_EmptyBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/empty", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //correct board, no cont
+ @Test
+ public void UnresolvedNumberContradictionRule_SolvedBoardTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/common/Solved", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //invalid board, no cont
+ @Test
+ public void UnresolvedNumberContradictionRule_OtherContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedAllContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNotNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+
+ //3 in a row, 1 in col creates contradiction
+ @Test
+ public void UnresolvedNumberContradictionRule_RowContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1RowContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if (i == 3) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //3 in a col, 1 in row creates contradiction
+ @Test
+ public void UnresolvedNumberContradictionRule_ColContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1ColContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if (i == 1) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //2 in a row/col, 2 in other row/cols creates number contradiction
+ @Test
+ public void UnresolvedNumberContradictionRule_TwoContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2NumberContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if (i == 1 || i == 3) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+
+ //1 in a row/col, 3 in other row/cols creates number contradiction
+ @Test
+ public void UnresolvedNumberContradictionRule_ThreeContradictionTest() throws InvalidFileFormatException {
+ TestUtilities.importTestBoard("puzzles/skyscrapers/rules/UnresolvedContradictionRules/1-3NumberContradiction", skyscrapers);
+
+ TreeNode rootNode = skyscrapers.getTree().getRootNode();
+ TreeTransition transition = rootNode.getChildren().get(0);
+ transition.setRule(RULE);
+
+ Assert.assertNull(RULE.checkContradiction((SkyscrapersBoard) transition.getBoard()));
+
+ SkyscrapersBoard board = (SkyscrapersBoard) transition.getBoard();
+ for (int i = 0; i < board.getHeight(); i++) {
+ if (i == 1 || i == 2) {
+ Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ else {
+ Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(i, i)));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/AllContradiction b/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/AllContradiction
new file mode 100644
index 000000000..a1e81a86e
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/AllContradiction
@@ -0,0 +1,39 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/ColContradiction b/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/ColContradiction
new file mode 100644
index 000000000..2fd32645c
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/ColContradiction
@@ -0,0 +1,25 @@
+
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/RowContradiction b/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/RowContradiction
new file mode 100644
index 000000000..29da502d9
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/DuplicateNumberContradictionRule/RowContradiction
@@ -0,0 +1,25 @@
+
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/1-3NumberContradiction b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/1-3NumberContradiction
new file mode 100644
index 000000000..51aa44822
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/1-3NumberContradiction
@@ -0,0 +1,27 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2CellContradiction b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2CellContradiction
new file mode 100644
index 000000000..2d6dd8df0
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2CellContradiction
@@ -0,0 +1,27 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2NumberContradiction b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2NumberContradiction
new file mode 100644
index 000000000..7bd380e92
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/2-2NumberContradiction
@@ -0,0 +1,28 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1ColContradiction b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1ColContradiction
new file mode 100644
index 000000000..046d2ea8e
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1ColContradiction
@@ -0,0 +1,27 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1RowContradiction b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1RowContradiction
new file mode 100644
index 000000000..3063aeea1
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/UnresolvedContradictionRules/3-1RowContradiction
@@ -0,0 +1,27 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/AllContradiction b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/AllContradiction
new file mode 100644
index 000000000..1b2a81ca8
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/AllContradiction
@@ -0,0 +1,42 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/FullColContradiction b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/FullColContradiction
new file mode 100644
index 000000000..3c0e67993
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/FullColContradiction
@@ -0,0 +1,32 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/FullRowContradiction b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/FullRowContradiction
new file mode 100644
index 000000000..0a731bc7d
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/FullRowContradiction
@@ -0,0 +1,32 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedAllContradiction b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedAllContradiction
new file mode 100644
index 000000000..29aa271bf
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedAllContradiction
@@ -0,0 +1,31 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedColContradiction b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedColContradiction
new file mode 100644
index 000000000..bdef438d5
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedColContradiction
@@ -0,0 +1,24 @@
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedRowContradiction b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedRowContradiction
new file mode 100644
index 000000000..3402712ad
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/VisibilityContradictionRules/ImpliedRowContradiction
@@ -0,0 +1,24 @@
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/common/Solved b/src/test/resources/puzzles/skyscrapers/rules/common/Solved
new file mode 100644
index 000000000..5dc1210e9
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/common/Solved
@@ -0,0 +1,42 @@
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/puzzles/skyscrapers/rules/common/empty b/src/test/resources/puzzles/skyscrapers/rules/common/empty
new file mode 100644
index 000000000..64fa7a340
--- /dev/null
+++ b/src/test/resources/puzzles/skyscrapers/rules/common/empty
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+