Skip to content

Commit

Permalink
Automated Java code formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram28 committed May 5, 2024
1 parent ecfbff6 commit 9e623a0
Show file tree
Hide file tree
Showing 16 changed files with 450 additions and 536 deletions.
27 changes: 13 additions & 14 deletions src/main/java/edu/rpi/legup/model/PuzzleImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import edu.rpi.legup.model.rules.Rule;
import edu.rpi.legup.model.tree.*;
import edu.rpi.legup.save.InvalidFileFormatException;

import java.lang.reflect.Array;
import java.util.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -132,18 +130,19 @@ public void initializePuzzle(Node node) throws InvalidFileFormatException {
public abstract void initializeBoard(String[] statements)
throws UnsupportedOperationException, IllegalArgumentException;

/**
* Used to check that elements in the proof tree are saved properly.
* <p> Make sure the list elements are lowercase
*
* @return A list of elements that will change when solving the puzzle
* * e.g. {"cell"}, {"cell", "line"}
*/
public List<String> getImporterElements() {
List<String> elements = new ArrayList<>();
elements.add("cell");
return elements;
}
/**
* Used to check that elements in the proof tree are saved properly.
*
* <p>Make sure the list elements are lowercase
*
* @return A list of elements that will change when solving the puzzle * e.g. {"cell"}, {"cell",
* "line"}
*/
public List<String> getImporterElements() {
List<String> elements = new ArrayList<>();
elements.add("cell");
return elements;
}

/**
* Creates the proof for building
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import edu.rpi.legup.model.gameboard.Board;
import edu.rpi.legup.model.gameboard.GridBoard;
import edu.rpi.legup.model.gameboard.PuzzleElement;
import edu.rpi.legup.model.tree.Tree;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package edu.rpi.legup.puzzle.treetent.rules;

import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.model.gameboard.Board;
import edu.rpi.legup.model.gameboard.CaseBoard;
import edu.rpi.legup.model.gameboard.PuzzleElement;
import edu.rpi.legup.model.rules.CaseRule;
import edu.rpi.legup.model.tree.Tree;
import edu.rpi.legup.model.tree.TreeTransition;
import edu.rpi.legup.puzzle.treetent.TreeTentBoard;
import edu.rpi.legup.puzzle.treetent.TreeTentCell;
import edu.rpi.legup.puzzle.treetent.TreeTentClue;
import edu.rpi.legup.puzzle.treetent.TreeTentType;
import java.awt.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class FillinRowCaseRule extends CaseRule {

Expand Down Expand Up @@ -95,7 +91,6 @@ public ArrayList<Board> getCases(Board board, PuzzleElement puzzleElement) {
}

/**
*
* @param iBoard the board to place tents onto
* @param tiles the locations where tents can be placed
* @param target the target number of tents to place
Expand All @@ -111,14 +106,21 @@ private ArrayList<Board> genCombinations(
boolean isRow) {
ArrayList<Board> generatedBoards = new ArrayList<>();
genCombRecursive(
iBoard, tiles, target, 0, new ArrayList<TreeTentCell>(), 0, index, generatedBoards, isRow);
iBoard,
tiles,
target,
0,
new ArrayList<TreeTentCell>(),
0,
index,
generatedBoards,
isRow);
return generatedBoards;
}

/**
*
* Recursive function to generate all ways of placing the target number of tents
* from the list of tiles to fill.
* Recursive function to generate all ways of placing the target number of tents from the list
* of tiles to fill.
*
* @param iBoard The board
* @param tiles Unknown Tiles to fill
Expand All @@ -128,10 +130,8 @@ private ArrayList<Board> genCombinations(
* @param selected the cells which have tents
* @param index The index of the clue
* @param isRow Used for checking if the board is good
*
* The generated boards are placed into generatedBoards (passed by reference)
* <p>The generated boards are placed into generatedBoards (passed by reference)
*/

private void genCombRecursive(
TreeTentBoard iBoard,
List<TreeTentCell> tiles,
Expand Down Expand Up @@ -168,14 +168,23 @@ private void genCombRecursive(
//
// Backtracking:
// Remove the placed tent from the board and selected
for (int i = currentTile; i < tiles.size(); ++i){
for (int i = currentTile; i < tiles.size(); ++i) {
TreeTentCell tile = tiles.get(i);
selected.add(tile);
PuzzleElement element = iBoard.getPuzzleElement(tile);
element.setData(TreeTentType.TENT);
iBoard.addModifiedData(element);
if (goodBoard(iBoard, index, isRow)) {
genCombRecursive(iBoard, tiles, target, current + 1, selected, i + 1, index, generatedBoards, isRow);
genCombRecursive(
iBoard,
tiles,
target,
current + 1,
selected,
i + 1,
index,
generatedBoards,
isRow);
}
element.setData(TreeTentType.UNKNOWN);
iBoard.addModifiedData(element);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private void saveProofAs() {
if (puzzle == null) {
return;
}

LegupPreferences preferences = LegupPreferences.getInstance();
File preferredDirectory =
new File(preferences.getUserPref(LegupPreferences.WORK_DIRECTORY));
Expand Down
49 changes: 26 additions & 23 deletions src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
// Commenting this out for now, but once Star Battle is fully implemented this should
// be uncommented and finished.

//package puzzles.starbattle.rules;
// package puzzles.starbattle.rules;
//
//import edu.rpi.legup.puzzle.nurikabe.Nurikabe;
//import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard;
//import edu.rpi.legup.puzzle.nurikabe.NurikabeCell;
//import edu.rpi.legup.puzzle.nurikabe.NurikabeType;
//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;
// import edu.rpi.legup.puzzle.nurikabe.Nurikabe;
// import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard;
// import edu.rpi.legup.puzzle.nurikabe.NurikabeCell;
// import edu.rpi.legup.puzzle.nurikabe.NurikabeType;
// 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;
//
//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.puzzle.starbattle.rules.BlackoutDirectRule;
//import edu.rpi.legup.save.InvalidFileFormatException;
// 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.puzzle.starbattle.rules.BlackoutDirectRule;
// import edu.rpi.legup.save.InvalidFileFormatException;
//
//import java.awt.*;
// import java.awt.*;
//
//public class BlackoutDirectRuleTest {
// public class BlackoutDirectRuleTest {
//
// private static final BlackoutDirectRule RULE = new BlackoutDirectRule();
// private static StarBattle starbattle;
Expand All @@ -38,7 +38,9 @@
//
// @Test
// public void BlackoutDirectRuleTest_ColumnBlackout() throws InvalidFileFormatException {
// TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/ColumnBlackout", starbattle);
//
// TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/ColumnBlackout",
// starbattle);
// TreeNode rootNode = starbattle.getTree().getRootNode();
// TreeTransition transition = rootNode.getChildren().get(0);
// transition.setRule(RULE);
Expand All @@ -61,7 +63,8 @@
// 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())) {
// if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) ||
// point.equals(cell3.getLocation())) {
// Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
// }
// else {
Expand All @@ -70,4 +73,4 @@
// }
// }
// }
//}
// }
83 changes: 39 additions & 44 deletions src/test/java/puzzles/treetent/rules/EmptyFieldDirectRuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ public static void setUp() {
treetent = new TreeTent();
}

/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
* <p> Empty
* XXX
* XGX
* XXX
* <p> Makes the (1, 1) tile GRASS
* Checks if the rule correctly detects no trees around the grass tile
*/
@Test
public void EmptyFieldTest() throws InvalidFileFormatException {
/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
*
* <p>Empty XXX XGX XXX
*
* <p>Makes the (1, 1) tile GRASS Checks if the rule correctly detects no trees around the grass
* tile
*/
@Test
public void EmptyFieldTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/EmptyFieldDirectRule/EmptyField", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
Expand Down Expand Up @@ -70,17 +69,16 @@ public void EmptyFieldTest() throws InvalidFileFormatException {
}
}

/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
* <p> Trees are at (0, 0), (2, 0), (0, 2), and (2, 2)
* RXR
* XGX
* RXR
* <p> Makes the (1, 1) tile GRASS
* Checks if the rule correctly ignores the trees on the diagonals
*/
@Test
public void DiagonalTreeTest() throws InvalidFileFormatException {
/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
*
* <p>Trees are at (0, 0), (2, 0), (0, 2), and (2, 2) RXR XGX RXR
*
* <p>Makes the (1, 1) tile GRASS Checks if the rule correctly ignores the trees on the
* diagonals
*/
@Test
public void DiagonalTreeTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/EmptyFieldDirectRule/DiagonalTree", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
Expand Down Expand Up @@ -114,17 +112,15 @@ public void DiagonalTreeTest() throws InvalidFileFormatException {
}
}

/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
* <p> Trees are at (0, 1), (1, 0), (1, 2), and (2, 1)
* XRX
* RGR
* XRX
* <p> Makes the (1, 1) tile GRASS
* Checks if the rule is not valid when there are adjacent trees
*/
@Test
public void EmptyFieldTestFail() throws InvalidFileFormatException {
/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
*
* <p>Trees are at (0, 1), (1, 0), (1, 2), and (2, 1) XRX RGR XRX
*
* <p>Makes the (1, 1) tile GRASS Checks if the rule is not valid when there are adjacent trees
*/
@Test
public void EmptyFieldTestFail() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/EmptyFieldDirectRule/EmptyFieldFail", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
Expand Down Expand Up @@ -153,17 +149,16 @@ public void EmptyFieldTestFail() throws InvalidFileFormatException {
}
}

/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
* <p> Tree at (1, 0)
* XRX
* XGX
* XXX
* <p> Makes the (1, 1) tile GRASS
* Checks if the rule is not valid when there is one adjacent tree
*/
@Test
public void EmptyFieldTestFailTop() throws InvalidFileFormatException {
/**
* 3x3 TreeTent puzzle Tests EmptyFieldDirectRule
*
* <p>Tree at (1, 0) XRX XGX XXX
*
* <p>Makes the (1, 1) tile GRASS Checks if the rule is not valid when there is one adjacent
* tree
*/
@Test
public void EmptyFieldTestFailTop() throws InvalidFileFormatException {
TestUtilities.importTestBoard(
"puzzles/treetent/rules/EmptyFieldDirectRule/EmptyFieldFailTop", treetent);
TreeNode rootNode = treetent.getTree().getRootNode();
Expand Down
Loading

0 comments on commit 9e623a0

Please sign in to comment.