Skip to content

Commit

Permalink
Debugging process rooted out issue
Browse files Browse the repository at this point in the history
Issue has been found where changes that are meant to be isolated within the rule's temporary board are instead permanent, considering if copy constructor is the problem
  • Loading branch information
offline171 committed Jul 26, 2024
1 parent 9d95045 commit f99a1d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,25 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
StarBattleCell[] adjacent = {northWest, north, northEast, west, east, southWest, south, southEast};

StarBattleBoard modified = (StarBattleBoard) origBoard.copy();
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.STAR.value);
for(int i = 0; i < 8; i++){ //sets each spot to a black square if not filled
StarBattleCell temp = adjacent[i];

if (temp != null && temp.getType() == StarBattleCellType.UNKNOWN) {
modified.getCell(temp.getLocation().x, temp.getLocation().y).setData(-1);
temp.setData(StarBattleCellType.BLACK.value);
int X = temp.getLocation().x;
int Y = temp.getLocation().y;
modified.getCell(X,Y).setData(StarBattleCellType.BLACK.value);
System.out.println("covering square " + X + " " + Y + " type " + modified.getCell(X,Y).getType() + " i = " + i + "\n");
if(contraRule.checkContradictionAt(modified, temp) == null){
System.out.println("Good job!");
return null; //used correctly if even one space causes a toofewstars issue
}
}
}
System.out.println("Wait why did this exit?\n");

if (contraRule.checkContradictionAt(modified, puzzleElement) != null) {
return "Black cells must be placed adjacent to a tile(s) where a star is needed!";
}
return null;
return "Black cells must be placed adjacent to a tile(s) where a star is needed!";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
++columnCount;
}
}

System.out.println("rowCount = " + rowCount + " columnCount = " + columnCount + " at " + column + "," + row + "\n");
if (rowCount < sbBoard.getPuzzleNumber() || columnCount < sbBoard.getPuzzleNumber()) {
System.out.println("Returning Null\n");
return null;
}
StarBattleRegion region = sbBoard.getRegion(cell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,33 @@ public void EmptyAdjacentDirectRule_TwoLeft() throws InvalidFileFormatException
StarBattleBoard board = (StarBattleBoard) transition.getBoard();
StarBattleCell cell1 = board.getCell(1,1);
cell1.setData(StarBattleCellType.BLACK.value);
/*
StarBattleCell cell2 = board.getCell(2,1);
cell2.setData(StarBattleCellType.BLACK.value);
StarBattleCell cell3 = board.getCell(1,3);
cell3.setData(StarBattleCellType.BLACK.value);
StarBattleCell cell4 = board.getCell(2,3);
cell4.setData(StarBattleCellType.BLACK.value);
*/

board.addModifiedData(cell1);
/*
board.addModifiedData(cell2);
board.addModifiedData(cell3);
board.addModifiedData(cell4);
*/

Assert.assertNull(RULE.checkRule(transition));

System.out.println("General Case is done\n");
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()) ||
point.equals(cell3.getLocation()) || point.equals(cell4.getLocation())) {
if (point.equals(cell1.getLocation())) {
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
}
} /*
else {
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(j, i)));
}
} */
}
}
}
Expand Down

0 comments on commit f99a1d1

Please sign in to comment.