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

Complete Nurikabe test suite #678

Merged
merged 12 commits into from
Nov 17, 2023
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions bin/main/edu/rpi/legup/log4j2.properties
Original file line number Diff line number Diff line change
@@ -1,15 1,15 @@
# Logging level
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=Legup.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
# Logging level
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=Legup.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 30,9 @@ public static void setUp() {
nurikabe = new Nurikabe();
}

/**
* Tests the Black Between Regions direct rule for regions that are diagonal to each other (diagonal going from top left to bottom right)
*/
@Test
public void BlackBetweenRegionsDirectRule_DiagonalBlackBetweenRegions1Test() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBetweenRegionsDirectRule/DiagonalBlackBetweenRegions1", nurikabe);
Expand Down Expand Up @@ -62,6 65,9 @@ public void BlackBetweenRegionsDirectRule_DiagonalBlackBetweenRegions1Test() thr
}
}

/**
* Tests the Black Between Regions direct rule for regions that are diagonal to each other (diagonal going from bottom left to top right)
*/
@Test
public void BlackBetweenRegionsDirectRule_DiagonalBlackBetweenRegions2Test() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBetweenRegionsDirectRule/DiagonalBlackBetweenRegions2", nurikabe);
Expand Down Expand Up @@ -94,6 100,9 @@ public void BlackBetweenRegionsDirectRule_DiagonalBlackBetweenRegions2Test() thr
}
}

/**
* Tests the Black Between Regions direct rule for regions that are horizontally opposite each other
*/
@Test
public void BlackBetweenRegionsDirectRule_HorizontalBlackBetweenRegionsTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBetweenRegionsDirectRule/HorizontalBlackBetweenRegions", nurikabe);
Expand Down Expand Up @@ -123,6 132,9 @@ public void BlackBetweenRegionsDirectRule_HorizontalBlackBetweenRegionsTest() th
}
}

/**
* Tests the Black Between Regions direct rule for regions that are vertically opposite each other
*/
@Test
public void BlackBetweenRegionsDirectRule_VerticalBlackBetweenRegionsTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBetweenRegionsDirectRule/VerticalBlackBetweenRegions", nurikabe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 27,9 @@ public static void setUp() {
nurikabe = new Nurikabe();
}

/**
* Tests the Black BottleNeck direct rule for a bottleneck in the center of the board
*/
@Test
public void BlackBottleNeckDirectRule_TwoSurroundBlackTest() throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBottleNeckDirectRule/SimpleBlackBottleNeck", nurikabe);
Expand Down Expand Up @@ -54,4 57,64 @@ public void BlackBottleNeckDirectRule_TwoSurroundBlackTest() throws InvalidFileF
}
}
}


/**
* Tests the Black BottleNeck direct rule for a bottleneck in the corner of the board
*/
@Test
public void BlackBottleNeckDirectRule_CornerBottleneck() throws InvalidFileFormatException{
TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBottleNeckDirectRule/CornerBottleNeck", nurikabe);
TreeNode rootNode = nurikabe.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

NurikabeBoard board = (NurikabeBoard)transition.getBoard();
NurikabeCell cell = board.getCell(0,1);
cell.setData(NurikabeType.BLACK.toValue());

board.addModifiedData(cell);

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

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(cell.getLocation())){
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
}
else {
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
}
}
}
}


/**
* Tests the Black BottleNeck direct rule for a false bottleneck
*/
@Test
public void BlackBottleNeckDirectRule_FalseBottleneck() throws InvalidFileFormatException{
TestUtilities.importTestBoard("puzzles/nurikabe/rules/BlackBottleNeckDirectRule/FalseBottleNeck", nurikabe);
TreeNode rootNode = nurikabe.getTree().getRootNode();
TreeTransition transition = rootNode.getChildren().get(0);
transition.setRule(RULE);

NurikabeBoard board = (NurikabeBoard)transition.getBoard();
NurikabeCell cell = board.getCell(0,1);
cell.setData(NurikabeType.BLACK.toValue());

board.addModifiedData(cell);

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

for(int i = 0; i < board.getHeight(); i ){
for(int k = 0; k < board.getWidth(); k ){
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
}
}
}
}


Loading
Loading