Add some fun stuff
This commit is contained in:
1 parent
e4fcb06949
commit
3c43233d96
5 files changed
+269
-4
No files matched your search
Executable
+51
@@ -0,0 +1,51 @@
|
||||
package search;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import search.uninformed.breadthfirstsearch.BreadthFirstSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static search.SearchTestUtils.countNodes;
|
||||
import static search.SearchTestUtils.printSolution;
|
||||
|
||||
public class ChessKnightTest
|
||||
{
|
||||
@Test
|
||||
public void shouldReturnOne()
|
||||
{
|
||||
final var state = new ChessKnightNode.KnightPair('a', '3');
|
||||
|
||||
final var root = new ChessKnightNode(state);
|
||||
|
||||
final var targetState = new ChessKnightNode.KnightPair('b', '5');
|
||||
final var expected = new ChessKnightNode(targetState);
|
||||
|
||||
final var actual = new BreadthFirstSearch().breadthFirstSearch(List.of(root), expected);
|
||||
|
||||
printSolution(actual);
|
||||
var nodeCount = countNodes(actual);
|
||||
var edgeCount = nodeCount - 1;
|
||||
|
||||
Assertions.assertEquals(1, edgeCount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnThree()
|
||||
{
|
||||
final var state = new ChessKnightNode.KnightPair('a', '1');
|
||||
|
||||
final var root = new ChessKnightNode(state);
|
||||
|
||||
final var targetState = new ChessKnightNode.KnightPair('f', '1');
|
||||
final var expected = new ChessKnightNode(targetState);
|
||||
|
||||
final var actual = new BreadthFirstSearch().breadthFirstSearch(List.of(root), expected);
|
||||
|
||||
printSolution(actual);
|
||||
var nodeCount = countNodes(actual);
|
||||
var edgeCount = nodeCount - 1;
|
||||
|
||||
Assertions.assertEquals(3, edgeCount);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user