From 46be57f1d6e0243e64706935aa784efd200a205b Mon Sep 17 00:00:00 2001 From: adash Date: Sat, 28 Feb 2009 02:34:21 +0000 Subject: [PATCH] new files for search algorithm... needs testing --- .../Distributed/RainForest/dsm/Goal.java | 27 ++++ .../Distributed/RainForest/dsm/Path.java | 150 ++++++++++++++++++ .../RainForest/dsm/RainForest.java | 73 ++++++++- .../Distributed/RainForest/dsm/makefile | 3 +- 4 files changed, 250 insertions(+), 3 deletions(-) create mode 100644 Robust/src/Benchmarks/Distributed/RainForest/dsm/Goal.java create mode 100644 Robust/src/Benchmarks/Distributed/RainForest/dsm/Path.java diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/Goal.java b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Goal.java new file mode 100644 index 00000000..0f44184d --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Goal.java @@ -0,0 +1,27 @@ +public class Goal { + private int LocX; + private int LocY; + + public Goal() { + LocX = 0; + LocY = 0; + } + + public Goal(int x, int y) { + LocX = x; + LocY = y; + } + + public void setXY(int x, int y) { + LocX = x; + LocY = y; + } + + public int getX() { + return LocX; + } + + public int getY() { + return LocY; + } +} diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/Path.java b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Path.java new file mode 100644 index 00000000..515b5dc5 --- /dev/null +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/Path.java @@ -0,0 +1,150 @@ +/** + ** A path determined by some path finding algorithm. A series of steps from + ** the starting location to the target location. This includes a step for the + ** initial location. + ** + **/ +public class Path { + /** The list of steps building up this path */ + private Vector steps = new Vector(); + + /** + * * Create an empty path + * */ + public Path() { + + } + + /** + ** Get the length of the path, i.e. the number of steps + ** + ** @return The number of steps in this path + **/ + public int getLength() { + return steps.size(); + } + + /** + ** Get the step at a given index in the path + ** + ** @param index The index of the step to retrieve. Note this should + ** be >= 0 and < getLength(); + ** @return The step information, the position on the map. + **/ + public Step getStep(int index) { + return (Step) steps.get(index); + } + + /** + ** Get the x coordinate for the step at the given index + ** + ** @param index The index of the step whose x coordinate should be retrieved + ** @return The x coordinate at the step + **/ + public int getX(int index) { + return getStep(index).x; + } + + /** + ** Get the y coordinate for the step at the given index + ** + ** @param index The index of the step whose y coordinate should be retrieved + ** @return The y coordinate at the step + **/ + public int getY(int index) { + return getStep(index).y; + } + + /** + ** Append a step to the path. + ** + ** @param x The x coordinate of the new step + ** @param y The y coordinate of the new step + **/ + public void appendStep(int x, int y) { + steps.add(new Step(x,y)); + } + + /** + ** Prepend a step to the path. + ** + ** @param x The x coordinate of the new step + ** @param y The y coordinate of the new step + **/ + public void prependStep(int x, int y) { + steps.add(0, new Step(x, y)); + } + + /** + ** Check if this path contains the given step + ** + ** @param x The x coordinate of the step to check for + ** @param y The y coordinate of the step to check for + ** @return True if the path contains the given step + **/ + public boolean contains(int x, int y) { + return steps.contains(new Step(x,y)); + } + + /** + ** A single step within the path + ** + ** @author Kevin Glass + **/ + public class Step { + /** The x coordinate at the given step */ + private int x; + /** The y coordinate at the given step */ + private int y; + + /** + ** Create a new step + ** + ** @param x The x coordinate of the new step + ** @param y The y coordinate of the new step + **/ + public Step(int x, int y) { + this.x = x; + this.y = y; + } + + /** + ** Get the x coordinate of the new step + ** + ** @return The x coodindate of the new step + **/ + public int getX() { + return x; + } + + /** + ** Get the y coordinate of the new step + ** + ** @return The y coodindate of the new step + **/ + public int getY() { + return y; + } + + /** + ** @see Object#hashCode() + **/ + public int hashCode() { + return x*y; + } + + /** + ** @see Object#equals(Object) + **/ + public boolean equals(Object other) { + if (other instanceof Step) { + Step o = (Step) other; + + return (o.x == x) && (o.y == y); + } + + return false; + } + } +} + diff --git a/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java b/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java index 061a4148..73b04b12 100644 --- a/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java +++ b/Robust/src/Benchmarks/Distributed/RainForest/dsm/RainForest.java @@ -20,7 +20,16 @@ public class RainForest extends Thread { public void run() { // For N interations do one move and synchronise - return; + System.println("Start run\n"); + Barrier barr; + barr = new Barrier("128.196.136.162"); + for(int i = 0; i