From 1e554fbdb01edfe5bc6bf6f29fd74398254ab003 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 11 Feb 2024 03:38:54 -0500 Subject: [PATCH] Added an interface to allow for simplier traversal. Need to implement to DFS as well. --- src/main/java/Assignments/A1/models/Solver.java | 9 +++++++++ .../java/Assignments/A1/solving_algorithms/AStar.java | 3 ++- src/main/java/Assignments/A1/solving_algorithms/BFS.java | 3 ++- src/main/java/Assignments/A1/solving_algorithms/UCS.java | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/main/java/Assignments/A1/models/Solver.java diff --git a/src/main/java/Assignments/A1/models/Solver.java b/src/main/java/Assignments/A1/models/Solver.java new file mode 100644 index 0000000..5285802 --- /dev/null +++ b/src/main/java/Assignments/A1/models/Solver.java @@ -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); +} diff --git a/src/main/java/Assignments/A1/solving_algorithms/AStar.java b/src/main/java/Assignments/A1/solving_algorithms/AStar.java index 667148b..d297b51 100644 --- a/src/main/java/Assignments/A1/solving_algorithms/AStar.java +++ b/src/main/java/Assignments/A1/solving_algorithms/AStar.java @@ -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 visited = new HashSet<>(); diff --git a/src/main/java/Assignments/A1/solving_algorithms/BFS.java b/src/main/java/Assignments/A1/solving_algorithms/BFS.java index 3d06d4d..8e97e4d 100644 --- a/src/main/java/Assignments/A1/solving_algorithms/BFS.java +++ b/src/main/java/Assignments/A1/solving_algorithms/BFS.java @@ -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 visited = new HashSet<>(); private static final Board solved = new Board(); diff --git a/src/main/java/Assignments/A1/solving_algorithms/UCS.java b/src/main/java/Assignments/A1/solving_algorithms/UCS.java index d0a4cb9..888cca2 100644 --- a/src/main/java/Assignments/A1/solving_algorithms/UCS.java +++ b/src/main/java/Assignments/A1/solving_algorithms/UCS.java @@ -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 visited = new HashSet<>();