Skip to content

Commit

Permalink
Revert "Starbattle rules causing checkstyle error on github"
Browse files Browse the repository at this point in the history
This reverts commit c274436.
  • Loading branch information
zacharybonagura committed Aug 19, 2024
1 parent c274436 commit 76aa2e7
Show file tree
Hide file tree
Showing 12 changed files with 2,501 additions and 2,501 deletions.
432 changes: 216 additions & 216 deletions src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.java

Large diffs are not rendered by default.

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)));
}
}
}
}
Loading

0 comments on commit 76aa2e7

Please sign in to comment.