Class BreadthFirstSearch<T>
java.lang.Object
puzzle.solver.BreadthFirstSearch<T>
- Type Parameters:
T
- represents the moves that can be applied to the states
Implements the breadth-first search (BFS) algorithm to solve puzzles.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSearches for the shortest solution for the puzzle starting from the state provided.solveAndPrintSolution
(State<T> state) Searches for the shortest solution for the puzzle starting from the state provided, and it also prints the solution to the standard output.
-
Constructor Details
-
BreadthFirstSearch
public BreadthFirstSearch()
-
-
Method Details
-
solve
-
solveAndPrintSolution
Searches for the shortest solution for the puzzle starting from the state provided, and it also prints the solution to the standard output.- Parameters:
state
- the initial state- Returns:
- an
Optional
describing the shortest solution for the puzzle, or an emptyOptional
if no solution is found
-