Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surround Completed Region bad attempt #633

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard;
import edu.rpi.legup.puzzle.nurikabe.NurikabeCell;
import edu.rpi.legup.puzzle.nurikabe.NurikabeType;
import edu.rpi.legup.puzzle.nurikabe.NurikabeUtilities;
import edu.rpi.legup.utility.DisjointSets;

import java.util.ArrayList;
import java.util.Set;

public class SurroundRegionDirectRule extends DirectRule {

Expand All @@ -29,7 +34,7 @@ public SurroundRegionDirectRule() {
*/
@Override
public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) {
ContradictionRule contraRule = new TooManySpacesContradictionRule();
//ContradictionRule contraRule = new TooManySpacesContradictionRule();

NurikabeBoard destBoardState = (NurikabeBoard) transition.getBoard();
NurikabeBoard origBoardState = (NurikabeBoard) transition.getParents().get(0).getBoard();
Expand All @@ -44,12 +49,27 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
NurikabeCell modCell = (NurikabeCell) modified.getPuzzleElement(puzzleElement);
modCell.setData(NurikabeType.WHITE.toValue());

if (contraRule.checkContradiction(modified) == null) {
return null;
// if (contraRule.checkContradiction(modified) == null) {
// return null;
// }
if (cell.getType() == NurikabeType.BLACK) { //below, unsure of destBoardState or origBoardState
DisjointSets<NurikabeCell> regions = NurikabeUtilities.getNurikabeRegions(destBoardState);
Set<NurikabeCell> whiteRegion = regions.getSet(cell);
ArrayList<NurikabeCell> numberedCells = new ArrayList<>();
for (NurikabeCell c : whiteRegion) {
if (c.getType() == NurikabeType.NUMBER) {
numberedCells.add(c);
}
}
for (NurikabeCell number : numberedCells) {
if (whiteRegion.size() == number.getData()) {
return null;
}
}
}
else {
//else {
return "Does not follow from this rule at this index";
}
//}
}

/**
Expand Down
Loading