Add extra test class with "tests" for own needed applications like solving riddle in games
This commit is contained in:
parent
1842ade5c0
commit
f9a4040946
55
test/search/GameHelperTest.java
Normal file
55
test/search/GameHelperTest.java
Normal file
@ -0,0 +1,55 @@
|
||||
package search;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import search.uninformed.iterativedeepening.IterativeDeepening;
|
||||
|
||||
import static search.SearchTestUtils.printSolution;
|
||||
|
||||
public class GameHelperTest
|
||||
{
|
||||
@Test
|
||||
void shouldReturnCorrectTargetWartales()
|
||||
{
|
||||
final int[][] state = {
|
||||
{5, 0, 3},
|
||||
{2, 1, 6},
|
||||
{4, 7, 8}
|
||||
};
|
||||
final var root = new EightPuzzleNode(state);
|
||||
|
||||
final int[][] targetState = {
|
||||
{1, 2, 3},
|
||||
{4, 5, 6},
|
||||
{7, 8, 0}
|
||||
};
|
||||
final var expected = new EightPuzzleNode(targetState);
|
||||
|
||||
final var actual = new IterativeDeepening().iterativeDeepening(root, expected);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -51,28 +51,4 @@ class IterativeDeepeningTest
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user