-
Notifications
You must be signed in to change notification settings - Fork 82
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 newest #673
Conversation
src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/SurroundRegionDirectRule.java
Outdated
Show resolved
Hide resolved
src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/SurroundRegionDirectRule.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure you also fill out the checklist when opening a pull request. This not only ensures you went through the steps to submitting quality code, but helps us understand what has been done and what still needs work. It's ok to not have everything done, we just want to know the progress that has been made especially if someone else wants to work on this in the future.
DisjointSets<NurikabeCell> regions = NurikabeUtilities.getNurikabeRegions(destBoardState); | ||
Set<NurikabeCell> adj = new HashSet<>(); //set to hold adjacent cells | ||
Point loc = cell.getLocation(); //position of placed cell | ||
NurikabeCell cellLeft = destBoardState.getCell(loc.x - 1, loc.y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is logically correct, this code block uses duplicate code for each direction. I recommend iteration through each direction in a for loop rather than copy pasting the code four times.
Some pseudocode that might help:
import java.awt.Point;
List<Point> directions = { new Point(-1, 0), new Point(1, 0), new Point(0, -1), new Point(0, 1) };
for (Point direction : directions) {
NurikabeCell cell = destBoardState.getCell(loc.x + direction.x, loc.y + direction.y);
// avoid redundant nested clauses
if (cell != null && (...) {
// apply logic
}
}
src/main/java/edu/rpi/legup/puzzle/nurikabe/rules/SurroundRegionDirectRule.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. I made a quick change to simply directions
to one line, but everything else looks solid.
Description
Nurikabe Surround Region #553
Altered surround region rule so that it only works with regions of the exact right size as the number within the region. Still need to change the rule name as requested in the issue from "Surround Region" to "Surround Completed Region. Most
relevant information related to this issue can be viewed in the [BUG] Nurikabe Surround Region #553.
Type of change
How Has This Been Tested?
Replicated all cases in [BUG] Nurikabe Surround Region #553.
Checklist: