Skip to content

Commit

Permalink
Merge branch 'binary' of https://github.com/Bram-Hub/LEGUP into binary
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharybonagura committed Mar 26, 2024
2 parents 5972432 + b303e73 commit 13aa225
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public OneOrZeroCaseRule() {

@Override
public String checkRuleRaw(TreeTransition transition) {
List<TreeTransition> childTransitions = transition.getParents().get(3).getChildren();
List<TreeTransition> childTransitions = transition.getParents().get(0).getChildren();
if (childTransitions.size() != 2) {
return super.getInvalidUseOfRuleMessage() + ": This case rule must have 2 children.";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,26 @@ public SurroundPairDirectRule() {

@Override
public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) {
return null;
BinaryBoard board = (BinaryBoard) transition.getBoard();
BinaryBoard origBoard = (BinaryBoard) transition.getParents().get(0).getBoard();
ContradictionRule contraRule = new ThreeAdjacentContradictionRule();


BinaryCell cell = (BinaryCell) board.getPuzzleElement(puzzleElement);

if (cell.getType() == BinaryType.UNKNOWN) {
return "Only ONE or ZERO cells are allowed for this rule!";
}

BinaryBoard modified = origBoard.copy();
modified.getPuzzleElement(puzzleElement).setData(BinaryType.WHITE.toValue());
if (contraRule.checkContradictionAt(modified, puzzleElement) != null) {
return "Black cells must be placed in a region of black cells!";
}
return null;

return super.getNoContradictionMessage() + ": " + this.NO_CONTRADICTION_MESSAGE;

}

@Override
Expand Down

0 comments on commit 13aa225

Please sign in to comment.