forked from Bram-Hub/LEGUP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Starbattle rules causing checkstyle error on github"
This reverts commit c274436.
- Loading branch information
1 parent
c274436
commit 76aa2e7
Showing
12 changed files
with
2,501 additions
and
2,501 deletions.
There are no files selected for viewing
432 changes: 216 additions & 216 deletions
432
src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
274 changes: 137 additions & 137 deletions
274
src/test/java/puzzles/starbattle/rules/ClashingOrbitContradictionRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +1,137 @@ | ||
//package puzzles.starbattle.rules; | ||
// | ||
//import edu.rpi.legup.puzzle.starbattle.rules.ClashingOrbitContradictionRule; | ||
//import edu.rpi.legup.model.tree.TreeNode; | ||
//import edu.rpi.legup.model.tree.TreeTransition; | ||
//import edu.rpi.legup.puzzle.starbattle.StarBattle; | ||
//import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; | ||
//import edu.rpi.legup.puzzle.starbattle.StarBattleCell; | ||
//import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; | ||
//import edu.rpi.legup.save.InvalidFileFormatException; | ||
//import java.awt.*; | ||
//import legup.MockGameBoardFacade; | ||
//import legup.TestUtilities; | ||
//import org.junit.Assert; | ||
//import org.junit.BeforeClass; | ||
//import org.junit.Test; | ||
// | ||
//public class ClashingOrbitContradictionRuleTest { | ||
// | ||
// private static final ClashingOrbitContradictionRule RULE = new ClashingOrbitContradictionRule(); | ||
// private static StarBattle starBattle; | ||
// | ||
// @BeforeClass | ||
// public static void setUp() { | ||
// MockGameBoardFacade.getInstance(); | ||
// starBattle = new StarBattle(); | ||
// } | ||
// | ||
// /*Tests the Clashing Orbit contradiction rule for directly adjacent stars not at the | ||
// edge of the board */ | ||
// @Test | ||
// public void ClashingOrbitContradictionRule_DirectlyAdjacentCenter() | ||
// throws InvalidFileFormatException | ||
// { | ||
// TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter", starBattle); | ||
// TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
// TreeTransition transition = rootNode.getChildren().get(0); | ||
// transition.setRule(RULE); | ||
// | ||
// StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
// StarBattleCell cell1 = board.getCell(1,1); | ||
// StarBattleCell cell2 = board.getCell(2,1); | ||
// | ||
// Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
// | ||
// for (int i = 0; i < board.getHeight(); ++i) { | ||
// for (int j = 0; j < board.getWidth(); ++j) { | ||
// Point point = new Point(j,i); | ||
// if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { | ||
// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
// } | ||
// else { | ||
// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
// } | ||
// } | ||
// } | ||
// } | ||
// | ||
// /* Tests the Clashing Orbit contradiction rule for diagonally adjacent stars */ | ||
// @Test | ||
// public void ClashingOrbitContradictionRule_DiagonallyAdjacent() | ||
// throws InvalidFileFormatException | ||
// { | ||
// TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DiagonallyAdjacent", starBattle); | ||
// TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
// TreeTransition transition = rootNode.getChildren().get(0); | ||
// transition.setRule(RULE); | ||
// | ||
// StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
// StarBattleCell cell1 = board.getCell(1,1); | ||
// StarBattleCell cell2 = board.getCell(2,2); | ||
// | ||
// Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
// | ||
// for (int i = 0; i < board.getHeight(); ++i) { | ||
// for (int j = 0; j < board.getWidth(); ++j) { | ||
// Point point = new Point(j,i); | ||
// if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { | ||
// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
// } | ||
// else { | ||
// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
// } | ||
// } | ||
// } | ||
// } | ||
// | ||
// /*Tests the Clashing Orbit contradiction rule for stars at the edge of the board */ | ||
// @Test | ||
// public void ClashingOrbitContradictionRule_DirectlyAdjacentEdge() | ||
// throws InvalidFileFormatException | ||
// { | ||
// TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentEdge", starBattle); | ||
// TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
// TreeTransition transition = rootNode.getChildren().get(0); | ||
// transition.setRule(RULE); | ||
// | ||
// StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
// StarBattleCell cell1 = board.getCell(0,0); | ||
// StarBattleCell cell2 = board.getCell(1,0); | ||
// | ||
// Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
// | ||
// for (int i = 0; i < board.getHeight(); ++i) { | ||
// for (int j = 0; j < board.getWidth(); ++j) { | ||
// Point point = new Point(j,i); | ||
// if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { | ||
// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
// } | ||
// else { | ||
// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
// } | ||
// } | ||
// } | ||
// } | ||
// | ||
// /*Tests the Clashing Orbit contradiction rule for a false contradiction. */ | ||
// @Test | ||
// public void ClashingOrbitContradictionRule_FalseContradiction() | ||
// throws InvalidFileFormatException | ||
// { | ||
// TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/FalseContradiction", starBattle); | ||
// TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
// TreeTransition transition = rootNode.getChildren().get(0); | ||
// transition.setRule(RULE); | ||
// | ||
// StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
// | ||
// Assert.assertNotNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
// | ||
// for (int i = 0; i < board.getHeight(); ++i) { | ||
// for (int j = 0; j < board.getWidth(); ++j) { | ||
// Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
// } | ||
// } | ||
// } | ||
//} | ||
package puzzles.starbattle.rules; | ||
|
||
import edu.rpi.legup.puzzle.starbattle.rules.ClashingOrbitContradictionRule; | ||
import edu.rpi.legup.model.tree.TreeNode; | ||
import edu.rpi.legup.model.tree.TreeTransition; | ||
import edu.rpi.legup.puzzle.starbattle.StarBattle; | ||
import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; | ||
import edu.rpi.legup.puzzle.starbattle.StarBattleCell; | ||
import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; | ||
import edu.rpi.legup.save.InvalidFileFormatException; | ||
import java.awt.*; | ||
import legup.MockGameBoardFacade; | ||
import legup.TestUtilities; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
public class ClashingOrbitContradictionRuleTest { | ||
|
||
private static final ClashingOrbitContradictionRule RULE = new ClashingOrbitContradictionRule(); | ||
private static StarBattle starBattle; | ||
|
||
@BeforeClass | ||
public static void setUp() { | ||
MockGameBoardFacade.getInstance(); | ||
starBattle = new StarBattle(); | ||
} | ||
|
||
/*Tests the Clashing Orbit contradiction rule for directly adjacent stars not at the | ||
edge of the board */ | ||
@Test | ||
public void ClashingOrbitContradictionRule_DirectlyAdjacentCenter() | ||
throws InvalidFileFormatException | ||
{ | ||
TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentCenter", starBattle); | ||
TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
StarBattleCell cell1 = board.getCell(1,1); | ||
StarBattleCell cell2 = board.getCell(2,1); | ||
|
||
Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
|
||
for (int i = 0; i < board.getHeight(); ++i) { | ||
for (int j = 0; j < board.getWidth(); ++j) { | ||
Point point = new Point(j,i); | ||
if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { | ||
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
} | ||
else { | ||
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* Tests the Clashing Orbit contradiction rule for diagonally adjacent stars */ | ||
@Test | ||
public void ClashingOrbitContradictionRule_DiagonallyAdjacent() | ||
throws InvalidFileFormatException | ||
{ | ||
TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DiagonallyAdjacent", starBattle); | ||
TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
StarBattleCell cell1 = board.getCell(1,1); | ||
StarBattleCell cell2 = board.getCell(2,2); | ||
|
||
Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
|
||
for (int i = 0; i < board.getHeight(); ++i) { | ||
for (int j = 0; j < board.getWidth(); ++j) { | ||
Point point = new Point(j,i); | ||
if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { | ||
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
} | ||
else { | ||
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/*Tests the Clashing Orbit contradiction rule for stars at the edge of the board */ | ||
@Test | ||
public void ClashingOrbitContradictionRule_DirectlyAdjacentEdge() | ||
throws InvalidFileFormatException | ||
{ | ||
TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/DirectlyAdjacentEdge", starBattle); | ||
TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
StarBattleCell cell1 = board.getCell(0,0); | ||
StarBattleCell cell2 = board.getCell(1,0); | ||
|
||
Assert.assertNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
|
||
for (int i = 0; i < board.getHeight(); ++i) { | ||
for (int j = 0; j < board.getWidth(); ++j) { | ||
Point point = new Point(j,i); | ||
if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation())) { | ||
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
} | ||
else { | ||
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/*Tests the Clashing Orbit contradiction rule for a false contradiction. */ | ||
@Test | ||
public void ClashingOrbitContradictionRule_FalseContradiction() | ||
throws InvalidFileFormatException | ||
{ | ||
TestUtilities.importTestBoard("puzzles/starbattle/rules/ClashingOrbitContradictionRule/FalseContradiction", starBattle); | ||
TreeNode rootNode = starBattle.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
|
||
Assert.assertNotNull(RULE.checkContradiction((StarBattleBoard) transition.getBoard())); | ||
|
||
for (int i = 0; i < board.getHeight(); ++i) { | ||
for (int j = 0; j < board.getWidth(); ++j) { | ||
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i))); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.