diff --git a/README b/README index c1423d6..b8bc353 100644 --- a/README +++ b/README @@ -3,7 +3,8 @@ This is a personal project to generate a 2D maze using in depth path generation. Download the 'latest' laby.zip containing java jar from my blog http://blog.artisanlogiciel.net/public/tech/laby.zip -this can generate a stl file, overall goal was to print it with a 3D printer, i didn't test it yet ( even if i actualy have a 3D printer ). +this can generate a stl file, overall goal was to print it with a 3D printer. +After years i finaly printed one maze, find it at https://www.thingiverse.com/thing:2814655 This is the very first usable part. It was developped under debian 7/8 but since it is java based it might be very easily recompiled or even just copied on other platform. diff --git a/build.xml b/build.xml index 1ee3026..8242244 100644 --- a/build.xml +++ b/build.xml @@ -1,4 +1,4 @@ - + simple example build file diff --git a/java/Makefile b/java/Makefile index 90904b5..1b58e23 100644 --- a/java/Makefile +++ b/java/Makefile @@ -11,8 +11,8 @@ $(OUT): # mkdir -p $(OUT) clean: - @find $(PACKAGE_DIR) -name "*.class" -type f -print0|xargs -0 rm 2>/dev/null && echo "cleaned classes in source" - @find $(OUT) -name "*.class" -type f -print0|xargs -0 rm 2>/dev/null || echo "nothing to clean" + @find $(PACKAGE_DIR) -name "*.class" -type f -print0|xargs -0 --no-run-if-empty rm 2>/dev/null + @find $(OUT) -name "*.class" -type f -print0|xargs -0 --no-run-if-empty rm 2>/dev/null test: echo "$(pwd)/$(PACKAGE_DIR)" diff --git a/java/org/artisanlogiciel/games/LabyModel.java b/java/org/artisanlogiciel/games/LabyModel.java index 9e2da37..aec3358 100644 --- a/java/org/artisanlogiciel/games/LabyModel.java +++ b/java/org/artisanlogiciel/games/LabyModel.java @@ -87,27 +87,6 @@ public class LabyModel implements WallsProvider MazeCreationListener listener = null; - /** -TODO - private static MyLinkedList

- { - MyLinkedList

next; - P content - - MyLinkedList

( P object) - { - content=object; - next=null; - } - - MyLinkedList

addLast(P object) - { - next = new MyLinkedList(object); - return next; - } - } - */ - public LabyModel(int width, int height, int maxdepth, Random random) { this.width = width; @@ -525,13 +504,16 @@ TODO } } + /** + generate a maze with an entry set at (x,y) + **/ public void generateWithEntry(int x, int y) { openList.add(new Position(x, y)); while (!openList.isEmpty()) { - step(0); // fixme depth not set + step(); synchronized (coherentLock) { @@ -834,10 +816,19 @@ TODO return backpath; } + private final void closePosition(int x, int y) + { + t[x][y] &= ~OPEN; + t[x][y] |= CLOSED; + } + /** - * @returns wheter process closed current node. + * One step in Maze generation process + * get last element in open list and explore one random direction with it. + * + * @returns whether process closed current node. **/ - public boolean step(int depth) + public boolean step() { boolean complete = false; Position current = null; @@ -977,11 +968,12 @@ TODO } } complete = true; - t[x][y] &= ~OPEN; - t[x][y] |= CLOSED; - if (current.getDepth() > deepest) + closePosition(x,y); + + final int currentdepth = current.getDepth(); + if ( currentdepth > deepest) { - deepest = depth; + deepest = currentdepth; deepestEnd = current; } } // current != null;