aboutsummaryrefslogtreecommitdiff
path: root/Week6/src/Solver.java
diff options
context:
space:
mode:
authorCamil Staps2015-03-11 10:50:52 +0100
committerCamil Staps2015-03-11 10:50:52 +0100
commitd0972c57cc23d7a6c913594e8166770fc1b28ff6 (patch)
treeb64f573920d6796ffc0612476ad25dbe4135b53f /Week6/src/Solver.java
parentWeek 6 framework (diff)
Added framework
Diffstat (limited to 'Week6/src/Solver.java')
-rw-r--r--Week6/src/Solver.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/Week6/src/Solver.java b/Week6/src/Solver.java
new file mode 100644
index 0000000..137646c
--- /dev/null
+++ b/Week6/src/Solver.java
@@ -0,0 +1,37 @@
+import java.util.Queue;
+
+
+/**
+ * A class that implements a breadth-first search algorithm
+ * for finding the Configurations for which the isSolution predicate holds
+ * @author Pieter Koopman, Sjaak Smetsers
+ * @version 1.3
+ * @date 28-02-2013
+ */
+public class Solver
+{
+ // A queue for maintaining graphs that are not visited yet.
+ Queue<Configuration> toExamine;
+
+ public Solver(Configuration g) {
+ throw new UnsupportedOperationException("Solver: not supported yet.");
+ }
+
+ /* A skeleton implementation of the solver
+ * @return a string representation of the solution
+ */
+ public String solve () {
+ while (! toExamine.isEmpty() ) {
+ Configuration next = toExamine.remove();
+ if ( next.isSolution() ) {
+ return "Success!";
+ } else {
+ for ( Configuration succ: next.successors() ) {
+ toExamine.add (succ);
+ }
+ }
+ }
+ return "Failure!";
+ }
+
+}