ki_rwu_java/test/search/uninformed/iterativedeepening/IterativeDeepeningTest.java

78 lines
1.9 KiB
Java
Raw Normal View History

package search.uninformed.iterativedeepening;
2019-03-27 20:38:47 +01:00
import org.junit.jupiter.api.Test;
import search.EightPuzzleNode;
import search.LabyrinthineNode;
2019-03-27 20:38:47 +01:00
import static search.SearchTestUtils.printSolution;
class IterativeDeepeningTest
{
@Test
void shouldReturnCorrectTargetEightPuzzle()
2019-03-27 20:38:47 +01:00
{
final int[][] state = {
2019-03-27 20:38:47 +01:00
{5, 0, 3},
{2, 1, 6},
{4, 7, 8}
};
final var root = new EightPuzzleNode(state);
2019-03-27 20:38:47 +01:00
final int[][] targetState = {
2019-03-27 20:38:47 +01:00
{1, 2, 3},
{4, 5, 6},
{7, 8, 0}
};
final var expected = new EightPuzzleNode(targetState);
2019-03-27 20:38:47 +01:00
final var actual = new IterativeDeepening().iterativeDeepening(root, expected);
2019-03-27 20:38:47 +01:00
printSolution(actual);
}
@Test
void shouldReturnCorrectTargetCubekNodeEightPuzzle()
2019-03-27 20:38:47 +01:00
{
final int[][] state = {
2019-03-27 20:38:47 +01:00
{2, 0, 4},
{6, 7, 1},
{8, 5, 3}
};
final var root = new EightPuzzleNode(state);
2019-03-27 20:38:47 +01:00
final int[][] targetState = {
2019-03-27 20:38:47 +01:00
{1, 2, 3},
{4, 5, 6},
{7, 8, 0}
};
final var expected = new EightPuzzleNode(targetState);
2019-03-27 20:38:47 +01:00
final var actual = new IterativeDeepening().iterativeDeepening(root, expected);
2019-03-27 20:38:47 +01:00
printSolution(actual);
}
@Test
void shouldReturnCorrectTargetLabyrinthine()
{
final boolean[][] state = {
{true, false, true},
{false, true, false},
{true, false, true}
};
final var root = new LabyrinthineNode(state);
final boolean[][] targetState = {
{true, true, true},
{true, true, true},
{true, true, true},
};
final var expected = new LabyrinthineNode(targetState);
final var actual = new IterativeDeepening().iterativeDeepening(root, expected);
printSolution(actual);
}
2019-03-27 20:38:47 +01:00
}