Added an interface to allow for simplier traversal. Need to implement to DFS as well.
This commit is contained in:
parent
f7d888305d
commit
1e554fbdb0
9
src/main/java/Assignments/A1/models/Solver.java
Normal file
9
src/main/java/Assignments/A1/models/Solver.java
Normal file
@ -0,0 +1,9 @@
|
||||
package Assignments.A1.models;
|
||||
|
||||
import Assignments.A1.models.Board;
|
||||
import Assignments.A1.models.BoardNode;
|
||||
|
||||
public interface Solver {
|
||||
|
||||
BoardNode traverse(Board board);
|
||||
}
|
@ -3,13 +3,14 @@ package Assignments.A1.solving_algorithms;
|
||||
import Assignments.A1.models.Board;
|
||||
import Assignments.A1.models.BoardNode;
|
||||
import Assignments.A1.models.Move;
|
||||
import Assignments.A1.models.Solver;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
public class AStar {
|
||||
public class AStar implements Solver {
|
||||
private final Board solved = new Board();
|
||||
private final HashSet<Board> visited = new HashSet<>();
|
||||
|
||||
|
@ -3,13 +3,14 @@ package Assignments.A1.solving_algorithms;
|
||||
import Assignments.A1.models.Board;
|
||||
import Assignments.A1.models.BoardNode;
|
||||
import Assignments.A1.models.Move;
|
||||
import Assignments.A1.models.Solver;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
public class BFS {
|
||||
public class BFS implements Solver {
|
||||
|
||||
private final HashSet<Board> visited = new HashSet<>();
|
||||
private static final Board solved = new Board();
|
||||
|
@ -3,13 +3,14 @@ package Assignments.A1.solving_algorithms;
|
||||
import Assignments.A1.models.Board;
|
||||
import Assignments.A1.models.BoardNode;
|
||||
import Assignments.A1.models.Move;
|
||||
import Assignments.A1.models.Solver;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
public class UCS {
|
||||
public class UCS implements Solver {
|
||||
private final Board solved = new Board();
|
||||
private final HashSet<Board> visited = new HashSet<>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user